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:
Callum Alpass committed 2026-11-02 18:55:47 +11:00
1 parent 121bbd9137
commit 626d37a4e9
18 files changed
+1074 -49

No files matched your search

+40
View File
@@ -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 }] });
});
});