New threads, model and mode picker, alerts, $EDITOR and terminal attach
- c starts a draft thread (project, model, mode, worktree) launched with orchestration.launchThread - m picks model, provider options and access mode from the server's providers, following the web's provider lock; model changes ride on the next message - Alerts port T3's notification gate: bell, OSC 9/99 desktop notifications when unfocused, in-app flash - ctrl+g edits the message in $EDITOR; ctrl+j attaches to the thread's T3 terminal - Credential gains terminal:read
This commit is contained in:
1 parent
121bbd9137
commit
626d37a4e9
18 files changed
+1074
-49
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import type { OrchestrationV2ShellSnapshot } from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
|
||||
import { createAlerts, type Alert } from "../src/model/alerts.ts";
|
||||
|
||||
const at = (ms: number) => DateTime.makeUnsafe(ms);
|
||||
const thread = (extra: Record<string, unknown> = {}) => ({
|
||||
id: "t1",
|
||||
title: "fix the build",
|
||||
projectId: "p1",
|
||||
status: "running",
|
||||
activeRunId: "run-1",
|
||||
latestRunId: "run-1",
|
||||
latestRunRequestedAt: at(100),
|
||||
latestRunStartedAt: at(110),
|
||||
latestRunCompletedAt: null,
|
||||
pendingRuntimeRequest: null,
|
||||
latestUserMessageAt: null,
|
||||
lineage: { relationshipToParent: null, parentThreadId: null },
|
||||
modelSelection: { instanceId: "codex", model: "gpt" },
|
||||
archivedAt: null,
|
||||
deletedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
pinnedAt: null,
|
||||
lastVisitedAt: at(50),
|
||||
hasActionableProposedPlan: false,
|
||||
interactionMode: "default",
|
||||
createdAt: at(0),
|
||||
updatedAt: at(120),
|
||||
...extra,
|
||||
});
|
||||
const snapshot = (threads: unknown[]) => ({ projects: [], threads }) as unknown as OrchestrationV2ShellSnapshot;
|
||||
const approval = { pendingRuntimeRequest: { id: "q", kind: "command", createdAt: at(130) }, updatedAt: at(130) };
|
||||
|
||||
describe("alerts", () => {
|
||||
test("say nothing about state that was there on connect, then alert once per new attention", () => {
|
||||
const seen: Alert[] = [];
|
||||
const alerts = createAlerts((alert) => seen.push(alert));
|
||||
alerts.observe(snapshot([thread(approval)]));
|
||||
expect(seen).toEqual([]);
|
||||
|
||||
alerts.clear();
|
||||
alerts.observe(snapshot([thread()]));
|
||||
alerts.observe(snapshot([thread(approval)]));
|
||||
alerts.observe(snapshot([thread({ ...approval, updatedAt: at(140) })]));
|
||||
expect(seen.map((alert) => [alert.title, alert.thread.title])).toEqual([["Approval needed", "fix the build"]]);
|
||||
});
|
||||
|
||||
test("leave subagents to their parent", () => {
|
||||
const seen: Alert[] = [];
|
||||
const alerts = createAlerts((alert) => seen.push(alert));
|
||||
const child = { id: "c1", lineage: { relationshipToParent: "subagent", parentThreadId: "t1" } };
|
||||
alerts.observe(snapshot([thread(child)]));
|
||||
alerts.observe(snapshot([thread({ ...child, ...approval })]));
|
||||
expect(seen).toEqual([]);
|
||||
});
|
||||
});
|
||||
+32
-1
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { OrchestrationV2Command, ThreadId, RuntimeRequestId } from "@t3tools/contracts";
|
||||
import { OrchestrationV2Command, OrchestrationV2ThreadLaunchInput, ProjectId, ProviderInstanceId, ThreadId, RuntimeRequestId } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schema from "effect/Schema";
|
||||
|
||||
import { T3Session } from "../src/client/session.ts";
|
||||
@@ -63,4 +64,34 @@ describe("commands tui3 dispatches", () => {
|
||||
expect(isCommand(sent[0])).toBe(true);
|
||||
expect(sent[0]).toMatchObject({ type: "thread.stop", threadId });
|
||||
});
|
||||
|
||||
test("a model change rides on the next message, and a mode change is its own command", async () => {
|
||||
const { session, sent } = capturingSession();
|
||||
const modelSelection = { instanceId: ProviderInstanceId.make("claude"), model: "claude-opus-5-5", options: [{ id: "effort", value: "high" }] };
|
||||
await session.sendMessage(threadId, "carry on", "auto", modelSelection);
|
||||
await session.setRuntimeMode(threadId, "approval-required");
|
||||
expect(sent.every(isCommand)).toBe(true);
|
||||
expect(sent[0]).toMatchObject({ type: "message.dispatch", modelSelection });
|
||||
expect(sent[1]).toMatchObject({ type: "thread.runtime-mode.set", runtimeMode: "approval-required" });
|
||||
});
|
||||
|
||||
test("a new thread launches with a payload the server accepts", async () => {
|
||||
const session = new T3Session();
|
||||
let payload: unknown;
|
||||
const rpc = { "orchestration.launchThread": (input: unknown) => ((payload = input), Effect.succeed({ threadId: ThreadId.make("new-1") })) };
|
||||
(session as unknown as { connection: unknown }).connection = { rpc };
|
||||
const id = await session.launchThread({
|
||||
projectId: ProjectId.make("p1"),
|
||||
title: "Fix the flaky test",
|
||||
generateTitle: true,
|
||||
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
workspaceStrategy: { type: "worktree", baseRef: "main", startFromOrigin: true },
|
||||
text: "Fix the flaky test",
|
||||
});
|
||||
expect(id as string).toBe("new-1");
|
||||
expect(Schema.is(OrchestrationV2ThreadLaunchInput)(payload)).toBe(true);
|
||||
expect(payload).toMatchObject({ initialMessage: { text: "Fix the flaky test", attachments: [] } });
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -28,7 +28,7 @@ describe("config", () => {
|
||||
|
||||
test("labels settings for the settings view", () => {
|
||||
const rows = settingRows({ ...DEFAULT_CONFIG, followUpBehavior: "queue" });
|
||||
expect(rows.map((row) => row.key)).toEqual(["followUpBehavior", "sendShortcut", "timestampFormat", "diffIgnoreWhitespace"]);
|
||||
expect(rows.map((row) => row.key)).toEqual(["followUpBehavior", "sendShortcut", "timestampFormat", "diffIgnoreWhitespace", "notificationMode", "inAppNotificationsEnabled"]);
|
||||
expect(rows[0]?.value).toBe("queues");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import type { ModelSelection, ProviderInstanceId, ServerConfig } from "@t3tools/contracts";
|
||||
|
||||
import { modelSummary, optionValue, selectableProviders, withModel, withOption } from "../src/model/models.ts";
|
||||
|
||||
const effort = { id: "effort", label: "Thinking", type: "select", options: [{ id: "low", label: "Low" }, { id: "high", label: "High", isDefault: true }] } as const;
|
||||
const fast = { id: "fast", label: "Fast", type: "boolean" } as const;
|
||||
const config = {
|
||||
providers: [
|
||||
{
|
||||
instanceId: "claude",
|
||||
driver: "claude",
|
||||
enabled: true,
|
||||
models: [
|
||||
{ slug: "opus", name: "Claude Opus", isCustom: false, isDefault: true, capabilities: { optionDescriptors: [effort, fast] } },
|
||||
{ slug: "haiku", name: "Claude Haiku", isCustom: false, capabilities: { optionDescriptors: [fast] } },
|
||||
],
|
||||
},
|
||||
{ instanceId: "gone", driver: "codex", enabled: true, availability: "unavailable", models: [] },
|
||||
{ instanceId: "off", driver: "codex", enabled: false, models: [] },
|
||||
],
|
||||
} as unknown as ServerConfig;
|
||||
const opus: ModelSelection = { instanceId: "claude" as ProviderInstanceId, model: "opus" };
|
||||
|
||||
describe("models", () => {
|
||||
test("lists only enabled, available providers", () => {
|
||||
expect(selectableProviders(config).map((provider) => provider.instanceId as string)).toEqual(["claude"]);
|
||||
});
|
||||
|
||||
test("summarises the model with its options, using defaults until chosen", () => {
|
||||
expect(modelSummary(config, opus)).toBe("Claude Opus · High");
|
||||
expect(modelSummary(config, withOption(withOption(opus, "effort", "low"), "fast", true))).toBe("Claude Opus · Low · Fast");
|
||||
expect(optionValue(opus, effort)).toBe("high");
|
||||
});
|
||||
|
||||
test("switching model keeps only the options the new model has", () => {
|
||||
const tuned = withOption(withOption(opus, "effort", "low"), "fast", true);
|
||||
expect(withModel(config, tuned, "claude" as ProviderInstanceId, "haiku")).toEqual({ instanceId: "claude" as ProviderInstanceId, model: "haiku", options: [{ id: "fast", value: true }] });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user