Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Add react-query, refactor BranchToolbar async state, and fix stale deps

Julius Marminge807e3d18dec8
diff --git a/AGENTS.md b/AGENTS.md
index 7f5148fce..affea58d0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,11 +1,13 @@
# CLAUDE.md
## Project Snapshot
+
T3 Code is a minimal web GUI for using code agents like Codex and Claude Code (coming soon).
This repository is a VERY EARLY WIP. Proposing sweeping changes that improve long-term maintainability is encouraged.
## Core Priorities
+
1. Performance first.
2. Reliability first.
3. Keep behavior predictable under load and during failures (session restarts, reconnects, partial streams).
@@ -13,23 +15,28 @@ This repository is a VERY EARLY WIP. Proposing sweeping changes that improve lon
If a tradeoff is required, choose correctness and robustness over short-term convenience.
## Package Roles
+
- `apps/server`: Node.js WebSocket server. Wraps Codex app-server (JSON-RPC over stdio), serves the React web app, and manages provider sessions.
- `apps/web`: React/Vite UI. Owns session UX, conversation/event rendering, and client-side state. Connects to the server via WebSocket.
- `packages/contracts`: Shared Zod schemas and TypeScript contracts for provider events, WebSocket protocol, and model/session types.
## Codex App Server (Important)
+
T3 Code is currently Codex-first. The server starts `codex app-server` (JSON-RPC over stdio) per provider session, then streams structured events to the browser through WebSocket push messages.
How we use it in this codebase:
+
- Session startup/resume and turn lifecycle are brokered in `apps/server/src/codexAppServerManager.ts`.
- Provider dispatch and thread event logging are coordinated in `apps/server/src/providerManager.ts`.
- WebSocket server routes NativeApi methods in `apps/server/src/wsServer.ts`.
- Web app consumes provider event streams via WebSocket push on channel `providers.event`.
Docs:
+
- Codex App Server docs: https://developers.openai.com/codex/sdk/#app-server
## Reference Repos
+
- Open-source Codex repo: https://github.com/openai/codex
- Codex-Monitor (Tauri, feature-complete, strong reference implementation): https://github.com/Dimillian/CodexMonitor
diff --git a/apps/desktop/turbo.jsonc b/apps/desktop/turbo.jsonc
index 8994c7806..2ff803229 100644
--- a/apps/desktop/turbo.jsonc
+++ b/apps/desktop/turbo.jsonc
@@ -4,21 +4,21 @@
"tasks": {
"build": {
"dependsOn": ["^build"],
- "outputs": ["dist-electron/**"]
+ "outputs": ["dist-electron/**"],
},
"dev": {
"dependsOn": ["t3#build"],
- "persistent": true
+ "persistent": true,
},
"start": {
"dependsOn": ["build", "@t3tools/web#build", "t3#build"],
"cache": false,
- "persistent": true
+ "persistent": true,
},
"smoke-test": {
"dependsOn": ["build", "@t3tools/web#build", "t3#build"],
"cache": false,
- "outputs": []
- }
- }
+ "outputs": [],
+ },
+ },
}
diff --git a/apps/server/src/codexAppServerManager.test.ts b/apps/server/src/codexAppServerManager.test.ts
index b611e4d4d..7c87e4442 100644
--- a/apps/server/src/codexAppServerManager.test.ts
+++ b/apps/server/src/codexAppServerManager.test.ts
@@ -57,17 +57,13 @@ describe("normalizeCodexModelSlug", () => {
describe("isRecoverableThreadResumeError", () => {
it("matches not-found resume errors", () => {
expect(
- isRecoverableThreadResumeError(
- new Error("thread/resume failed: thread not found"),
- ),
+ isRecoverableThreadResumeError(new Error("thread/resume failed: thread not found")),
).toBe(true);
});
it("ignores non-resume errors", () => {
expect(
- isRecoverableThreadResumeError(
- new Error("thread/start failed: permission denied"),
- ),
+ isRecoverableThreadResumeError(new Error("thread/start failed: permission denied")),
).toBe(false);
});
diff --git a/apps/server/src/codexAppServerManager.ts b/apps/server/src/codexAppServerManager.ts
index af1e67e36..f4ed54ab1 100644
--- a/apps/server/src/codexAppServerManager.ts
+++ b/apps/server/src/codexAppServerManager.ts
@@ -26,9 +26,7 @@ interface PendingRequest {
interface PendingApprovalRequest {
requestId: string;
jsonRpcId: string | number;
- method:
- | "item/commandExecution/requestApproval"
- | "item/fileChange/requestApproval";
+ method: "item/commandExecution/requestApproval" | "item/fileChange/requestApproval";
requestKind: ProviderRequestKind;
threadId?: string;
turnId?: string;
@@ -122,16 +120,12 @@ export function classifyCodexStderrLine(rawLine: string): { message: string } |
}
export function isRecoverableThreadResumeError(error: unknown): boolean {
- const message = (
- error instanceof Error ? error.message : String(error)
- ).toLowerCase();
+ const message = (error instanceof Error ? error.message : String(error)).toLowerCase();
if (!message.includes("thread/resume")) {
return false;
}
- return RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS.some((snippet) =>
- message.includes(snippet),
- );
+ return RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS.some((snippet) => message.includes(snippet));
}
export interface CodexAppServerManagerEvents {
@@ -209,14 +203,10 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
if (input.resumeThreadId) {
try {
threadOpenMethod = "thread/resume";
- threadOpenResponse = await this.sendRequest(
- context,
- "thread/resume",
- {
- ...sessionOverrides,
- threadId: input.resumeThreadId,
- },
- );
+ threadOpenResponse = await this.sendRequest(context, "thread/resume", {
+ ...sessionOverrides,
+ threadId: input.resumeThreadId,
+ });
} catch (error) {
if (!isRecoverableThreadResumeError(error)) {
throw error;
@@ -228,19 +218,11 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
"session/threadResumeFallback",
`Could not resume thread ${input.resumeThreadId}; started a new thread instead.`,
);
- threadOpenResponse = await this.sendRequest(
- context,
- "thread/start",
- threadStartParams,
- );
+ threadOpenResponse = await this.sendRequest(context, "thread/start", threadStartParams);
}
} else {
threadOpenMethod = "thread/start";
- threadOpenResponse = await this.sendRequest(
- context,
- "thread/start",
- threadStartParams,
- );
+ threadOpenResponse = await this.sendRequest(context, "thread/start", threadStartParams);
}
const threadOpenRecord = this.readObject(threadOpenResponse);
@@ -248,9 +230,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
this.readString(this.readObject(threadOpenRecord, "thread"), "id") ??
this.readString(threadOpenRecord, "threadId");
if (!threadId) {
- throw new Error(
- `${threadOpenMethod} response did not include a thread id.`,
- );
+ throw new Error(`${threadOpenMethod} response did not include a thread id.`);
}
this.updateSession(context, {
@@ -732,9 +712,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
};
}
- private requestKindForMethod(
- method: string,
- ): ProviderRequestKind | undefined {
+ private requestKindForMethod(method: string): ProviderRequestKind | undefined {
if (method === "item/commandExecution/requestApproval") {
return "command";
}
diff --git a/apps/server/src/git.ts b/apps/server/src/git.ts
index e6e06cb21..59fb1b694 100644
--- a/apps/server/src/git.ts
+++ b/apps/server/src/git.ts
@@ -16,11 +16,7 @@ import type {
} from "@t3tools/contracts";
/** Spawn git directly with an argv array — no shell, no quoting needed. */
-function runGit(
- args: string[],
- cwd: string,
- timeoutMs = 30_000,
-): Promise<TerminalCommandResult> {
+function runGit(args: string[], cwd: string, timeoutMs = 30_000): Promise<TerminalCommandResult> {
return new Promise((resolve, reject) => {
const child = spawn("git", args, {
cwd,
@@ -127,11 +123,7 @@ export async function listGitBranches(input: GitListBranchesInput): Promise<GitL
}
// Resolve the real default branch from the remote
- const defaultRef = await runGit(
- ["symbolic-ref", "refs/remotes/origin/HEAD"],
- input.cwd,
- 5_000,
- );
+ const defaultRef = await runGit(["symbolic-ref", "refs/remotes/origin/HEAD"], input.cwd, 5_000);
const defaultBranch =
defaultRef.code === 0 ? defaultRef.stdout.trim().replace(/^refs\/remotes\/origin\//, "") : null;
diff --git a/apps/server/src/providerManager.test.ts b/apps/server/src/providerManager.test.ts
index c159bb296..424cfce16 100644
--- a/apps/server/src/providerManager.test.ts
+++ b/apps/server/src/providerManager.test.ts
@@ -16,10 +16,7 @@ describe("ProviderManager", () => {
method: string;
threadId: string;
}) => void;
- threadLogStreams: Map<
- string,
- { writableEnded: boolean; destroyed: boolean }
- >;
+ threadLogStreams: Map<string, { writableEnded: boolean; destroyed: boolean }>;
};
internals.onCodexEvent({
id: "evt-1",
diff --git a/apps/server/src/providerManager.ts b/apps/server/src/providerManager.ts
index be17babc3..52fb1b648 100644
--- a/apps/server/src/providerManager.ts
+++ b/apps/server/src/providerManager.ts
@@ -87,11 +87,7 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
throw new Error(`Unknown provider session: ${input.sessionId}`);
}
- await this.codex.respondToRequest(
- input.sessionId,
- input.requestId,
- input.decision,
- );
+ await this.codex.respondToRequest(input.sessionId, input.requestId, input.decision);
}
stopSession(raw: ProviderStopSessionInput): void {
@@ -151,10 +147,7 @@ export class ProviderManager extends EventEmitter<ProviderManagerEvents> {
private resolveThreadId(event: ProviderEvent): string | undefined {
const fromPayload = this.readThreadIdFromPayload(event.payload);
- const threadId =
- event.threadId ??
- fromPayload ??
- this.sessionThreadIds.get(event.sessionId);
+ const threadId = event.threadId ?? fromPayload ?? this.sessionThreadIds.get(event.sessionId);
if (threadId) {
this.sessionThreadIds.set(event.sessionId, threadId);
diff --git a/apps/server/src/wsServer.ts b/apps/server/src/wsServer.ts
index 97c35f166..353535ae3 100644
--- a/apps/server/src/wsServer.ts
+++ b/apps/server/src/wsServer.ts
@@ -369,7 +369,10 @@ export function createServer(options: ServerOptions) {
const isServerNotRunningError = (error: unknown): boolean => {
if (!(error instanceof Error)) return false;
const maybeCode = (error as NodeJS.ErrnoException).code;
- return maybeCode === "ERR_SERVER_NOT_RUNNING" || error.message.toLowerCase().includes("not running");
+ return (
+ maybeCode === "ERR_SERVER_NOT_RUNNING" ||
+ error.message.toLowerCase().includes("not running")
+ );
};
const closeWebSocketServer = new Promise<void>((resolve, reject) => {
diff --git a/apps/server/turbo.jsonc b/apps/server/turbo.jsonc
index c466a3a02..34f8874f8 100644
--- a/apps/server/turbo.jsonc
+++ b/apps/server/turbo.jsonc
@@ -5,7 +5,7 @@
"start": {
"dependsOn": ["build"],
"cache": false,
- "persistent": true
- }
- }
+ "persistent": true,
+ },
+ },
}
diff --git a/apps/web/index.html b/apps/web/index.html
index fe848c528..25aace82a 100644
--- a/apps/web/index.html
+++ b/apps/web/index.html
@@ -5,7 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..800;1,9..40,300..800&display=swap" rel="stylesheet" />
+ <link
+ href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300..800;1,9..40,300..800&display=swap"
+ rel="stylesheet"
+ />
<title>T3 Code</title>
</head>
<body>
diff --git a/apps/web/package.json b/apps/web/package.json
index 2594309c1..d995f4819 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -12,6 +12,7 @@
},
"dependencies": {
"@t3tools/contracts": "workspace:*",
+ "@tanstack/react-query": "^5.90.0",
"highlight.js": "^11.11.1",
"lucide-react": "^0.563.0",
"react": "^19.0.0",
diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx
index 969f55a04..4619f6c93 100644
--- a/apps/web/src/App.tsx
+++ b/apps/web/src/App.tsx
@@ -1,3 +1,4 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useEffect, useMemo, useRef } from "react";
import ChatView from "./components/ChatView";
@@ -168,10 +169,14 @@ function Layout() {
);
}
+const queryClient = new QueryClient();
+
export default function App() {
return (
- <StoreProvider>
- <Layout />
- </StoreProvider>
+ <QueryClientProvider client={queryClient}>
+ <StoreProvider>
+ <Layout />
+ </StoreProvider>
+ </QueryClientProvider>
);
}
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index 1ba9c0cec..aed876f20 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -1,5 +1,6 @@
import type { GitBranch } from "@t3tools/contracts";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import { useEffect, useMemo, useRef, useState } from "react";
import { readNativeApi } from "../session-logic";
import { useStore } from "../store";
@@ -10,76 +11,85 @@ interface BranchToolbarProps {
envLocked: boolean;
}
-export default function BranchToolbar({
- envMode,
- onEnvModeChange,
- envLocked,
-}: BranchToolbarProps) {
+export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: BranchToolbarProps) {
const { state, dispatch } = useStore();
const api = useMemo(() => readNativeApi(), []);
+ const queryClient = useQueryClient();
- const [branches, setBranches] = useState<GitBranch[]>([]);
- const [isRepo, setIsRepo] = useState(false);
- const [isLoadingBranches, setIsLoadingBranches] = useState(false);
const [isBranchMenuOpen, setIsBranchMenuOpen] = useState(false);
const [isCreatingBranch, setIsCreatingBranch] = useState(false);
const [newBranchName, setNewBranchName] = useState("");
- const [isInitializingRepo, setIsInitializingRepo] = useState(false);
const branchMenuRef = useRef<HTMLDivElement>(null);
const activeThread = state.threads.find((thread) => thread.id === state.activeThreadId);
const activeProject = state.projects.find((project) => project.id === activeThread?.projectId);
- const branchCwd = activeThread?.worktreePath ?? activeProject?.cwd;
+ const activeThreadId = activeThread?.id;
+ const activeThreadBranch = activeThread?.branch ?? null;
+ const activeWorktreePath = activeThread?.worktreePath ?? null;
+ const branchCwd = activeWorktreePath ?? activeProject?.cwd;
- const loadBranches = useCallback(async () => {
- if (!api || !branchCwd) return;
- setIsLoadingBranches(true);
- try {
- const result = await api.git.listBranches({ cwd: branchCwd });
- setIsRepo(result.isRepo);
- setBranches(result.branches);
- } catch (error) {
- setIsRepo(false);
- setBranches([]);
- if (activeThread) {
- dispatch({
- type: "SET_ERROR",
- threadId: activeThread.id,
- error:
- error instanceof Error ? error.message : "Failed to load git branches.",
- });
- }
- } finally {
- setIsLoadingBranches(false);
- }
- }, [activeThread, api, branchCwd, dispatch]);
+ // ── Queries ───────────────────────────────────────────────────────────
- useEffect(() => {
- void loadBranches();
- }, [loadBranches]);
+ const branchesQuery = useQuery({
+ queryKey: ["git", "branches", branchCwd],
+ queryFn: () => api!.git.listBranches({ cwd: branchCwd! }),
+ enabled: !!api && !!branchCwd,
+ });
+
+ const branches = branchesQuery.data?.branches ?? [];
+ const isRepo = branchesQuery.data?.isRepo ?? false;
+
+ // ── Mutations ─────────────────────────────────────────────────────────
+
+ const checkoutMutation = useMutation({
+ mutationFn: (branch: string) => api!.git.checkout({ cwd: branchCwd!, branch }),
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: ["git", "branches", branchCwd] }),
+ onError: (error) =>
+ setThreadError(error instanceof Error ? error.message : "Failed to checkout branch."),
+ });
+
+ const createBranchMutation = useMutation({
+ mutationFn: (branch: string) =>
+ api!.git
+ .createBranch({ cwd: branchCwd!, branch })
+ .then(() => api!.git.checkout({ cwd: branchCwd!, branch })),
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: ["git", "branches", branchCwd] }),
+ onError: (error) =>
+ setThreadError(error instanceof Error ? error.message : "Failed to create branch."),
+ });
+
+ const initMutation = useMutation({
+ mutationFn: () => api!.git.init({ cwd: branchCwd! }),
+ onSuccess: () => {
+ setThreadError(null);
+ queryClient.invalidateQueries({ queryKey: ["git", "branches", branchCwd] });
+ },
+ onError: (error) =>
+ setThreadError(error instanceof Error ? error.message : "Failed to initialize git repo."),
+ });
+
+ // ── Effects ───────────────────────────────────────────────────────────
// Keep thread branch synced to git current branch for local threads.
+ const queryBranches = branchesQuery.data?.branches;
useEffect(() => {
- if (!activeThread || activeThread.worktreePath) return;
- const current = branches.find((branch) => branch.current);
+ if (!activeThreadId || activeWorktreePath) return;
+ const current = queryBranches?.find((branch) => branch.current);
if (!current) return;
- if (current.name === activeThread.branch) return;
+ if (current.name === activeThreadBranch) return;
dispatch({
type: "SET_THREAD_BRANCH",
- threadId: activeThread.id,
+ threadId: activeThreadId,
branch: current.name,
worktreePath: null,
});
- }, [activeThread, branches, dispatch]);
+ }, [activeThreadId, activeWorktreePath, activeThreadBranch, queryBranches, dispatch]);
useEffect(() => {
if (!isBranchMenuOpen) return;
const handleClickOutside = (event: MouseEvent) => {
if (!branchMenuRef.current) return;
- if (
- event.target instanceof Node &&
- !branchMenuRef.current.contains(event.target)
- ) {
+ if (event.target instanceof Node && !branchMenuRef.current.contains(event.target)) {
setIsBranchMenuOpen(false);
}
};
@@ -89,79 +99,50 @@ export default function BranchToolbar({
};
}, [isBranchMenuOpen]);
+ // ── Helpers ───────────────────────────────────────────────────────────
+
const setThreadError = (error: string | null) => {
- if (!activeThread) return;
- dispatch({
- type: "SET_ERROR",
- threadId: activeThread.id,
- error,
- });
+ if (!activeThreadId) return;
+ dispatch({ type: "SET_ERROR", threadId: activeThreadId, error });
};
const setThreadBranch = (branch: string | null, worktreePath: string | null) => {
- if (!activeThread) return;
- dispatch({
- type: "SET_THREAD_BRANCH",
- threadId: activeThread.id,
- branch,
- worktreePath,
- });
- };
-
- const initializeRepo = async () => {
- if (!api || !branchCwd || !activeThread || isInitializingRepo) return;
- setIsInitializingRepo(true);
- try {
- await api.git.init({ cwd: branchCwd });
- setThreadError(null);
- await loadBranches();
- } catch (error) {
- setThreadError(error instanceof Error ? error.message : "Failed to initialize git repo.");
- } finally {
- setIsInitializingRepo(false);
- }
+ if (!activeThreadId) return;
+ dispatch({ type: "SET_THREAD_BRANCH", threadId: activeThreadId, branch, worktreePath });
};
- const selectBranch = async (branch: GitBranch) => {
- if (!api || !activeThread || !branchCwd) return;
+ const selectBranch = (branch: GitBranch) => {
+ if (!api || !activeThreadId || !branchCwd) return;
// For new worktree mode, selecting a branch picks the base branch.
- if (envMode === "worktree" && !envLocked && !activeThread.worktreePath) {
+ if (envMode === "worktree" && !envLocked && !activeWorktreePath) {
setThreadError(null);
setThreadBranch(branch.name, null);
setIsBranchMenuOpen(false);
return;
}
- try {
- await api.git.checkout({
- cwd: branchCwd,
- branch: branch.name,
- });
- setThreadError(null);
- setThreadBranch(branch.name, activeThread.worktreePath);
- setIsBranchMenuOpen(false);
- await loadBranches();
- } catch (error) {
- setThreadError(error instanceof Error ? error.message : "Failed to checkout branch.");
- }
+ checkoutMutation.mutate(branch.name, {
+ onSuccess: () => {
+ setThreadError(null);
+ setThreadBranch(branch.name, activeWorktreePath);
+ setIsBranchMenuOpen(false);
+ },
+ });
};
- const createBranch = async () => {
+ const createBranch = () => {
const name = newBranchName.trim();
- if (!api || !activeThread || !branchCwd || !name) return;
- try {
- await api.git.createBranch({ cwd: branchCwd, branch: name });
- await api.git.checkout({ cwd: branchCwd, branch: name });
- setThreadError(null);
- setThreadBranch(name, activeThread.worktreePath);
- setNewBranchName("");
- setIsCreatingBranch(false);
- setIsBranchMenuOpen(false);
- await loadBranches();
- } catch (error) {
- setThreadError(error instanceof Error ? error.message : "Failed to create branch.");
- }
+ if (!api || !activeThreadId || !branchCwd || !name) return;
+ createBranchMutation.mutate(name, {
+ onSuccess: () => {
+ setThreadError(null);
+ setThreadBranch(name, activeWorktreePath);
+ setNewBranchName("");
+ setIsCreatingBranch(false);
+ setIsBranchMenuOpen(false);
+ },
+ });
};
if (!activeThread || !activeProject) return null;
@@ -192,10 +173,10 @@ export default function BranchToolbar({
<button
type="button"
className="inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1 text-[12px] text-muted-foreground/70 transition-colors duration-150 hover:bg-accent hover:text-foreground/80 disabled:cursor-not-allowed disabled:opacity-50"
- disabled={!branchCwd || isInitializingRepo}
- onClick={() => void initializeRepo()}
+ disabled={!branchCwd || initMutation.isPending}
+ onClick={() => initMutation.mutate()}
>
- {isInitializingRepo ? "Initializing…" : "Initialize git"}
+ {initMutation.isPending ? "Initializing\u2026" : "Initialize git"}
</button>
) : (
<div className="relative" ref={branchMenuRef}>
@@ -203,7 +184,7 @@ export default function BranchToolbar({
type="button"
className="inline-flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] text-muted-foreground/60 transition-colors duration-150 hover:bg-accent/50 hover:text-muted-foreground/80"
onClick={() => setIsBranchMenuOpen((open) => !open)}
- disabled={isLoadingBranches}
+ disabled={branchesQuery.isLoading}
>
<span className="max-w-[240px] truncate font-mono">
{activeThread.branch
@@ -246,7 +227,7 @@ export default function BranchToolbar({
? "bg-accent text-foreground"
: "text-foreground/90 hover:bg-accent/50"
}`}
- onClick={() => void selectBranch(branch)}
+ onClick={() => selectBranch(branch)}
>
<span className="truncate">{branch.name}</span>
{(branch.current || branch.isDefault) && (
@@ -266,7 +247,7 @@ export default function BranchToolbar({
className="flex items-center gap-1 px-1"
onSubmit={(event) => {
event.preventDefault();
- void createBranch();
+ createBranch();
}}
>
<input
@@ -286,7 +267,7 @@ export default function BranchToolbar({
/>
<button
type="submit"
- disabled={!newBranchName.trim()}
+ disabled={!newBranchName.trim() || createBranchMutation.isPending}
className="rounded-lg px-2 py-1.5 text-xs text-muted-foreground/70 transition-colors hover:bg-accent hover:text-foreground/80 disabled:opacity-30"
>
Create
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 6a36885f1..9792d07ff 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -92,23 +92,17 @@ function approvalDetail(event: ProviderEvent): string | undefined {
return asString(payload?.reason);
}
-function derivePendingApprovals(
- events: ProviderEvent[],
-): PendingApprovalCard[] {
+function derivePendingApprovals(events: ProviderEvent[]): PendingApprovalCard[] {
const pending = new Map<string, PendingApprovalCard>();
const ordered = [...events].toReversed();
for (const event of ordered) {
- if (
- event.method === "session/closed" ||
- event.method === "session/exited"
- ) {
+ if (event.method === "session/closed" || event.method === "session/exited") {
pending.clear();
continue;
}
- const requestId =
- event.requestId ?? asString(asRecord(event.payload)?.requestId);
+ const requestId = event.requestId ?? asString(asRecord(event.payload)?.requestId);
if (!requestId) continue;
if (
@@ -143,20 +137,13 @@ export default function ChatView() {
const [isEditorMenuOpen, setIsEditorMenuOpen] = useState(false);
const [lastEditor, setLastEditor] = useState<EditorId>(() => {
const stored = localStorage.getItem(LAST_EDITOR_KEY);
- return EDITORS.some((e) => e.id === stored)
- ? (stored as EditorId)
- : EDITORS[0].id;
+ return EDITORS.some((e) => e.id === stored) ? (stored as EditorId) : EDITORS[0].id;
});
- const [selectedEffort, setSelectedEffort] =
- useState<string>(DEFAULT_REASONING);
+ const [selectedEffort, setSelectedEffort] = useState<string>(DEFAULT_REASONING);
const [envMode, setEnvMode] = useState<"local" | "worktree">("local");
const [isSwitchingRuntimeMode, setIsSwitchingRuntimeMode] = useState(false);
- const [respondingRequestIds, setRespondingRequestIds] = useState<string[]>(
- [],
- );
- const [expandedWorkGroups, setExpandedWorkGroups] = useState<
- Record<string, boolean>
- >({});
+ const [respondingRequestIds, setRespondingRequestIds] = useState<string[]>([]);
+ const [expandedWorkGroups, setExpandedWorkGroups] = useState<Record<string, boolean>>({});
const [nowTick, setNowTick] = useState(() => Date.now());
const messagesEndRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -177,11 +164,7 @@ export default function ChatView() {
[activeThread?.events],
);
const latestTurnWorkEntries = useMemo(
- () =>
- deriveWorkLogEntries(
- activeThread?.events ?? [],
- activeThread?.latestTurnId,
- ),
+ () => deriveWorkLogEntries(activeThread?.events ?? [], activeThread?.latestTurnId),
[activeThread?.events, activeThread?.latestTurnId],
);
const pendingApprovals = useMemo(
@@ -269,22 +252,18 @@ export default function ChatView() {
} as const);
const envLocked = Boolean(
activeThread &&
- (activeThread.messages.length > 0 ||
- (activeThread.session !== null && activeThread.session.status !== "closed")),
+ (activeThread.messages.length > 0 ||
+ (activeThread.session !== null && activeThread.session.status !== "closed")),
);
- const handleRuntimeModeChange = async (
- mode: "approval-required" | "full-access",
- ) => {
+ const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {
if (mode === state.runtimeMode) return;
dispatch({ type: "SET_RUNTIME_MODE", mode });
if (!api) return;
const sessionIds = state.threads
.map((t) => t.session)
- .filter(
- (s): s is NonNullable<typeof s> => s !== null && s.status !== "closed",
- )
+ .filter((s): s is NonNullable<typeof s> => s !== null && s.status !== "closed")
.map((s) => s.sessionId);
if (sessionIds.length === 0) return;
@@ -292,9 +271,7 @@ export default function ChatView() {
setIsSwitchingRuntimeMode(true);
try {
await Promise.all(
- sessionIds.map((id) =>
- api.providers.stopSession({ sessionId: id }).catch(() => undefined),
- ),
+ sessionIds.map((id) => api.providers.stopSession({ sessionId: id }).catch(() => undefined)),
);
} finally {
setIsSwitchingRuntimeMode(false);
@@ -316,10 +293,11 @@ export default function ChatView() {
setExpandedWorkGroups({});
}, [activeThread?.id]);
+ const activeWorktreePath = activeThread?.worktreePath;
useEffect(() => {
- if (!activeThread) return;
- setEnvMode(activeThread.worktreePath ? "worktree" : "local");
- }, [activeThread?.id, activeThread?.worktreePath]);
+ if (!activeThread?.id) return;
+ setEnvMode(activeWorktreePath ? "worktree" : "local");
+ }, [activeThread?.id, activeWorktreePath]);
// Auto-resize textarea
useEffect(() => {
@@ -360,10 +338,7 @@ export default function ChatView() {
const handleClickOutside = (event: MouseEvent) => {
if (!editorMenuRef.current) return;
- if (
- event.target instanceof Node &&
- !editorMenuRef.current.contains(event.target)
- ) {
+ if (event.target instanceof Node && !editorMenuRef.current.contains(event.target)) {
setIsEditorMenuOpen(false);
}
};
@@ -398,9 +373,7 @@ export default function ChatView() {
setIsEditorMenuOpen(false);
};
- const ensureSession = async (
- cwdOverride?: string,
- ): Promise<EnsuredSessionInfo | null> => {
+ const ensureSession = async (cwdOverride?: string): Promise<EnsuredSessionInfo | null> => {
if (!api || !activeThread || !activeProject) return null;
if (activeThread.session && activeThread.session.status !== "closed") {
const sessionThreadId = activeThread.session.threadId ?? null;
@@ -527,14 +500,9 @@ export default function ChatView() {
try {
const shouldBootstrap =
previousMessages.length > 0 &&
- (sessionInfo.continuityState === "new" ||
- sessionInfo.continuityState === "fallback_new");
+ (sessionInfo.continuityState === "new" || sessionInfo.continuityState === "fallback_new");
const input = shouldBootstrap
- ? buildBootstrapInput(
- previousMessages,
- trimmed,
- PROVIDER_SEND_TURN_MAX_INPUT_CHARS,
- ).text
+ ? buildBootstrapInput(previousMessages, trimmed, PROVIDER_SEND_TURN_MAX_INPUT_CHARS).text
: trimmed;
await api.providers.sendTurn({
sessionId: sessionInfo.sessionId,
@@ -561,10 +529,7 @@ export default function ChatView() {
});
};
- const onRespondToApproval = async (
- requestId: string,
- decision: ProviderApprovalDecision,
- ) => {
+ const onRespondToApproval = async (requestId: string, decision: ProviderApprovalDecision) => {
if (!api || !activeThread?.session) return;
setRespondingRequestIds((existing) =>
@@ -580,15 +545,10 @@ export default function ChatView() {
dispatch({
type: "SET_ERROR",
threadId: activeThread.id,
- error:
- err instanceof Error
- ? err.message
- : "Failed to submit approval decision.",
+ error: err instanceof Error ? err.message : "Failed to submit approval decision.",
});
} finally {
- setRespondingRequestIds((existing) =>
- existing.filter((id) => id !== requestId),
- );
+ setRespondingRequestIds((existing) => existing.filter((id) => id !== requestId));
}
};
@@ -626,11 +586,11 @@ export default function ChatView() {
return (
<div className="flex flex-1 flex-col bg-background">
{/* Top bar */}
- <header className={`flex items-center justify-between border-b border-border px-5 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}>
+ <header
+ className={`flex items-center justify-between border-b border-border px-5 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}
+ >
<div className="flex items-center gap-3">
- <h2 className="text-sm font-medium text-foreground">
- {activeThread.title}
- </h2>
+ <h2 className="text-sm font-medium text-foreground">{activeThread.title}</h2>
{activeProject && (
<span className="rounded-full bg-accent px-2 py-0.5 text-[10px] text-muted-foreground/50">
{activeProject.name}
@@ -666,9 +626,7 @@ export default function ChatView() {
{editorLabel(editor)}
{editor.id === lastEditor && (
<kbd className="ml-auto text-[9px] text-muted-foreground/40">
- {navigator.platform.includes("Mac")
- ? "\u2318O"
- : "Ctrl+O"}
+ {navigator.platform.includes("Mac") ? "\u2318O" : "Ctrl+O"}
</kbd>
)}
</button>
@@ -702,9 +660,7 @@ export default function ChatView() {
{pendingApprovals.length > 0 && (
<div className="mx-4 mt-3 space-y-2">
{pendingApprovals.map((approval) => {
- const isResponding = respondingRequestIds.includes(
- approval.requestId,
- );
+ const isResponding = respondingRequestIds.includes(approval.requestId);
return (
<div
key={approval.requestId}
@@ -728,9 +684,7 @@ export default function ChatView() {
type="button"
className="rounded-md border border-border bg-accent px-2 py-1 text-[11px] text-foreground transition-colors duration-150 hover:bg-accent/80 disabled:cursor-not-allowed disabled:opacity-50"
disabled={isResponding}
- onClick={() =>
- void onRespondToApproval(approval.requestId, "accept")
- }
+ onClick={() => void onRespondToApproval(approval.requestId, "accept")}
>
Approve once
</button>
@@ -738,12 +692,7 @@ export default function ChatView() {
type="button"
className="rounded-md border border-sky-300/30 bg-sky-500/[0.15] px-2 py-1 text-[11px] text-sky-100 transition-colors duration-150 hover:bg-sky-500/[0.22] disabled:cursor-not-allowed disabled:opacity-50"
disabled={isResponding}
- onClick={() =>
- void onRespondToApproval(
- approval.requestId,
- "acceptForSession",
- )
- }
+ onClick={() => void onRespondToApproval(approval.requestId, "acceptForSession")}
>
Always allow this session
</button>
@@ -751,9 +700,7 @@ export default function ChatView() {
type="button"
className="rounded-md border border-border px-2 py-1 text-[11px] text-foreground/90 transition-colors duration-150 hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"
disabled={isResponding}
- onClick={() =>
- void onRespondToApproval(approval.requestId, "decline")
- }
+ onClick={() => void onRespondToApproval(approval.requestId, "decline")}
>
Decline
</button>
@@ -761,9 +708,7 @@ export default function ChatView() {
type="button"
className="rounded-md border border-rose-300/30 bg-rose-500/[0.12] px-2 py-1 text-[11px] text-rose-100 transition-colors duration-150 hover:bg-rose-500/[0.2] disabled:cursor-not-allowed disabled:opacity-50"
disabled={isResponding}
- onClick={() =>
- void onRespondToApproval(approval.requestId, "cancel")
- }
+ onClick={() => void onRespondToApproval(approval.requestId, "cancel")}
>
Cancel turn
</button>
@@ -778,15 +723,14 @@ export default function ChatView() {
<div className="flex-1 overflow-y-auto px-5 py-4">
{activeThread.messages.length === 0 && !isWorking ? (
<div className="flex h-full items-center justify-center">
- <p className="text-sm text-muted-foreground/30">Send a message to start the conversation.</p>
+ <p className="text-sm text-muted-foreground/30">
+ Send a message to start the conversation.
+ </p>
</div>
) : (
<div className="mx-auto max-w-3xl space-y-4">
{timelineEntries.map((timelineEntry, index) => {
- if (
- timelineEntry.kind === "work" &&
- timelineEntries[index - 1]?.kind === "work"
- ) {
+ if (timelineEntry.kind === "work" && timelineEntries[index - 1]?.kind === "work") {
return null;
}
@@ -807,16 +751,13 @@ export default function ChatView() {
const groupId = timelineEntry.id;
const isExpanded = expandedWorkGroups[groupId] ?? false;
- const hasOverflow =
- groupedEntries.length > MAX_VISIBLE_WORK_LOG_ENTRIES;
+ const hasOverflow = groupedEntries.length > MAX_VISIBLE_WORK_LOG_ENTRIES;
const visibleEntries =
hasOverflow && !isExpanded
? groupedEntries.slice(-MAX_VISIBLE_WORK_LOG_ENTRIES)
: groupedEntries;
const hiddenCount = groupedEntries.length - visibleEntries.length;
- const onlyToolEntries = groupedEntries.every(
- (entry) => entry.tone === "tool",
- );
+ const onlyToolEntries = groupedEntries.every((entry) => entry.tone === "tool");
const groupLabel = onlyToolEntries
? groupedEntries.length === 1
? "Tool call"
@@ -902,9 +843,7 @@ export default function ChatView() {
<div className="my-3 flex items-center gap-3">
<span className="h-px flex-1 bg-border" />
<span className="rounded-full border border-border bg-background px-2.5 py-1 text-[10px] uppercase tracking-[0.14em] text-muted-foreground/80">
- {completionSummary
- ? `Response • ${completionSummary}`
- : "Response"}
+ {completionSummary ? `Response • ${completionSummary}` : "Response"}
</span>
<span className="h-px flex-1 bg-border" />
</div>
@@ -913,24 +852,17 @@ export default function ChatView() {
<ChatMarkdown
text={
timelineEntry.message.text ||
- (timelineEntry.message.streaming
- ? ""
- : "(empty response)")
+ (timelineEntry.message.streaming ? "" : "(empty response)")
}
/>
<p className="mt-1.5 text-[10px] text-muted-foreground/30">
{formatMessageMeta(
timelineEntry.message.createdAt,
timelineEntry.message.streaming
- ? formatElapsed(
- timelineEntry.message.createdAt,
- nowIso,
- )
+ ? formatElapsed(timelineEntry.message.createdAt, nowIso)
: formatElapsed(
timelineEntry.message.createdAt,
- assistantCompletionByItemId.get(
- timelineEntry.message.id,
- ),
+ assistantCompletionByItemId.get(timelineEntry.message.id),
),
)}
</p>
@@ -1086,9 +1018,7 @@ export default function ChatView() {
disabled={isSwitchingRuntimeMode}
onClick={() =>
void handleRuntimeModeChange(
- state.runtimeMode === "full-access"
- ? "approval-required"
- : "full-access",
+ state.runtimeMode === "full-access" ? "approval-required" : "full-access",
)
}
title={
@@ -1098,13 +1028,7 @@ export default function ChatView() {
}
>
{state.runtimeMode === "full-access" ? (
- <svg
- width="14"
- height="14"
- viewBox="0 0 14 14"
- fill="none"
- aria-hidden="true"
- >
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
<rect
x="2"
y="5.5"
@@ -1122,13 +1046,7 @@ export default function ChatView() {
/>
</svg>
) : (
- <svg
- width="14"
- height="14"
- viewBox="0 0 14 14"
- fill="none"
- aria-hidden="true"
- >
+ <svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
<rect
x="2"
y="5.5"
@@ -1146,11 +1064,7 @@ export default function ChatView() {
/>
</svg>
)}
- <span>
- {state.runtimeMode === "full-access"
- ? "Full access"
- : "Supervised"}
- </span>
+ <span>{state.runtimeMode === "full-access" ? "Full access" : "Supervised"}</span>
</button>
</div>
@@ -1226,11 +1140,7 @@ export default function ChatView() {
</form>
</div>
- <BranchToolbar
- envMode={envMode}
- onEnvModeChange={setEnvMode}
- envLocked={envLocked}
- />
+ <BranchToolbar envMode={envMode} onEnvModeChange={setEnvMode} envLocked={envLocked} />
</div>
);
}
diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx
index 6a546c848..72e11aa4a 100644
--- a/apps/web/src/components/DiffPanel.tsx
+++ b/apps/web/src/components/DiffPanel.tsx
@@ -7,7 +7,9 @@ export default function DiffPanel() {
return (
<aside className="flex h-full w-[400px] shrink-0 flex-col border-l border-border bg-card">
{/* Header */}
- <div className={`flex items-center justify-between border-b border-border px-4 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}>
+ <div
+ className={`flex items-center justify-between border-b border-border px-4 pb-3 ${isElectron ? "drag-region pt-[28px]" : "pt-3"}`}
+ >
<h3 className="text-xs font-medium text-foreground">Uncommitted changes</h3>
<button
type="button"
diff --git a/apps/web/src/historyBootstrap.ts b/apps/web/src/historyBootstrap.ts
index 6d0f504d3..02f262ad1 100644
--- a/apps/web/src/historyBootstrap.ts
+++ b/apps/web/src/historyBootstrap.ts
@@ -36,13 +36,8 @@ export function buildBootstrapInput(
latestPrompt: string,
maxChars: number,
): BootstrapInputResult {
- const budget = Number.isFinite(maxChars)
- ? Math.max(1, Math.floor(maxChars))
- : 1;
- const promptOnly =
- latestPrompt.length <= budget
- ? latestPrompt
- : latestPrompt.slice(0, budget);
+ const budget = Number.isFinite(maxChars) ? Math.max(1, Math.floor(maxChars)) : 1;
+ const promptOnly = latestPrompt.length <= budget ? latestPrompt : latestPrompt.slice(0, budget);
if (previousMessages.length === 0) {
return {
@@ -87,8 +82,7 @@ export function buildBootstrapInput(
let includedChronological = [...includedNewestFirst].reverse();
while (true) {
- const omittedCount =
- newestFirstBlocks.length - includedChronological.length;
+ const omittedCount = newestFirstBlocks.length - includedChronological.length;
const transcriptBody =
omittedCount > 0
? includedChronological.length > 0
@@ -101,8 +95,7 @@ export function buildBootstrapInput(
text: finalized,
includedCount: includedChronological.length,
omittedCount,
- truncated:
- omittedCount > 0 || latestPrompt.length !== promptOnly.length,
+ truncated: omittedCount > 0 || latestPrompt.length !== promptOnly.length,
};
}
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index 96a2093ae..484bf4a82 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -88,11 +88,7 @@
--secondary: --alpha(var(--color-black) / 4%);
--secondary-foreground: var(--color-neutral-800);
--muted: --alpha(var(--color-black) / 4%);
- --muted-foreground: color-mix(
- in srgb,
- var(--color-neutral-500) 90%,
- var(--color-black)
- );
+ --muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-black));
--accent: --alpha(var(--color-black) / 5%);
--accent-foreground: var(--color-neutral-800);
--destructive: var(--color-red-500);
@@ -122,11 +118,7 @@
@variant dark {
color-scheme: dark;
- --background: color-mix(
- in srgb,
- var(--color-neutral-950) 95%,
- var(--color-white)
- );
+ --background: color-mix(in srgb, var(--color-neutral-950) 95%, var(--color-white));
--foreground: var(--color-neutral-100);
--card: color-mix(in srgb, var(--background) 98%, var(--color-white));
--card-foreground: var(--color-neutral-100);
@@ -137,18 +129,10 @@
--secondary: --alpha(var(--color-white) / 4%);
--secondary-foreground: var(--color-neutral-100);
--muted: --alpha(var(--color-white) / 4%);
- --muted-foreground: color-mix(
- in srgb,
- var(--color-neutral-500) 90%,
- var(--color-white)
- );
+ --muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-white));
--accent: --alpha(var(--color-white) / 4%);
--accent-foreground: var(--color-neutral-100);
- --destructive: color-mix(
- in srgb,
- var(--color-red-500) 90%,
- var(--color-white)
- );
+ --destructive: color-mix(in srgb, var(--color-red-500) 90%, var(--color-white));
--border: --alpha(var(--color-white) / 6%);
--input: --alpha(var(--color-white) / 8%);
--ring: oklch(0.588 0.217 264);
@@ -177,7 +161,12 @@
body {
font-family:
- "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
+ "DM Sans",
+ -apple-system,
+ BlinkMacSystemFont,
+ "Segoe UI",
+ system-ui,
+ sans-serif;
margin: 0;
padding: 0;
min-height: 100vh;
@@ -287,11 +276,7 @@ label:has(> select#reasoning-effort) select {
.chat-markdown a {
color: var(--info-foreground);
text-decoration: underline;
- text-decoration-color: color-mix(
- in srgb,
- var(--info-foreground) 40%,
- transparent
- );
+ text-decoration-color: color-mix(in srgb, var(--info-foreground) 40%, transparent);
}
.chat-markdown a:hover {
diff --git a/apps/web/src/persistenceSchema.ts b/apps/web/src/persistenceSchema.ts
index eb4514b7f..dae15e37c 100644
--- a/apps/web/src/persistenceSchema.ts
+++ b/apps/web/src/persistenceSchema.ts
@@ -1,12 +1,7 @@
import { z } from "zod";
import { DEFAULT_MODEL, resolveModelSlug } from "./model-logic";
-import {
- DEFAULT_RUNTIME_MODE,
- type Project,
- type RuntimeMode,
- type Thread,
-} from "./types";
+import { DEFAULT_RUNTIME_MODE, type Project, type RuntimeMode, type Thread } from "./types";
const LEGACY_DEFAULT_MODEL = "gpt-5.2-codex";
@@ -150,13 +145,9 @@ export function hydratePersistedState(
return {
projects,
threads,
- activeThreadId: hasActiveThread
- ? parsedState.data.activeThreadId
- : (threads[0]?.id ?? null),
+ activeThreadId: hasActiveThread ? parsedState.data.activeThreadId : (threads[0]?.id ?? null),
runtimeMode:
- "runtimeMode" in parsedState.data
- ? parsedState.data.runtimeMode
- : DEFAULT_RUNTIME_MODE,
+ "runtimeMode" in parsedState.data ? parsedState.data.runtimeMode : DEFAULT_RUNTIME_MODE,
};
}
diff --git a/apps/web/src/session-logic.ts b/apps/web/src/session-logic.ts
index 9f5564707..7622864db 100644
--- a/apps/web/src/session-logic.ts
+++ b/apps/web/src/session-logic.ts
@@ -109,11 +109,7 @@ function normalizeItemType(raw: string | undefined): string {
}
function shouldDropItemType(type: string): boolean {
- if (
- type.includes("preamble") ||
- type.includes("reasoning") ||
- type.includes("thought")
- ) {
+ if (type.includes("preamble") || type.includes("reasoning") || type.includes("thought")) {
return true;
}
@@ -121,11 +117,7 @@ function shouldDropItemType(type: string): boolean {
}
function shouldShowItemLifecycle(type: string): boolean {
- return (
- type.includes("tool") ||
- type.includes("command") ||
- type.includes("file change")
- );
+ return type.includes("tool") || type.includes("command") || type.includes("file change");
}
function shouldDropMethod(method: string): boolean {
@@ -182,9 +174,7 @@ function extractDetail(
return undefined;
}
-function lifecycleCandidateFromItemEvent(
- event: ProviderEvent,
-): ItemLifecycleCandidate | null {
+function lifecycleCandidateFromItemEvent(event: ProviderEvent): ItemLifecycleCandidate | null {
const payload = asObject(event.payload);
const item = asObject(payload?.item);
const normalizedType = normalizeItemType(asString(item?.type));
@@ -360,10 +350,7 @@ export function deriveWorkLogEntries(
) {
continue;
}
- if (
- lifecycleCandidate.label === "Tool call" &&
- !lifecycleCandidate.detail
- ) {
+ if (lifecycleCandidate.label === "Tool call" && !lifecycleCandidate.detail) {
continue;
}
@@ -371,9 +358,7 @@ export function deriveWorkLogEntries(
id: lifecycleCandidate.id,
createdAt: lifecycleCandidate.createdAt,
label: lifecycleCandidate.label,
- ...(lifecycleCandidate.detail
- ? { detail: lifecycleCandidate.detail }
- : {}),
+ ...(lifecycleCandidate.detail ? { detail: lifecycleCandidate.detail } : {}),
tone: lifecycleCandidate.tone,
});
continue;
diff --git a/apps/web/src/store.ts b/apps/web/src/store.ts
index 5f9c6165f..2ac4e173a 100644
--- a/apps/web/src/store.ts
+++ b/apps/web/src/store.ts
@@ -395,9 +395,7 @@ export function reducer(state: AppState, action: Action): AppState {
case "DELETE_THREAD": {
const threads = state.threads.filter((t) => t.id !== action.threadId);
const activeThreadId =
- state.activeThreadId === action.threadId
- ? (threads[0]?.id ?? null)
- : state.activeThreadId;
+ state.activeThreadId === action.threadId ? (threads[0]?.id ?? null) : state.activeThreadId;
return { ...state, threads, activeThreadId };
}
diff --git a/apps/web/src/wsNativeApi.ts b/apps/web/src/wsNativeApi.ts
index c837bcea1..1705d0ae9 100644
--- a/apps/web/src/wsNativeApi.ts
+++ b/apps/web/src/wsNativeApi.ts
@@ -98,10 +98,8 @@ export function createWsNativeApi(): NativeApi {
},
git: {
listBranches: (input) => transport.request(WS_METHODS.gitListBranches, input),
- createWorktree: (input) =>
- transport.request(WS_METHODS.gitCreateWorktree, input),
- removeWorktree: (input) =>
- transport.request(WS_METHODS.gitRemoveWorktree, input),
+ createWorktree: (input) => transport.request(WS_METHODS.gitCreateWorktree, input),
+ removeWorktree: (input) => transport.request(WS_METHODS.gitRemoveWorktree, input),
createBranch: (input) => transport.request(WS_METHODS.gitCreateBranch, input),
checkout: (input) => transport.request(WS_METHODS.gitCheckout, input),
init: (input) => transport.request(WS_METHODS.gitInit, input),
diff --git a/apps/web/turbo.jsonc b/apps/web/turbo.jsonc
index 619cc63b3..271f93794 100644
--- a/apps/web/turbo.jsonc
+++ b/apps/web/turbo.jsonc
@@ -3,7 +3,7 @@
"extends": ["//"],
"tasks": {
"dev": {
- "persistent": true
- }
- }
+ "persistent": true,
+ },
+ },
}
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index b46780ec5..f65e60321 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -13,9 +13,7 @@ export default defineConfig({
],
define: {
// In dev mode, tell the web app where the WebSocket server lives
- "import.meta.env.VITE_WS_URL": JSON.stringify(
- process.env.VITE_WS_URL ?? "",
- ),
+ "import.meta.env.VITE_WS_URL": JSON.stringify(process.env.VITE_WS_URL ?? ""),
},
server: {
port: Number(process.env.PORT ?? 5173),
diff --git a/bun.lock b/bun.lock
index 49f27c421..8af5a901c 100644
--- a/bun.lock
+++ b/bun.lock
@@ -51,6 +51,7 @@
"version": "0.0.0",
"dependencies": {
"@t3tools/contracts": "workspace:*",
+ "@tanstack/react-query": "^5.90.0",
"highlight.js": "^11.11.1",
"lucide-react": "^0.563.0",
"react": "^19.0.0",
@@ -364,6 +365,10 @@
"@tailwindcss/vite": ["@tailwindcss/[email protected]", "", { "dependencies": { "@tailwindcss/node": "4.1.18", "@tailwindcss/oxide": "4.1.18", "tailwindcss": "4.1.18" }, "peerDependencies": { "vite": "^5.2.0 || ^6 || ^7" } }, "sha512-jVA+/UpKL1vRLg6Hkao5jldawNmRo7mQYrZtNHMIVpLfLhDml5nMRUo/8MwoX2vNXvnaXNNMedrMfMugAVX1nA=="],
+ "@tanstack/query-core": ["@tanstack/[email protected]", "", {}, "sha512-OMD2HLpNouXEfZJWcKeVKUgQ5n+n3A2JFmBaScpNDUqSrQSjiveC7dKMe53uJUg1nDG16ttFPz2xfilz6i2uVg=="],
+
+ "@tanstack/react-query": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/query-core": "5.90.20" }, "peerDependencies": { "react": "^18 || ^19" } }, "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg=="],
+
"@tybys/wasm-util": ["@tybys/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],
"@types/babel__core": ["@types/[email protected]", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],
diff --git a/packages/contracts/src/git.ts b/packages/contracts/src/git.ts
index a4284f286..be5d568c2 100644
--- a/packages/contracts/src/git.ts
+++ b/packages/contracts/src/git.ts
@@ -51,13 +51,9 @@ export const gitWorktreeSchema = z.object({
export type GitListBranchesInput = z.infer<typeof gitListBranchesInputSchema>;
export type GitBranch = z.infer<typeof gitBranchSchema>;
-export type GitCreateWorktreeInput = z.infer<
- typeof gitCreateWorktreeInputSchema
->;
+export type GitCreateWorktreeInput = z.infer<typeof gitCreateWorktreeInputSchema>;
export type GitWorktree = z.infer<typeof gitWorktreeSchema>;
-export type GitRemoveWorktreeInput = z.infer<
- typeof gitRemoveWorktreeInputSchema
->;
+export type GitRemoveWorktreeInput = z.infer<typeof gitRemoveWorktreeInputSchema>;
export type GitCreateBranchInput = z.infer<typeof gitCreateBranchInputSchema>;
export type GitCheckoutInput = z.infer<typeof gitCheckoutInputSchema>;
export type GitInitInput = z.infer<typeof gitInitInputSchema>;
diff --git a/packages/contracts/src/provider.ts b/packages/contracts/src/provider.ts
index 0d0c30a1a..b31e8f04e 100644
--- a/packages/contracts/src/provider.ts
+++ b/packages/contracts/src/provider.ts
@@ -83,12 +83,7 @@ export const providerRespondToRequestInputSchema = z.object({
decision: providerApprovalDecisionSchema,
});
-export const providerEventKindSchema = z.enum([
- "session",
- "notification",
- "request",
- "error",
-]);
+export const providerEventKindSchema = z.enum(["session", "notification", "request", "error"]);
export const providerEventSchema = z.object({
id: z.string().min(1),
@@ -111,24 +106,14 @@ export type ProviderKind = z.infer<typeof providerKindSchema>;
export type ProviderApprovalPolicy = z.infer<typeof providerApprovalPolicySchema>;
export type ProviderSandboxMode = z.infer<typeof providerSandboxModeSchema>;
export type ProviderRequestKind = z.infer<typeof providerRequestKindSchema>;
-export type ProviderApprovalDecision = z.infer<
- typeof providerApprovalDecisionSchema
->;
+export type ProviderApprovalDecision = z.infer<typeof providerApprovalDecisionSchema>;
export type ProviderSessionStatus = z.infer<typeof providerSessionStatusSchema>;
export type ProviderSession = z.infer<typeof providerSessionSchema>;
export type ProviderSessionStartInput = z.input<typeof providerSessionStartInputSchema>;
export type ProviderSendTurnInput = z.input<typeof providerSendTurnInputSchema>;
-export type ProviderTurnStartResult = z.infer<
- typeof providerTurnStartResultSchema
->;
-export type ProviderInterruptTurnInput = z.input<
- typeof providerInterruptTurnInputSchema
->;
-export type ProviderStopSessionInput = z.input<
- typeof providerStopSessionInputSchema
->;
-export type ProviderRespondToRequestInput = z.input<
- typeof providerRespondToRequestInputSchema
->;
+export type ProviderTurnStartResult = z.infer<typeof providerTurnStartResultSchema>;
+export type ProviderInterruptTurnInput = z.input<typeof providerInterruptTurnInputSchema>;
+export type ProviderStopSessionInput = z.input<typeof providerStopSessionInputSchema>;
+export type ProviderRespondToRequestInput = z.input<typeof providerRespondToRequestInputSchema>;
export type ProviderEventKind = z.infer<typeof providerEventKindSchema>;
export type ProviderEvent = z.infer<typeof providerEventSchema>;