Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(context): map opus/sonnet/fable to 1M window (bare model id can't reveal active 1M)
enes923e3670579b
diff --git a/src/main/model-window.ts b/src/main/model-window.tsindex ebcac2546..4be2bcf2e 100644--- a/src/main/model-window.ts+++ b/src/main/model-window.ts@@ -1,21 +1,28 @@-// Resolves a Claude model id → its EFFECTIVE context window (max input tokens).+// Resolves a Claude model id → its context window (max input tokens).//-// Claude Code's effective window is 200k by default and 1M only for extended-context-// ("[1m]") models — the same default ccstatusline and Claude Code's own status line use.-// The Anthropic Models API's max_input_tokens reports the model's *capability* (1M for-// opus/sonnet), not the session's *effective* window, so it is intentionally NOT consulted-// here — using it understated fill ~5x. Resolution is fully synchronous (no network).+// Empirically (verified via `/context` on this machine) Claude Code runs opus/sonnet/fable+// sessions in a 1M window — the model id in the transcript stays bare ("claude-opus-4-8")+// even when 1M is active, so the window can NOT be detected from the id alone. We therefore+// map the model FAMILY to its window: opus/sonnet/fable/mythos → 1M, haiku → 200k, unknown+// → 200k. (Accounts with 1M access see the right denominator; the Models API is not consulted+// — it returns capability, and the call added latency for no gain.) Fully synchronous.const DEFAULT_WINDOW = 200_000const LARGE_WINDOW = 1_000_000-// Matches a "1m" extended-context marker as a standalone token anywhere in the id, e.g.-// "[1m]", "-1m", " 1m ", or a trailing "1m". Plain ids like "claude-opus-4-8" do not match.-const ONE_M = /(^|[^a-z0-9])1m([^a-z0-9]|$)/i+// Model family → window. First match wins; an explicit "1m" marker also forces the large+// window. Plain ids like "claude-opus-4-8" resolve to 1M via the opus/sonnet/fable rule.+const STATIC: Array<[RegExp, number]> = [+ [/haiku/i, DEFAULT_WINDOW],+ [/opus|sonnet|fable|mythos|(^|[^a-z0-9])1m([^a-z0-9]|$)/i, LARGE_WINDOW]+]-/** Effective context window for a model id: 1M only for [1m] models, else 200k. */+/** Context window for a model id: 1M for opus/sonnet/fable/[1m], 200k for haiku/unknown. */export function staticWindowFor(model: string | null): number {- return model && ONE_M.test(model) ? LARGE_WINDOW : DEFAULT_WINDOW+ if (model) {+ for (const [re, win] of STATIC) if (re.test(model)) return win+ }+ return DEFAULT_WINDOW}/** Synchronous best guess for the model's window (no cache/network needed). */@@ -24,7 +31,7 @@ export function cachedWindowFor(model: string | null): number {}/**- * Kept only for call-site compatibility with context-tail.ts. Window resolution is now fully+ * Kept only for call-site compatibility with context-tail.ts. Window resolution is fully* synchronous via cachedWindowFor/staticWindowFor, so there is nothing to resolve — no-op.*/export async function resolveModelWindow(_model: string | null): Promise<void> {