Skip to content

Commit 2368541

Browse files
Merge browser ownership fixes and preserve timeout isolation
2 parents 1ead03a + dbd8343 commit 2368541

91 files changed

Lines changed: 1772 additions & 405 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/desktop/src/app/DesktopCliCommand.test.ts‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
2-
import { expect, it } from "@effect/vitest";
2+
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
33
import * as Effect from "effect/Effect";
44
import * as FileSystem from "effect/FileSystem";
55
import * as Option from "effect/Option";
@@ -85,6 +85,15 @@ const fakePowerShell = (initial: string) => {
8585
return { registry, spawner };
8686
};
8787

88+
// The machine's own PATH may already hold a t3; each test sets the PATH it means.
89+
const machinePath = process.env.PATH;
90+
beforeEach(() => {
91+
process.env.PATH = "";
92+
});
93+
afterEach(() => {
94+
process.env.PATH = machinePath;
95+
});
96+
8897
it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
8998
it.effect("links the launcher onto PATH and removes only that link", () =>
9099
Effect.gen(function* () {
@@ -165,24 +174,31 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
165174
}).pipe(Effect.scoped),
166175
);
167176

168-
it.effect("reports when another t3 earlier on PATH would run instead", () =>
177+
it.effect("refuses to install behind another t3 that runs first", () =>
169178
Effect.gen(function* () {
170179
const fs = yield* FileSystem.FileSystem;
171180
const path = yield* Path.Path;
172181
const home = yield* fs.makeTempDirectoryScoped();
173182
const shadow = path.join(home, "shadow");
174183
yield* fs.makeDirectory(shadow);
175184
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
176-
const previous = process.env.PATH;
177185
process.env.PATH = [shadow, path.join(home, ".local", "bin")].join(":");
178-
yield* Effect.addFinalizer(() => Effect.sync(() => (process.env.PATH = previous)));
179186

180187
const command = yield* commandIn({ home });
188+
const theirs = path.join(shadow, "t3");
189+
expect((yield* command.state).shadowedBy).toBe(theirs);
190+
// A link behind it would never run, so nothing is created.
191+
const error = yield* Effect.flip(command.install);
192+
expect(error.message).toContain(theirs);
193+
expect(yield* fs.exists(path.join(home, ".local", "bin", "t3"))).toBe(false);
194+
195+
yield* fs.remove(theirs);
181196
const installed = yield* command.install;
182-
expect(installed.installedPath).toBe(path.join(home, ".local", "bin", "t3"));
183-
expect(installed.onPath).toBe(false);
184-
yield* fs.remove(path.join(shadow, "t3"));
185-
expect((yield* command.state).onPath).toBe(true);
197+
expect(installed).toMatchObject({
198+
onPath: true,
199+
installedPath: path.join(home, ".local", "bin", "t3"),
200+
});
201+
expect(installed.shadowedBy).toBeUndefined();
186202
}).pipe(Effect.scoped),
187203
);
188204

‎apps/desktop/src/app/DesktopCliCommand.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ export const make = Effect.gen(function* () {
146146
return Option.none<string>();
147147
});
148148

149+
/** The `t3` a new shell runs when it is not this app's, on Unix. */
150+
const foreignFirstOnPath = Effect.gen(function* () {
151+
if (windows) return Option.none<string>();
152+
const first = yield* firstOnPath;
153+
if (Option.isNone(first) || (yield* isOurLink(first.value))) return Option.none<string>();
154+
return first;
155+
});
156+
149157
/** Where this app's command is installed now, if anywhere. */
150158
const installedAt = Effect.gen(function* () {
151159
if (windows) {
@@ -167,12 +175,16 @@ export const make = Effect.gen(function* () {
167175
return { supported: false, installedPath: null, onPath: false } as const;
168176
}
169177
const installed = yield* installedAt;
170-
if (Option.isNone(installed)) return { supported: true, installedPath: null, onPath: false };
178+
const shadowedBy = yield* foreignFirstOnPath;
179+
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
180+
if (Option.isNone(installed)) {
181+
return { supported: true, installedPath: null, onPath: false, ...shadow };
182+
}
171183
// On Windows only terminals opened after the change see it. On Unix the
172184
// first `t3` on PATH must be ours; a `t3` earlier on PATH would shadow it.
173185
const first = yield* firstOnPath;
174186
const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
175-
return { supported: true, installedPath: installed.value, onPath };
187+
return { supported: true, installedPath: installed.value, onPath, ...shadow };
176188
}).pipe(Effect.orElseSucceed(() => ({ supported: false, installedPath: null, onPath: false })));
177189

178190
/** Writes the launcher if the app has not yet, e.g. when no local backend runs. */
@@ -209,6 +221,13 @@ export const make = Effect.gen(function* () {
209221
.remove(existing.value)
210222
.pipe(Effect.mapError(() => fail(`Could not replace ${existing.value}.`)));
211223
}
224+
// A link behind another `t3` never runs, so installing one would only hide the problem.
225+
const shadowedBy = yield* foreignFirstOnPath;
226+
if (Option.isSome(shadowedBy)) {
227+
return yield* fail(
228+
`Another t3 at ${shadowedBy.value} runs first in a new terminal. Remove it, or run the launcher directly at ${launcher}.`,
229+
);
230+
}
212231
const onPath = pathEntries(process.env.PATH, ":");
213232
const candidates = unixCandidates(environment.homeDirectory, environment.platform);
214233
// Prefer a folder already on PATH that the user can write to without admin rights.

‎apps/mobile/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"@t3tools/mobile-review-diff-native": "file:./modules/t3-review-diff",
7171
"@t3tools/mobile-terminal-native": "file:./modules/t3-terminal",
7272
"@t3tools/provider-core": "workspace:*",
73+
"@t3tools/provider-muse": "workspace:*",
7374
"@t3tools/provider-pi": "workspace:*",
7475
"@t3tools/shared": "workspace:*",
7576
"@tabler/icons-react-native": "^3.44.0",

‎apps/mobile/src/components/AppSymbol.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
3737
import IconChevronUp from "@tabler/icons-react-native/IconChevronUp";
3838
import IconCircle from "@tabler/icons-react-native/IconCircle";
3939
import IconCircleCheck from "@tabler/icons-react-native/IconCircleCheck";
40+
import IconCircleDashed from "@tabler/icons-react-native/IconCircleDashed";
4041
import IconCircleXFilled from "@tabler/icons-react-native/IconCircleXFilled";
4142
import IconTicket from "@tabler/icons-react-native/IconTicket";
4243
import IconClock from "@tabler/icons-react-native/IconClock";
@@ -75,6 +76,7 @@ import IconMicrophone from "@tabler/icons-react-native/IconMicrophone";
7576
import IconLink from "@tabler/icons-react-native/IconLink";
7677
import IconListNumbers from "@tabler/icons-react-native/IconListNumbers";
7778
import IconMenu2 from "@tabler/icons-react-native/IconMenu2";
79+
import IconMessageCircleQuestion from "@tabler/icons-react-native/IconMessageCircleQuestion";
7880
import IconMessage from "@tabler/icons-react-native/IconMessage";
7981
import IconMinus from "@tabler/icons-react-native/IconMinus";
8082
import IconMoon from "@tabler/icons-react-native/IconMoon";
@@ -98,6 +100,7 @@ import IconStar from "@tabler/icons-react-native/IconStar";
98100
import IconStarFilled from "@tabler/icons-react-native/IconStarFilled";
99101
import IconStethoscope from "@tabler/icons-react-native/IconStethoscope";
100102
import IconSun from "@tabler/icons-react-native/IconSun";
103+
import IconShieldQuestion from "@tabler/icons-react-native/IconShieldQuestion";
101104
import IconTarget from "@tabler/icons-react-native/IconTarget";
102105
import IconTerminal2 from "@tabler/icons-react-native/IconTerminal2";
103106
import IconTextDecrease from "@tabler/icons-react-native/IconTextDecrease";
@@ -148,6 +151,7 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
148151
checkmark: IconCheck,
149152
"checkmark.circle": IconCircleCheck,
150153
circle: IconCircle,
154+
"circle.dashed": IconCircleDashed,
151155
clock: IconClock,
152156
timer: IconClock,
153157
ticket: IconTicket,
@@ -221,6 +225,8 @@ const ANDROID_ICON_BY_SF_SYMBOL = {
221225
terminal: IconTerminal2,
222226
"text.alignleft": IconAlignLeft,
223227
"text.bubble": IconMessage,
228+
"questionmark.bubble": IconMessageCircleQuestion,
229+
"exclamationmark.shield": IconShieldQuestion,
224230
"text.word.spacing": IconLetterSpacing,
225231
"textformat.size": IconTypography,
226232
"textformat.size.larger": IconTextIncrease,

‎apps/mobile/src/components/ProviderIcon.tsx‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,6 @@ export function ProviderIcon(props: ProviderIconProps) {
120120
);
121121
}
122122

123-
if (props.provider === "muse") {
124-
return (
125-
<Svg width={size} height={size} viewBox="0 0 150.4828 100" fill="none">
126-
<Path
127-
fill={mono}
128-
fillRule="evenodd"
129-
d="M107.9999847,0.0000013c-12.3391113,0-21.984787,9.2935991-30.7164001,21.0993118 C65.2847366,5.821527,55.2499847,0,43.2413788,0C18.7586193,0,0,31.8620682,0,65.5862122 C0,86.6896515,10.2095623,100,27.3103466,100c12.3080502,0,21.1600361-5.8025894,36.8965454-33.3103409 c0,0,6.5597382-11.5841255,11.0725021-19.563858c1.5813522,2.5531845,3.2431107,5.3001404,4.9964676,8.2535095 l7.379303,12.4137955C102.0298843,91.8478851,110.039032,100,124.5517273,100 c16.6595764,0,25.9310303-13.4923325,25.9310303-35.0344849 C150.4827576,29.6551723,131.301178,0.0000013,107.9999847,0.0000013z M52.2068977,59.2413788 c-12.7586212,20-17.1724167,24.4827576-24.2758656,24.4827576c-7.3103428,0-11.6551704-6.4178314-11.6551704-17.8620682 c0-24.4827576,12.2068977-49.5172424,26.7586231-49.5172424c7.880127,0,14.4653816,4.5510426,24.5522308,18.9913158 C58.0087967,50.0272293,52.2068977,59.2413788,52.2068977,59.2413788z M100.3597336,56.7235756L91.5367355,42.00877 c-2.3876724-3.8832092-4.6757278-7.451458-6.8838348-10.7230263 c7.951973-12.273531,14.5113449-18.3891907,22.3126144-18.3891907c16.2069016,0,29.1724243,23.8620682,29.1724243,53.1724091 c0,11.1724167-3.6593475,17.6551743-11.2413864,17.6551743 C117.6294937,83.7241364,114.1578674,78.924736,100.3597336,56.7235756z"
130-
/>
131-
</Svg>
132-
);
133-
}
134-
135123
const packageIcon = getProviderClient(props.provider)?.icon;
136124
if (packageIcon) {
137125
const themeFill = (fill: { readonly light: string; readonly dark: string }) =>

‎apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ function WorkspaceStackView(props: ViewProps) {
247247
const routes = [baseRoute, ...overlays.map((group) => group[0]!)];
248248
return (
249249
<NativeStackView
250+
presentationEnvelope
250251
{...props}
251252
state={{ ...props.state, routes, index: routes.length - 1, preloadedRoutes: [] }}
252253
descriptors={{

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

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Alert, Pressable, useWindowDimensions, View } from "react-native";
2525
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
2626

2727
import type { ThreadListProvider } from "../../state/thread-list-environments";
28-
import { SymbolView } from "../../components/AppSymbol";
28+
import { SymbolView, type AppSymbolName } from "../../components/AppSymbol";
2929
import { AppText as Text } from "../../components/AppText";
3030
import { ControlPillMenu } from "../../components/ControlPill";
3131
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
@@ -51,6 +51,7 @@ import {
5151
type ThreadListV2Status,
5252
} from "./threadListV2";
5353
import { QueuedMessageIcon } from "./queued-message-icon";
54+
import { shouldRecedeThreadRow } from "./thread-row-emphasis";
5455
import { ThreadSearchMatchExcerpt } from "./thread-search-match";
5556

5657
/**
@@ -63,14 +64,50 @@ import { ThreadSearchMatchExcerpt } from "./thread-search-match";
6364
// Status hues follow the system-wide convention set by sidebar v1 and the
6465
// Live Activity/widgets (amber approval, indigo input, sky working) so a
6566
// thread reads the same color everywhere it surfaces.
66-
const STATUS_LABEL_BY_STATUS: Partial<
67-
Record<ThreadListV2Status, { label: string; className: string }>
68-
> = {
69-
approval: { label: "Approval", className: "text-warning-foreground" },
70-
input: { label: "Input", className: "text-adaptive-indigo-600-300" },
71-
working: { label: "Working", className: "text-adaptive-sky-600-400" },
72-
failed: { label: "Failed", className: "text-danger-foreground" },
73-
limited: { label: "Limited", className: "text-warning-foreground" },
67+
// Icons match the web sidebar's status glyphs.
68+
interface StatusLabel {
69+
readonly label: string;
70+
readonly icon: AppSymbolName;
71+
readonly className: string;
72+
readonly iconTintClassName: string;
73+
}
74+
const STATUS_LABEL_BY_STATUS: Partial<Record<ThreadListV2Status, StatusLabel>> = {
75+
approval: {
76+
label: "Approval",
77+
icon: "exclamationmark.shield",
78+
className: "text-warning-foreground",
79+
iconTintClassName: "accent-warning-foreground",
80+
},
81+
input: {
82+
label: "Input",
83+
icon: "questionmark.bubble",
84+
className: "text-adaptive-indigo-600-300",
85+
iconTintClassName: "accent-adaptive-indigo-600-300",
86+
},
87+
working: {
88+
label: "Working",
89+
icon: "circle.dashed",
90+
className: "text-adaptive-sky-600-400",
91+
iconTintClassName: "accent-adaptive-sky-600-400",
92+
},
93+
failed: {
94+
label: "Failed",
95+
icon: "exclamationmark.circle",
96+
className: "text-danger-foreground",
97+
iconTintClassName: "accent-danger-foreground",
98+
},
99+
limited: {
100+
label: "Limited",
101+
icon: "exclamationmark.circle",
102+
className: "text-warning-foreground",
103+
iconTintClassName: "accent-warning-foreground",
104+
},
105+
};
106+
const DONE_STATUS_LABEL: StatusLabel = {
107+
label: "Done",
108+
icon: "checkmark.circle",
109+
className: "text-adaptive-emerald-700-300",
110+
iconTintClassName: "accent-adaptive-emerald-700-300",
74111
};
75112

76113
// Menus keep lifecycle and title regeneration together. Archive keeps its
@@ -593,8 +630,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
593630
// A native /goal keeps the agent going across turns until it is met.
594631
(status === "working" && workingLabel !== undefined && thread.goal?.status === "active"
595632
? { ...workingLabel, label: "Goal" }
596-
: workingLabel) ??
597-
(isUnread ? { label: "Done", className: "text-adaptive-emerald-700-300" } : undefined);
633+
: workingLabel) ?? (isUnread ? DONE_STATUS_LABEL : undefined);
634+
const recede = shouldRecedeThreadRow({ status, selected });
598635
// The timestamp is precomputed on the list item (same stamps the settled
599636
// tail sorts by) so a minute tick only re-renders rows that draw it.
600637
const timeLabel = props.timeLabel;
@@ -959,21 +996,44 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
959996
type="monochrome"
960997
/>
961998
) : null}
962-
<Text
963-
className={cn(
964-
"text-xs tabular-nums",
965-
statusLabel?.className ??
966-
(selected
999+
{statusLabel ? (
1000+
<View className="flex-row items-center gap-1">
1001+
<SymbolView
1002+
name={statusLabel.icon}
1003+
size={13}
1004+
tintColorClassName={
1005+
selected ? selectedThreadRowColors.iconTintClassName : statusLabel.iconTintClassName
1006+
}
1007+
type="monochrome"
1008+
weight="semibold"
1009+
/>
1010+
<Text
1011+
className={cn(
1012+
"text-xs font-t3-bold",
1013+
selected ? selectedThreadRowColors.foregroundClassName : statusLabel.className,
1014+
)}
1015+
>
1016+
{statusLabel.label}
1017+
</Text>
1018+
</View>
1019+
) : (
1020+
<Text
1021+
className={cn(
1022+
"text-xs tabular-nums",
1023+
selected
9671024
? selectedThreadRowColors.foregroundClassName
968-
: rowAppearance.tertiaryForegroundClassName),
969-
)}
970-
>
971-
{statusLabel?.label ?? timeLabel}
972-
</Text>
1025+
: rowAppearance.tertiaryForegroundClassName,
1026+
)}
1027+
>
1028+
{timeLabel}
1029+
</Text>
1030+
)}
9731031
</View>
9741032
<Text
9751033
className={cn(
976-
"mt-1 text-base font-t3-medium",
1034+
"mt-1 text-base",
1035+
// Background work recedes to regular weight, matching web.
1036+
!recede && "font-t3-medium",
9771037
selected
9781038
? selectedThreadRowColors.foregroundClassName
9791039
: rowAppearance.foregroundClassName,
@@ -1115,6 +1175,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
11151175
</>
11161176
);
11171177

1178+
// Background work fades as a whole, status label included, so it takes
1179+
// less attention than rows that need a human (input, approval, done).
1180+
const fadedCardContent = recede ? (
1181+
<View style={{ opacity: 0.55 }}>{cardContent}</View>
1182+
) : (
1183+
cardContent
1184+
);
1185+
11181186
const rowContent = (close: () => void) =>
11191187
variant === "card" ? (
11201188
<RowPressable
@@ -1135,14 +1203,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
11351203
style={rowAppearance.cardStyle}
11361204
>
11371205
{sidebarPane ? (
1138-
cardContent
1206+
fadedCardContent
11391207
) : (
11401208
/* Flat native list rows: no tonal containers — colored status
11411209
labels and text hierarchy carry state, an inset hairline
11421210
separates rows. The opaque screen background stays so swipe
11431211
actions reveal behind the row. */
11441212
<View>
1145-
<View className={THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME}>{cardContent}</View>
1213+
<View className={THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME}>{fadedCardContent}</View>
11461214
{THREAD_LIST_V2_ROW_DIVIDERS && props.showTrailingDivider !== false ? (
11471215
<View className="ml-5 h-px bg-border-subtle" />
11481216
) : null}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
3+
import { shouldRecedeThreadRow } from "./thread-row-emphasis";
4+
5+
describe("shouldRecedeThreadRow", () => {
6+
it("recedes background work", () => {
7+
expect(shouldRecedeThreadRow({ status: "working", selected: false })).toBe(true);
8+
expect(shouldRecedeThreadRow({ status: "waiting", selected: false })).toBe(true);
9+
});
10+
11+
it("keeps rows that need a human at full strength", () => {
12+
for (const status of ["approval", "input", "failed", "limited", "ready"] as const) {
13+
expect(shouldRecedeThreadRow({ status, selected: false })).toBe(false);
14+
}
15+
});
16+
17+
it("never fades the selected row", () => {
18+
expect(shouldRecedeThreadRow({ status: "working", selected: true })).toBe(false);
19+
});
20+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ThreadListV2Status } from "./threadListV2";
2+
3+
/**
4+
* Mirrors web's recede rule: background work fades so rows that need a
5+
* human (approval, input, failure, unseen completion) stand out. An unseen
6+
* completion cannot pull a still-working thread forward.
7+
*/
8+
export function shouldRecedeThreadRow(input: {
9+
readonly status: ThreadListV2Status;
10+
readonly selected: boolean;
11+
}): boolean {
12+
return !input.selected && (input.status === "working" || input.status === "waiting");
13+
}

0 commit comments

Comments
 (0)