Say how to leave silent mode, and drop the belief when it is contradicted

Silent mode is entered and exited only by long-pressing both touchpads. While
it is on the firmware ignores all input and blanks the display, so from the
phone the glasses look connected and simply answer nothing. The app cannot turn
it off either: the communicator exposes onSilentMode and a listener set, and no
setter.

The status read "Connected (Silent mode enabled)", which names the state but
not the way out of it, and someone who triggered the gesture by accident has no
reason to know the gesture exists. It now names it.

The belief can also go stale. silentMode is set by the firmware's push event
and cleared only when the phase goes to disconnected, on the assumption that it
is re-reported on the way back up. Toggle silent mode on the glasses without
the link ever dropping and that assumption does not hold: a missed "off" leaves
the phone claiming silent mode for as long as the connection lasts. Observed
with the status reading silent while the glasses were granting framebuffer
leases and rendering frames, which cannot happen in a mode whose whole
behaviour is to blank the display and ignore input.

So the belief is dropped whenever the glasses do something that mode makes
impossible: input from them, since the firmware discards input while silent, or
a shell render that gets past the display-target check, since silent mode does
not leave a display target standing. The second matters because it self-heals
without the user touching anything.

Not unit-tested. Both halves are in dashboard-controller.ts, which imports 56
modules, so a test there would mostly exercise mocks, and the stale-clear is
state management across events rather than a pure function. The refactor that
would make it testable is moving the silent-mode belief into a small state
holder taking the firmware's push events plus the two kinds of contradicting
evidence; glasses-display-state.ts next door is already exactly that shape.
This commit is contained in:
JMO committed 2026-09-22 22:09:40 -07:00
1 parent be20b24985
commit b361cdd934
1 file changed
+28 -1
+28 -1
View File
@@ -1007,12 +1007,30 @@ class DashboardController {
* charging and silent mode both make the display unavailable while BLE stays
* up, and a battery that just ran out simply stops answering.
*/
/**
* Drop a stale silent-mode belief when the glasses do something they could
* not do in silent mode. The firmware blanks the display and ignores input
* while silent, so input or a presented frame is direct evidence it ended.
*/
private clearSilentModeOnEvidence(reason: string): void {
if (!this.silentMode) return;
this.silentMode = false;
this.appendLog(`silent mode cleared: ${reason}`);
this.emit();
}
private displayPreviewMessage(): string {
if (this.phase === "charging") {
return this.glassesDisplayLabel();
}
if (this.silentMode && this.phase === "connected") {
return "Connected (Silent mode enabled)";
// Say how to leave it. Silent mode is entered and exited only by the
// same gesture on the glasses, the firmware ignores all input and blanks
// the display while it is on, and nothing here can turn it off -- there
// is no setter, only onSilentMode. So a user who triggered it by
// accident sees a connected pair of glasses that answers nothing, with
// no way to find out why. The instruction belongs where they are looking.
return "Connected (Silent mode — long-press both touchpads on the glasses to exit)";
}
// The preview compositor keeps the mirror live (including as a black
// frame while the simulated screen is off), so never cover it.
@@ -1399,6 +1417,12 @@ class DashboardController {
}
});
this.offRing = communicator.onRingEvent((event) => {
// Input is proof silent mode ended: the firmware ignores all input while
// it is on, so one cannot arrive in that state. silentMode is otherwise
// cleared only on a disconnect, on the assumption that the firmware
// re-reports it, so a toggle made on the glasses without the link ever
// dropping leaves the phone claiming silent mode indefinitely.
this.clearSilentModeOnEvidence("input from the glasses");
void this.handleInputEvent(event).catch((error) => {
const message = this.formatError(error);
this.appendLog(`input handler failed: ${message}`);
@@ -2503,6 +2527,9 @@ class DashboardController {
frameTimings.finishFrame(frameId, "discarded: shell render with no display target");
return;
}
// A display target is standing, which silent mode does not leave in place.
// Evidence enough to drop the flag even if the user never touches the glasses.
this.clearSilentModeOnEvidence("the glasses are presenting frames");
// A shell overlay that dims what it covers (a context menu) must dim the
// window surfaces too, which live below the shell surface in the
// compositor: forward the factor before this frame composites.