Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Desktop: the app's own agent starts (pin pi-codemode to 1.1.0) (#55)

UpXuu604fc14e10aa
diff --git a/.changeset/pin-pi-codemode.md b/.changeset/pin-pi-codemode.md
new file mode 100644
index 0000000..38bf65f
--- /dev/null
+++ b/.changeset/pin-pi-codemode.md
@@ -0,0 +1,5 @@
+---
+"@openfilm/desktop": patch
+---
+
+The app's own agent starts again: the packaged app had `@earendil-works/pi-coding-agent` 1.1.0 beside `pi-codemode` 1.2.0, which no longer exports `MCP_TYPESCRIPT_PREAMBLE`, so the agent crashed on start and every "Own key" message ended with "ACP connection closed". `pi-codemode` is now a direct dependency at 1.1.0.
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 6b81301..423ecce 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -18,6 +18,7 @@
"@agentclientprotocol/claude-agent-acp": "^0.81.2",
"@agentclientprotocol/codex-acp": "^1.13.1",
"@agentclientprotocol/sdk": "1.5.0",
+ "@earendil-works/pi-codemode": "1.1.0",
"@earendil-works/pi-coding-agent": "1.1.0",
"diff": "9.0.0",
"electron-updater": "6.8.9",
diff --git a/apps/desktop/src/chat-store.test.mjs b/apps/desktop/src/chat-store.test.mjs
index 856108f..00722a6 100644
--- a/apps/desktop/src/chat-store.test.mjs
+++ b/apps/desktop/src/chat-store.test.mjs
@@ -7,6 +7,16 @@ import { chatDir, loadChat, logsDir, openLog, readLog, refsDir, saveRefImage, sa
const project = () => mkdtempSync(join(tmpdir(), 'of-chat-'));
const turn = (id, createdAt) => ({ turn: { id, createdAt, sessionId: 's1', prompt: id }, items: [{ kind: 'text', text: id }] });
+/** a turn's log is written through a stream: wait until what a reader needs is on disk (a slow runner needs more than a fixed pause) */
+async function until(fn, ok) {
+ for (let i = 0; i < 500; i += 1) {
+ const value = fn();
+ if (ok(value)) return value;
+ await new Promise((done) => setTimeout(done, 10));
+ }
+ return fn();
+}
+const logOnDisk = (dir, id, lines = 1) => until(() => readLog(dir, id), (read) => Boolean(read && read.events.length >= lines));
test('a project with no chat yet has none; what is saved comes back, the turns in the order they were asked', () => {
const dir = project();
@@ -29,7 +39,7 @@ test('a turn is written to its log as it happens and read back, a broken last li
log.write('update', { update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'hi' } } });
log.write('done', { ok: true, stopReason: 'end_turn' });
log.end();
- await new Promise((done) => setTimeout(done, 50));
+ await logOnDisk(dir, 't1', 3);
appendFileSync(join(logsDir(dir), 't1.jsonl'), '{"t":1,"kind":"upd');
const read = readLog(dir, 't1');
assert.deepEqual(read.events.map((e) => e.kind), ['prompt', 'update', 'done']);
@@ -43,9 +53,9 @@ test('a local turn\'s id (local:…) names a file any system allows', async () =
const log = openLog(dir, 'local:abc123');
log.write('prompt', {});
log.end();
- await new Promise((done) => setTimeout(done, 50));
+ const read = await logOnDisk(dir, 'local:abc123');
assert.deepEqual(loadChat(dir).turns.map((t) => t.turn.id), ['local:abc123']);
- assert.ok(readLog(dir, 'local:abc123').file.endsWith('local-abc123.jsonl'));
+ assert.ok(read.file.endsWith('local-abc123.jsonl'));
});
test('ids that are not ids name no file', () => {
@@ -70,13 +80,11 @@ test('a turn\'s model requests are kept beside its log and read back with it', a
const log = openLog(dir, 'local:m1', () => {}, '.model');
log.write('call', { startedAt: 1, ms: 2, prefix: 0, messages: [{ role: 'user', content: 'hi' }], params: { model: 'm' }, response: null, error: null });
log.end();
- await new Promise((done) => setTimeout(done, 50));
assert.equal(readLog(dir, 'local:m1'), null, 'no log of its own, nothing to show');
const events = openLog(dir, 'local:m1');
events.write('prompt', { text: 'hi' });
events.end();
- await new Promise((done) => setTimeout(done, 50));
- const read = readLog(dir, 'local:m1');
+ const read = await until(() => readLog(dir, 'local:m1'), (r) => Boolean(r && r.events.length >= 1 && r.calls.length >= 1));
assert.deepEqual(read.calls.map((c) => c.messages[0].content), ['hi']);
assert.ok(read.file.endsWith('local-m1.jsonl'));
});
@@ -99,12 +107,11 @@ test('a log not grown since the sizes a reader has is not read again', async ()
const dir = project();
const log = openLog(dir, 't2');
log.write('prompt', { text: 'hello' });
- await new Promise((done) => setTimeout(done, 50));
- const first = readLog(dir, 't2');
+ const first = await logOnDisk(dir, 't2', 1);
assert.deepEqual(readLog(dir, 't2', { unless: { size: first.size, callsSize: first.callsSize } }), { same: true });
log.write('done', { ok: true });
log.end();
- await new Promise((done) => setTimeout(done, 50));
+ await logOnDisk(dir, 't2', 2);
assert.deepEqual(readLog(dir, 't2', { unless: { size: first.size, callsSize: first.callsSize } }).events.map((e) => e.kind), ['prompt', 'done']);
});
@@ -116,7 +123,7 @@ test('a turn with a log and no saved record is found with its events; a saved on
write('local:busy1', { turnId: 'local:busy1', sessionId: 's1' });
write('local:bare1', null);
saveTurn(dir, turn('local:kept1', '2026-10-12T00:00:00Z'));
- await new Promise((done) => setTimeout(done, 50));
+ await Promise.all(['local:lost1', 'local:kept1', 'local:busy1', 'local:bare1'].map((id) => logOnDisk(dir, id, 2)));
const found = unsavedTurns(dir, { except: ['local:busy1'] });
assert.deepEqual(found.map((f) => f.turnId), ['local:lost1']);
assert.deepEqual(found[0].events.map((e) => e.kind), ['prompt', 'update']);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9afa8bf..bc49810 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -26,6 +26,9 @@ importers:
'@agentclientprotocol/sdk':
specifier: 1.5.0
version: 1.5.0([email protected])
+ '@earendil-works/pi-codemode':
+ specifier: 1.1.0
+ version: 1.1.0
'@earendil-works/pi-coding-agent':
specifier: 1.1.0