Skip to content

Commit d9baeb1

Browse files
committed
fix(web,mobile): Hebrew and Arabic read right to left in more text boxes, previews and titles
1 parent da93945 commit d9baeb1

24 files changed

Lines changed: 97 additions & 17 deletions

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ import { ThreadSearchMatchExcerpt } from "./thread-search-match";
8181
import { useScaledTextRole } from "../settings/appearance/useScaledTextRole";
8282
import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
8383
import { pullRequestStatus } from "../pull-requests/pullRequestStatus";
84+
import { textDirection } from "@t3tools/shared/textDirection";
85+
86+
function textDirectionStyle(text: string) {
87+
const direction = textDirection(text);
88+
return direction ? { direction, writingDirection: direction } : undefined;
89+
}
8490

8591
interface StatusLabel {
8692
readonly label: string;
@@ -465,6 +471,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
465471
sidebarPane && "text-drawer-foreground",
466472
)}
467473
numberOfLines={1}
474+
style={textDirectionStyle(pendingTask.title)}
468475
>
469476
{pendingTask.title}
470477
</Text>
@@ -1081,6 +1088,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
10811088
: rowAppearance.foregroundClassName,
10821089
)}
10831090
numberOfLines={2}
1091+
style={textDirectionStyle(thread.title)}
10841092
>
10851093
{thread.title}
10861094
</Text>

‎apps/web/src/components/GitActionsControl.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import { getSourceControlPresentation, sourceControlIcon } from "~/sourceControl
111111
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
112112
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
113113
import { useOpenLink } from "~/browser/useOpenLink";
114+
import { textDirection } from "~/textDirection";
114115

