mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Hide remaining test-only helper details
This commit is contained in:
parent
79bc2e6422
commit
9144fd9e48
5 changed files with 9 additions and 32 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<NamingRuntime> {
|
||||
const runtime = namingRuntime(settings);
|
||||
if (!runtime.model || !runtime.effort) return runtime;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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<Thread> & { id: string }): Thread {
|
||||
return {
|
||||
id: options.id,
|
||||
|
|
|
|||
Loading…
Reference in a new issue