fix: restore the display before silent-exit confirmation
Secret scan / gitleaks (pull_request) Canceled after 0s
Tests / test (pull_request) Canceled after 0s
Tests / test-kotlin (pull_request) Canceled after 0s
Tests / stats-server (pull_request) Canceled after 0s
Tests / evenhub-extensions (pull_request) Canceled after 0s

This commit is contained in:
Blendman974 committed 2026-11-06 22:23:26 +01:00
1 parent 02dba88131
commit 799bdc153f
3 files changed
+55 -19

No files matched your search

+21 -5
View File
@@ -296,6 +296,7 @@ class DashboardController {
private displayPreviewCrop: ScreenRect | null = null;
private silentMode = false;
private silentModeFeedback = "";
private silentModeFeedbackGeneration = 0;
private silentModeFeedbackTimer: ReturnType<typeof setTimeout> | null = null;
// Brightness value last pushed to the glasses; see pushBrightness.
private lastPushedBrightness: string | null = null;
@@ -1188,17 +1189,16 @@ class DashboardController {
private handleSilentMode(silent: boolean): void {
if (this.silentMode === silent) return;
this.silentMode = silent;
const generation = ++this.silentModeFeedbackGeneration;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = silent
? "Silent mode enabled — hold both touchpads to exit"
: "Silent mode disabled";
if (!silent) {
// Do not wake a sleeping/locked display merely to announce a state change.
if (this.phase === "connected" && shell.isScreenOn() && !this.glassesLocked) {
shell.showAlert("Silent mode disabled");
shell.foregroundWindow()?.requestRender();
}
void this.showSilentModeExit(generation).catch(error => {
this.appendLog(`silent-mode exit feedback failed: ${this.formatError(error)}`);
});
this.silentModeFeedbackTimer = setTimeout(() => {
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = "";
@@ -1208,6 +1208,21 @@ class DashboardController {
this.emit();
}
private async showSilentModeExit(generation: number): Promise<void> {
if (this.phase !== "connected" || this.silentMode || this.glassesLocked) return;
// The firmware powered the lenses down, and Faceclaw may have gone to
// sleep/suspended EvenHub meanwhile. Reusing the ordinary wake barrier is
// essential: rendering an alert into the retained surface alone is invisible.
this.cancelEvenHubSuspendTimer();
shell.wake("sidebar");
const ready = await this.ensureEvenHubSessionActive();
if (!ready || generation !== this.silentModeFeedbackGeneration || this.silentMode ||
this.phase !== "connected" || this.glassesLocked) return;
shell.showAlert("Silent mode disabled");
shell.foregroundWindow()?.requestRender();
this.requestShellRender();
}
private displayPreviewMessage(): string {
if (this.phase === "charging") {
return chargingPreviewMessage(this.glassesDisplayState());
@@ -3009,6 +3024,7 @@ class DashboardController {
// Kept across "connecting": silent mode blocks app launches, so it can
// itself cause the reconnect churn, and Java re-reports it either way.
this.silentMode = false;
this.silentModeFeedbackGeneration++;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = "";
+4 -2
View File
@@ -1,9 +1,11 @@
# Silent-mode feedback
The firmware blanks the lenses and stops ordinary input while silent mode is active. App code cannot display an activation popup on lenses that the firmware has switched off. The phone now shows a persistent enabled banner with the exit gesture, and a five-second disabled banner on exit. Awake, unlocked glasses also show the existing alert popup on exit; no display is woken solely for feedback. Duplicate state reports do not repeat feedback, stale timers are cancelled, and disconnect clears the notice.
The firmware blanks the lenses and stops ordinary input while silent mode is active. App code cannot display an activation popup on lenses that the firmware has switched off. The phone now shows a persistent enabled banner with the exit gesture, and a five-second disabled banner on exit. On exit, unlocked glasses wake through the normal screen/EvenHub barrier before the alert popup is rendered. This also handles the shell falling asleep during a long silent period. Locked glasses keep the phone feedback without being woken. A generation check suppresses stale notices after re-entry or disconnect. Duplicate state reports do not repeat feedback, stale timers are cancelled, and disconnect clears the notice.
Silent-off firmware pushes are not reliable. The existing fallback read used the five-minute battery cadence. While silent mode is known to be on, settings are now polled every two seconds when the session is ready and the message queues are idle. Normal battery cadence and shutdown guards are retained. This bounds ordinary missing-push recovery without assuming a touch gesture always means silent mode ended.
Independent JavaScript suite: 1065 passed, 2 skipped. TypeScript and changed-source lint passed. Controller tests cover enabled/disabled notices, duplicates, timer cancellation, disconnect and sleeping/locked displays. A Kotlin session test checks the two-second silent cadence, normal cadence and shutdown guard. Kotlin compilation and hardware checks are tracked with the combined integration validation.
Independent JavaScript suite: 1065 passed, 2 skipped. TypeScript and changed-source lint passed. Controller tests cover enabled/disabled notices, duplicates, timer cancellation, disconnect and sleeping-display recovery, locked displays, wake-barrier failure and stale async completion. A Kotlin session test checks the two-second silent cadence, normal cadence and shutdown guard. Kotlin compilation and hardware checks are tracked with the combined integration validation.
Hardware validation remains pending: both transitions via the temple gesture, missing exit push, phone background/foreground, lenses that are awake/asleep/locked, reconnect and charging. No firmware was flashed.
Follow-up after device-log inspection: both silent transitions arrived, but the exit could occur after the normal idle timeout. Exit now cancels pending suspension, wakes the shell, awaits the existing EvenHub/screen wake barrier and only then shows the notice. It resets idle activity through the ordinary wake path. Re-entry, disconnect, locking or a failed resume suppress stale asynchronous notices. Activation still turns the lenses off in firmware; phone feedback does not claim a lens-side activation popup.
+30 -12
View File
@@ -6,41 +6,59 @@ const ts = require('typescript');
function fixture() {
const source = ts.createSourceFile('controller.ts', fs.readFileSync('app/g2/dashboard-controller.ts', 'utf8'), ts.ScriptTarget.Latest, true);
const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name?.text === 'DashboardController');
const methods = cls.members.filter(n => ['handleSilentMode', 'setPhase'].includes(n.name?.getText(source)));
const alerts = [], timers = new Map(); let next = 0, on = true;
const methods = cls.members.filter(n => ['handleSilentMode', 'showSilentModeExit', 'setPhase'].includes(n.name?.getText(source)));
const alerts = [], timers = new Map(); let next = 0, on = true, wakes = 0;
const context = { exports: {}, setTimeout: fn => { timers.set(++next, fn); return next; }, clearTimeout: id => timers.delete(id),
updateGlassesPresence() {}, shell: { isScreenOn: () => on, showAlert: text => alerts.push(text),
updateGlassesPresence() {}, shell: { isScreenOn: () => on, wake: () => { on = true; wakes++; }, showAlert: text => alerts.push(text),
foregroundWindow: () => ({ requestRender() {} }), setBatteryLevels() {}, getBatteryLevels: () => ({}) } };
vm.runInNewContext(ts.transpileModule(`export class Controller { ${methods.map(n => n.getText(source)).join('\n')} }`, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
const c = new context.exports.Controller();
Object.assign(c, { silentMode: false, silentModeFeedback: '', silentModeFeedbackTimer: null, phase: 'connected', emit() {} });
return { c, alerts, timers, dark: () => { on = false; }, expire() { const callbacks = [...timers.values()]; timers.clear(); callbacks.forEach(fn => fn()); } };
Object.assign(c, { silentMode: false, silentModeFeedback: '', silentModeFeedbackTimer: null, silentModeFeedbackGeneration: 0, phase: 'connected', emit() {},
cancelEvenHubSuspendTimer() {}, ensureEvenHubSessionActive: async () => true, requestShellRender() {},
appendLog() {}, formatError: error => String(error) });
return { c, alerts, timers, wakes: () => wakes, dark: () => { on = false; }, expire() { const callbacks = [...timers.values()]; timers.clear(); callbacks.forEach(fn => fn()); } };
}
test('silent activation remains visible on phone; exit is visible on phone and awake glasses', () => {
test('silent activation remains visible on phone; exit waits for the display wake barrier', async () => {
const h = fixture(); h.c.handleSilentMode(false);
assert.equal(h.c.silentModeFeedback, '');
h.c.handleSilentMode(true);
assert.match(h.c.silentModeFeedback, /enabled/); assert.equal(h.timers.size, 0); assert.equal(h.alerts.length, 0);
h.c.handleSilentMode(false);
assert.equal(h.c.silentModeFeedback, 'Silent mode disabled');
await new Promise(setImmediate);
assert.deepEqual(h.alerts, ['Silent mode disabled']);
h.expire(); assert.equal(h.c.silentModeFeedback, '');
});
test('repeated state reports do not duplicate feedback; an old timer cannot clear a new activation', () => {
test('repeated state reports do not duplicate feedback; an old timer cannot clear a new activation', async () => {
const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false);
h.c.handleSilentMode(false); assert.equal(h.alerts.length, 1);
h.c.handleSilentMode(false); await new Promise(setImmediate); assert.equal(h.alerts.length, 1);
h.c.handleSilentMode(true); h.expire();
assert.match(h.c.silentModeFeedback, /enabled/);
});
test('silent exit never wakes a sleeping or locked display for its announcement', () => {
test('silent exit wakes a sleeping display before showing feedback but leaves locked glasses alone', async () => {
for (const locked of [false, true]) {
const h = fixture(); if (locked) h.c.glassesLocked = true; else h.dark();
h.c.handleSilentMode(true); h.c.handleSilentMode(false);
assert.equal(h.alerts.length, 0); assert.equal(h.c.silentModeFeedback, 'Silent mode disabled');
const h = fixture(); h.c.glassesLocked = locked; h.dark();
h.c.handleSilentMode(true); h.c.handleSilentMode(false); await new Promise(setImmediate);
assert.equal(h.wakes(), locked ? 0 : 1);
assert.equal(h.alerts.length, locked ? 0 : 1);
assert.equal(h.c.silentModeFeedback, 'Silent mode disabled');
}
});
test('an unavailable session, re-entry into silence or disconnect suppresses a stale exit popup', async () => {
for (const state of ['not-ready', 'silent', 'disconnected']) {
const h = fixture(); let finish;
h.c.ensureEvenHubSessionActive = () => new Promise(resolve => { finish = resolve; });
h.c.handleSilentMode(true); h.c.handleSilentMode(false);
assert.equal(h.alerts.length, 0);
if (state === 'silent') h.c.handleSilentMode(true);
if (state === 'disconnected') h.c.setPhase('disconnected');
finish(state !== 'not-ready'); await new Promise(setImmediate);
assert.equal(h.alerts.length, 0);
}
});
test('disconnect clears feedback and any pending timer without announcing a silent exit', () => {
const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false);
h.c.setPhase('disconnected');