115116
interface GitActionsControlProps {
116117
gitCwd: string | null;
@@ -1792,6 +1793,7 @@ export default function GitActionsControl({
17921793
<p className="text-sm font-medium">Commit message (optional)</p>
17931794
<Textarea
17941795
value={dialogCommitMessage}
1796+
dir={textDirection(dialogCommitMessage)}
17951797
onChange={(event) => setDialogCommitMessage(event.target.value)}
17961798
placeholder="Leave empty to auto-generate"
17971799
size="sm"

‎apps/web/src/components/ThreadContextChip.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useProject, useThreadShell } from "~/state/entities";
77
import { ContextChip, ContextChipLabel } from "./ContextChip";
88
import { ProjectFavicon } from "./ProjectFavicon";
99
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
10+
import { textDirection } from "~/textDirection";
1011

1112
export function ThreadContextChip(props: {
1213
record: Pick<ThreadContextRecord, "environmentId" | "threadId" | "title">;
@@ -34,7 +35,7 @@ export function ThreadContextChip(props: {
3435
) : (
3536
<MessagesSquareIcon />
3637
)}
37-
<ContextChipLabel>{title}</ContextChipLabel>
38+
<ContextChipLabel dir={textDirection(title)}>{title}</ContextChipLabel>
3839
</ContextChip>
3940
}
4041
/>

‎apps/web/src/components/ThreadHoverCard.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ComponentProps, ReactNode } from "react";
22
import { TooltipPopup } from "./ui/tooltip";
33
import { cn } from "~/lib/utils";
4+
import { textDirection } from "~/textDirection";
45

56
export function ThreadHoverCardPopup({ className, ...props }: ComponentProps<typeof TooltipPopup>) {
67
return (
@@ -23,7 +24,10 @@ export function ThreadHoverCard({
2324
}) {
2425
return (
2526
<div className="flex min-w-0 max-w-80 flex-col gap-2 px-1 py-2">
26-
<div className="min-w-0 truncate text-xs leading-tight font-medium text-foreground">
27+
<div
28+
className="min-w-0 truncate text-xs leading-tight font-medium text-foreground"
29+
dir={textDirection(title)}
30+
>
2731
{title}
2832
</div>
2933
<div className="grid gap-1.5 pl-0.5 text-xs text-muted-foreground">{children}</div>

‎apps/web/src/components/ThreadSearchMatch.tsx‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
type SearchMatchHint,
55
type SearchRange,
66
} from "@t3tools/shared/paletteSearch";
7+
import { textDirection } from "~/textDirection";
78

89
/** `text` with each range in semibold foreground. */
910
function HighlightedSearchText(props: { text: string; ranges: ReadonlyArray<SearchRange> }) {
@@ -22,8 +23,13 @@ function HighlightedSearchText(props: { text: string; ranges: ReadonlyArray<Sear
2223
/** Why a row matched when its title does not show it: the field and its match. */
2324
export function SearchMatchHintLine(props: { hint: SearchMatchHint }) {
2425
return (
25-
<span className="truncate text-xs text-muted-foreground/85">
26-
<span className="text-muted-foreground/70">{props.hint.label}:</span>{" "}
26+
<span
27+
className="truncate text-xs text-muted-foreground/85"
28+
dir={textDirection(props.hint.text)}
29+
>
30+
<span className="text-muted-foreground/70" dir="ltr">
31+
{props.hint.label}:
32+
</span>{" "}
2733
<HighlightedSearchText text={props.hint.text} ranges={props.hint.ranges} />
2834
</span>
2935
);
@@ -38,8 +44,11 @@ export function ThreadSearchMatchExcerpt(props: {
3844
}) {
3945
const isUser = props.match.source === "user";
4046
return (
41-
<span className="truncate text-xs text-muted-foreground/85">
42-
<span className={isUser ? "text-info-foreground" : "text-success-foreground"}>
47+
<span
48+
className="truncate text-xs text-muted-foreground/85"
49+
dir={textDirection(props.match.snippet)}
50+
>
51+
<span className={isUser ? "text-info-foreground" : "text-success-foreground"} dir="ltr">
4352
{isUser ? "You:" : "Agent:"}
4453
</span>{" "}
4554
<HighlightedSearchText

‎apps/web/src/components/ThreadStatusIndicators.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export {
153153
resolveThreadPullRequestBadge,
154154
type ThreadPullRequestBadge,
155155
} from "@t3tools/client-runtime/thread-pull-requests";
156+
import { textDirection } from "~/textDirection";
156157

157158
export interface ThreadPullRequestBadgePresentation {
158159
readonly Icon: PullRequestGlyphIcon;
@@ -387,7 +388,9 @@ function ThreadPullRequestMiniListItem({
387388
className={cn("size-3 shrink-0", presentation?.toneClassName ?? "stroke-muted-foreground")}
388389
/>
389390
<span className="shrink-0 font-mono tabular-nums">#{number}</span>
390-
<span className="min-w-0 truncate text-foreground/75">{title}</span>
391+
<span className="min-w-0 truncate text-foreground/75" dir={textDirection(title)}>
392+
{title}
393+
</span>
391394
{children}
392395
</>
393396
);

‎apps/web/src/components/chat/ComposerStashMenu.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { RelativeTime } from "../RelativeTime";
66
import { cn } from "~/lib/utils";
77
import { type PromptStashEntry } from "../../promptStashStore";
88
import { ComposerBanner } from "./ComposerBanner";
9+
import { markdownProseDirection } from "~/textDirection";
910

1011
const SNIPPET_MAX_CHARS = 90;
1112

@@ -175,8 +176,9 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
175176
<ComposerBanner.Content>
176177
<button
177178
type="button"
178-
className="min-w-0 flex-1 cursor-pointer truncate text-left text-foreground/80 outline-none before:absolute before:inset-0 before:rounded-sm focus-visible:before:ring-2 focus-visible:before:ring-inset focus-visible:before:ring-ring"
179+
className="min-w-0 flex-1 cursor-pointer truncate text-start text-foreground/80 outline-none before:absolute before:inset-0 before:rounded-sm focus-visible:before:ring-2 focus-visible:before:ring-inset focus-visible:before:ring-ring"
179180
data-stash-restore={entry.id}
181+
dir={markdownProseDirection(stashEntrySnippet(entry))}
180182
aria-label={`Restore stashed prompt: ${stashEntrySnippet(entry)}`}
181183
onPointerDown={(event) => event.preventDefault()}
182184
onClick={() => onRestore(entry)}

‎apps/web/src/components/chat/QueuedRunsControl.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import type { TimestampFormat } from "@t3tools/contracts/settings";
3535
import { GuestMessageName } from "./guestMessageStyle";
3636
import { TimelineRowTimestamp } from "./TimelineRowParts";
3737
import { FoldedMessageHeader, useScheduledTaskTitle } from "./TimelineUserMessageRow";
38+
import { markdownProseDirection } from "~/textDirection";
3839

3940
export interface EditQueuedRunRequest {
4041
readonly runId: RunId;
@@ -486,7 +487,12 @@ function QueuedMessage(props: {
486487
) : null}
487488
{/* In full, like a sent turn: a queued message is read before it is sent. */}
488489
{props.previewText ? (
489-
<p className="whitespace-pre-wrap wrap-anywhere">{props.previewText}</p>
490+
<p
491+
className="whitespace-pre-wrap wrap-anywhere"
492+
dir={markdownProseDirection(props.previewText)}
493+
>
494+
{props.previewText}
495+
</p>
490496
) : null}
491497
</div>
492498
) : null}

‎apps/web/src/components/chat/TimelineUserMessageRow.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import {
7070
import { chatMarkdownClipboardPayload } from "../../markdown-clipboard";
7171
import type { ChatMarkdownContextReference } from "../ChatMarkdown";
7272
import { cn } from "~/lib/utils";
73-
import { markdownProseDirection } from "~/textDirection";
73+
import { markdownProseDirection, textDirection } from "~/textDirection";
7474
import { formatChatTimestampTooltip, formatDayAwareTimestamp } from "../../timestampFormat";
7575
import { WorkflowOpeningBlock } from "./WorkflowOpeningBlock";
7676
import { TimelineRowCtx, TimelineRowActivityCtx, type TimelineRow } from "./timelineRowContext";
@@ -260,7 +260,9 @@ export function FoldedMessageHeader(props: {
260260
>
261261
<Icon className="size-4 shrink-0 stroke-2 text-muted-foreground" />
262262
<span className="max-w-1/2 shrink-0 truncate text-muted-foreground">{props.label}</span>
263-
<span className="min-w-0 flex-1 truncate">{props.summary}</span>
263+
<span className="min-w-0 flex-1 truncate" dir={textDirection(props.summary)}>
264+
{props.summary}
265+
</span>
264266
<ChevronDownIcon
265267
className={cn(
266268
"size-3.5 shrink-0 text-muted-foreground transition-transform",

‎apps/web/src/components/guest/GuestPage.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import {
6969
unplacedGuestMessages,
7070
} from "./guestStream.logic";
7171
import { guestTurnItemSource } from "./guestTurnItemSource";
72+
import { textDirection } from "~/textDirection";
7273

7374
interface GuestEntry {
7475
/** Unspent invite from the URL hash, if this load came from a link. */
@@ -726,6 +727,7 @@ function GuestComposer({
726727
rows={2}
727728
maxLength={GUEST_MESSAGE_MAX_LENGTH}
728729
value={text}
730+
dir={textDirection(text)}
729731
onChange={(event) => setText(event.target.value)}
730732
onKeyDown={onKeyDown}
731733
onPaste={onPaste}

0 commit comments

Comments
 (0)