- support `claudeAgent.fastMode` in shared/contracts, provider dispatch, and Claude adapter SDK settings - gate fast mode to supported Claude models and restart/forward options in orchestration - unify draft/UI fast mode state (not Codex-only) and add browser/server tests plus SDK probe
Unified · Split
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | "test": "vitest run" |
| 23 | 23 | }, |
| 24 | 24 | "dependencies": { |
| 25 | − "@anthropic-ai/claude-agent-sdk": "^0.2.76", | |
| 25 | + "@anthropic-ai/claude-agent-sdk": "^0.2.77", | |
| 26 | 26 | "@effect/platform-node": "catalog:", |
| 27 | 27 | "@effect/sql-sqlite-bun": "catalog:", |
| 28 | 28 | "@pierre/diffs": "^1.1.0-beta.16", |
| @@ -83,9 +83,13 @@ describe("ProviderCommandReactor", () => { · 82 unmodified lines | ||
| 83 | 83 | createdStateDirs.clear(); |
| 84 | 84 | }); |
| 85 | 85 | |
| 86 | − async function createHarness(input?: { readonly stateDir?: string }) { | |
| 86 | + async function createHarness(input?: { | |
| 87 | + readonly stateDir?: string; | |
| 88 | + readonly threadModel?: string; | |
| 89 | + }) { | |
| 87 | 90 | const now = new Date().toISOString(); |
| 88 | 91 | const stateDir = input?.stateDir ?? fs.mkdtempSync(path.join(os.tmpdir(), "t3code-reactor-")); |
| 92 | + const threadModel = input?.threadModel ?? "gpt-5-codex"; | |
| 89 | 93 | createdStateDirs.add(stateDir); |
| 90 | 94 | const runtimeEventPubSub = Effect.runSync(PubSub.unbounded<ProviderRuntimeEvent>()); |
| 91 | 95 | let nextSessionIndex = 1; |
| @@ -228,7 +232,7 @@ describe("ProviderCommandReactor", () => { · 136 unmodified lines | ||
| 228 | 232 | projectId: asProjectId("project-1"), |
| 229 | 233 | title: "Provider Project", |
| 230 | 234 | workspaceRoot: "/tmp/provider-project", |
| 231 | − defaultModel: "gpt-5-codex", | |
| 235 | + defaultModel: threadModel, | |
| 232 | 236 | createdAt: now, |
| 233 | 237 | }), |
| 234 | 238 | ); |
| @@ -239,7 +243,7 @@ describe("ProviderCommandReactor", () => { · 4 unmodified lines | ||
| 239 | 243 | threadId: ThreadId.makeUnsafe("thread-1"), |
| 240 | 244 | projectId: asProjectId("project-1"), |
| 241 | 245 | title: "Thread", |
| 242 | − model: "gpt-5-codex", | |
| 246 | + model: threadModel, | |
| 243 | 247 | interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE, |
| 244 | 248 | runtimeMode: "approval-required", |
| 245 | 249 | branch: null, |
| @@ -352,7 +356,7 @@ describe("ProviderCommandReactor", () => { · 106 unmodified lines | ||
| 352 | 356 | }); |
| 353 | 357 | |
| 354 | 358 | it("forwards claude effort options through session start and turn send", async () => { |
| 355 | − const harness = await createHarness(); | |
| 359 | + const harness = await createHarness({ threadModel: "claude-sonnet-4-6" }); | |
| 356 | 360 | const now = new Date().toISOString(); |
| 357 | 361 | |
| 358 | 362 | await Effect.runPromise( |
| @@ -401,6 +405,56 @@ describe("ProviderCommandReactor", () => { · 42 unmodified lines | ||
| 401 | 405 | }); |
| 402 | 406 | }); |
| 403 | 407 | |
| 408 | + it("forwards claude fast mode options through session start and turn send", async () => { | |
| 409 | + const harness = await createHarness({ threadModel: "claude-opus-4-6" }); | |
| 410 | + const now = new Date().toISOString(); | |
| 411 | + | |
| 412 | + await Effect.runPromise( | |
| 413 | + harness.engine.dispatch({ | |
| 414 | + type: "thread.turn.start", | |
| 415 | + commandId: CommandId.makeUnsafe("cmd-turn-start-claude-fast-mode"), | |
| 416 | + threadId: ThreadId.makeUnsafe("thread-1"), | |
| 417 | + message: { | |
| 418 | + messageId: asMessageId("user-message-claude-fast-mode"), | |
| 419 | + role: "user", | |
| 420 | + text: "hello with fast mode", | |
| 421 | + attachments: [], | |
| 422 | + }, | |
| 423 | + provider: "claudeAgent", | |
| 424 | + model: "claude-opus-4-6", | |
| 425 | + modelOptions: { | |
| 426 | + claudeAgent: { | |
| 427 | + fastMode: true, | |
| 428 | + }, | |
| 429 | + }, | |
| 430 | + interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE, | |
| 431 | + runtimeMode: "approval-required", | |
| 432 | + createdAt: now, | |
| 433 | + }), | |
| 434 | + ); | |
| 435 | + | |
| 436 | + await waitFor(() => harness.startSession.mock.calls.length === 1); | |
| 437 | + await waitFor(() => harness.sendTurn.mock.calls.length === 1); | |
| 438 | + expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({ | |
| 439 | + provider: "claudeAgent", | |
| 440 | + model: "claude-opus-4-6", | |
| 441 | + modelOptions: { | |
| 442 | + claudeAgent: { | |
| 443 | + fastMode: true, | |
| 444 | + }, | |
| 445 | + }, | |
| 446 | + }); | |
| 447 | + expect(harness.sendTurn.mock.calls[0]?.[0]).toMatchObject({ | |
| 448 | + threadId: ThreadId.makeUnsafe("thread-1"), | |
| 449 | + model: "claude-opus-4-6", | |
| 450 | + modelOptions: { | |
| 451 | + claudeAgent: { | |
| 452 | + fastMode: true, | |
| 453 | + }, | |
| 454 | + }, | |
| 455 | + }); | |
| 456 | + }); | |
| 457 | + | |
| 404 | 458 | it("forwards plan interaction mode to the provider turn request", async () => { |
| 405 | 459 | const harness = await createHarness(); |
| 406 | 460 | const now = new Date().toISOString(); |
| @@ -582,7 +636,7 @@ describe("ProviderCommandReactor", () => { · 175 unmodified lines | ||
| 582 | 636 | }); |
| 583 | 637 | |
| 584 | 638 | it("restarts claude sessions when claude effort changes", async () => { |
| 585 | − const harness = await createHarness(); | |
| 639 | + const harness = await createHarness({ threadModel: "claude-sonnet-4-6" }); | |
| 586 | 640 | const now = new Date().toISOString(); |
| 587 | 641 | |
| 588 | 642 | await Effect.runPromise( |
| @@ -258,6 +258,7 @@ describe("ClaudeAdapterLive", () => { · 257 unmodified lines | ||
| 258 | 258 | yield* adapter.startSession({ |
| 259 | 259 | threadId: THREAD_ID, |
| 260 | 260 | provider: "claudeAgent", |
| 261 | + model: "claude-opus-4-6", | |
| 261 | 262 | runtimeMode: "full-access", |
| 262 | 263 | modelOptions: { |
| 263 | 264 | claudeAgent: { |
| @@ -274,6 +275,56 @@ describe("ClaudeAdapterLive", () => { · 10 unmodified lines | ||
| 274 | 275 | ); |
| 275 | 276 | }); |
| 276 | 277 | |
| 278 | + it.effect("forwards claude fast mode into SDK settings", () => { | |
| 279 | + const harness = makeHarness(); | |
| 280 | + return Effect.gen(function* () { | |
| 281 | + const adapter = yield* ClaudeAdapter; | |
| 282 | + yield* adapter.startSession({ | |
| 283 | + threadId: THREAD_ID, | |
| 284 | + provider: "claudeAgent", | |
| 285 | + model: "claude-opus-4-6", | |
| 286 | + runtimeMode: "full-access", | |
| 287 | + modelOptions: { | |
| 288 | + claudeAgent: { | |
| 289 | + fastMode: true, | |
| 290 | + }, | |
| 291 | + }, | |
| 292 | + }); | |
| 293 | + | |
| 294 | + const createInput = harness.getLastCreateQueryInput(); | |
| 295 | + assert.deepEqual(createInput?.options.settings, { | |
| 296 | + fastMode: true, | |
| 297 | + }); | |
| 298 | + }).pipe( | |
| 299 | + Effect.provideService(Random.Random, makeDeterministicRandomService()), | |
| 300 | + Effect.provide(harness.layer), | |
| 301 | + ); | |
| 302 | + }); | |
| 303 | + | |
| 304 | + it.effect("ignores claude fast mode for non-opus models", () => { | |
| 305 | + const harness = makeHarness(); | |
| 306 | + return Effect.gen(function* () { | |
| 307 | + const adapter = yield* ClaudeAdapter; | |
| 308 | + yield* adapter.startSession({ | |
| 309 | + threadId: THREAD_ID, | |
| 310 | + provider: "claudeAgent", | |
| 311 | + model: "claude-sonnet-4-6", | |
| 312 | + runtimeMode: "full-access", | |
| 313 | + modelOptions: { | |
| 314 | + claudeAgent: { | |
| 315 | + fastMode: true, | |
| 316 | + }, | |
| 317 | + }, | |
| 318 | + }); | |
| 319 | + | |
| 320 | + const createInput = harness.getLastCreateQueryInput(); | |
| 321 | + assert.equal(createInput?.options.settings, undefined); | |
| 322 | + }).pipe( | |
| 323 | + Effect.provideService(Random.Random, makeDeterministicRandomService()), | |
| 324 | + Effect.provide(harness.layer), | |
| 325 | + ); | |
| 326 | + }); | |
| 327 | + | |
| 277 | 328 | it.effect("maps ultrathink to max effort and prefixes the prompt", () => { |
| 278 | 329 | const harness = makeHarness(); |
| 279 | 330 | return Effect.gen(function* () { |
| @@ -37,7 +37,11 @@ import { · 36 unmodified lines | ||
| 37 | 37 | TurnId, |
| 38 | 38 | type UserInputQuestion, |
| 39 | 39 | } from "@t3tools/contracts"; |
| 40 | −import { applyClaudePromptEffortPrefix, getEffectiveClaudeCodeEffort } from "@t3tools/shared/model"; | |
| 40 | +import { | |
| 41 | + applyClaudePromptEffortPrefix, | |
| 42 | + getEffectiveClaudeCodeEffort, | |
| 43 | + supportsClaudeFastMode, | |
| 44 | +} from "@t3tools/shared/model"; | |
| 41 | 45 | import { Cause, DateTime, Deferred, Effect, Layer, Queue, Random, Ref, Stream } from "effect"; |
| 42 | 46 | |
| 43 | 47 | import { |
| @@ -2194,6 +2198,8 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 2150 unmodified lines | ||
| 2194 | 2198 | |
| 2195 | 2199 | const providerOptions = input.providerOptions?.claudeAgent; |
| 2196 | 2200 | const effort = input.modelOptions?.claudeAgent?.effort; |
| 2201 | + const fastMode = | |
| 2202 | + input.modelOptions?.claudeAgent?.fastMode === true && supportsClaudeFastMode(input.model); | |
| 2197 | 2203 | const effectiveEffort = getEffectiveClaudeCodeEffort(effort); |
| 2198 | 2204 | const permissionMode = |
| 2199 | 2205 | toPermissionMode(providerOptions?.permissionMode) ?? |
| @@ -2213,6 +2219,7 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 13 unmodified lines | ||
| 2213 | 2219 | ...(providerOptions?.maxThinkingTokens !== undefined |
| 2214 | 2220 | ? { maxThinkingTokens: providerOptions.maxThinkingTokens } |
| 2215 | 2221 | : {}), |
| 2222 | + ...(fastMode ? { settings: { fastMode: true } } : {}), | |
| 2216 | 2223 | ...(resumeState?.resume ? { resume: resumeState.resume } : {}), |
| 2217 | 2224 | ...(resumeState?.resumeSessionAt ? { resumeSessionAt: resumeState.resumeSessionAt } : {}), |
| 2218 | 2225 | includePartialMessages: true, |
| @@ -2302,6 +2309,7 @@ function makeClaudeAdapter(options?: ClaudeAdapterLiveOptions) { · 83 unmodified lines | ||
| 2302 | 2309 | ...(providerOptions?.maxThinkingTokens !== undefined |
| 2303 | 2310 | ? { maxThinkingTokens: providerOptions.maxThinkingTokens } |
| 2304 | 2311 | : {}), |
| 2312 | + ...(fastMode ? { fastMode: true } : {}), | |
| 2305 | 2313 | }, |
| 2306 | 2314 | }, |
| 2307 | 2315 | providerRefs: {}, |
| @@ -0,0 +1,149 @@ | ||
| 1 | +import { EventEmitter } from "node:events"; | |
| 2 | +import { PassThrough } from "node:stream"; | |
| 3 | +import { query, type SpawnOptions, type SpawnedProcess } from "@anthropic-ai/claude-agent-sdk"; | |
| 4 | +import { afterEach, describe, expect, it } from "vitest"; | |
| 5 | + | |
| 6 | +async function* emptyPrompt(): AsyncGenerator<never, void, void> {} | |
| 7 | + | |
| 8 | +class FakeClaudeCodeProcess implements SpawnedProcess { | |
| 9 | + readonly stdin = new PassThrough(); | |
| 10 | + readonly stdout = new PassThrough(); | |
| 11 | + killed = false; | |
| 12 | + exitCode: number | null = null; | |
| 13 | + | |
| 14 | + private readonly events = new EventEmitter(); | |
| 15 | + private bufferedInput = ""; | |
| 16 | + | |
| 17 | + constructor( | |
| 18 | + private readonly onMessage: ( | |
| 19 | + message: Record<string, unknown>, | |
| 20 | + process: FakeClaudeCodeProcess, | |
| 21 | + ) => void, | |
| 22 | + ) { | |
| 23 | + this.stdin.setEncoding("utf8"); | |
| 24 | + this.stdin.on("data", (chunk: string) => { | |
| 25 | + this.bufferedInput += chunk; | |
| 26 | + this.drainInput(); | |
| 27 | + }); | |
| 28 | + } | |
| 29 | + | |
| 30 | + emitJson(message: unknown): void { | |
| 31 | + this.stdout.write(`${JSON.stringify(message)}\n`); | |
| 32 | + } | |
| 33 | + | |
| 34 | + kill(_signal: NodeJS.Signals): boolean { | |
| 35 | + this.killed = true; | |
| 36 | + this.exitCode = 0; | |
| 37 | + this.stdout.end(); | |
| 38 | + this.events.emit("exit", 0, null); | |
| 39 | + return true; | |
| 40 | + } | |
| 41 | + | |
| 42 | + on( | |
| 43 | + event: "exit" | "error", | |
| 44 | + listener: | |
| 45 | + | ((code: number | null, signal: NodeJS.Signals | null) => void) | |
| 46 | + | ((error: Error) => void), | |
| 47 | + ): void { | |
| 48 | + this.events.on(event, listener); | |
| 49 | + } | |
| 50 | + | |
| 51 | + once( | |
| 52 | + event: "exit" | "error", | |
| 53 | + listener: | |
| 54 | + | ((code: number | null, signal: NodeJS.Signals | null) => void) | |
| 55 | + | ((error: Error) => void), | |
| 56 | + ): void { | |
| 57 | + this.events.once(event, listener); | |
| 58 | + } | |
| 59 | + | |
| 60 | + off( | |
| 61 | + event: "exit" | "error", | |
| 62 | + listener: | |
| 63 | + | ((code: number | null, signal: NodeJS.Signals | null) => void) | |
| 64 | + | ((error: Error) => void), | |
| 65 | + ): void { | |
| 66 | + this.events.off(event, listener); | |
| 67 | + } | |
| 68 | + | |
| 69 | + private drainInput(): void { | |
| 70 | + while (true) { | |
| 71 | + const newlineIndex = this.bufferedInput.indexOf("\n"); | |
| 72 | + if (newlineIndex === -1) { | |
| 73 | + return; | |
| 74 | + } | |
| 75 | + const line = this.bufferedInput.slice(0, newlineIndex).trim(); | |
| 76 | + this.bufferedInput = this.bufferedInput.slice(newlineIndex + 1); | |
| 77 | + if (line.length === 0) { | |
| 78 | + continue; | |
| 79 | + } | |
| 80 | + this.onMessage(JSON.parse(line) as Record<string, unknown>, this); | |
| 81 | + } | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | +describe("Claude SDK fast mode probe", () => { | |
| 86 | + let activeQuery: ReturnType<typeof query> | null = null; | |
| 87 | + | |
| 88 | + afterEach(() => { | |
| 89 | + activeQuery?.close(); | |
| 90 | + activeQuery = null; | |
| 91 | + }); | |
| 92 | + | |
| 93 | + it("passes fast mode through the SDK settings flag", async () => { | |
| 94 | + let spawnOptions: SpawnOptions | undefined; | |
| 95 | + | |
| 96 | + activeQuery = query({ | |
| 97 | + prompt: emptyPrompt(), | |
| 98 | + options: { | |
| 99 | + persistSession: false, | |
| 100 | + settings: { | |
| 101 | + fastMode: true, | |
| 102 | + }, | |
| 103 | + spawnClaudeCodeProcess: (options): SpawnedProcess => { | |
| 104 | + spawnOptions = options; | |
| 105 | + return new FakeClaudeCodeProcess((message, process) => { | |
| 106 | + if ( | |
| 107 | + message.type !== "control_request" || | |
| 108 | + typeof message.request_id !== "string" || | |
| 109 | + !message.request || | |
| 110 | + typeof message.request !== "object" || | |
| 111 | + (message.request as { subtype?: unknown }).subtype !== "initialize" | |
| 112 | + ) { | |
| 113 | + return; | |
| 114 | + } | |
| 115 | + | |
| 116 | + process.emitJson({ | |
| 117 | + type: "control_response", | |
| 118 | + response: { | |
| 119 | + subtype: "success", | |
| 120 | + request_id: message.request_id, | |
| 121 | + response: { | |
| 122 | + commands: [], | |
| 123 | + agents: [], | |
| 124 | + output_style: "default", | |
| 125 | + available_output_styles: ["default"], | |
| 126 | + models: [], | |
| 127 | + account: { | |
| 128 | + subscriptionType: "max", | |
| 129 | + }, | |
| 130 | + fast_mode_state: "on", | |
| 131 | + }, | |
| 132 | + }, | |
| 133 | + }); | |
| 134 | + }); | |
| 135 | + }, | |
| 136 | + }, | |
| 137 | + }); | |
| 138 | + | |
| 139 | + const initialization = await activeQuery.initializationResult(); | |
| 140 | + expect(initialization.fast_mode_state).toBe("on"); | |
| 141 | + | |
| 142 | + expect(spawnOptions).toBeDefined(); | |
| 143 | + const settingsFlagIndex = spawnOptions?.args.indexOf("--settings") ?? -1; | |
| 144 | + expect(settingsFlagIndex).toBeGreaterThan(-1); | |
| 145 | + expect(JSON.parse(spawnOptions?.args[settingsFlagIndex + 1] ?? "")).toEqual({ | |
| 146 | + fastMode: true, | |
| 147 | + }); | |
| 148 | + }); | |
| 149 | +}); | |
| @@ -30,6 +30,7 @@ import { · 29 unmodified lines | ||
| 30 | 30 | normalizeModelSlug, |
| 31 | 31 | resolveReasoningEffortForProvider, |
| 32 | 32 | resolveModelSlugForProvider, |
| 33 | + supportsClaudeFastMode, | |
| 33 | 34 | } from "@t3tools/shared/model"; |
| 34 | 35 | import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; |
| 35 | 36 | import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; |
| @@ -232,7 +233,7 @@ export default function ChatView({ threadId }: ChatViewProps) { · 196 unmodified lines | ||
| 232 | 233 | (store) => store.setInteractionMode, |
| 233 | 234 | ); |
| 234 | 235 | const setComposerDraftEffort = useComposerDraftStore((store) => store.setEffort); |
| 235 | − const setComposerDraftCodexFastMode = useComposerDraftStore((store) => store.setCodexFastMode); | |
| 236 | + const setComposerDraftFastMode = useComposerDraftStore((store) => store.setFastMode); | |
| 236 | 237 | const addComposerDraftImage = useComposerDraftStore((store) => store.addImage); |
| 237 | 238 | const addComposerDraftImages = useComposerDraftStore((store) => store.addImages); |
| 238 | 239 | const removeComposerDraftImage = useComposerDraftStore((store) => store.removeImage); |
| @@ -546,8 +547,10 @@ export default function ChatView({ threadId }: ChatViewProps) { · 307 unmodified lines | ||
| 546 | 547 | getDefaultReasoningEffort("claudeAgent")) |
| 547 | 548 | : null; |
| 548 | 549 | const selectedEffort = selectedCodexEffort ?? selectedClaudeEffort; |
| 549 | − const selectedCodexFastModeEnabled = | |
| 550 | − selectedProvider === "codex" ? composerDraft.codexFastMode : false; | |
| 550 | + const selectedClaudeFastModeAvailable = | |
| 551 | + selectedProvider === "claudeAgent" && supportsClaudeFastMode(selectedModel); | |
| 552 | + const selectedFastModeAvailable = selectedProvider === "codex" || selectedClaudeFastModeAvailable; | |
| 553 | + const selectedFastModeEnabled = selectedFastModeAvailable ? composerDraft.fastMode : false; | |
| 551 | 554 | const isClaudeUltrathink = selectedClaudeEffort === "ultrathink"; |
| 552 | 555 | const selectedModelOptionsForDispatch = useMemo(() => { |
| 553 | 556 | if (selectedProvider === "codex") { |
| @@ -555,22 +558,27 @@ export default function ChatView({ threadId }: ChatViewProps) { · 1 unmodified line | ||
| 555 | 558 | ...(supportsReasoningEffort && selectedCodexEffort |
| 556 | 559 | ? { reasoningEffort: selectedCodexEffort } |
| 557 | 560 | : {}), |
| 558 | − ...(selectedCodexFastModeEnabled ? { fastMode: true } : {}), | |
| 561 | + ...(selectedFastModeEnabled ? { fastMode: true } : {}), | |
| 559 | 562 | }; |
| 560 | 563 | return Object.keys(codexOptions).length > 0 ? { codex: codexOptions } : undefined; |
| 561 | 564 | } |
| 562 | − if (selectedProvider === "claudeAgent" && selectedClaudeEffort) { | |
| 565 | + if (selectedProvider === "claudeAgent") { | |
| 566 | + const claudeOptions = { | |
| 567 | + ...(selectedClaudeEffort ? { effort: selectedClaudeEffort } : {}), | |
| 568 | + ...(selectedFastModeEnabled ? { fastMode: true } : {}), | |
| 569 | + }; | |
| 570 | + if (Object.keys(claudeOptions).length === 0) { | |
| 571 | + return undefined; | |
| 572 | + } | |
| 563 | 573 | return { |
| 564 | − claudeAgent: { | |
| 565 | − effort: selectedClaudeEffort, | |
| 566 | − }, | |
| 574 | + claudeAgent: claudeOptions, | |
| 567 | 575 | }; |
| 568 | 576 | } |
| 569 | 577 | return undefined; |
| 570 | 578 | }, [ |
| 571 | 579 | selectedClaudeEffort, |
| 572 | 580 | selectedCodexEffort, |
| 573 | − selectedCodexFastModeEnabled, | |
| 581 | + selectedFastModeEnabled, | |
| 574 | 582 | selectedProvider, |
| 575 | 583 | supportsReasoningEffort, |
| 576 | 584 | ]); |
| @@ -2966,12 +2974,12 @@ export default function ChatView({ threadId }: ChatViewProps) { · 2389 unmodified lines | ||
| 2966 | 2974 | }, |
| 2967 | 2975 | [scheduleComposerFocus, setComposerDraftEffort, threadId], |
| 2968 | 2976 | ); |
| 2969 | − const onCodexFastModeChange = useCallback( | |
| 2977 | + const onFastModeChange = useCallback( | |
| 2970 | 2978 | (enabled: boolean) => { |
| 2971 | − setComposerDraftCodexFastMode(threadId, enabled); | |
| 2979 | + setComposerDraftFastMode(threadId, enabled); | |
| 2972 | 2980 | scheduleComposerFocus(); |
| 2973 | 2981 | }, |
| 2974 | − [scheduleComposerFocus, setComposerDraftCodexFastMode, threadId], | |
| 2982 | + [scheduleComposerFocus, setComposerDraftFastMode, threadId], | |
| 2975 | 2983 | ); |
| 2976 | 2984 | const onEnvModeChange = useCallback( |
| 2977 | 2985 | (mode: DraftThreadEnvMode) => { |
| @@ -3604,10 +3612,11 @@ export default function ChatView({ threadId }: ChatViewProps) { · 626 unmodified lines | ||
| 3604 | 3612 | runtimeMode={runtimeMode} |
| 3605 | 3613 | selectedEffort={selectedEffort} |
| 3606 | 3614 | selectedProvider={selectedProvider} |
| 3607 | − selectedCodexFastModeEnabled={selectedCodexFastModeEnabled} | |
| 3615 | + supportsFastMode={selectedFastModeAvailable} | |
| 3616 | + selectedFastModeEnabled={selectedFastModeEnabled} | |
| 3608 | 3617 | reasoningOptions={reasoningOptions} |
| 3609 | 3618 | onEffortSelect={onEffortSelect} |
| 3610 | − onCodexFastModeChange={onCodexFastModeChange} | |
| 3619 | + onFastModeChange={onFastModeChange} | |
| 3611 | 3620 | onToggleInteractionMode={toggleInteractionMode} |
| 3612 | 3621 | onTogglePlanSidebar={togglePlanSidebar} |
| 3613 | 3622 | onToggleRuntimeMode={toggleRuntimeMode} |
| @@ -3623,12 +3632,13 @@ export default function ChatView({ threadId }: ChatViewProps) { · 9 unmodified lines | ||
| 3623 | 3632 | <ProviderTraitsPicker |
| 3624 | 3633 | provider={selectedProvider} |
| 3625 | 3634 | effort={selectedEffort} |
| 3635 | + supportsFastMode={selectedFastModeAvailable} | |
| 3626 | 3636 | options={reasoningOptions} |
| 3627 | 3637 | onEffortChange={onEffortSelect} |
| 3628 | − {...(selectedProvider === "codex" | |
| 3638 | + {...(selectedFastModeAvailable | |
| 3629 | 3639 | ? { |
| 3630 | − fastModeEnabled: selectedCodexFastModeEnabled, | |
| 3631 | − onFastModeChange: onCodexFastModeChange, | |
| 3640 | + fastModeEnabled: selectedFastModeEnabled, | |
| 3641 | + onFastModeChange, | |
| 3632 | 3642 | } |
| 3633 | 3643 | : {})} |
| 3634 | 3644 | /> |
| @@ -0,0 +1,101 @@ | ||
| 1 | +import "../../index.css"; | |
| 2 | + | |
| 3 | +import type { ProviderReasoningEffort } from "@t3tools/contracts"; | |
| 4 | +import { page } from "vitest/browser"; | |
| 5 | +import { afterEach, describe, expect, it, vi } from "vitest"; | |
| 6 | +import { render } from "vitest-browser-react"; | |
| 7 | + | |
| 8 | +import { ProviderTraitsPicker } from "./CodexTraitsPicker"; | |
| 9 | + | |
| 10 | +async function mountPicker(props: { | |
| 11 | + effort: ProviderReasoningEffort; | |
| 12 | + supportsFastMode: boolean; | |
| 13 | + fastModeEnabled: boolean; | |
| 14 | +}) { | |
| 15 | + const host = document.createElement("div"); | |
| 16 | + document.body.append(host); | |
| 17 | + const onEffortChange = vi.fn(); | |
| 18 | + const onFastModeChange = vi.fn(); | |
| 19 | + const screen = await render( | |
| 20 | + <ProviderTraitsPicker | |
| 21 | + provider="claudeAgent" | |
| 22 | + effort={props.effort} | |
| 23 | + supportsFastMode={props.supportsFastMode} | |
| 24 | + fastModeEnabled={props.fastModeEnabled} | |
| 25 | + options={["low", "medium", "high", "max", "ultrathink"]} | |
| 26 | + onEffortChange={onEffortChange} | |
| 27 | + onFastModeChange={onFastModeChange} | |
| 28 | + />, | |
| 29 | + { container: host }, | |
| 30 | + ); | |
| 31 | + | |
| 32 | + return { | |
| 33 | + onEffortChange, | |
| 34 | + onFastModeChange, | |
| 35 | + cleanup: async () => { | |
| 36 | + await screen.unmount(); | |
| 37 | + host.remove(); | |
| 38 | + }, | |
| 39 | + }; | |
| 40 | +} | |
| 41 | + | |
| 42 | +describe("ProviderTraitsPicker", () => { | |
| 43 | + afterEach(() => { | |
| 44 | + document.body.innerHTML = ""; | |
| 45 | + }); | |
| 46 | + | |
| 47 | + it("shows fast mode controls for claude", async () => { | |
| 48 | + const mounted = await mountPicker({ | |
| 49 | + effort: "high", | |
| 50 | + supportsFastMode: true, | |
| 51 | + fastModeEnabled: false, | |
| 52 | + }); | |
| 53 | + | |
| 54 | + try { | |
| 55 | + await page.getByRole("button").click(); | |
| 56 | + | |
| 57 | + await vi.waitFor(() => { | |
| 58 | + const text = document.body.textContent ?? ""; | |
| 59 | + expect(text).toContain("Fast Mode"); | |
| 60 | + expect(text).toContain("off"); | |
| 61 | + expect(text).toContain("on"); | |
| 62 | + }); | |
| 63 | + } finally { | |
| 64 | + await mounted.cleanup(); | |
| 65 | + } | |
| 66 | + }); | |
| 67 | + | |
| 68 | + it("shows Fast in the trigger label when claude fast mode is active", async () => { | |
| 69 | + const mounted = await mountPicker({ | |
| 70 | + effort: "high", | |
| 71 | + supportsFastMode: true, | |
| 72 | + fastModeEnabled: true, | |
| 73 | + }); | |
| 74 | + | |
| 75 | + try { | |
| 76 | + await vi.waitFor(() => { | |
| 77 | + expect(document.body.textContent ?? "").toContain("High · Fast"); | |
| 78 | + }); | |
| 79 | + } finally { | |
| 80 | + await mounted.cleanup(); | |
| 81 | + } | |
| 82 | + }); | |
| 83 | + | |
| 84 | + it("hides fast mode controls for non-opus claude models", async () => { | |
| 85 | + const mounted = await mountPicker({ | |
| 86 | + effort: "high", | |
| 87 | + supportsFastMode: false, | |
| 88 | + fastModeEnabled: false, | |
| 89 | + }); | |
| 90 | + | |
| 91 | + try { | |
| 92 | + await page.getByRole("button").click(); | |
| 93 | + | |
| 94 | + await vi.waitFor(() => { | |
| 95 | + expect(document.body.textContent ?? "").not.toContain("Fast Mode"); | |
| 96 | + }); | |
| 97 | + } finally { | |
| 98 | + await mounted.cleanup(); | |
| 99 | + } | |
| 100 | + }); | |
| 101 | +}); | |
| @@ -37,6 +37,7 @@ function effortLabel(provider: ProviderKind, effort: ProviderReasoningEffort): s · 36 unmodified lines | ||
| 37 | 37 | export const ProviderTraitsPicker = memo(function ProviderTraitsPicker(props: { |
| 38 | 38 | provider: ProviderKind; |
| 39 | 39 | effort: ProviderReasoningEffort; |
| 40 | + supportsFastMode?: boolean; | |
| 40 | 41 | fastModeEnabled?: boolean; |
| 41 | 42 | options: ReadonlyArray<ProviderReasoningEffort>; |
| 42 | 43 | onEffortChange: (effort: ProviderReasoningEffort) => void; |
| @@ -46,7 +47,7 @@ export const ProviderTraitsPicker = memo(function ProviderTraitsPicker(props: { · 3 unmodified lines | ||
| 46 | 47 | const defaultReasoningEffort = getDefaultReasoningEffort(props.provider); |
| 47 | 48 | const triggerLabel = [ |
| 48 | 49 | effortLabel(props.provider, props.effort), |
| 49 | − ...(props.provider === "codex" && props.fastModeEnabled ? ["Fast"] : []), | |
| 50 | + ...(props.supportsFastMode && props.fastModeEnabled ? ["Fast"] : []), | |
| 50 | 51 | ] |
| 51 | 52 | .filter(Boolean) |
| 52 | 53 | .join(" · "); |
| @@ -92,7 +93,7 @@ export const ProviderTraitsPicker = memo(function ProviderTraitsPicker(props: { · 39 unmodified lines | ||
| 92 | 93 | ))} |
| 93 | 94 | </MenuRadioGroup> |
| 94 | 95 | </MenuGroup> |
| 95 | − {props.provider === "codex" && props.onFastModeChange ? ( | |
| 96 | + {props.supportsFastMode && props.onFastModeChange ? ( | |
| 96 | 97 | <> |
| 97 | 98 | <MenuDivider /> |
| 98 | 99 | <MenuGroup> |
| @@ -0,0 +1,75 @@ | ||
| 1 | +import "../../index.css"; | |
| 2 | + | |
| 3 | +import { page } from "vitest/browser"; | |
| 4 | +import { afterEach, describe, expect, it, vi } from "vitest"; | |
| 5 | +import { render } from "vitest-browser-react"; | |
| 6 | + | |
| 7 | +import { CompactComposerControlsMenu } from "./CompactComposerControlsMenu"; | |
| 8 | + | |
| 9 | +async function mountMenu(supportsFastMode = true) { | |
| 10 | + const host = document.createElement("div"); | |
| 11 | + document.body.append(host); | |
| 12 | + const screen = await render( | |
| 13 | + <CompactComposerControlsMenu | |
| 14 | + activePlan={false} | |
| 15 | + interactionMode="default" | |
| 16 | + planSidebarOpen={false} | |
| 17 | + runtimeMode="approval-required" | |
| 18 | + selectedEffort="high" | |
| 19 | + selectedProvider="claudeAgent" | |
| 20 | + supportsFastMode={supportsFastMode} | |
| 21 | + selectedFastModeEnabled={false} | |
| 22 | + reasoningOptions={["low", "medium", "high", "max", "ultrathink"]} | |
| 23 | + onEffortSelect={vi.fn()} | |
| 24 | + onFastModeChange={vi.fn()} | |
| 25 | + onToggleInteractionMode={vi.fn()} | |
| 26 | + onTogglePlanSidebar={vi.fn()} | |
| 27 | + onToggleRuntimeMode={vi.fn()} | |
| 28 | + />, | |
| 29 | + { container: host }, | |
| 30 | + ); | |
| 31 | + | |
| 32 | + return { | |
| 33 | + cleanup: async () => { | |
| 34 | + await screen.unmount(); | |
| 35 | + host.remove(); | |
| 36 | + }, | |
| 37 | + }; | |
| 38 | +} | |
| 39 | + | |
| 40 | +describe("CompactComposerControlsMenu", () => { | |
| 41 | + afterEach(() => { | |
| 42 | + document.body.innerHTML = ""; | |
| 43 | + }); | |
| 44 | + | |
| 45 | + it("shows fast mode controls for claude", async () => { | |
| 46 | + const mounted = await mountMenu(); | |
| 47 | + | |
| 48 | + try { | |
| 49 | + await page.getByLabelText("More composer controls").click(); | |
| 50 | + | |
| 51 | + await vi.waitFor(() => { | |
| 52 | + const text = document.body.textContent ?? ""; | |
| 53 | + expect(text).toContain("Fast Mode"); | |
| 54 | + expect(text).toContain("off"); | |
| 55 | + expect(text).toContain("on"); | |
| 56 | + }); | |
| 57 | + } finally { | |
| 58 | + await mounted.cleanup(); | |
| 59 | + } | |
| 60 | + }); | |
| 61 | + | |
| 62 | + it("hides fast mode controls for non-opus claude models", async () => { | |
| 63 | + const mounted = await mountMenu(false); | |
| 64 | + | |
| 65 | + try { | |
| 66 | + await page.getByLabelText("More composer controls").click(); | |
| 67 | + | |
| 68 | + await vi.waitFor(() => { | |
| 69 | + expect(document.body.textContent ?? "").not.toContain("Fast Mode"); | |
| 70 | + }); | |
| 71 | + } finally { | |
| 72 | + await mounted.cleanup(); | |
| 73 | + } | |
| 74 | + }); | |
| 75 | +}); | |
| @@ -26,10 +26,11 @@ export const CompactComposerControlsMenu = memo(function CompactComposerControls · 25 unmodified lines | ||
| 26 | 26 | runtimeMode: RuntimeMode; |
| 27 | 27 | selectedEffort: ProviderReasoningEffort | null; |
| 28 | 28 | selectedProvider: ProviderKind; |
| 29 | − selectedCodexFastModeEnabled: boolean; | |
| 29 | + supportsFastMode: boolean; | |
| 30 | + selectedFastModeEnabled: boolean; | |
| 30 | 31 | reasoningOptions: ReadonlyArray<ProviderReasoningEffort>; |
| 31 | 32 | onEffortSelect: (effort: ProviderReasoningEffort) => void; |
| 32 | − onCodexFastModeChange: (enabled: boolean) => void; | |
| 33 | + onFastModeChange: (enabled: boolean) => void; | |
| 33 | 34 | onToggleInteractionMode: () => void; |
| 34 | 35 | onTogglePlanSidebar: () => void; |
| 35 | 36 | onToggleRuntimeMode: () => void; |
| @@ -82,7 +83,7 @@ export const CompactComposerControlsMenu = memo(function CompactComposerControls · 46 unmodified lines | ||
| 82 | 83 | ))} |
| 83 | 84 | </MenuRadioGroup> |
| 84 | 85 | </MenuGroup> |
| 85 | − {props.selectedProvider === "codex" ? ( | |
| 86 | + {props.supportsFastMode ? ( | |
| 86 | 87 | <> |
| 87 | 88 | <MenuDivider /> |
| 88 | 89 | <MenuGroup> |
| @@ -90,9 +91,9 @@ export const CompactComposerControlsMenu = memo(function CompactComposerControls · 1 unmodified line | ||
| 90 | 91 | Fast Mode |
| 91 | 92 | </div> |
| 92 | 93 | <MenuRadioGroup |
| 93 | − value={props.selectedCodexFastModeEnabled ? "on" : "off"} | |
| 94 | + value={props.selectedFastModeEnabled ? "on" : "off"} | |
| 94 | 95 | onValueChange={(value) => { |
| 95 | − props.onCodexFastModeChange(value === "on"); | |
| 96 | + props.onFastModeChange(value === "on"); | |
| 96 | 97 | }} |
| 97 | 98 | > |
| 98 | 99 | <MenuRadioItem value="off">off</MenuRadioItem> |
| @@ -337,7 +337,7 @@ describe("composerDraftStore project draft thread mapping", () => { · 336 unmodified lines | ||
| 337 | 337 | }); |
| 338 | 338 | }); |
| 339 | 339 | |
| 340 | −describe("composerDraftStore codex fast mode", () => { | |
| 340 | +describe("composerDraftStore fast mode", () => { | |
| 341 | 341 | const threadId = ThreadId.makeUnsafe("thread-service-tier"); |
| 342 | 342 | |
| 343 | 343 | beforeEach(() => { |
| @@ -348,17 +348,17 @@ describe("composerDraftStore codex fast mode", () => { · 4 unmodified lines | ||
| 348 | 348 | }); |
| 349 | 349 | }); |
| 350 | 350 | |
| 351 | − it("stores codex fast mode in the draft", () => { | |
| 351 | + it("stores fast mode in the draft", () => { | |
| 352 | 352 | const store = useComposerDraftStore.getState(); |
| 353 | − store.setCodexFastMode(threadId, true); | |
| 353 | + store.setFastMode(threadId, true); | |
| 354 | 354 | |
| 355 | − expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.codexFastMode).toBe(true); | |
| 355 | + expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.fastMode).toBe(true); | |
| 356 | 356 | }); |
| 357 | 357 | |
| 358 | − it("clears codex fast mode when reset to the default", () => { | |
| 358 | + it("clears fast mode when reset to the default", () => { | |
| 359 | 359 | const store = useComposerDraftStore.getState(); |
| 360 | − store.setCodexFastMode(threadId, true); | |
| 361 | − store.setCodexFastMode(threadId, false); | |
| 360 | + store.setFastMode(threadId, true); | |
| 361 | + store.setFastMode(threadId, false); | |
| 362 | 362 | |
| 363 | 363 | expect(useComposerDraftStore.getState().draftsByThreadId[threadId]).toBeUndefined(); |
| 364 | 364 | }); |
| @@ -80,6 +80,7 @@ interface PersistedComposerThreadDraftState { · 79 unmodified lines | ||
| 80 | 80 | runtimeMode?: RuntimeMode | null; |
| 81 | 81 | interactionMode?: ProviderInteractionMode | null; |
| 82 | 82 | effort?: ProviderReasoningEffort | null; |
| 83 | + fastMode?: boolean | null; | |
| 83 | 84 | codexFastMode?: boolean | null; |
| 84 | 85 | serviceTier?: string | null; |
| 85 | 86 | } |
| @@ -110,7 +111,7 @@ interface ComposerThreadDraftState { · 24 unmodified lines | ||
| 110 | 111 | runtimeMode: RuntimeMode | null; |
| 111 | 112 | interactionMode: ProviderInteractionMode | null; |
| 112 | 113 | effort: ProviderReasoningEffort | null; |
| 113 | − codexFastMode: boolean; | |
| 114 | + fastMode: boolean; | |
| 114 | 115 | } |
| 115 | 116 | |
| 116 | 117 | export interface DraftThreadState { |
| @@ -169,7 +170,7 @@ interface ComposerDraftStoreState { · 52 unmodified lines | ||
| 169 | 170 | interactionMode: ProviderInteractionMode | null | undefined, |
| 170 | 171 | ) => void; |
| 171 | 172 | setEffort: (threadId: ThreadId, effort: ProviderReasoningEffort | null | undefined) => void; |
| 172 | − setCodexFastMode: (threadId: ThreadId, enabled: boolean | null | undefined) => void; | |
| 173 | + setFastMode: (threadId: ThreadId, enabled: boolean | null | undefined) => void; | |
| 173 | 174 | addImage: (threadId: ThreadId, image: ComposerImageAttachment) => void; |
| 174 | 175 | addImages: (threadId: ThreadId, images: ComposerImageAttachment[]) => void; |
| 175 | 176 | removeImage: (threadId: ThreadId, imageId: string) => void; |
| @@ -204,7 +205,7 @@ const EMPTY_THREAD_DRAFT = Object.freeze({ · 28 unmodified lines | ||
| 204 | 205 | runtimeMode: null, |
| 205 | 206 | interactionMode: null, |
| 206 | 207 | effort: null, |
| 207 | − codexFastMode: false, | |
| 208 | + fastMode: false, | |
| 208 | 209 | }) as ComposerThreadDraftState; |
| 209 | 210 | |
| 210 | 211 | const REASONING_EFFORT_VALUES = new Set<ProviderReasoningEffort>([ |
| @@ -227,7 +228,7 @@ function createEmptyThreadDraft(): ComposerThreadDraftState { · 16 unmodified lines | ||
| 227 | 228 | runtimeMode: null, |
| 228 | 229 | interactionMode: null, |
| 229 | 230 | effort: null, |
| 230 | − codexFastMode: false, | |
| 231 | + fastMode: false, | |
| 231 | 232 | }; |
| 232 | 233 | } |
| 233 | 234 | |
| @@ -247,7 +248,7 @@ function shouldRemoveDraft(draft: ComposerThreadDraftState): boolean { · 13 unmodified lines | ||
| 247 | 248 | draft.runtimeMode === null && |
| 248 | 249 | draft.interactionMode === null && |
| 249 | 250 | draft.effort === null && |
| 250 | − draft.codexFastMode === false | |
| 251 | + draft.fastMode === false | |
| 251 | 252 | ); |
| 252 | 253 | } |
| 253 | 254 | |
| @@ -430,7 +431,8 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer · 176 unmodified lines | ||
| 430 | 431 | effortCandidate && REASONING_EFFORT_VALUES.has(effortCandidate as ProviderReasoningEffort) |
| 431 | 432 | ? (effortCandidate as ProviderReasoningEffort) |
| 432 | 433 | : null; |
| 433 | − const codexFastMode = | |
| 434 | + const fastMode = | |
| 435 | + draftCandidate.fastMode === true || | |
| 434 | 436 | draftCandidate.codexFastMode === true || |
| 435 | 437 | (typeof draftCandidate.serviceTier === "string" && draftCandidate.serviceTier === "fast"); |
| 436 | 438 | if ( |
| @@ -441,7 +443,7 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer · 4 unmodified lines | ||
| 441 | 443 | !runtimeMode && |
| 442 | 444 | !interactionMode && |
| 443 | 445 | !effort && |
| 444 | − !codexFastMode | |
| 446 | + !fastMode | |
| 445 | 447 | ) { |
| 446 | 448 | continue; |
| 447 | 449 | } |
| @@ -453,7 +455,7 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer · 5 unmodified lines | ||
| 453 | 455 | ...(runtimeMode ? { runtimeMode } : {}), |
| 454 | 456 | ...(interactionMode ? { interactionMode } : {}), |
| 455 | 457 | ...(effort ? { effort } : {}), |
| 456 | − ...(codexFastMode ? { codexFastMode } : {}), | |
| 458 | + ...(fastMode ? { fastMode } : {}), | |
| 457 | 459 | }; |
| 458 | 460 | } |
| 459 | 461 | return { |
| @@ -559,7 +561,7 @@ function toHydratedThreadDraft( · 99 unmodified lines | ||
| 559 | 561 | runtimeMode: persistedDraft.runtimeMode ?? null, |
| 560 | 562 | interactionMode: persistedDraft.interactionMode ?? null, |
| 561 | 563 | effort: persistedDraft.effort ?? null, |
| 562 | − codexFastMode: persistedDraft.codexFastMode === true, | |
| 564 | + fastMode: persistedDraft.fastMode === true || persistedDraft.codexFastMode === true, | |
| 563 | 565 | }; |
| 564 | 566 | } |
| 565 | 567 | |
| @@ -965,23 +967,23 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()( · 399 unmodified lines | ||
| 965 | 967 | return { draftsByThreadId: nextDraftsByThreadId }; |
| 966 | 968 | }); |
| 967 | 969 | }, |
| 968 | − setCodexFastMode: (threadId, enabled) => { | |
| 970 | + setFastMode: (threadId, enabled) => { | |
| 969 | 971 | if (threadId.length === 0) { |
| 970 | 972 | return; |
| 971 | 973 | } |
| 972 | − const nextCodexFastMode = enabled === true; | |
| 974 | + const nextFastMode = enabled === true; | |
| 973 | 975 | set((state) => { |
| 974 | 976 | const existing = state.draftsByThreadId[threadId]; |
| 975 | − if (!existing && nextCodexFastMode === false) { | |
| 977 | + if (!existing && nextFastMode === false) { | |
| 976 | 978 | return state; |
| 977 | 979 | } |
| 978 | 980 | const base = existing ?? createEmptyThreadDraft(); |
| 979 | − if (base.codexFastMode === nextCodexFastMode) { | |
| 981 | + if (base.fastMode === nextFastMode) { | |
| 980 | 982 | return state; |
| 981 | 983 | } |
| 982 | 984 | const nextDraft: ComposerThreadDraftState = { |
| 983 | 985 | ...base, |
| 984 | − codexFastMode: nextCodexFastMode, | |
| 986 | + fastMode: nextFastMode, | |
| 985 | 987 | }; |
| 986 | 988 | const nextDraftsByThreadId = { ...state.draftsByThreadId }; |
| 987 | 989 | if (shouldRemoveDraft(nextDraft)) { |
| @@ -1229,7 +1231,7 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()( · 241 unmodified lines | ||
| 1229 | 1231 | draft.runtimeMode === null && |
| 1230 | 1232 | draft.interactionMode === null && |
| 1231 | 1233 | draft.effort === null && |
| 1232 | − draft.codexFastMode === false | |
| 1234 | + draft.fastMode === false | |
| 1233 | 1235 | ) { |
| 1234 | 1236 | continue; |
| 1235 | 1237 | } |
| @@ -1252,8 +1254,8 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()( · 16 unmodified lines | ||
| 1252 | 1254 | if (draft.effort) { |
| 1253 | 1255 | persistedDraft.effort = draft.effort; |
| 1254 | 1256 | } |
| 1255 | − if (draft.codexFastMode) { | |
| 1256 | − persistedDraft.codexFastMode = true; | |
| 1257 | + if (draft.fastMode) { | |
| 1258 | + persistedDraft.fastMode = true; | |
| 1257 | 1259 | } |
| 1258 | 1260 | persistedDraftsByThreadId[threadId as ThreadId] = persistedDraft; |
| 1259 | 1261 | } |
| @@ -48,7 +48,7 @@ · 47 unmodified lines | ||
| 48 | 48 | "t3": "./dist/index.mjs", |
| 49 | 49 | }, |
| 50 | 50 | "dependencies": { |
| 51 | − "@anthropic-ai/claude-agent-sdk": "^0.2.76", | |
| 51 | + "@anthropic-ai/claude-agent-sdk": "^0.2.77", | |
| 52 | 52 | "@effect/platform-node": "catalog:", |
| 53 | 53 | "@effect/sql-sqlite-bun": "catalog:", |
| 54 | 54 | "@pierre/diffs": "^1.1.0-beta.16", |
| @@ -153,6 +153,7 @@ · 98 unmodified lines | ||
| 153 | 153 | "scripts": { |
| 154 | 154 | "name": "@t3tools/scripts", |
| 155 | 155 | "dependencies": { |
| 156 | + "@anthropic-ai/claude-agent-sdk": "^0.2.77", | |
| 156 | 157 | "@effect/platform-node": "catalog:", |
| 157 | 158 | "@t3tools/contracts": "workspace:*", |
| 158 | 159 | "@t3tools/shared": "workspace:*", |
| @@ -183,7 +184,7 @@ · 24 unmodified lines | ||
| 183 | 184 | "vitest": "^4.0.0", |
| 184 | 185 | }, |
| 185 | 186 | "packages": { |
| 186 | − "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.2.76", "", { "optionalDependencies": { "@img/sharp-darwin-arm64": "^0.34.2", "@img/sharp-darwin-x64": "^0.34.2", "@img/sharp-linux-arm": "^0.34.2", "@img/sharp-linux-arm64": "^0.34.2", "@img/sharp-linux-x64": "^0.34.2", "@img/sharp-linuxmusl-arm64": "^0.34.2", "@img/sharp-linuxmusl-x64": "^0.34.2", "@img/sharp-win32-arm64": "^0.34.2", "@img/sharp-win32-x64": "^0.34.2" }, "peerDependencies": { "zod": "^4.0.0" } }, "sha512-HZxvnT8ZWkzCnQygaYCA0dl8RSUzuVbxE1YG4ecy6vh4nQbTT36CxUxBy+QVdR12pPQluncC0mCOLhI2918Eaw=="], | |
| 187 | + "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.2.77", "", { "optionalDependencies": { "@img/sharp-darwin-arm64": "^0.34.2", "@img/sharp-darwin-x64": "^0.34.2", "@img/sharp-linux-arm": "^0.34.2", "@img/sharp-linux-arm64": "^0.34.2", "@img/sharp-linux-x64": "^0.34.2", "@img/sharp-linuxmusl-arm64": "^0.34.2", "@img/sharp-linuxmusl-x64": "^0.34.2", "@img/sharp-win32-arm64": "^0.34.2", "@img/sharp-win32-x64": "^0.34.2" }, "peerDependencies": { "zod": "^4.0.0" } }, "sha512-t+R1BW3ahCFMNM7/8WJq7+Gw9KPA9Cl7UUK8fWPokJZ75cf/xwEd9MqB+MVNoQT45dJiom/wxybT7tqYPkCqyg=="], | |
| 187 | 188 | |
| 188 | 189 | "@astrojs/check": ["@astrojs/check@0.9.8", "", { "dependencies": { "@astrojs/language-server": "^2.16.5", "chokidar": "^4.0.3", "kleur": "^4.1.5", "yargs": "^17.7.2" }, "peerDependencies": { "typescript": "^5.0.0" }, "bin": { "astro-check": "bin/astro-check.js" } }, "sha512-LDng8446QLS5ToKjRHd3bgUdirvemVVExV7nRyJfW2wV36xuv7vDxwy5NWN9zqeSEDgg0Tv84sP+T3yEq+Zlkw=="], |
| 189 | 190 | |
| @@ -16,6 +16,7 @@ export type CodexModelOptions = typeof CodexModelOptions.Type; · 15 unmodified lines | ||
| 16 | 16 | export const ClaudeModelOptions = Schema.Struct({ |
| 17 | 17 | thinking: Schema.optional(Schema.Boolean), |
| 18 | 18 | effort: Schema.optional(Schema.Literals(CLAUDE_CODE_EFFORT_OPTIONS)), |
| 19 | + fastMode: Schema.optional(Schema.Boolean), | |
| 19 | 20 | }); |
| 20 | 21 | export type ClaudeModelOptions = typeof ClaudeModelOptions.Type; |
| 21 | 22 | |
| @@ -53,6 +53,7 @@ describe("ProviderSessionStartInput", () => { · 52 unmodified lines | ||
| 53 | 53 | claudeAgent: { |
| 54 | 54 | thinking: true, |
| 55 | 55 | effort: "max", |
| 56 | + fastMode: true, | |
| 56 | 57 | }, |
| 57 | 58 | }, |
| 58 | 59 | providerOptions: { |
| @@ -67,6 +68,7 @@ describe("ProviderSessionStartInput", () => { · 8 unmodified lines | ||
| 67 | 68 | expect(parsed.provider).toBe("claudeAgent"); |
| 68 | 69 | expect(parsed.modelOptions?.claudeAgent?.thinking).toBe(true); |
| 69 | 70 | expect(parsed.modelOptions?.claudeAgent?.effort).toBe("max"); |
| 71 | + expect(parsed.modelOptions?.claudeAgent?.fastMode).toBe(true); | |
| 70 | 72 | expect(parsed.providerOptions?.claudeAgent?.binaryPath).toBe("/usr/local/bin/claude"); |
| 71 | 73 | expect(parsed.providerOptions?.claudeAgent?.permissionMode).toBe("plan"); |
| 72 | 74 | expect(parsed.providerOptions?.claudeAgent?.maxThinkingTokens).toBe(12_000); |
| @@ -99,10 +101,12 @@ describe("ProviderSendTurnInput", () => { · 26 unmodified lines | ||
| 99 | 101 | modelOptions: { |
| 100 | 102 | claudeAgent: { |
| 101 | 103 | effort: "ultrathink", |
| 104 | + fastMode: true, | |
| 102 | 105 | }, |
| 103 | 106 | }, |
| 104 | 107 | }); |
| 105 | 108 | |
| 106 | 109 | expect(parsed.modelOptions?.claudeAgent?.effort).toBe("ultrathink"); |
| 110 | + expect(parsed.modelOptions?.claudeAgent?.fastMode).toBe(true); | |
| 107 | 111 | }); |
| 108 | 112 | }); |
| @@ -20,6 +20,7 @@ import { · 19 unmodified lines | ||
| 20 | 20 | resolveReasoningEffortForProvider, |
| 21 | 21 | resolveModelSlug, |
| 22 | 22 | resolveModelSlugForProvider, |
| 23 | + supportsClaudeFastMode, | |
| 23 | 24 | } from "./model"; |
| 24 | 25 | |
| 25 | 26 | describe("normalizeModelSlug", () => { |
| @@ -166,3 +167,13 @@ describe("getEffectiveClaudeCodeEffort", () => { · 140 unmodified lines | ||
| 166 | 167 | expect(getEffectiveClaudeCodeEffort(undefined)).toBeNull(); |
| 167 | 168 | }); |
| 168 | 169 | }); |
| 170 | + | |
| 171 | +describe("supportsClaudeFastMode", () => { | |
| 172 | + it("only enables Claude fast mode for Opus 4.6", () => { | |
| 173 | + expect(supportsClaudeFastMode("claude-opus-4-6")).toBe(true); | |
| 174 | + expect(supportsClaudeFastMode("opus")).toBe(true); | |
| 175 | + expect(supportsClaudeFastMode("claude-sonnet-4-6")).toBe(false); | |
| 176 | + expect(supportsClaudeFastMode("claude-haiku-4-5")).toBe(false); | |
| 177 | + expect(supportsClaudeFastMode(undefined)).toBe(false); | |
| 178 | + }); | |
| 179 | +}); | |
| @@ -26,6 +26,10 @@ export function getDefaultModel(provider: ProviderKind = "codex"): ModelSlug { · 25 unmodified lines | ||
| 26 | 26 | return DEFAULT_MODEL_BY_PROVIDER[provider]; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | +export function supportsClaudeFastMode(model: string | null | undefined): boolean { | |
| 30 | + return normalizeModelSlug(model, "claudeAgent") === "claude-opus-4-6"; | |
| 31 | +} | |
| 32 | + | |
| 29 | 33 | export function normalizeModelSlug( |
| 30 | 34 | model: string | null | undefined, |
| 31 | 35 | provider: ProviderKind = "codex", |
| @@ -0,0 +1,129 @@ | ||
| 1 | +import { query, type SDKMessage } from "@anthropic-ai/claude-agent-sdk"; | |
| 2 | + | |
| 3 | +type ProbeMode = "off" | "on"; | |
| 4 | + | |
| 5 | +async function* emptyPrompt(): AsyncGenerator<never, void, void> {} | |
| 6 | + | |
| 7 | +function parseArgs(argv: ReadonlyArray<string>): { | |
| 8 | + readonly mode: ProbeMode | "both"; | |
| 9 | + readonly model?: string; | |
| 10 | + readonly cwd?: string; | |
| 11 | + readonly prompt?: string; | |
| 12 | +} { | |
| 13 | + let mode: ProbeMode | "both" = "both"; | |
| 14 | + let model: string | undefined; | |
| 15 | + let cwd: string | undefined; | |
| 16 | + let prompt: string | undefined; | |
| 17 | + | |
| 18 | + for (let index = 0; index < argv.length; index += 1) { | |
| 19 | + const value = argv[index]; | |
| 20 | + if (!value) { | |
| 21 | + continue; | |
| 22 | + } | |
| 23 | + if (value === "--mode") { | |
| 24 | + const next = argv[index + 1]; | |
| 25 | + if (next === "off" || next === "on" || next === "both") { | |
| 26 | + mode = next; | |
| 27 | + index += 1; | |
| 28 | + } | |
| 29 | + continue; | |
| 30 | + } | |
| 31 | + if (value === "--model") { | |
| 32 | + model = argv[index + 1]; | |
| 33 | + index += 1; | |
| 34 | + continue; | |
| 35 | + } | |
| 36 | + if (value === "--cwd") { | |
| 37 | + cwd = argv[index + 1]; | |
| 38 | + index += 1; | |
| 39 | + continue; | |
| 40 | + } | |
| 41 | + if (value === "--prompt") { | |
| 42 | + prompt = argv[index + 1] ?? prompt; | |
| 43 | + index += 1; | |
| 44 | + } | |
| 45 | + } | |
| 46 | + | |
| 47 | + return { | |
| 48 | + mode, | |
| 49 | + ...(model ? { model } : {}), | |
| 50 | + ...(cwd ? { cwd } : {}), | |
| 51 | + ...(prompt ? { prompt } : {}), | |
| 52 | + }; | |
| 53 | +} | |
| 54 | + | |
| 55 | +async function runProbe(input: { | |
| 56 | + readonly mode: ProbeMode; | |
| 57 | + readonly model?: string; | |
| 58 | + readonly cwd?: string; | |
| 59 | + readonly prompt?: string; | |
| 60 | +}): Promise<void> { | |
| 61 | + const messages = query({ | |
| 62 | + prompt: input.prompt ?? emptyPrompt(), | |
| 63 | + options: { | |
| 64 | + ...(input.model ? { model: input.model } : {}), | |
| 65 | + ...(input.cwd ? { cwd: input.cwd } : {}), | |
| 66 | + persistSession: false, | |
| 67 | + tools: [], | |
| 68 | + permissionMode: "plan", | |
| 69 | + includePartialMessages: true, | |
| 70 | + ...(input.mode === "on" ? { settings: { fastMode: true } } : {}), | |
| 71 | + }, | |
| 72 | + }); | |
| 73 | + | |
| 74 | + const summary = { | |
| 75 | + mode: input.mode, | |
| 76 | + initFastModeState: null as string | null, | |
| 77 | + resultFastModeState: null as string | null, | |
| 78 | + resultSubtype: null as string | null, | |
| 79 | + resultText: null as string | null, | |
| 80 | + }; | |
| 81 | + | |
| 82 | + const initialization = await messages.initializationResult(); | |
| 83 | + summary.initFastModeState = initialization.fast_mode_state ?? null; | |
| 84 | + | |
| 85 | + if (!input.prompt) { | |
| 86 | + messages.close(); | |
| 87 | + console.log(JSON.stringify(summary, null, 2)); | |
| 88 | + return; | |
| 89 | + } | |
| 90 | + | |
| 91 | + for await (const message of messages) { | |
| 92 | + handleProbeMessage(message, summary); | |
| 93 | + } | |
| 94 | + console.log(JSON.stringify(summary, null, 2)); | |
| 95 | +} | |
| 96 | + | |
| 97 | +function handleProbeMessage( | |
| 98 | + message: SDKMessage, | |
| 99 | + summary: { | |
| 100 | + mode: ProbeMode; | |
| 101 | + initFastModeState: string | null; | |
| 102 | + resultFastModeState: string | null; | |
| 103 | + resultSubtype: string | null; | |
| 104 | + resultText: string | null; | |
| 105 | + }, | |
| 106 | +): void { | |
| 107 | + if (message.type !== "result") { | |
| 108 | + return; | |
| 109 | + } | |
| 110 | + summary.resultSubtype = message.subtype; | |
| 111 | + summary.resultFastModeState = message.fast_mode_state ?? null; | |
| 112 | + summary.resultText = message.subtype === "success" ? message.result : message.errors.join("\n"); | |
| 113 | +} | |
| 114 | + | |
| 115 | +async function main(): Promise<void> { | |
| 116 | + const args = parseArgs(process.argv.slice(2)); | |
| 117 | + const modes = args.mode === "both" ? (["off", "on"] as const) : [args.mode]; | |
| 118 | + | |
| 119 | + for (const mode of modes) { | |
| 120 | + await runProbe({ | |
| 121 | + mode, | |
| 122 | + ...(args.model ? { model: args.model } : {}), | |
| 123 | + ...(args.cwd ? { cwd: args.cwd } : {}), | |
| 124 | + ...(args.prompt ? { prompt: args.prompt } : {}), | |
| 125 | + }); | |
| 126 | + } | |
| 127 | +} | |
| 128 | + | |
| 129 | +await main(); | |
| @@ -4,10 +4,12 @@ · 3 unmodified lines | ||
| 4 | 4 | "type": "module", |
| 5 | 5 | "scripts": { |
| 6 | 6 | "prepare": "effect-language-service patch", |
| 7 | + "claude-fast-mode-probe": "bun run claude-fast-mode-probe.ts", | |
| 7 | 8 | "typecheck": "tsc --noEmit", |
| 8 | 9 | "test": "vitest run" |
| 9 | 10 | }, |
| 10 | 11 | "dependencies": { |
| 12 | + "@anthropic-ai/claude-agent-sdk": "^0.2.77", | |
| 11 | 13 | "@effect/platform-node": "catalog:", |
| 12 | 14 | "@t3tools/contracts": "workspace:*", |
| 13 | 15 | "@t3tools/shared": "workspace:*", |