Skip to content

Commit bdbdad0

Browse files
committed
Merge remote-tracking branch 'github/main' into feat/split-chat-workspace
# Conflicts: # apps/web/src/components/Sidebar.tsx
2 parents 082fd06 + d756fed commit bdbdad0

132 files changed

Lines changed: 4296 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/global.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
/* ─── Theme tokens ──────────────────────────────────────────────────── */
66
@layer theme {
77
:root {
8+
/* Native text takes one family name, not Tailwind's font stack. */
9+
@variant ios {
10+
--font-mono: "ui-monospace";
11+
}
812
@variant android {
913
--font-mono: "monospace";
1014
}

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ import { readEnvironmentScope, usePreparedConnection } from "../../state/session
236236
import { projectEnvironment } from "../../state/projects";
237237
import {
238238
needsWorkspaceBasenameLookup,
239-
pickWorkspaceBasenameMatch,
239+
pickWorkspaceLinkMatch,
240240
WORKSPACE_BASENAME_LOOKUP_LIMIT,
241+
workspaceLinkLookupQuery,
241242
} from "@t3tools/client-runtime/workspace-basename-lookup";
242243
import {
243244
resolveThreadLink,
@@ -1913,7 +1914,10 @@ function renderFeedEntry(
19131914
const bubbleBodyVisible = foldRowId === null || foldExpanded;
19141915
const intentBadge = props.userMessageGrouping.continuesSteer
19151916
? null
1916-
: resolveUserMessageIntentBadge(message.inputIntent);
1917+
: resolveUserMessageIntentBadge(
1918+
message.inputIntent,
1919+
message.projectedItem?.item.status === "pending",
1920+
);
19171921
const referenceIds = new Set(
19181922
collectComposerContextReferences(message.text).map((reference) => reference.contextId),
19191923
);
@@ -2894,17 +2898,18 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
28942898
props.workspaceRoot &&
28952899
relativePath &&
28962900
!/[\\/]$/.test(presentation.path) &&
2897-
needsWorkspaceBasenameLookup(relativePath) &&
2901+
workspaceLinkLookupQuery(presentation.path, props.workspaceRoot) !== null &&
28982902
readEnvironmentScope(props.environmentId, AuthFilesystemReadScope)
28992903
) {
2904+
const workspaceRoot = props.workspaceRoot;
29002905
const originalPath = resolveWorkspaceFilePath(props.workspaceRoot, relativePath);
29012906
void executeAtomQuery(
29022907
appAtomRegistry,
29032908
projectEnvironment.searchEntries({
29042909
environmentId: props.environmentId,
29052910
input: {
2906-
cwd: props.workspaceRoot,
2907-
query: relativePath,
2911+
cwd: workspaceRoot,
2912+
query: workspaceLinkLookupQuery(relativePath, workspaceRoot) ?? relativePath,
29082913
kind: "file",
29092914
limit: WORKSPACE_BASENAME_LOOKUP_LIMIT,
29102915
},
@@ -2914,7 +2919,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29142919
(result) => {
29152920
const match =
29162921
result._tag === "Success"
2917-
? pickWorkspaceBasenameMatch(relativePath, result.value.entries)
2922+
? pickWorkspaceLinkMatch(relativePath, workspaceRoot, result.value.entries)
29182923
: null;
29192924
if (!match || match === relativePath) {
29202925
openAt(relativePath);
@@ -2931,7 +2936,10 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29312936
).then(
29322937
(metadata) =>
29332938
openAt(
2934-
metadata._tag === "Success" && metadata.value?.kind !== "directory"
2939+
metadata._tag === "Success" &&
2940+
(needsWorkspaceBasenameLookup(relativePath)
2941+
? metadata.value?.kind !== "directory"
2942+
: metadata.value === null)
29352943
? match
29362944
: relativePath,
29372945
),

‎apps/mobile/src/features/threads/subagent-card-presentation.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("subagent card", () => {
2222
expect(subagentCardElapsed([unfinished], DateTime.toEpochMillis(later))).toBeNull();
2323
expect(
2424
subagentCardElapsed([{ ...unfinished, status: "running" }], DateTime.toEpochMillis(later)),
25-
).toBe("2m");
25+
).toBe("2m 0s");
2626
expect(
2727
subagentCardElapsed([{ ...unfinished, status: "idle" }], DateTime.toEpochMillis(later)),
2828
).toBeNull();

‎apps/mobile/src/features/threads/thread-command-output.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ export function ThreadCommandOutput(props: {
5353
}
5454
return (
5555
<View className="pt-1.5">
56-
{data?.output.truncated ? (
57-
<Text className="pb-0.5 text-3xs text-foreground-subtle">Earlier output not shown</Text>
58-
) : null}
5956
<ScrollView
6057
ref={scrollRef}
6158
nestedScrollEnabled
@@ -73,6 +70,9 @@ export function ThreadCommandOutput(props: {
7370
if (followRef.current) scrollRef.current?.scrollToEnd({ animated: false });
7471
}}
7572
>
73+
{data?.output.truncated ? (
74+
<Text className="pb-0.5 text-3xs text-foreground-subtle">Earlier output not shown</Text>
75+
) : null}
7676
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
7777
{spans.map((span, index) =>
7878
span.style === null ? (

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
useEffect,
2626
useId,
2727
useLayoutEffect,
28+
useMemo,
2829
useRef,
2930
useState,
3031
type ComponentProps,
@@ -36,6 +37,7 @@ import {
3637
Pressable,
3738
ScrollView,
3839
StyleSheet,
40+
Text as RNText,
3941
useAnimatedValue,
4042
View,
4143
} from "react-native";
@@ -54,6 +56,11 @@ import { useAtomCommand } from "../../state/use-atom-command";
5456
import { toolActivityFaviconUrl } from "@t3tools/shared/favicon";
5557
import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
5658
import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
59+
import { highlightCommand, type HighlightedLines } from "../../lib/highlights";
60+
import {
61+
commandHighlightLanguage,
62+
withVisibleControlCharacters,
63+
} from "@t3tools/client-runtime/work-log/command-label";
5764

5865
import { AppText as Text } from "../../components/ui/AppText";
5966
import { T3Wordmark } from "../../components/T3Wordmark";
@@ -807,6 +814,31 @@ function ToolCodeText({
807814
readonly theme: "light" | "dark";
808815
}) {
809816
const lines = useMarkdownCodeHighlight({ code, language, theme, enabled: true });
817+
return <HighlightedCodeText code={code} lines={lines} />;
818+
}
819+
820+
function CommandCodeText({
821+
command,
822+
theme,
823+
}: {
824+
readonly command: string;
825+
readonly theme: "light" | "dark";
826+
}) {
827+
const code = withVisibleControlCharacters(command.trim());
828+
const lines = useMemo(
829+
() => highlightCommand(code, commandHighlightLanguage(code), theme),
830+
[code, theme],
831+
);
832+
return <HighlightedCodeText code={code} lines={lines} />;
833+
}
834+
835+
function HighlightedCodeText({
836+
code,
837+
lines,
838+
}: {
839+
readonly code: string;
840+
readonly lines: HighlightedLines | null;
841+
}) {
810842
let offset = 0;
811843
const highlighted = lines?.flatMap((line, lineIndex) => {
812844
const separator = lineIndex > 0 ? "\n" : "";
@@ -816,10 +848,11 @@ function ToolCodeText({
816848
...line.map((token) => {
817849
const start = offset;
818850
offset += token.content.length;
851+
// Plain RN Text inherits the mono font; AppText would reset it to sans.
819852
return (
820-
<Text key={start} style={token.color ? { color: token.color } : undefined}>
853+
<RNText key={start} style={token.color ? { color: token.color } : undefined}>
821854
{token.content}
822-
</Text>
855+
</RNText>
823856
);
824857
}),
825858
];
@@ -1179,7 +1212,13 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
11791212
props.renderReasoning(reasoning.text)
11801213
) : call ? (
11811214
[
1182-
call.command,
1215+
call.command ? (
1216+
<CommandCodeText
1217+
key="command"
1218+
command={call.command}
1219+
theme={props.themeAppearance}
1220+
/>
1221+
) : null,
11831222
...(call.args ?? []).map(([key, value]) => {
11841223
const language =
11851224
key === "html"

‎apps/mobile/src/features/threads/userMessageIntentBadge.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ export interface UserMessageIntentBadgePresentation {
77

88
export function resolveUserMessageIntentBadge(
99
intent: OrchestrationV2UserMessageInputIntent | undefined,
10+
unread = false,
1011
): UserMessageIntentBadgePresentation | null {
12+
if (unread && (intent === "steer" || intent === "promoted_queued_to_steer")) {
13+
return {
14+
label: "Steer · waiting to be read",
15+
accessibilityLabel:
16+
"Steer waiting for the agent to read it after the running command finishes",
17+
};
18+
}
1119
switch (intent) {
1220
case "steer":
1321
return {

‎apps/mobile/src/lib/enrichedLinkPresentation.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ describe("Enriched link presentation", () => {
2020
"/tmp/report.md",
2121
"C:\\repo\\app.tsx",
2222
"app.tsx:12:3",
23+
"src/http.ts:42-64",
24+
"http.ts:42-64",
2325
]) {
2426
expect(ENRICHED_INLINE_FILE_LINK_REGEX.test(path), path).toBe(true);
2527
}
2628
for (const text of [
2729
"npm run dev",
2830
"port:3000",
31+
"port:3000-3010",
2932
"TODO:12",
3033
"example.com",
3134
"https://example.com/app.tsx",

‎apps/mobile/src/lib/enrichedLinkPresentation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function enrichedLinkVariantPattern(url: string) {
9292
}
9393

9494
export const ENRICHED_INLINE_FILE_LINK_REGEX =
95-
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+)?)$/;
95+
/^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[A-Za-z0-9._-]+[\\/])+[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+(?::\d+|-\d+)?)?|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+|-\d+)?)$/;
9696

9797
export function enrichedSkillLinkRegex(skills?: ReadonlyArray<SelectableMarkdownSkill>) {
9898
const names = [...new Set(skills?.map((skill) => skill.name) ?? [])].filter(Boolean);

‎apps/mobile/src/lib/highlights.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { pierreDark, pierreLight } from "@pierre/highlights/themes";
33
import { describe, expect, it, vi } from "vite-plus/test";
44

55
import { resolveHighlightLanguage } from "./highlightLanguage";
6-
import { highlightCode, tokenizeCode } from "./highlights";
6+
import { highlightCode, highlightCommand, tokenizeCode, type HighlightedLines } from "./highlights";
77

88
vi.mock("react-native-nitro-modules", async () => {
99
const { createWasmHighlightsModule } = await import("./highlights.testing");
@@ -37,6 +37,19 @@ describe("highlightCode", () => {
3737
}
3838
});
3939

40+
it("colors a command's embedded script with that script's grammar", () => {
41+
const body = "import json\r\nprint(json.dumps({'ok': True}))";
42+
const code = `python3 - <<'PY'\r\n${body}\r\nPY`;
43+
const colors = (lines: HighlightedLines) =>
44+
lines.map((line) => line.map(({ content, color }) => [content, color]));
45+
const lines = highlightCommand(code, "shellscript", "dark");
46+
47+
expect(lines.map((line) => line.map((token) => token.content).join(""))).toEqual(
48+
code.split("\r\n"),
49+
);
50+
expect(colors(lines.slice(1, 3))).toEqual(colors(highlightCode(body, "python", "dark")));
51+
});
52+
4053
it("keeps an over-long line as one plain token", () => {
4154
const longLine = `const data = "${"x".repeat(1_000)}";`;
4255
const [first, second] = highlightCode(`let a = 1;\n${longLine}`, "typescript", "dark");

‎apps/mobile/src/lib/highlights.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import {
2+
embeddedScripts,
3+
withEmbeddedScripts,
4+
type SyntaxToken,
5+
} from "@t3tools/client-runtime/work-log/embedded-scripts";
16
import type { T3Highlights } from "@t3tools/mobile-highlights-native";
27
import { NitroModules } from "react-native-nitro-modules";
38

@@ -82,6 +87,46 @@ export function tokenizeCode(code: string, language: string): TokenizedCode {
8287
};
8388
}
8489

90+
/** Shell commands also color the scripts they embed, such as heredocs and `python -c`. */
91+
export function highlightCommand(
92+
code: string,
93+
language: "shellscript" | "powershell",
94+
scheme: HighlightScheme,
95+
): HighlightedLines {
96+
const tokenize = (text: string, lang: string) => {
97+
// A missing grammar keeps the shell colors, as on web.
98+
if (highlightLanguageId(lang) === 0) throw new Error(`No grammar for ${lang}`);
99+
return withOffsets(text, highlightCode(text, lang, scheme));
100+
};
101+
const embedded = language === "shellscript" ? embeddedScripts(code) : [];
102+
return withEmbeddedScripts(code, tokenize(code, language), embedded, tokenize).map((line) =>
103+
line.map((token) => ({
104+
content: token.content,
105+
color: token.color ?? null,
106+
fontStyle: token.fontStyle ?? null,
107+
})),
108+
);
109+
}
110+
111+
function withOffsets(code: string, lines: HighlightedLines): SyntaxToken[][] {
112+
const endings = code.match(/\r?\n/gu) ?? [];
113+
let offset = 0;
114+
return lines.map((line, index) => {
115+
const tokens = line.map((token) => {
116+
const start = offset;
117+
offset += token.content.length;
118+
return {
119+
content: token.content,
120+
offset: start,
121+
...(token.color ? { color: token.color } : {}),
122+
...(token.fontStyle ? { fontStyle: token.fontStyle } : {}),
123+
};
124+
});
125+
offset += endings[index]?.length ?? 0;
126+
return tokens;
127+
});
128+
}
129+
85130
/** LF and CRLF split lines; a trailing line break yields a final empty line. */
86131
export function highlightCode(
87132
code: string,

0 commit comments

Comments
 (0)