Skip to content

Commit 26aa3a3

Browse files
authored
Merge branch 'main' into fix/chip-trailing-punctuation
2 parents 706025a + 5ef5685 commit 26aa3a3

161 files changed

Lines changed: 6849 additions & 710 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/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const SNAP_SHOT_EVENT_CHANNEL = "desktop:snap-shot-event";
1414
export const WEB_LINK_OPEN_CHANNEL = "desktop:web-link-open";
1515
export const WEB_LINK_READY_CHANNEL = "desktop:web-link-ready";
1616
export const QUIT_SHORTCUT_CHANNEL = "desktop:quit-shortcut";
17+
export const TRACKPAD_SCROLL_BEGIN_CHANNEL = "desktop:trackpad-scroll-begin";
1718
export const TRACKPAD_SCROLL_END_CHANNEL = "desktop:trackpad-scroll-end";
1819
export const GET_WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:get-window-fullscreen-state";
1920
export const WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:window-fullscreen-state";

‎apps/desktop/src/preload.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ contextBridge.exposeInMainWorld("desktopBridge", {
9191
ipcRenderer.on(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, handler);
9292
return () => ipcRenderer.removeListener(IpcChannels.SET_NOTIFICATION_BADGE_CHANNEL, handler);
9393
},
94+
onTrackpadScrollBegin: (listener) => {
95+
const handler = () => listener();
96+
ipcRenderer.on(IpcChannels.TRACKPAD_SCROLL_BEGIN_CHANNEL, handler);
97+
return () => ipcRenderer.removeListener(IpcChannels.TRACKPAD_SCROLL_BEGIN_CHANNEL, handler);
98+
},
9499
onTrackpadScrollEnd: (listener) => {
95100
const handler = () => listener();
96101
ipcRenderer.on(IpcChannels.TRACKPAD_SCROLL_END_CHANNEL, handler);

‎apps/desktop/src/window/DesktopWindow.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
MENU_ACTION_CHANNEL,
2424
QUIT_SHORTCUT_CHANNEL,
2525
SNAP_SHOT_EVENT_CHANNEL,
26+
TRACKPAD_SCROLL_BEGIN_CHANNEL,
2627
TRACKPAD_SCROLL_END_CHANNEL,
2728
WINDOW_FULLSCREEN_STATE_CHANNEL,
2829
} from "../ipc/channels.ts";
@@ -652,7 +653,11 @@ export const make = Effect.gen(function* () {
652653
}
653654
});
654655
window.webContents.on("input-event", (_event, input) => {
655-
if (input.type === "gestureScrollEnd") window.webContents.send(TRACKPAD_SCROLL_END_CHANNEL);
656+
if (input.type === "gestureScrollBegin") {
657+
window.webContents.send(TRACKPAD_SCROLL_BEGIN_CHANNEL);
658+
} else if (input.type === "gestureScrollEnd") {
659+
window.webContents.send(TRACKPAD_SCROLL_END_CHANNEL);
660+
}
656661
});
657662
// Ctrl+wheel bypasses menus; guest contents emit their own zoom-changed event.
658663
window.webContents.on("zoom-changed", (_event, direction) => {

‎apps/mobile/src/features/review/reviewModel.ts‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,22 @@ export function buildReviewSectionItems(input: {
534534
},
535535
);
536536

537-
const gitItems = input.gitSections.map<ReviewSectionItem>((section) => ({
538-
id: `git:${section.kind}`,
539-
kind: section.kind,
540-
title: section.title,
541-
subtitle: gitSubtitle(section),
542-
diff: section.diff,
543-
source: section,
544-
...(section.files ? { files: section.files } : {}),
545-
truncated: section.truncated,
546-
isLoading: false,
547-
}));
537+
const gitItems = input.gitSections
538+
.filter(
539+
(section): section is typeof section & { kind: ReviewSectionKind } =>
540+
section.kind !== "commit",
541+
)
542+
.map<ReviewSectionItem>((section) => ({
543+
id: `git:${section.kind}`,
544+
kind: section.kind,
545+
title: section.title,
546+
subtitle: gitSubtitle(section),
547+
diff: section.diff,
548+
source: section,
549+
...(section.files ? { files: section.files } : {}),
550+
truncated: section.truncated,
551+
isLoading: false,
552+
}));
548553
const hasChangesItem = gitItems.some((item) => item.id === CHANGES_SECTION_ID);
549554
const visibleGitItems =
550555
input.loadingGitSections && !hasChangesItem

‎apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
294294
void run("refresh", async () => {
295295
if (!readEnvironmentScope(environmentId, AuthOrchestrationReadScope))
296296
return;
297-
const result = await refreshProviders({ environmentId, input: {} });
297+
const result = await refreshProviders({
298+
environmentId,
299+
input: { reloadSecrets: true },
300+
});
298301
if (AsyncResult.isFailure(result)) throw squashAtomCommandFailure(result);
299302
setNotice("Provider status refreshed.");
300303
});

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type {
4646
ScopedThreadRef,
4747
ServerConfig as T3ServerConfig,
4848
UsageLimitsReport,
49+
RunId,
4950
} from "@t3tools/contracts";
5051
import {
5152
appendCodexArtifactTemplateUsePrompt,
@@ -156,8 +157,10 @@ import {
156157
import { appAtomRegistry } from "../../state/atom-registry";
157158
import { threadStreamHaptics } from "./threadStreamHaptics";
158159
import { useAtomCommand } from "../../state/use-atom-command";
160+
import { orchestrationEnvironment } from "../../state/orchestration";
159161
import { useDelayedStatus } from "../../lib/useDelayedStatus";
160162
import type { PendingUserInputDraftAnswer } from "@t3tools/client-runtime/state/pending-user-input";
163+
import type { RunStopPresentation } from "@t3tools/client-runtime/state/thread-execution";
161164
import type {
162165
PendingApproval,
163166
PendingUserInput,
@@ -339,6 +342,9 @@ const threadVisitTracker = createThreadVisitTracker({
339342

340343
// Past the composer's 180 ms height animation.
341344
const COMPOSER_HEIGHT_SETTLE_MS = 220;
345+
const NO_RUN_STOP_ATOM = Atom.make<RunStopPresentation | null>(null).pipe(
346+
Atom.withLabel("mobile-thread-run-stop:empty"),
347+
);
342348

343349
// Anchors, the submitted message, follow state and pending scrolls belong to
344350
// one thread, so the body remounts when the thread changes.
@@ -528,6 +534,50 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
528534
const unsettleThread = useAtomCommand(threadEnvironment.unsettle, { reportFailure: false });
529535
const updateMetadata = useAtomCommand(threadEnvironment.updateMetadata, { reportFailure: false });
530536
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
537+
const anyRunStop = useAtomValue(
538+
props.selectedThreadDetailRef === null
539+
? NO_RUN_STOP_ATOM
540+
: environmentThreadDetails.runStopAtom(props.selectedThreadDetailRef),
541+
);
542+
// A background Stop matters only while that work is still pending.
543+
const runStop =
544+
anyRunStop?.background && props.selectedThread.pendingBackgroundTasks.length === 0
545+
? null
546+
: anyRunStop;
547+
const forceStopThread = useAtomCommand(orchestrationEnvironment.forceStopThread, {
548+
reportFailure: false,
549+
});
550+
const canForceStop =
551+
useAtomValue(orchestrationEnvironment.forceStopThread.permissionAtom(props.environmentId)) &&
552+
props.serverConfig?.environment.capabilities.threadForceStop === true;
553+
const [forceStoppingKey, setForceStoppingKey] = useState<string | null>(null);
554+
// The run that ignored Stop, so a confirmation left open cannot hit a newer run.
555+
const forceStop = async (runId: RunId | undefined) => {
556+
const threadKey = selectedThreadKey;
557+
setForceStoppingKey(threadKey);
558+
const result = await forceStopThread({
559+
environmentId: props.environmentId,
560+
input:
561+
runId === undefined
562+
? { threadId: props.selectedThread.id }
563+
: { threadId: props.selectedThread.id, runId },
564+
});
565+
setForceStoppingKey((current) => (current === threadKey ? null : current));
566+
if (result._tag === "Failure") {
567+
if (!isAtomCommandInterrupted(result)) Dialog.alert("Could not force stop the agent");
568+
return;
569+
}
570+
const others = result.value.sharedWithThreadIds.length;
571+
if (result.value.outcome === "releasing") {
572+
Dialog.alert("Turn stopped; the agent is still shutting down");
573+
}
574+
if (result.value.outcome === "shared") {
575+
Dialog.alert(
576+
"Turn stopped; the agent process kept running",
577+
`It is shared with ${others === 0 ? "other" : others} working ${others === 1 ? "thread" : "threads"}. Stop those to free it.`,
578+
);
579+
}
580+
};
531581
const [statusRequest, setStatusRequest] = useState<{ threadKey: string } | null>(null);
532582
const statusPending = statusRequest?.threadKey === selectedThreadKey;
533583
const [lifecycleNow, setLifecycleNow] = useState(() => new Date().toISOString());
@@ -619,6 +669,32 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {
619669
if (connectionStatus !== null && !props.draftMode) {
620670
return connectionStatus;
621671
}
672+
// Before the request check: an agent stuck on an approval may also ignore Stop.
673+
if (runStop !== null && contentPresentationKind === "ready") {
674+
const unresponsive = runStop.state === "unresponsive";
675+
return {
676+
kind: "stop",
677+
unresponsive,
678+
label: unresponsive ? "Not responding to Stop" : "Stopping…",
679+
action:
680+
unresponsive && canForceStop
681+
? {
682+
label: forceStoppingKey === selectedThreadKey ? "Force stopping..." : "Force stop",
683+
accessibilityLabel: "Force stop the agent",
684+
disabled: forceStoppingKey === selectedThreadKey,
685+
onPress: () =>
686+
Dialog.confirm({
687+
title: "Force stop the agent?",
688+
message:
689+
"It has not answered Stop. Force stop ends the turn and kills the agent's processes, unless other working threads share them.",
690+
confirmText: "Force stop",
691+
destructive: true,
692+
onConfirm: () => void forceStop(runStop.runId),
693+
}),
694+
}
695+
: null,
696+
};
697+
}
622698
if (props.activePendingApproval !== null || props.activePendingUserInput !== null) {
623699
return null;
624700
}

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ export function FloatingWorkingControl(props: {
8383
const [queueWidth, setQueueWidth] = useState(0);
8484
const [actionWidth, setActionWidth] = useState(0);
8585
const action =
86-
props.status?.kind === "background" || props.status?.kind === "lifecycle"
86+
props.status?.kind === "background" ||
87+
props.status?.kind === "lifecycle" ||
88+
props.status?.kind === "stop"
8789
? props.status.action
8890
: null;
8991
const [agentsWidth, setAgentsWidth] = useState(0);
@@ -471,6 +473,30 @@ function FloatingStatusLabel(props: {
471473
</StatusLabelRow>
472474
);
473475
}
476+
if (props.status.kind === "stop") {
477+
return (
478+
<StatusLabelRow
479+
key="stop"
480+
accessibilityLabel={props.status.label}
481+
className="gap-2"
482+
onLayout={props.onLayout}
483+
>
484+
{props.status.unresponsive ? (
485+
<SymbolView
486+
name="exclamationmark.triangle"
487+
size={13}
488+
tintColorClassName="accent-warning-foreground"
489+
type="monochrome"
490+
/>
491+
) : (
492+
<AppActivityIndicator size="small" colorClassName="accent-icon-muted" />
493+
)}
494+
<Text className="shrink font-t3-medium text-xs text-foreground" numberOfLines={1}>
495+
{props.status.label}
496+
</Text>
497+
</StatusLabelRow>
498+
);
499+
}
474500
if (props.status.kind === "goal") {
475501
return (
476502
<StatusLabelRow

‎apps/mobile/src/features/threads/floating-working-status.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export type FloatingWorkingStatus =
3131
readonly label: string;
3232
readonly action: FloatingStatusAction;
3333
}
34+
| {
35+
readonly kind: "stop";
36+
readonly label: string;
37+
readonly unresponsive: boolean;
38+
readonly action: FloatingStatusAction | null;
39+
}
3440
| { readonly kind: "goal"; readonly label: string; readonly accessibilityLabel: string }
3541
| { readonly kind: "preparing"; readonly label: string }
3642
| {

‎apps/server/package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
"@opencode-ai/sdk": "^1.3.15",
7979
"@t3tools/contracts": "workspace:*",
8080
"@t3tools/provider-testing": "workspace:*",
81+
"@t3tools/secret-provider-core": "workspace:*",
82+
"@t3tools/secret-provider-definitions": "workspace:*",
83+
"@t3tools/secret-provider-onepassword": "workspace:*",
8184
"@t3tools/shared": "workspace:*",
8285
"@t3tools/source-control-testing": "workspace:*",
8386
"@t3tools/ssh": "workspace:*",

‎apps/server/src/auth/RpcAuthorization.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
AuthProvidersManageScope,
66
AuthSettingsWriteScope,
77
DEFAULT_SERVER_SETTINGS,
8+
ProviderDriverKind,
89
ProviderInstanceId,
910
SecretProviderId,
1011
ThreadId,
@@ -164,13 +165,34 @@ describe("settings mutation authorization", () => {
164165
);
165166
yield* client[WS_METHODS.serverUpdateSettings]({ patch: {}, providerInstanceMutation });
166167
expect(handled).toBe(1);
168+
yield* client[WS_METHODS.serverUpdateSettings]({
169+
patch: {},
170+
providerInstanceMutation: {
171+
operation: "upsert",
172+
instanceId: ProviderInstanceId.make("codex_work"),
173+
instance: {
174+
driver: ProviderDriverKind.make("codex"),
175+
environment: [
176+
{
177+
name: "OPENAI_API_KEY",
178+
sensitive: true,
179+
value: {
180+
provider: SecretProviderId.make("personal"),
181+
reference: "op://Private/OpenAI/credential",
182+
},
183+
},
184+
],
185+
},
186+
},
187+
});
188+
expect(handled).toBe(2);
167189
expect(
168190
yield* client[WS_METHODS.serverUpdateSettings]({
169191
patch: { defaultRuntimeMode: "full-access" },
170192
providerInstanceMutation,
171193
}).pipe(Effect.flip),
172194
).toMatchObject({ requiredPermission: AuthSettingsWriteScope });
173-
expect(handled).toBe(1);
195+
expect(handled).toBe(2);
174196
}).pipe(Effect.scoped),
175197
);
176198

0 commit comments

Comments
 (0)