CODY-016, 017, 018: launch source cannot be missed; a failed idle exit is retried
CODY-016. The SDK pushes the launch source once, early. The Even adapter now subscribes in its constructor, remembers the value and replays it to a listener that subscribes later. appMenu still does not arm idle exit. CODY-018. exitNow() returns whether the host confirmed. The adapter keeps at most one shutdown call in flight (through the same queue as every other host call), lets a repeat request wait on that call, and never calls the host again after a confirmed exit, including one confirmed late. The controller marks itself as gone only on confirmation or on a system_exit/abnormal_exit event; otherwise it retries after 3 s, at most 4 attempts in a row, under the same resting-screen and phone-grace guards, and starts again after activity. CODY-017. README: one owner-reported locked-phone success; pocketed, five-minute and ten-cycle runs unverified. Tests: production-adapter tests with a stand-in host, including the default 30 s under a fake clock; a simulator scenario that performs the real exit (development-only ?idleExit=fast). Not reviewed. 0.1.1 is not uploaded. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -126,6 +126,7 @@ describe('CODY-002: host calls stay serialised and a late microphone start ends
|
||||
shutDownPageContainer: (...a: unknown[]) => call('exit', a),
|
||||
getLocalStorage: (...a: unknown[]) => call('get', a),
|
||||
setLocalStorage: (...a: unknown[]) => call('set', a),
|
||||
onLaunchSource: () => () => undefined,
|
||||
};
|
||||
return { bridge, calls, micOpen: () => micOpen, maxInFlight: () => maxInFlight, pending: () => calls.filter((c) => !c.settled) };
|
||||
}
|
||||
@@ -165,6 +166,33 @@ describe('CODY-002: host calls stay serialised and a late microphone start ends
|
||||
expect(host.pending()).toEqual([]);
|
||||
});
|
||||
|
||||
it('an idle exit waits its turn behind a host call that is still in flight, and is asked only once', async () => {
|
||||
const host = fakeHost();
|
||||
const device = new EvenDevice(host.bridge as never);
|
||||
|
||||
const writing = device.storageSet('k', 'v');
|
||||
await tick();
|
||||
const leaving = device.exitNow();
|
||||
const leavingAgain = device.exitNow();
|
||||
await tick();
|
||||
// The write has not settled: the exit has not been sent.
|
||||
expect(host.calls.map((c) => c.name)).toEqual(['set']);
|
||||
|
||||
host.pending()[0]!.resolve(true);
|
||||
await tick();
|
||||
expect(await writing).toBe(true);
|
||||
expect(host.calls.map((c) => c.name)).toEqual(['set', 'exit']);
|
||||
expect(host.calls[1]!.args).toEqual([0]); // immediate mode, no dialog
|
||||
host.pending()[0]!.resolve(true);
|
||||
await tick();
|
||||
expect(await leaving).toBe(true);
|
||||
expect(await leavingAgain).toBe(true);
|
||||
// Confirmed: nothing further is ever sent for an exit.
|
||||
expect(await device.exitNow()).toBe(true);
|
||||
expect(host.calls.map((c) => c.name)).toEqual(['set', 'exit']);
|
||||
expect(host.maxInFlight()).toBe(1);
|
||||
});
|
||||
|
||||
it('a stop requested while the start is still pending waits its turn and still leaves the microphone closed', async () => {
|
||||
const host = fakeHost();
|
||||
const device = new EvenDevice(host.bridge as never);
|
||||
|
||||
Reference in New Issue
Block a user