GeezerVison is showing github.com — fix(web,mobile): approval cards show characters a screen would not dr… · patroza/t3code@d5d5c17
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/PendingApprovalCard.tsx +65-6Lines changed: 65 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,14 +5,16 @@ import type { | 5 | 5 | RuntimeRequestId, | 6 | 6 | } from "@t3tools/contracts"; | 7 | 7 | import { | | 8 | + type ApprovalTextPart, | | 9 | + approvalTextParts, | 8 | 10 | FULL_ACCESS_OVERRIDE_QUESTION, | 9 | 11 | fullAccessOverrideExplanation, | 10 | 12 | PUSH_HOOKS_APPROVAL_QUESTION, | 11 | 13 | pushHooksApprovalRows, | 12 | 14 | } from "@t3tools/client-runtime/state/thread-requests"; | 13 | 15 | import { T, useGT, useMessages } from "gt-react-native"; | 14 | | -import { useState } from "react"; | 15 | | -import { Pressable, View } from "react-native"; | | 16 | +import { type ComponentRef, useRef, useState } from "react"; | | 17 | +import { Pressable, ScrollView, View } from "react-native"; | 16 | 18 |
| 17 | 19 | import { AppText as Text } from "../../components/ui/AppText"; | 18 | 20 | import type { PendingApproval } from "../../lib/threadActivity"; | @@ -44,6 +46,8 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) { | 44 | 46 | const [explanationOpen, setExplanationOpen] = useState(false); | 45 | 47 | // T3 Code's own question reads as the app asking: a plain sentence, then what it names. | 46 | 48 | const { pushHooks } = props.approval; | | 49 | + const detail = | | 50 | + !pushHooks && props.approval.detail ? approvalTextParts(props.approval.detail) : null; | 47 | 51 | return ( | 48 | 52 | <View className="gap-2.5 rounded-[20px] border border-border bg-card-alt p-4"> | 49 | 53 | <Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-foreground-secondary"> | @@ -67,10 +71,23 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) { | 67 | 71 | </View> | 68 | 72 | ))} | 69 | 73 | </View> | 70 | | - ) : props.approval.detail ? ( | 71 | | - <Text className="font-sans text-sm leading-normal text-foreground-secondary"> | 72 | | - {props.approval.detail} | 73 | | - </Text> | | 74 | + ) : detail ? ( | | 75 | + <> | | 76 | + {detail.hiddenLength > 0 ? ( | | 77 | + <> | | 78 | + <ApprovalTextScroll parts={detail.parts} /> | | 79 | + <Text className="font-sans text-xs leading-normal text-warning-foreground"> | | 80 | + {gt( | | 81 | + "{count, plural, one {… {hidden} character in the middle is not shown.} other {… {hidden} characters in the middle are not shown.}} The text ends with:", | | 82 | + { count: detail.hiddenLength, hidden: detail.hiddenLength.toLocaleString() }, | | 83 | + )} | | 84 | + </Text> | | 85 | + <ApprovalTextScroll parts={detail.tail} fromEnd /> | | 86 | + </> | | 87 | + ) : ( | | 88 | + <ApprovalTextParts parts={detail.parts} /> | | 89 | + )} | | 90 | + </> | 74 | 91 | ) : null} | 75 | 92 | {props.approval.reason ? ( | 76 | 93 | <Text className="font-sans text-xs leading-normal text-warning-foreground"> | @@ -130,3 +147,45 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) { | 130 | 147 | </View> | 131 | 148 | ); | 132 | 149 | } | | 150 | + | | 151 | +/** | | 152 | + * One end of text too long to show in full, in a box that scrolls on its own, so the note, the | | 153 | + * other end and the buttons stay within reach. The end opens on its last line. | | 154 | + */ | | 155 | +function ApprovalTextScroll(props: { | | 156 | + readonly parts: ReadonlyArray<ApprovalTextPart>; | | 157 | + readonly fromEnd?: boolean; | | 158 | +}) { | | 159 | + const box = useRef<ComponentRef<typeof ScrollView>>(null); | | 160 | + return ( | | 161 | + <ScrollView | | 162 | + ref={box} | | 163 | + className="max-h-40" | | 164 | + nestedScrollEnabled | | 165 | + onContentSizeChange={ | | 166 | + props.fromEnd ? () => box.current?.scrollToEnd({ animated: false }) : undefined | | 167 | + } | | 168 | + > | | 169 | + <ApprovalTextParts parts={props.parts} /> | | 170 | + </ScrollView> | | 171 | + ); | | 172 | +} | | 173 | + | | 174 | +function ApprovalTextParts(props: { readonly parts: ReadonlyArray<ApprovalTextPart> }) { | | 175 | + return ( | | 176 | + <Text className="font-sans text-sm leading-normal text-foreground-secondary"> | | 177 | + {props.parts.map((part, index) => | | 178 | + part.named ? ( | | 179 | + // Tinted only: a second font inside wrapped lines makes Android lay the text out shorter | | 180 | + // than it draws, which cuts off its last lines. | | 181 | + // oxlint-disable-next-line react/no-array-index-key -- parts never reorder and two may read alike | | 182 | + <Text key={index} className="text-warning-foreground"> | | 183 | + {part.text} | | 184 | + </Text> | | 185 | + ) : ( | | 186 | + part.text | | 187 | + ), | | 188 | + )} | | 189 | + </Text> | | 190 | + ); | | 191 | +} |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/de.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} Zeichen in der Mitte wird nicht angezeigt.} other {… {hidden} Zeichen in der Mitte werden nicht angezeigt.}} Der Text endet mit:", | 2 | 3 | "4bcfa3b976a421cf": "Nebenchat", | 3 | 4 | "23be753133ae6950": "Thread", | 4 | 5 | "0001ae5846061bb6": "Thread auf {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/en.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} character in the middle is not shown.} other {… {hidden} characters in the middle are not shown.}} The text ends with:", | 2 | 3 | "4bcfa3b976a421cf": "Side chat", | 3 | 4 | "23be753133ae6950": "Thread", | 4 | 5 | "0001ae5846061bb6": "Thread on {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/es.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… No se muestra {hidden} carácter del medio.} other {… No se muestran {hidden} caracteres del medio.}} El texto termina con:", | 2 | 3 | "4bcfa3b976a421cf": "Chat lateral", | 3 | 4 | "23be753133ae6950": "Hilo", | 4 | 5 | "0001ae5846061bb6": "Hilo en {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/fr.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} caractère au milieu n’est pas affiché.} other {… {hidden} caractères au milieu ne sont pas affichés.}} Le texte se termine par :", | 2 | 3 | "4bcfa3b976a421cf": "Discussion annexe", | 3 | 4 | "23be753133ae6950": "Fil", | 4 | 5 | "0001ae5846061bb6": "Fil sur {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ja.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, other {… 途中の {hidden} 文字は表示されていません。}} テキストの末尾:", | 2 | 3 | "4bcfa3b976a421cf": "サイドチャット", | 3 | 4 | "23be753133ae6950": "スレッド", | 4 | 5 | "0001ae5846061bb6": "{machine} 上のスレッド", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ko.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, other {… 중간의 {hidden}자는 표시되지 않습니다.}} 텍스트의 끝부분:", | 2 | 3 | "4bcfa3b976a421cf": "사이드 채팅", | 3 | 4 | "23be753133ae6950": "스레드", | 4 | 5 | "0001ae5846061bb6": "{machine}의 스레드", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/pt-BR.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} caractere do meio não é exibido.} other {… {hidden} caracteres do meio não são exibidos.}} O texto termina com:", | 2 | 3 | "4bcfa3b976a421cf": "Chat paralelo", | 3 | 4 | "23be753133ae6950": "Thread", | 4 | 5 | "0001ae5846061bb6": "Thread em {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/ru.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} символ в середине не показан.} few {… {hidden} символа в середине не показаны.} many {… {hidden} символов в середине не показаны.} other {… {hidden} символа в середине не показаны.}} Текст заканчивается так:", | 2 | 3 | "4bcfa3b976a421cf": "Боковой чат", | 3 | 4 | "23be753133ae6950": "Тред", | 4 | 5 | "0001ae5846061bb6": "Тред на {machine}", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/i18n/translations/sv.json +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | | 2 | + "035aab5e99159bd8": "{count, plural, one {… {hidden} tecken i mitten visas inte.} other {… {hidden} tecken i mitten visas inte.}} Texten slutar med:", | 2 | 3 | "4bcfa3b976a421cf": "Sidochatt", | 3 | 4 | "23be753133ae6950": "Tråd", | 4 | 5 | "0001ae5846061bb6": "Tråd på {machine}", | |
|