The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Desktop: a Copilot reply names its model at the bottom (#203)
WEBGRS108dc6a8c57d
diff --git a/.changeset/copilot-footer-model.md b/.changeset/copilot-footer-model.mdnew file mode 100644index 0000000..d8b466a--- /dev/null+++ b/.changeset/copilot-footer-model.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++A GitHub Copilot reply names its model at the bottom, as the other agents' do. When Copilot's session lists no models (on some accounts it offers only its mode and Allow All), the model is the one Copilot's own record says answered the turn, such as "GPT-6 Luna", where before only the time showed.diff --git a/apps/desktop/chat/src/App.tsx b/apps/desktop/chat/src/App.tsxindex 984ccef..98dc9bb 100644--- a/apps/desktop/chat/src/App.tsx+++ b/apps/desktop/chat/src/App.tsx@@ -195,6 +195,8 @@ function ChatPane({ project, banners, selection, assetsOpen }: { project: Projecfunction settleLocalTurn(meta: LocalAgentTurnMeta, turn: LocalAgentTurn, patch: Partial<Turn & TurnBalance>): Turn {const id = meta.turnId;finishRunningLocalTurn(id);+ /* the model that answered, for an agent whose session names none (GitHub Copilot's): its footer says it */+ if (turn.model) patch = { ...patch, localAgent: { id: meta.agent, model: turn.model } };const done: Turn = { ...(meta.turn as Turn), ...patch, updatedAt: new Date().toISOString() };primeStoredTranscript(id, turn.items);saveLocalAgentTurn(meta.projectId, done, turn.items);diff --git a/apps/desktop/chat/src/lib/desktop-bridge.ts b/apps/desktop/chat/src/lib/desktop-bridge.tsindex acb5d4d..f2db756 100644--- a/apps/desktop/chat/src/lib/desktop-bridge.ts+++ b/apps/desktop/chat/src/lib/desktop-bridge.ts@@ -205,7 +205,8 @@ export interface DesktopBridge {>;/** `images`: pictures sent after the text, to an agent that takes them (the shell asks the session) *//** `balance`: the service the app's own agent runs on had no balance left for it */- prompt(key: string, text: string, meta?: LocalAgentTurnMeta, images?: PromptImage[]): Promise<{ ok: true; stopReason: string } | { ok: false; error: string; balance?: Balance }>;+ /** `model`: the model that answered, for an agent whose session names none (GitHub Copilot's, from its record) */+ prompt(key: string, text: string, meta?: LocalAgentTurnMeta, images?: PromptImage[]): Promise<{ ok: true; stopReason: string; model?: string } | { ok: false; error: string; balance?: Balance }>;/** Turns still held by the shell (a reload mid-turn). Older shells lack it. */running?(): Promise<LocalAgentRunningTurn[]>;/** The page has put this finished turn back: the shell forgets it. */diff --git a/apps/desktop/chat/src/lib/local-agent-run.ts b/apps/desktop/chat/src/lib/local-agent-run.tsindex e6146e3..21b64d0 100644--- a/apps/desktop/chat/src/lib/local-agent-run.ts+++ b/apps/desktop/chat/src/lib/local-agent-run.ts@@ -313,6 +313,9 @@ export class LocalAgentTurn {/** When its last update arrived (see drain). */lastEventAt = Date.now();+ /** The model that answered, when its session names none (GitHub Copilot's, from its record): for the footer. */+ model: string | null = null;+apply(update: AcpUpdate): void {this.lastEventAt = Date.now();const kind = update.sessionUpdate;@@ -877,6 +880,7 @@ export async function runLocalAgentTurn({listening only once they have stopped coming, or the saved reply ends mid-sentence. */await drain(last());if (!r.ok) throw Object.assign(new Error(r.error), { lastTurnId: last().turnId }, r.balance ? { balance: r.balance } : {});+ turn.model = last().model = r.model ?? null;return { stopReason: r.stopReason, lastTurnId: last().turnId };} finally {const ended = last();diff --git a/apps/desktop/src/agent-records.mjs b/apps/desktop/src/agent-records.mjsindex 2d8c1e7..44fea22 100644--- a/apps/desktop/src/agent-records.mjs+++ b/apps/desktop/src/agent-records.mjs@@ -556,6 +556,21 @@ export function copilotCallsOf(entries, { from = 0, to = Infinity } = {}) {export const copilotCalls = (file, { from = 0, to = Infinity } = {}) => copilotCallsOf(lines(file), { from, to });+/**+ * The model that answered a Copilot turn, by the name Copilot gives it ("GPT-6 Luna"): its last usage record from+ * `from` (ms) on, or null. Copilot does not always name its model over ACP (1.0.98 to 1.0.103, on some accounts: its+ * session's options are its mode and Allow All, and its "auto" picks the model), so the turn's footer takes this one.+ */+export function copilotModelOf(entries, { from = 0 } = {}) {+ let model = null;+ for (const e of entries) {+ if (e?.type !== 'session.usage_record' || (ms(e.timestamp) ?? 0) < from) continue;+ const name = e.data?.usage?.modelDisplayName || e.data?.usage?.model;+ if (typeof name === 'string' && name) model = name;+ }+ return model;+}+/* ── all ─────────────────────────────────────────────────────────────────── *//**@@ -579,6 +594,12 @@ export function agentRecordCalls({ agent, sessionId, cwd, from, to, env = {}, horeturn { file, calls: calls.map((c) => ({ ...c, source: { agent, file } })) };}+/** The model a turn ran on (from `from`, ms) as the agent's own record names it, or null: only Copilot's is read. */+export function recordedModel({ agent, sessionId, from = 0, env = {}, home = homedir() }) {+ const file = agent === 'copilot' ? findCopilotRecord({ sessionId, env, home }) : null;+ return file ? copilotModelOf(lines(file), { from }) : null;+}+/*** Calls as the turn log keeps them: each line only what is new since the one before (`prefix`: how many of that* one's messages come first, then its own), its system prompt, tools, settings and source only when they changed.diff --git a/apps/desktop/src/agent-records.test.mjs b/apps/desktop/src/agent-records.test.mjsindex aca9556..f722631 100644--- a/apps/desktop/src/agent-records.test.mjs+++ b/apps/desktop/src/agent-records.test.mjs@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { agentRecordCalls, claudeCallsOf, claudeProjectName, codexCallsOf, compactCalls, copilotCallsOf, findClaudeRecord, findCodexRecord, findCopilotRecord, findKimiRecord, kimiCallsOf } from './agent-records.mjs';+import { agentRecordCalls, claudeCallsOf, claudeProjectName, codexCallsOf, compactCalls, copilotCallsOf, copilotModelOf, findClaudeRecord, findCodexRecord, findCopilotRecord, findKimiRecord, kimiCallsOf, recordedModel } from './agent-records.mjs';const at = (s) => new Date(Date.UTC(2026, 9, 15, 10, 0, s)).toISOString();const jsonl = (rows) => `${rows.map((r) => JSON.stringify(r)).join('\n')}\n`;@@ -225,6 +225,32 @@ test("Copilot's events: a request for each usage record, its answer by its API cassert.equal(agentRecordCalls({ agent: 'copilot', sessionId: 'cop-12345', home, from: Date.parse(at(7)), to: Date.parse(at(9)) }).calls.length, 1);});+test("the model that answered a Copilot turn, by the name Copilot gives it in its usage records", () => {+ /* GitHub Copilot 1.0.98 on Windows, its session naming no model over ACP: "auto" picks one, each request's usage+ record names it */+ const usage = (s, call, more = {}) => ({ type: 'session.usage_record', timestamp: at(s), data: { usage: {+ model: 'gpt-6-luna', provider: { id: 'copilot', kind: 'copilot', label: 'GitHub Copilot' }, modelDisplayName: 'GPT-6 Luna',+ inputTokens: 16912, outputTokens: 47, cacheReadTokens: 0, cacheWriteTokens: 16909, reasoningTokens: 26, duration: 2533, apiCallId: call, ...more } } });+ const rows = [+ { type: 'session.start', data: { sessionId: 'cop-67890' }, timestamp: at(0) },+ { type: 'session.model_change', data: { previousModel: null, newModel: 'auto', source: 'startup' }, timestamp: at(1) },+ { type: 'session.auto_mode_resolved', data: { chosenModel: 'gpt-6-luna', availableModels: ['gpt-6-luna'] }, timestamp: at(1) },+ { type: 'user.message', data: { content: 'Make a title' }, timestamp: at(2) },+ usage(5, 'a1'),+ { type: 'assistant.message', data: { content: 'Done.', apiCallId: 'a1', model: 'gpt-6-luna' }, timestamp: at(5) },+ ];+ assert.equal(copilotModelOf(rows), 'GPT-6 Luna');+ assert.equal(copilotModelOf(rows, { from: Date.parse(at(6)) }), null, 'no request in the turn: none');+ assert.equal(copilotModelOf([...rows, usage(9, 'a2', { model: 'gpt-x', modelDisplayName: undefined })]), 'gpt-x', 'the last one, by its id when it has no name');++ const home = mkdtempSync(join(tmpdir(), 'of-copilot-'));+ mkdirSync(join(home, '.copilot', 'session-state', 'cop-67890'), { recursive: true });+ writeFileSync(join(home, '.copilot', 'session-state', 'cop-67890', 'events.jsonl'), jsonl(rows));+ assert.equal(recordedModel({ agent: 'copilot', sessionId: 'cop-67890', home, from: Date.parse(at(2)) }), 'GPT-6 Luna');+ assert.equal(recordedModel({ agent: 'copilot', sessionId: 'cop-00000', home }), null);+ assert.equal(recordedModel({ agent: 'claude', sessionId: 'cop-67890', home }), null, 'only Copilot is read');+});+test('compactCalls keeps each request only as far as it is new, and reads back whole', () => {const calls = claudeCallsOf(claudeSession());const lines = compactCalls(calls);diff --git a/apps/desktop/src/local-agents-ipc.mjs b/apps/desktop/src/local-agents-ipc.mjsindex 801b94e..46d8de6 100644--- a/apps/desktop/src/local-agents-ipc.mjs+++ b/apps/desktop/src/local-agents-ipc.mjs@@ -14,7 +14,8 @@* desktop:local-agents:prompt { key, text, meta?, images? } → { ok, stopReason } | { ok: false, error }* images: [{ data (base64), mimeType }], the pictures of the message's references,* sent after the text to an agent that takes pictures (the text names their files- * either way)+ * either way); `model` beside the stopReason: the model that answered, for an+ * agent whose session names none (Copilot's, from its record)* desktop:local-agents:steer { key, text, images? } → { ok, outcome } a message sent while a turn runs,* into that turn (ok: it joined it); the page sends it as a turn of its own if not* desktop:local-agents:adopt { key, turnId | null, meta? } what the agent does with nobody having written (a@@ -48,7 +49,7 @@ import { randomUUID } from 'node:crypto';import { join } from 'node:path';import { recordProblem, problemsFile } from 'openfilm/problems';import { LOG_SETTLE_MS } from './agent-logs.mjs';-import { RECORDED_AGENTS, agentRecordCalls, compactCalls } from './agent-records.mjs';+import { RECORDED_AGENTS, agentRecordCalls, compactCalls, recordedModel } from './agent-records.mjs';import { skillStore } from './agent-skills.mjs';import { AGENTS, AgentSession, HARNESS_AGENTS, isAgentId, isChatAgent, listAgents, openAgentSignIn, probeFolder } from './agents.mjs';import { loggedBlocks, logsDir, openLog, writeModelLog } from './chat-store.mjs';@@ -88,6 +89,21 @@ export async function keepAgentRecord({ agent, sessionId, cwd, turnId, from, to,}}+/**+ * The model that answered a Copilot turn from `from` (ms), as its own record names it, for a session that names none:+ * read once its last usage record has had time to reach the file, as keepAgentRecord waits. Null for any other agent+ * (at once, without waiting), or when none is found.+ */+export async function turnModel({ agent, sessionId, from, env = null, settleMs = RECORD_SETTLE_MS }) {+ if (agent !== 'copilot' || !sessionId) return null;+ try {+ await new Promise((done) => setTimeout(done, settleMs));+ return recordedModel({ agent, sessionId, from, env: env ?? await loginShellVariables({ staleOk: true }) });+ } catch {+ return null;+ }+}+/** The page's pictures as ACP image blocks; anything not one is left out. */function imageBlocks(images) {if (!Array.isArray(images)) return [];@@ -332,6 +348,12 @@ export function registerLocalAgentIpc(ipcMain, { trusted, binDir = null, fallbacentry.running -= 1;onWorking(working());}+ /* GitHub Copilot, its session naming no model (on some accounts): the one that answered, as its own record says,+ for the turn's footer */+ if (result.ok && entry.agent === 'copilot' && !entry.info?.configOptions?.some((o) => o?.category === 'model')) {+ const model = await turnModel({ agent: entry.agent, sessionId: entry.info?.sessionId, from });+ if (model) result = { ...result, model };+ }entry.lastUsed = Date.now();if (turn) {/* a turn that failed: the error as the agent sent it, the step it stopped at, its program and what its processdiff --git a/apps/desktop/src/local-agents-ipc.test.mjs b/apps/desktop/src/local-agents-ipc.test.mjsindex 48aed28..cb3368e 100644--- a/apps/desktop/src/local-agents-ipc.test.mjs+++ b/apps/desktop/src/local-agents-ipc.test.mjs@@ -1,10 +1,10 @@import { test } from 'node:test';import assert from 'node:assert/strict';-import { mkdtempSync } from 'node:fs';+import { appendFileSync, mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { readLog } from './chat-store.mjs';-import { agentProblem, registerLocalAgentIpc, sentError } from './local-agents-ipc.mjs';+import { agentProblem, registerLocalAgentIpc, sentError, turnModel } from './local-agents-ipc.mjs';test("a start that fails is written in the log of the turn it was for, with why", async () => {const handlers = new Map();@@ -45,3 +45,23 @@ test('the error as the agent sent it, under any rewording on the way; none whenassert.deepEqual(sentError(reworded), { code: -32603, message: 'Internal error', data: { details: 'stream closed' } });assert.equal(sentError(new Error('not installed')), null);});++test("a Copilot turn's model, read once its usage record has reached the file; another agent's turn doesn't wait", async () => {+ const home = mkdtempSync(join(tmpdir(), 'openfilm-copilot-'));+ mkdirSync(join(home, 'session-state', 'cop-24680'), { recursive: true });+ const file = join(home, 'session-state', 'cop-24680', 'events.jsonl');+ const from = Date.now();+ const at = (ms) => new Date(from + ms).toISOString();+ writeFileSync(file, `${JSON.stringify({ type: 'user.message', data: { content: 'Make a title' }, timestamp: at(0) })}+`);+ /* a one-request turn: Copilot writes the request's usage record a moment after the prompt has answered */+ const usage = { type: 'session.usage_record', timestamp: at(50), data: { usage: { model: 'gpt-6-luna', modelDisplayName: 'GPT-6 Luna', apiCallId: 'a1' } } };+ setTimeout(() => appendFileSync(file, `${JSON.stringify(usage)}+`), 200);+ const env = { COPILOT_HOME: home };+ assert.equal(await turnModel({ agent: 'copilot', sessionId: 'cop-24680', from, env }), 'GPT-6 Luna');++ const started = Date.now();+ assert.equal(await turnModel({ agent: 'claude', sessionId: 'cop-24680', from, env }), null);+ assert.ok(Date.now() - started < 100, 'not waited for');+});