Leave the glasses when idle; new conversation after a long silence (0.1.1)
On a real G2 the app, while open, occupied the display indefinitely and a phone notification did not reach the lenses. The app now leaves the glasses by itself (shutDownPageContainer(0), no dialog) after a resting screen has been untouched: 20 s on an answer, 30 s at Ready, 10 s on an error or "Cancelled". Any gesture restarts the countdown. It never leaves while recording, transcribing, waiting for the agent or for an approval. It is armed only once the glasses are in use (a gesture arrived, or the session was opened from the glasses, which includes voice launch), and touching the phone page holds it open for two minutes, so setting up on the phone is not interrupted. Because the app now closes between questions, a question more than ten minutes after the last one starts a new conversation; sooner continues it. Diagnostics shows how the session was opened. Version 0.1.1. Tests: 233 unit/integration; simulator 7. Not reviewed, not deployed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -34,8 +34,12 @@ async function until(what: string, predicate: () => boolean, timeoutMs = 4000):
|
||||
}
|
||||
const phase = () => snapshot.state.phase;
|
||||
|
||||
let controllerExtras: Partial<ConstructorParameters<typeof Controller>[0]> = {};
|
||||
function makeController(dev: FakeDevice): Controller {
|
||||
return new Controller({
|
||||
// Off unless a test turns it on: most tests sit on a screen longer than a short timeout.
|
||||
idleExit: null,
|
||||
...controllerExtras,
|
||||
device: dev,
|
||||
measure: (text, width) => measureTextWrap(text, width).lineCount,
|
||||
locale: 'en-US',
|
||||
@@ -82,6 +86,7 @@ async function pairedController(): Promise<void> {
|
||||
|
||||
beforeEach(async () => {
|
||||
network = { down: false, dropReplies: false, hook: null, sent: [] };
|
||||
controllerExtras = {};
|
||||
h = await createHarness({ env: { HERMEVEN_CAPTURE_MAX_SECONDS: '2' } });
|
||||
});
|
||||
afterEach(async () => {
|
||||
@@ -681,3 +686,157 @@ describe('long press (a real G2 reported a slow tap as a long press)', () => {
|
||||
expect(snapshot.state.conversationId).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
const quiet = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
describe('leaving the glasses when idle (the app blocks notifications while it is open)', () => {
|
||||
const FAST = { answer: 150, ready: 250, message: 100 };
|
||||
|
||||
it('after an answer sits untouched, Pepper leaves the glasses once, without a confirmation dialog', async () => {
|
||||
controllerExtras = { idleExit: FAST };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
controller.askText('hello');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
expect(device.exits).toBe(0);
|
||||
await until('left the glasses', () => device.exits === 1, 1500);
|
||||
await quiet(400);
|
||||
expect(device.exits).toBe(1);
|
||||
expect(device.exitRequests).toBe(0); // not the "are you sure?" dialog
|
||||
expect(device.micOpen).toBe(false);
|
||||
expect(snapshot.log.some((e) => e.detail.includes('leaving the glasses: idle on answer'))).toBe(true);
|
||||
});
|
||||
|
||||
it('paging, or any gesture, restarts the countdown', async () => {
|
||||
controllerExtras = { idleExit: FAST };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
h.hermes.next({ kind: 'complete', output: Array.from({ length: 80 }, (_, i) => `Sentence ${i + 1} of a long answer.`).join(' ') });
|
||||
controller.askText('long one');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await quiet(90); // each gap is shorter than the 150 ms timeout
|
||||
device.swipeDown();
|
||||
}
|
||||
expect(device.exits).toBe(0); // 540 ms have passed, well over the timeout, but never idle
|
||||
await until('left once it was left alone', () => device.exits === 1, 1500);
|
||||
});
|
||||
|
||||
it('never leaves while recording, transcribing, thinking or waiting for an approval', async () => {
|
||||
controllerExtras = { idleExit: FAST };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
device.tap();
|
||||
await until('listening', () => phase() === 'listening' && device.micOpen);
|
||||
device.speak(0.2);
|
||||
await quiet(250); // (shorter than the 300 ms microphone-stall check in these tests)
|
||||
expect(device.exits).toBe(0);
|
||||
h.hermes.next({ kind: 'complete', afterMs: 500, output: 'slow answer' });
|
||||
device.tap();
|
||||
await until('thinking', () => phase() === 'thinking');
|
||||
await quiet(350);
|
||||
expect(phase()).toBe('thinking');
|
||||
expect(device.exits).toBe(0);
|
||||
await until('answer', () => phase() === 'answer');
|
||||
|
||||
h.hermes.next({ kind: 'approval' });
|
||||
controller.askText('needs approval');
|
||||
await until('approval', () => phase() === 'approval');
|
||||
await quiet(350);
|
||||
expect(device.exits).toBe(0);
|
||||
device.doubleTap();
|
||||
});
|
||||
|
||||
it('at Ready with nothing asked, and after an error or a cancel, it also leaves', async () => {
|
||||
controllerExtras = { idleExit: FAST };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
await until('left from Ready', () => device.exits === 1, 1500);
|
||||
|
||||
await controller.stop();
|
||||
const stored = device.storage;
|
||||
device = new FakeDevice();
|
||||
for (const [k, v] of stored) device.storage.set(k, v);
|
||||
controller = makeController(device);
|
||||
await controller.start();
|
||||
device.launchedFrom('glassesMenu');
|
||||
device.micAllowed = false;
|
||||
device.tap();
|
||||
await until('error', () => phase() === 'error');
|
||||
await until('left from the error screen', () => device.exits === 1, 1500);
|
||||
});
|
||||
|
||||
it('opened from the phone with no gesture yet, it stays: setting up on the phone is not interrupted', async () => {
|
||||
controllerExtras = { idleExit: FAST };
|
||||
await pairedController();
|
||||
device.launchedFrom('appMenu');
|
||||
controller.askText('typed on the phone');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
await quiet(500);
|
||||
expect(device.exits).toBe(0);
|
||||
// The first gesture on the glasses means they are in use: from then on it applies.
|
||||
device.swipeDown();
|
||||
await until('left after the glasses were used', () => device.exits === 1, 1500);
|
||||
});
|
||||
|
||||
it('touching the phone page holds it open for the grace period', async () => {
|
||||
controllerExtras = { idleExit: FAST, phoneGraceMs: 500 };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
controller.askText('hello');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
controller.notePhoneActivity();
|
||||
await quiet(450); // three timeouts' worth
|
||||
expect(device.exits).toBe(0);
|
||||
await until('left after the grace period', () => device.exits === 1, 2000);
|
||||
});
|
||||
|
||||
it('can be switched off entirely', async () => {
|
||||
controllerExtras = { idleExit: null };
|
||||
await pairedController();
|
||||
device.launchedFrom('glassesMenu');
|
||||
controller.askText('hello');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
await quiet(600);
|
||||
expect(device.exits).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('conversations now that Pepper leaves between questions', () => {
|
||||
it('a question soon after the last one continues the conversation across a relaunch', async () => {
|
||||
await pairedController();
|
||||
controller.askText('My dog is called Biscuit.');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
await until('saved', () => typeof JSON.parse(device.storage.get('hermeven.v1')!).lastTurnAt === 'number');
|
||||
await controller.stop();
|
||||
const reborn = new FakeDevice();
|
||||
for (const [k, v] of device.storage) reborn.storage.set(k, v);
|
||||
device = reborn;
|
||||
controller = makeController(device);
|
||||
await controller.start();
|
||||
controller.askText('What is my dog called?');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
expect(device.frame.body).toContain('turn=2');
|
||||
expect(h.hermes.sessions.size).toBe(1);
|
||||
});
|
||||
|
||||
it('a question after a long silence starts a new conversation', async () => {
|
||||
await pairedController();
|
||||
controller.askText('My dog is called Biscuit.');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
await until('saved', () => typeof JSON.parse(device.storage.get('hermeven.v1')!).lastTurnAt === 'number');
|
||||
await controller.stop();
|
||||
const reborn = new FakeDevice();
|
||||
for (const [k, v] of device.storage) reborn.storage.set(k, v);
|
||||
device = reborn;
|
||||
controllerExtras = { conversationGapMs: 50 };
|
||||
await quiet(120);
|
||||
controller = makeController(device);
|
||||
await controller.start();
|
||||
expect(snapshot.state.conversationId).toBeNull();
|
||||
controller.askText('What is my dog called?');
|
||||
await until('answer', () => phase() === 'answer');
|
||||
expect(device.frame.body).toContain('turn=1');
|
||||
expect(h.hermes.sessions.size).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user