diff --git a/scripts/report-api-baseline.mjs b/scripts/report-api-baseline.mjs index f00c8b02..b9b63da2 100644 --- a/scripts/report-api-baseline.mjs +++ b/scripts/report-api-baseline.mjs @@ -1,5 +1,6 @@ import { readFile } from "node:fs/promises"; import { spawnSync } from "node:child_process"; +import { readJson } from "./release-utils.mjs"; const args = new Set(process.argv.slice(2)); const shouldCheck = args.has("--check"); @@ -13,10 +14,6 @@ function warn(message) { warnings.push(message); } -async function readJson(path) { - return JSON.parse(await readFile(path, "utf8")); -} - function parseSemver(value) { const match = String(value ?? "").match(/\b(\d+)\.(\d+)\.(\d+)\b/); if (!match) return null; diff --git a/src/app-server/thread-naming.ts b/src/app-server/thread-naming.ts index 676defe2..165f9496 100644 --- a/src/app-server/thread-naming.ts +++ b/src/app-server/thread-naming.ts @@ -16,7 +16,6 @@ import { createStructuredTurnRunLifecycle, structuredTurnRunMatches, transitionStructuredTurnRunLifecycle, - type StructuredTurnRunLifecycleState, } from "./structured-turn-run-lifecycle"; const NAMING_SERVICE_NAME = "codex-panel-naming"; @@ -90,12 +89,12 @@ export async function generateThreadTitleWithCodex( const resolveIfNamingTurn = (notification: ServerNotification): void => { if (lifecycle.kind === "completed") return; if (notification.method === "item/completed") { - if (!notificationMatchesThreadNamingTurn(lifecycle, notification.params.threadId, notification.params.turnId)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turnId)) return; completedItems.push(notification.params.item); return; } if (notification.method === "turn/completed") { - if (!notificationMatchesThreadNamingTurn(lifecycle, notification.params.threadId, notification.params.turn.id)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turn.id)) return; lifecycle = transitionStructuredTurnRunLifecycle(lifecycle, { type: "completed" }); resolve(turnWithCollectedItems(notification.params.turn, completedItems)); } @@ -165,10 +164,6 @@ function turnWithCollectedItems(turn: Turn, items: ThreadItem[]): Turn { return { ...turn, items: [...items], itemsView: "full" }; } -function notificationMatchesThreadNamingTurn(lifecycle: StructuredTurnRunLifecycleState, threadId: string, turnId: string): boolean { - return structuredTurnRunMatches(lifecycle, threadId, turnId); -} - async function namingRuntimeForClient(client: ThreadNamingClient, settings: ThreadNamingRuntimeSettings): Promise { const runtime = namingRuntime(settings); if (!runtime.model || !runtime.effort) return runtime; diff --git a/src/features/selection-rewrite/runner.ts b/src/features/selection-rewrite/runner.ts index 8799ba05..610a222b 100644 --- a/src/features/selection-rewrite/runner.ts +++ b/src/features/selection-rewrite/runner.ts @@ -3,7 +3,6 @@ import { createStructuredTurnRunLifecycle, structuredTurnRunMatches, transitionStructuredTurnRunLifecycle, - type StructuredTurnRunLifecycleState, } from "../../app-server/structured-turn-run-lifecycle"; import type { InitializeResponse } from "../../generated/app-server/InitializeResponse"; import type { RequestId } from "../../generated/app-server/RequestId"; @@ -85,7 +84,7 @@ export async function runSelectionRewrite(options: RunSelectionRewriteOptions): handleNotification = (notification): void => { if (lifecycle.kind === "completed") return; if (notification.method === "item/agentMessage/delta") { - if (!notificationMatchesSelectionRewriteTurn(lifecycle, notification.params.threadId, notification.params.turnId)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turnId)) return; options.onActivity?.("writing"); preview += notification.params.delta; options.onPreview?.(preview); @@ -96,17 +95,17 @@ export async function runSelectionRewrite(options: RunSelectionRewriteOptions): notification.method === "item/reasoning/textDelta" || notification.method === "item/reasoning/summaryPartAdded" ) { - if (!notificationMatchesSelectionRewriteTurn(lifecycle, notification.params.threadId, notification.params.turnId)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turnId)) return; options.onActivity?.("reasoning"); return; } if (notification.method === "item/completed") { - if (!notificationMatchesSelectionRewriteTurn(lifecycle, notification.params.threadId, notification.params.turnId)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turnId)) return; completedItems.push(notification.params.item); return; } if (notification.method === "turn/completed") { - if (!notificationMatchesSelectionRewriteTurn(lifecycle, notification.params.threadId, notification.params.turn.id)) return; + if (!structuredTurnRunMatches(lifecycle, notification.params.threadId, notification.params.turn.id)) return; lifecycle = transitionStructuredTurnRunLifecycle(lifecycle, { type: "completed" }); resolve(turnWithCollectedItems(notification.params.turn, completedItems)); } @@ -170,10 +169,6 @@ export async function runSelectionRewrite(options: RunSelectionRewriteOptions): } } -function notificationMatchesSelectionRewriteTurn(lifecycle: StructuredTurnRunLifecycleState, threadId: string, turnId: string): boolean { - return structuredTurnRunMatches(lifecycle, threadId, turnId); -} - function throwIfAborted(signal: AbortSignal | undefined): void { if (signal?.aborted) throw selectionRewriteAbortError(); } diff --git a/src/features/thread-picker/modal.ts b/src/features/thread-picker/modal.ts index a54ae952..10530769 100644 --- a/src/features/thread-picker/modal.ts +++ b/src/features/thread-picker/modal.ts @@ -25,7 +25,7 @@ type ThreadOpenMode = "current" | "available"; const MAX_THREAD_PICKER_SUGGESTIONS = 20; -export const THREAD_PICKER_MODIFIER_ENTER_LISTENER_OPTIONS = { capture: true } as const; +const THREAD_PICKER_MODIFIER_ENTER_LISTENER_OPTIONS = { capture: true } as const; export async function openThreadPicker(host: ThreadPickerHost): Promise { try { diff --git a/tests/features/thread-picker/modal.test.ts b/tests/features/thread-picker/modal.test.ts index 54988b69..dc4f8532 100644 --- a/tests/features/thread-picker/modal.test.ts +++ b/tests/features/thread-picker/modal.test.ts @@ -3,11 +3,7 @@ import { describe, expect, it } from "vitest"; import type { Thread } from "../../../src/generated/app-server/v2/Thread"; -import { - THREAD_PICKER_MODIFIER_ENTER_LISTENER_OPTIONS, - threadOpenModeFromEvent, - threadPickerSuggestions, -} from "../../../src/features/thread-picker/modal"; +import { threadOpenModeFromEvent, threadPickerSuggestions } from "../../../src/features/thread-picker/modal"; describe("threadPickerSuggestions", () => { it("orders title and id prefix matches before looser matches", () => { @@ -42,12 +38,6 @@ describe("threadOpenModeFromEvent", () => { }); }); -describe("THREAD_PICKER_MODIFIER_ENTER_LISTENER_OPTIONS", () => { - it("captures modifier Enter before the default SuggestModal handler can select", () => { - expect(THREAD_PICKER_MODIFIER_ENTER_LISTENER_OPTIONS).toEqual({ capture: true }); - }); -}); - function thread(options: Partial & { id: string }): Thread { return { id: options.id,