The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
Desktop: Start again opens the sign-in window again (#130)
WEBGRS315d15ae6b63
diff --git a/.changeset/sign-in-start-again.md b/.changeset/sign-in-start-again.mdnew file mode 100644index 0000000..4513732--- /dev/null+++ b/.changeset/sign-in-start-again.md@@ -0,0 +1,5 @@+---+"@openfilm/desktop": patch+---++Desktop: Start again, under an agent waiting for its sign-in, opens the sign-in window again; before, closing that window early left the agent waiting for 15 minutes.diff --git a/apps/desktop/src/agent-roster.mjs b/apps/desktop/src/agent-roster.mjsindex 1b145f8..51018a6 100644--- a/apps/desktop/src/agent-roster.mjs+++ b/apps/desktop/src/agent-roster.mjs@@ -279,17 +279,22 @@ export function createRoster(deps) {changed();}- /** Looked at again every few seconds until `done` says so, or for as long as a sign-in is waited for. */+ /**+ * Looked at again every few seconds until `done` says so, or for as long as a sign-in is waited for. A wait started+ * again for the same agent (Start again) takes over: the one before stops, and leaves the new one's state alone.+ */async function waitFor(id, kind, done) {- live[kind][id] = true;+ const mine = Symbol(kind);+ live[kind][id] = mine;changed();const wait = deps.signInWait ?? SIGN_IN_WAIT;const until = Date.now() + wait.ms;- while (Date.now() < until && live[kind][id]) {+ while (Date.now() < until && live[kind][id] === mine) {await new Promise((resolve) => setTimeout(resolve, wait.pollMs));await lookAgain(id);if (done(local?.find((a) => a.id === id))) break;}+ if (live[kind][id] !== mine) return;delete live[kind][id];changed();}@@ -309,7 +314,8 @@ export function createRoster(deps) {if (isOwn(id)) {deps.closeSessions(id);const [now] = (await refresh()).filter((a) => a.id === id);- if (now?.status !== 'sign-in') return { ok: true };+ /* signed out; or signing in already, its window closed before it was done (Start again): opened again */+ if (now?.status !== 'sign-in' && now?.status !== 'waiting') return { ok: true };const opened = await deps.openSignIn(id);if (!opened.ok) { live.errors[id] = opened.error ?? 'Terminal did not open.'; changed(); return { ok: false, error: live.errors[id] }; }void waitForSignIn(id);diff --git a/apps/desktop/src/agent-roster.test.mjs b/apps/desktop/src/agent-roster.test.mjsindex 73866e9..14b4d91 100644--- a/apps/desktop/src/agent-roster.test.mjs+++ b/apps/desktop/src/agent-roster.test.mjs@@ -275,6 +275,39 @@ test('a sign-in in Terminal is waited for asking only that agent, until it is siassert.equal(late.list().find((a) => a.id === 'cursor').status, 'sign-in');});+test('Start again while a sign-in is waited for opens its sign-in again, and the wait starts over', async () => {+ const dir = mkdtempSync(join(tmpdir(), 'of-roster-'));+ const cursor = (signedIn) => ({ id: 'cursor', cli: { path: '/bin/cursor-agent' }, signedIn, install: null, setupRequired: null });+ const opened = [];+ let signedIn = false;+ const r = roster(dir, undefined, {+ localAgents: async () => [cursor(signedIn)], localAgent: async () => cursor(signedIn),+ openSignIn: async (id) => { opened.push(id); return { ok: true }; },+ signInWait: { ms: 300, pollMs: 10 },+ });+ const status = () => r.list().find((a) => a.id === 'cursor').status;+ const after = (ms) => new Promise((done) => setTimeout(done, ms));+ await r.connect('cursor');+ await after(150);+ assert.equal(status(), 'waiting');++ /* its window was closed before the sign-in was done: Start again (connect) opens it again */+ assert.deepEqual(await r.connect('cursor'), { ok: true });+ assert.deepEqual(opened, ['cursor', 'cursor']);+ await after(230);+ assert.equal(status(), 'waiting', 'the first wait is over, the second is not');+ await after(220);+ assert.equal(status(), 'sign-in', 'the second wait is over too');++ /* and a sign-in finished after Start again is seen */+ await r.connect('cursor');+ await after(30);+ await r.connect('cursor');+ signedIn = true;+ await after(60);+ assert.equal(status(), 'ready');+});+test("an agent found only as its maker's app: the app said, and its installer run in a terminal and waited for until it is there", async () => {const dir = mkdtempSync(join(tmpdir(), 'of-roster-'));const missing = { id: 'cursor', cli: null, signedIn: null, install: 'https://cursor.com/cli', setupRequired: null, app: 'Cursor', installer: 'curl https://cursor.com/install -fsS | bash' };