connect() registers window surfaces in a loop that reads the foreground
window once, before the loop, then awaits each surface's configure call
before queuing its visibility. On a fresh process restoreOpenApps runs at
the same time and focuses windows as it relaunches them. The bridge runs
Java calls in order, so a visibility decided before the await lands after
the focus change's own calls and undoes them: the old foreground can stay
visible and cover the new one, and a later window switch doesn't clear
it, because a switch only hides the window being left.
configureWindowSurface now also accepts visibility as a function, asked
after the configure call, when the visibility call is queued. The display-
attach loops (glasses and preview), the display-mode, per-app layout and
vertical-position changes, and an in-process window's height-mode change
pass one. Launch paths that pass a literal false are unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The native session already clears silent mode on touchpad input and re-reads it on every battery poll, so the TypeScript-side clearing duplicated that. The display-target trigger was also wrong: the communicator stays up in silent mode, so it cleared the flag on the next shell render.
renderShell paints first and checks for a display target last, and the
stale-data repaint re-requests before that check. requestShellRender runs
`do { renderShell() } while (shellRenderQueued)`, and because a render is
already in progress the re-request just sets shellRenderQueued. So with no
display target the two feed each other: paint, report stale, re-queue, discard
the work, round again, with no yield and no backoff. SHELL_REFRESH_INTERVAL_MS
is 60 seconds, so the timer is not the driver.
Measured on a device with the glasses not presenting, from the app's own
frame-timings export: 40 of 40 recorded frames were render:shell
target=shell-overlay, every one discarded, mean 55 ms and median 53 ms apart,
so about 19 full renders a second all thrown away. Main thread state=Runnable
with utm=22599, and seven ANR records over three days, each "Input dispatching
timed out ... Waited 10001ms". Afterwards the same state produced 5 renders in
100 seconds, and the export showed a normal mixed workload again instead of
one loop crowding everything else out.
Hoisting the check above the paint fixes both halves at once: a frame with
nowhere to go costs nothing, and the stale-data re-request lives downstream of
the early return, so it can no longer feed the loop. The copy of the check that
used to sit after the paint is removed rather than left in place. Nothing
between the two points can change the result, and the compiler agrees: the
early return narrows this.phase, which made the "charging" comparison
unreachable (TS2367).
submitWindowFrame, the sibling path for in-process window frames, already
checks the display target before doing any work.
Not unit-tested. The change is in dashboard-controller.ts, which imports 56
modules, so a test there would mostly exercise mocks, and it is an ordering
defect rather than a predicate, so extracting a shouldPresent() helper would
pass both before and after. The shape that would work is pulling the render
gate and its stale-data retry into a small module taking the display target and
the stale flag and returning whether to paint and whether to re-request.
Open EvenHub once without finishing sign in and the phone side form comes back
on every app start, with no way to close it. Back exits the app rather than
closing the form.
Three things combine:
- EvenHubStoreLayer.paint() opened the credential editor on its first paint
when no credentials were stored. First paint includes the restore of a
still-open EvenHub at startup, so an unfinished sign in put the form back
every time. handleInput already opens it on a click, so the auto open only
removed the choice of when.
- LayerActions.startTextSettingsEdit declares a fifth onCancel parameter, but
the DashboardController wiring forwarded four and the method accepted four.
Nothing failed to compile, because a 4-parameter function is assignable to a
5-parameter function type. That callback resets openCredentialEditor's
phoneEditor guard, so with it dropped the guard latched at "credentials":
the screen timeout hid the panel without resetting the state behind it, and
the form could then be neither closed nor reopened. ios-preview-controller.ts
already forwards all five, so this was the G2 path only.
- The panel has no Cancel control, so the keyboard's Done key on the password
field is the only way to end the edit. On an untouched form that reached
submitCredentials, which called enterLogin("Email and password are
required."), which reopens the editor. A loop with no exit.
The auto open is removed; onCancel is forwarded, stored and fired from
endTextSettingEdit, with finishTextSettingEdit clearing it first so a completed
edit does not also report a cancel; and a wholly empty submission is treated as
a cancel. A half-filled form is a real mistake and still reopens with the
message.
tests/evenhub-signin.test.cjs covers the open and close contract through the
existing load-typescript.cjs loader. Two of its five tests fail against the
current store-layer.ts and pass with this change.
<details>
<summary>Prompts Used</summary>
User: This checkout corresponds to https://github.com/jimrandomh/faceclaw/pull/27. Review this branch.
GPT-6 Astra:
> Found one issue:
>
> - **[P2] Wait for Whisper’s final result before completing dictation** — [FaceclawVoiceController.java:729](/Users/jbabcock/repositories/g2/faceclaw/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawVoiceController.java:729). Skipping partial decodes leaves short utterances without text until release, but the dialog still finalizes after its existing timeout. If decoding exceeds roughly 2.7 seconds (native stop’s 1.5-second wait plus the dialog’s 1.2-second timeout), auto-send can abandon a short command or send an incomplete longer one. Continue can append the late editing instruction literally instead of refining the message. I reproduced these outcomes with delayed transcript events. These flows should await recognition completion.
>
> Validation: TypeScript and a clean Android build passed. All 21 test failures also occur on `main`. Actual Whisper latency was not tested on hardware.
<hr>
User: Thanks, let's fix that issue.
GPT-6 Astra:
> Fixed. Dictation now waits for native recognition to finish before fallback timers run. Auto-send, Continue, and AI Chat preserve delayed Whisper results; cancellation ignores late transcripts.
>
> TypeScript and Android builds pass. All 11 new regression tests pass. The full suite still has the same 21 pre-existing failures.
</details>
<details>
<summary>Prompts Used</summary>
User: Thanks, looks pretty good. I notice that during the transition from the glanceboard back to off, the glasses display a flash of the main UI. Let's address that.
AI:
> Fixed and built. The cause was the hide order in the glance host: it hid the glance surface first, which made the compositor recomposite and transmit the sleeping UI's retained window frames, and only afterwards did the screen-off path blank the display. That one transmitted frame was the flash.
>
> The hide path in `app/g2/glance-host.ts` now blanks the compositor first and hides the surface second. Blanked, the surface change composites to the same black frame, so nothing extra goes to the glasses. The controller's screen-off path still runs afterwards to drop the wakelock and re-arm the 5-second suspend. Its own blank call is now redundant but harmless.
>
> The double-tap path is unchanged on purpose: there the surface hides while the shell is waking, so the retained UI appearing is the intended result.
>
> Typecheck and the full Android build both pass. I recorded the finding in `notes/glanceboard.md` with a new checklist item for the timeout and release transitions. Worth re-checking on hardware: both the 3-second timeout and the long-press release should now go straight to dark.
<hr>
User: Thanks. Next up, let's make a firmware mod so that we can capture tap and tab-and-hold from deep sleep.
AI:
> Done. Firmware revision 2 forwards tap, long-press, and long-press release from deep sleep, and the phone side consumes them. Everything builds and the tests pass, but nothing is flashed or hardware-tested yet.
>
> **How the firmware does it**
>
> Decompiling the display thread showed that with no app on screen, its touch branch launches the dashboard on double-tap or head-up, launches the stock Menu on tap-then-hold, and frees every other gesture unhandled. The call right after that idle gate at `0x45f01a` has the input record in r4 (raw source at +2, gesture subtype at +4). The new hook in `g2flash/patches/settings_ext.c` wraps that call. When Faceclaw holds the wake lease and the firmware is in the mode where a double-tap would have woken the dashboard, it reports subtype 0 (tap), 3 (long press) and 0xe (release) as settings-sid field-102 events 2, 3 and 4, carrying the raw source. The stock result is returned unchanged, so stock behavior is untouched. Unlike the double-tap wake, nothing stock is deferred, so there is no claim or fallback handshake. I verified in the patched image that the site is a branch into the blob, that the shim hands r4 to the C function, and that the function preserves r4.
>
> **Phone side**
>
> - Java parses the new events into ordinary sys-events with the protobuf source while the page is suspended, so TypeScript sees exactly the soft-sleep gestures and the Glanceboard logic needs no change.
> - The firmware string is now `Faceclaw/2`, the app requires revision 2, and the embedded patch set was regenerated. Onboarding will offer the reflash.
> - A Java test covers the event and source mapping, the wake event staying distinct, and malformed payloads.
>
> **Verification**
>
> | Check | Result |
> |---|---|
> | g2flash `build_cfw.sh` | verified, new output hash pinned |
> | Faceclaw `build.sh` | success |
> | `npm test` | new tests pass; only the pre-existing pinball and compass-style failures remain |
>
> **Two caveats**
>
> - I read "tap-and-hold" as press-and-hold, which is the long-press the Glanceboard uses. The firmware's distinct tap-then-hold gesture still opens the stock Menu app from sleep and is not forwarded. Say so if you wanted that one instead.
> - Only the right lens notifies the phone. A double-tap on either temple wakes both lenses, so left-temple taps very likely reach the right lens's display thread while idle, but that is unverified until it runs on hardware. The checklist in `notes/glanceboard.md` has the new deep-sleep steps and the logcat line to look for.
>
> Nothing is committed in either repository.
<hr>
User: Thanks, that worked. Next up, there's also a screen-on trigger from the accelerometer detecting that you've tilted your head up 45deg. Let's make that trigger go to the glanceboard rather than the main app. (If this requires another firmware extension, go ahead and make it; otherwise use what's already there.)
AI:
> Done. It did need a firmware extension, so this is firmware revision 3 plus matching phone changes. Everything builds and tests pass; nothing is flashed or hardware-tested yet.
>
> **Why firmware was needed.** In deep sleep the head-up already reached the phone, but through the same deferred-wake event as a double-tap, so the phone could not tell them apart. In soft sleep, the first five seconds after the screen goes dark, the head-up never reached the phone at all: the display thread's idle gate drops it while an EvenHub page is on screen.
>
> **Firmware, revision 3**
>
> - **Deep sleep.** The idle policy's head-up display-start site now goes through its own wrapper. It runs the identical deferred-wake claim-and-ready handshake but reports field-102 event code 5 instead of 1. One deliberate difference: a head-up while a wake is already pending is ignored, instead of the double-tap's emergency stock-dashboard launch, so lifting your head right after a tap cannot flash the stock dashboard.
> - **Soft sleep.** The idle-gate call is wrapped, ported from the old head-tilt branch with two extra guards mirroring the stock idle path: the glasses' head-up switch must be on and the stock busy check must be clear. It forwards the head-up as EvenHub sys-event 12 under the framebuffer lease.
> - Both hooks and the two wrappers were verified by disassembling the patched image. The output hash is pinned and the embedded patch set in Faceclaw is regenerated.
>
> **Phone side**
>
> - Java decodes wake code 5 as a display-wake carrying the head-up event type, and rewrites the soft-sleep sys-event 12 into the same thing. The Glanceboard logic from earlier already treats that as a press, so a head-tilt now shows the board for the timeout instead of waking the main UI. With the Glanceboard toggle off, a head-tilt still wakes the regular UI as before.
> - The app now requires firmware revision 3, so onboarding will offer the reflash.
> - The Java test covers the new wake code alongside the tap, long-press, and release events.
>
> **One thing left as is.** Faceclaw does not push the head-up switch or angle to the glasses. The trigger uses whatever the Even app configured, which is what you have today. The old branch's setting for that is not merged.
>
> The hardware checklist in `notes/glanceboard.md` has the four head-tilt cases: deep sleep, soft sleep, screen on, and head-tilt right after a double-tap.
<hr>
User: Thanks. Next up, let's make a glanceboard widget for the Calendar.
AI:
> Waiting on the Android build; the widget, its registration, and the notes are done.
<hr>
User: Thanks. Next up, let's make a glanceboard widget for the Terminal app. This will show the same terminals (including, especially, activity indicators) as the terminal list window and reuse some code from it. If the window title is too long to fit, we truncate rather than wrap.
Also, if a terminal has a window open, that window's number will be shown in a left column in the terminals list (both the terminal-list window version and the glanceboard version). This will replace the "[open]" tag currently at the end of the line.
<hr>
User: Continue
AI:
> The Terminal widget is in, the hub list has the new number column, and the build passes. Not yet tried on hardware.
>
> **Getting the list to the main thread.** The Terminal app lives in a worker, so the widget cannot read its state directly. I added a small generic channel: a worker can post a `publish-state` reply with a key and a JSON value, and the host stores it in a main-thread registry with change notifications. The Terminal worker publishes a session snapshot under `terminal:sessions` whenever the hub would repaint, deduplicated by content. Each row carries its label, the open view window's sidebar glyph, and an activity deadline in the phone's clock, so the widget can blink and expire indicators on its own 800 ms timer without further messages.
>
> **Shared row painter.** `app/apps/terminal/session-list.ts` now holds one `drawSessionRow` used by both the hub and the widget: activity square in the gutter, the window number column, then the label truncated to fit, never wrapped. The hub used to draw labels untruncated, so it gains that too.
>
> **The number column.** A session with an open view window now shows that window's sidebar glyph, "1", "2" and so on, in a column left of the label, in both the hub and the widget. The "[open]" suffix is gone from the list. The assistant's list-sessions tool text says "[open in window 2]" instead.
>
> **Widget layout** at 288x144: "Terminal" label, then host headings only when more than one host is connected, then session rows, as many as fit. Empty states cover no connections, connecting, and no live sessions.
>
> **One limitation to know about.** The snapshot exists only once the Terminal app has been opened in this app session, because that is when the worker and its g2mirror control clients start. Before that the widget says to open the Terminal app. Since the shell restores open apps at boot, a hub left open carries across restarts. Making the worker start its control clients at boot without a window is a possible follow-up if you want the widget live from launch.
>
> Checklist entry 7c in the design note covers the blink sync, the number column in both views, and truncation. Nothing is committed.
<hr>
User: Thanks. Next up, let's make it so that selecting a widget for a slot that's already used in another slot clears that slot, _except_ that certain widgets that support it can occupy both left slots or both right slots, in which case they render at double height and the line between the slots is removed. We'll implement double-height for the Terminal and Calendar widgets.
AI:
> Done. Slot uniqueness and double-height regions are in, with a node test for the pure part, and the build passes.
>
> **The rule** lives in two places that share one adjacency helper in the layout module:
>
> - **When a picker changes**, the config app clears every other slot holding the same widget, unless the widget is marked tall and that slot is vertically adjacent to the one just chosen. So picking Terminal for Bottom left while it is in Top left keeps both, and then picking it for Top right clears both left slots. This runs from the picker's change hook and goes through the settings broadcast, so the board and the other rows follow on their own.
> - **When the board paints**, it resolves the slot choices into regions. A tall widget in two vertically adjacent slots becomes one 288x288 region and its widget gets the taller canvas. Dividers are drawn per region, so the line between the merged slots disappears.
>
> **Tall widgets.** Terminal and Calendar are marked tall. Both already lay out rows until they run out of height, so at double height they simply show more sessions or more events with no widget code changes. The other widgets stay single-slot.
>
> **Region diffing.** The board keys live regions by widget plus slots and restarts only what changed on a settings change. Switching a widget from single to tall restarts just that widget; unrelated widgets keep their subscriptions and hardware holds.
>
> **Verification.** `tests/glanceboard-layout.test.cjs` covers adjacency, left and right merges, non-spanning and diagonal duplicates staying separate, and empty boards. Typecheck and the Android build pass. The design note has a checklist step for the three picker cases. Nothing is committed.
<hr>
User: Thanks. Let's organize the Glanceboard configuration app into several screens. The entry page will have a title, a paragraph of text describing how the glanceboard works, and a menu with an "Enable Glanceboard" toggle, Preview, Select Contents, and Settings. Settings will contain:
* "Show on tap", which instead of a toggle will be a duration (from a list of options 3s, 5s, 7s, 10s, default 5s)
* "Show on long press", which will be a toggle
* "Show on head tilt", which will be a toggle
* "Show lines", which will toggle visibility of the quadrant-separator lines
Fable 5.1:
> The Glanceboard app is now three screens, the four settings are wired through, and the build and tests pass.
>
> **Entry page.** Title, a short paragraph on how the board works, and a menu drawn on the same page below it: Enable Glanceboard (toggle, the existing setting relabeled), Preview, Select Contents, Settings. Double-tap on the entry page yields to the sidebar as before; on the sub-screens it goes back.
>
> **Select Contents** is the slot pickers page from before, including the one-widget-per-board rule and double-height merging.
>
> **Settings** holds:
>
> - **Show on tap**: a duration picker, 3, 5, 7 or 10 seconds, default 5. The head-tilt uses the same duration since it behaves as a tap.
> - **Show on long press**: toggle. Off means a hold while asleep does nothing. A release still passes through so a hold already in progress can end.
> - **Show on head tilt**: toggle. Off sends the head-tilt wake to the regular UI, the pre-Glanceboard behavior.
> - **Show lines**: toggle for the slot dividers.
>
> **Wiring.** The gesture policy moved out of the controller into the glance host, which asks the board provider for the four values. The timeout is handed to the state reducer per event, so the pure module stays testable; a new test covers the supplied timeout. The master toggle off still makes every sleep gesture a no-op.
>
> The design note's checklist has a step per setting. Nothing is committed.
<hr>
User: Thanks. Let's maket the menu half width, and use the space on the right for a preview with the quadrant-separator lines and the title of what's in each slot. Instead of "Select Contents" opening a separate page, it will move the focus to that view, so you can pick one of the quadrants there and tap to open a menu of what goes in that quadrant. The four-quadrants preview will show the lines between them; if the show-lines setting is disabled, they'll be reduced to min brightness and dotted (every other pixel). The preview will omit the line between quadrants as appropriate for double-height views.
Fable 5.1:
> The entry page now has the half-width menu on the left and the slot preview on the right, with Select Contents working inside the preview. Build and tests pass.
>
> **Preview.** The right half shows the board scaled down with its slot dividers and the name of the widget in each region, or "Empty". A double-height region shows one name and no line across it. With "Show lines" off, the dividers drop to the dimmest visible shade and light only every other pixel, so the layout still reads but signals off.
>
> **Select Contents.** Choosing it moves focus into the preview instead of opening a page. Scroll moves a highlight between the four quadrants, a tap opens a modal picker for that slot with the current choice marked, and picking applies the same one-widget-per-board rule as before. The preview updates as soon as a choice lands. Double-tap returns focus to the menu. While the preview has focus the menu's selection shows as outline only, following the shell's convention that a filled selection means it has input.
>
> **Shared geometry.** The divider layout moved out of the board into a pure helper in the layout module, so the live board and the preview draw the same lines, including the merged-region rule. A new test pins the four-slot and tall-Terminal cases.
>
> The design note's checklist has a step for the preview interactions. Nothing is committed.
<hr>
User: Thanks. One fix: while the quadrants-preview is selecte, double-tap back currently goes to the app-switcher, but should go to the glanceboard menu. We can also remove the gesture-help below the preview.
Fable 5.1:
> Fixed and built. The cause was the root wrapper that turns any double-tap at the app's root into a yield to the sidebar, which ran before the page could see the gesture.
>
> The home page is now the window's root without that wrapper and routes double-tap itself: with the preview focused it returns focus to the menu, with the menu focused it yields to the sidebar as before. The gesture hint under the preview is gone.
>
> Typecheck and the Android build pass. Nothing is committed.
<hr>
User: Thanks, looks good.
Let's make the lines in the glanceboard (on the real glanceboard, not the configuration widget) dimmer.
In the Terminal glanceboard widget, with my configured font size (Roboto Light 12), there is room for one more row. It does seem to be responsive (when I increased the font size to 18 the row count dropped accordingly) but the bottom boundary might be above where it could be.
Let's add IOB to the Nightscout glanceboard widget. Also include any of cannula age, cartridge volume, battery voltage, and time since last loop that breach the limits configured in Nightscout settings (if they aren't already included), and double check that the glucose value is crossed out if it's too old.
Fable 5.1:
> All three done, typechecked and built.
>
> **Dimmer lines.** The live board's dividers dropped from shade 40 to 20, the dimmest level that survives the 4-bit quantization. The configuration preview keeps its own brighter lines.
>
> **Terminal rows.** The bottom bound was stricter than it needed to be: it required a full line step, which includes inter-line spacing, to fit above an 8 px bottom pad. Rows are still placed a step apart, but the last one now only needs its glyph line height to clear a 2 px margin, and the gap under the "Terminal" label lost two pixels. With a 12 px font that admits one more row. The Calendar widget got the same rule for consistency.
>
> **Nightscout widget.** IOB now follows the age line. Below that, only fields breaching the limits from Nightscout settings appear, inverted the way the app marks them: cannula age, reservoir volume, pump battery voltage, and loop age, one per line while room remains. Nothing shown means nothing is out of range. The strikethrough was already correct: the value is crossed at mid-height once the reading is older than the app's 15-minute limit, using the app's own helper. I added a comment saying so.
>
> Nothing is committed.
</details>
<details>
<summary>Prompts Used</summary>
Currently we receive user input events from the R1 ring mainly via the G2 glasses, which have their own connection to ring, and we also try to connect to the ring directly; but the direct connection currently winds up not workign reliably. Let's add a "Ring connection mode" to the Developer section of the Settings app, with options "Only via glasses" (new default) and "Direct". If the "Only via glasses" option is selected, we don't open a bluetooth connection to the ring at all.
> Done. Build + typecheck pass.
>
> **Changes:**
>
> - `app/ui/dashboard-settings.ts:393` — new `ringConnectionModeSetting` (`ConfigSettingEnum<RingConnectionMode>`), values `"glasses"` (default, displayed "Only via glasses") and `"direct"`, stored under `developer.ringConnectionMode`.
> - `app/ui/dashboard/settings-menus.ts:182` — added it as the first row of the Developer section.
> - `app/g2/dashboard-controller.ts:988` — `connect()` now computes `ringAddress = mode === "direct" ? addresses.ring : ""` and passes that to `FaceclawCommunicatorBridge` (and into the connect log line).
>
> The gate works by handing the Java communicator an empty ring address: `FaceclawBleCommunicator.hasRingAddress()` then returns false, so `tryConnectRing`/`shouldAttemptRingConnect`/the teardown `disconnect(ringAddress)` all short-circuit — no GATT connection to the ring is ever opened, and the retry loop never fires. Gestures still arrive over the glasses' own link to the ring, unchanged.
>
> Since the mode is read at connect time, changing it while connected takes effect on the next connection; the setting's description says so. If you'd rather it apply live (drop/raise the ring link without cycling the glasses), that needs a small new Java method on the communicator — say the word and I'll add it.
</details>
<details>
<summary>Prompts Used</summary>
Investigate and fix the bug in https://github.com/jimrandomh/faceclaw/issues/18
> Fixed. Here's what was going on and what changed.
>
> ## Root cause
>
> The issue's diagnosis was right, and the underlying flaw is a bit broader than the holder set: **`captureHolders` is phone-side bookkeeping, but the mic enable lives in the glasses' EvenHub session.** That enable dies — silently, from the phone's point of view — on a transport drop, the charging case, an EvenHub screen-off suspend, or a refused enable (`startG2AudioCapture` returns false when the display path isn't warm, and the Java worker then exits while the JS side still believes it started).
>
> `acquireCapture()` answered "is the mic running?" from the holder set, so a single stranded holder (a Transcribe window that was open when the link dropped) made every later request — wakeword assistant included — return early onto a stream that no longer existed, for the life of the process.
>
> The reported repro hits it via `resumeEvenHubSession()`, which resets `audioCaptureActive` and replays the prelude without re-enabling the mic; nothing on either side cleaned up.
>
> ## The fix
>
> **Java** — expose the real state of the stream instead of inferring it:
> - `FaceclawBleCommunicator.isAudioCaptureActive()` (`App_Resources/.../FaceclawBleCommunicator.java:363`) — true only while the session is up, not shut down, and the enable has been acked. Every teardown path already clears that flag.
> - `FaceclawVoiceController.isCapturing()` — `started` plus the communicator's view, with a lock-guarded `audioStarted` so the mic-warmup window doesn't read as dead.
>
> **`app/native/voice-control.ts`** — the bridge now asks `micIsLive()` rather than trusting the set, and tears a dead capture down before starting a new one. Added `handleSessionEnded()` (parks live holders, drops the local state) and `resumeCapture()` (restarts them on the next session); `releaseCapture`/`stop` clear the parked set. The raw-PCM tap for EvenHub mic apps had the identical staleness bug (`if (this.rawActive) return true`) and is covered the same way.
>
> **`app/g2/dashboard-controller.ts`** — wired the two session boundaries: any phase leaving `connected` parks the capture, and the first composited frame of the next session resumes it (a rendered frame is exactly the signal that a mic enable will be accepted). The screen-off EvenHub suspend is now deferred while a capture is held, so the screen timeout no longer kills a live transcription; a capture that races the suspend is parked by the same path.
>
> So Transcribe recovers on its own after a reconnect instead of sitting on a dead "Listening…", and the wakeword assistant is no longer blocked by anything left behind.
>
> ## Verification
>
> `./build.sh` (Java + webpack) clean, `tsc --noEmit` clean, `npm test` 61/61. Not committed.
>
> The behavior is all glasses-session state, which the test harness (pure modules only) can't reach, so it needs hardware. I wrote `notes/voice-capture-session-resume.md` with the five checks that matter — most importantly: Transcribe open → walk out of range → return → "Hey Even" should now get audio, and Transcribe should resume itself.
</details>
Makes the button-row appear and disappear with a slide-in/out gesture.
Rearranges the other UI elements for a more watchface-like view.
<details>
<summary>Prompts used</summary>
In faceclaw/wear, we have an Android Wear watch app which can be used as a glasses controller. Currently, its UI is a bit chaotic: we have a bottom row of buttons, the time, a foreground-window title, some help text, and a ring of indicators. The core interaction is tapping, double tapping, long tapping, and swiping (which have the same effect as on the R1 ring), which aren't location sensitive except that they can't hit the row of buttons. There is also a crown, which can be rotated as a prev/next input.
First, let's make a crown-direction setting (in the Watch section of the on-glasses Settings app), which is a toggle that can swap which crown-rotation direction is considered next vs prev. The default will be off, which will be opposite the direction that is currently default.
Next, we will make it so that the row of buttons is hidden by default. They will slide in from the bottom when the user swipes up from off-screen (distinguished from a swipe-up gesture sent to the glasses by the starting position of the swipe). They will slide out with a swipe down starting from anywhere below the top of the buttons (distinguishing from a swipe-down gesture sent to the glasses by the starting position of the swipe).
Next, we will remove the circle and four arrows; change the time from being small, curved and at the top of the screen to being larger, straight and vertically centered. We'll delete the gesture current hint ("● select ●● back"), and take the current foreground-window display (which is currently either "Disconnected", "Screen off", or an app title) and place it below the time. When the current state is "Screen off", it will display as "●● Wake". We'll then make it so that when the glasses screen is off, all gestures except for double tap (which wakes the screen) are ignored.
gpt-5.6-Sol:
> Implemented the Wear controller redesign.
>
> - Added on-glasses Settings → Watch toggle: “Clockwise crown = next.” Default off maps clockwise to previous, opposite the former default.
> - Replaced the obsolete “Watch input wakes display” setting.
> - Bottom buttons are hidden initially, slide up from a bottom-edge swipe, and dismiss with a downward swipe anywhere in the tray.
> - Removed the ring, arrows, and gesture hint.
> - Added a large centered straight clock with foreground status beneath it; screen-off status is now “●● Wake.”
> - While the glasses display is off, non-double-tap gestures are ignored locally and defensively on the phone.
> - Updated faceclaw/wear/README.md and faceclaw/wear/PROTOCOL.md.
>
> Verification:
>
> - TypeScript type-check passed.
> - All 59 tests passed.
> - git diff --check passed.
> - Wear Gradle compilation could not start because the sandbox blocks Gradle’s local lock socket/cache access.
</details>
<details>
<summary>Prompts Used</summary>
Thanks. Next up, let's add a "Phone display" section to the Settings app (above the Watch section). We'll add a "Preview color" setting (options: White, Green; default White), which controls whether the mirror display is white/grayscale (best looking) or green (matches the physical glasses). We'll move the "Touch mirror" toggle setting (currently on the phone main screen) into the phone display settings menu. We'll add a "Show brightness control" toggle setting (default off) and a "Show screen size" toggle setting (default off), which control the visibility of the corresponding elements on the phone main screen.
Let's also make it so that double-tapping the watch (or simulated watch on the phone, mirror, etc) while the app-switcher is selected turns off the glasses display, in the same way that double-tappign the R1 ring does.
> All four pieces are in and everything builds (webpack, Gradle with the Java changes, and a clean `tsc`). Summary:
>
> **"Phone display" Settings section** — added between Roam and Watch in the on-glasses Settings app, with four entries:
> - **Preview color** (White/Green, default White) — new enum setting `phone.previewColor`. The colorization happens in the Java preview path: `PreviewBitmapUtil.fromGray` gained a `green` variant whose LUT maps luminance to green-on-black instead of grayscale, threaded through `getCompositePreviewBitmap` → `getCompositePreview(green)` → the controller, which reads the setting per refresh. A settings change also schedules an immediate preview refresh, so flipping the color updates the mirror right away instead of waiting for the next composited frame.
> - **Touch mirror** — moved from the phone main screen. It's now a proper `ConfigSettingBoolean` reusing the existing `phone.mirrorTouch` storage key, so anyone who already turned it off keeps that choice. The label+switch pair is gone from the ring row in `remote-controls.xml`, and the view model reads the setting per gesture.
> - **Show brightness control** and **Show screen size** (both default off) — new booleans controlling visibility of the brightness slider/Auto toggle and the display-mode picker on the phone main screen. The whole display-controls row collapses when both are off; the bindings refresh through the existing `onAnySettingChanged` → `refreshDisplayControls` path, so toggling them from the glasses updates the phone screen live. Note this means the main screen is more minimal out of the box — brightness and screen size remain reachable via the Settings app either way.
>
> **Watch double-tap at the app switcher** — the watch-scheme special case in `handleSidebarInput` is removed: a double-click from any source (watch, phone pad/d-pad, mirror double-tap — they all arrive as source `"watch"`) now turns the display off when the sidebar is selected, exactly like the ring's. The original code deliberately excluded the watch on the theory that sleeping was a trap since any watch gesture re-wakes; with your "Watch input wakes display" setting now gated (and double-tap waking a dark display regardless), the toggle behavior is symmetric: double-tap at the switcher sleeps, double-tap again wakes.
>
> Hardware-test notes: the green preview tint and the collapsed-controls layout are worth one visual check on the phone, and the double-tap-to-sleep from the watch is a quick on-device confirm.
</details>
<summary>Prompts Used</summary>
Act as a code reviewer for https://github.com/jimrandomh/faceclaw/pull/14 (checked out in this working directory).
> * The review finished — 42 raw candidates were verified down to 10 confirmed findings. Reporting them now.
>
> * Code review(review · 10 findings)
> ⎿ app/phone-ui/main-view-model.ts
> ● 766 [correctness] mirrorFraction subtracts view.getLocationOnScreen() from tap coordinates that NativeScript already delivers
> view-local, so every phone-mirror tap is shifted up/left and misroutes
> ● 84 [resource-leak] MainViewModel's constructor registers onAnySettingChanged and discards the unsubscriber; a new view model is
> built on every page navigation, leaking listeners and retained preview bitmaps
> wear/app/src/main/kotlin/com/faceclaw/wear/MainActivity.kt
> ● 52 [correctness] onStop abandons an in-progress stem-button hold without sending LONG_PRESS_RELEASE, so the glasses shell
> escape menu opens by itself
> wear/app/src/main/kotlin/com/faceclaw/wear/ui/TouchpadGestures.kt
> ● 62 [correctness] Breaking out of the touchpad gesture loop on a consumed pointer event (or coroutine cancellation mid-hold)
> skips onLongPressEnd, leaving a stuck long-press
> wear/app/src/main/kotlin/com/faceclaw/wear/PhoneLink.kt
> ● 270 [correctness] loadStateItem queries the Data Layer with a hostless Uri (`wear:/faceclaw/state`), which matches no stored
> items, so the cached phone state is never read
> app/ui/shell/modal-layer.ts
> ● 14 [correctness] MODAL_INTERIOR is a module-level constant frozen at import time from the (now runtime-dynamic) display mode,
> while modalRect() is computed live, so modals render corrupted after a display-mode switch
> app/g2/dashboard-controller.ts
> ● 1404 [correctness] handleMirrorTouch wakes the glasses display unconditionally, bypassing the watchWakesDisplaySetting gate
> that the parallel injectSyntheticRingInput path honors
> ● 1440 [correctness] A mirror tap while any second layer is stacked (e.g. an in-window long-press menu) degrades to a blind
> synthetic click that activates whatever is highlighted, not what was tapped
> App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawWearBridge.java
> ● 147 [correctness] Watch gestures/commands queued while the JS listener is down are replayed up to 30 seconds later on listener
> registration, executing stale non-idempotent input the watch already reported as failed
> wear/app/src/main/kotlin/com/faceclaw/wear/ui/RemoteScreen.kt
> ● 232 [efficiency] WristTwistDetector (gyroscope, default-on) samples at 100 Hz via DisposableEffect and is not stopped when
> the activity stops, draining the watch battery while the process is cached
>
> * Review of PR #14 (Wear OS companion app + remote controls, 85 files, +5813/−102) is done — 10 confirmed findings reported above, ranked by
> severity. The headline items are the phone-mirror tap coordinate double-correction (which misroutes every mirror tap in the default
> configuration) and two independent paths on the watch that can drop LONG_PRESS_RELEASE, each of which makes the shell escape menu open on the
> glasses by itself.
>
> A few things beyond the reported list, for context:
>
> Refuted during verification (looked like bugs, aren't): the watch ack-timeout-during-render theory (input injection never blocks on BLE
> transmit), mirror swipes stealing page scroll (no enclosing ScrollView), and a suspected raw-settings-key notification gap (the store-level
> broadcast covers raw keys).
>
> Confirmed but below the 10-finding cap — worth folding in if you're touching those areas anyway:
> - shell.closeAssistant() no-ops via popIfTop when another layer sits above the assistant, yet still acks ok to the watch.
> - Landscape preview sizing still assumes the old 260-wide panel after the XML moved to 360 (overlap under ~568 dip).
> - The shell escape menu and tool-debug dialogs hardcode SIDEBAR_WIDTH + 8, wrong in the new full-panel mode.
> - A CapabilityClient IPC fires every 250 ms during streamed assistant replies even on watchless phones; backgrounded preview updates bypass
> their 150 ms floor.
> - Cleanups: the sidebarWidth() > 0 || focus === "sidebar" predicate appears three times, sidebar slot math is duplicated in chrome-layer.ts,
> dead protocol-version plumbing, dead padPointers field, and display-mode is missing from wear/PROTOCOL.md.
>
> If you'd like, I can apply fixes for any subset of these, or post the findings as inline PR comments (/code-review 14 --comment).
<hr>
Thanks, let's go ahead and write fixes for all of the issues you described.
> Everything builds and tests pass. All 16 issues from the review are fixed — the 10 reported findings plus the six below-cap items. Here's what changed, by fix:
>
> **Watch app (Kotlin)**
> - **Stuck long-press via onStop** — `MainActivity.onStop` now sends `LONG_PRESS_RELEASE` when a stem hold is in progress before dropping the link, so the phone's escape-menu countdown can't run to completion on its own.
> - **Stuck long-press via the gesture loop** — `detectTouchpadGestures` wraps the loop in try/finally that pairs every `onLongPressStart` with an `onLongPressEnd`, covering both the consumed-event `break` and coroutine cancellation mid-hold.
> - **Cached state never loading** — `PhoneLink.loadStateItem` now queries `wear://*/faceclaw/state` (wildcard host) instead of a hostless Uri that matched nothing, so the watch shows the cached dashboard state when the phone is unreachable.
> - **Sensors draining battery while stopped** — the gyroscope/accelerometer/off-body detectors are now driven by a `WhileStartedEffect` helper tied to the activity lifecycle: they stop on `ON_STOP` (palmed screen, back to watch face) and restart on `ON_START`, instead of running at 100 Hz for as long as the process is cached.
> - **Dead protocol plumbing** — removed the unused `Protocol.PROTOCOL_VERSION` const and the never-read `PhoneState.protocol` field; the wire field stays and PROTOCOL.md now documents it as reserved.
>
> **Phone Java**
> - **Stale input replay** — `FaceclawWearBridge` now queues only idempotent `/faceclaw/state/request` messages for replay after the JS listener registers; gestures and commands that arrived while the dashboard was down are acked as failed and dropped, never executed up to 30 seconds later.
>
> **Phone TypeScript**
> - **Mirror taps misrouting (the top finding)** — `mirrorFraction` no longer subtracts `getLocationOnScreen()`; NativeScript's `getX`/`getY` are view-local DIPs (I verified this in the installed `@nativescript/core` gesture source), so every mirror tap was being shifted up-left by the status bar + action bar. Taps now land where you touch.
> - **Mirror touch ignoring the wake setting** — `handleMirrorTouch` now honours `watchWakesDisplaySetting`: with it off, only a double-tap reaches a dark display, matching the rest of the watch scheme.
> - **Blind click through open menus** — `LayerStack.hitTest` now consumes a mirror tap when any layer is stacked (menu, dialog) instead of reporting a miss, so a tap on visible app content can no longer activate whatever menu row happened to be highlighted (e.g. "Close window").
> - **Modal corruption after display-mode switch** — `MODAL_INTERIOR` is now a live `modalInterior()` function, and `ShellModalLayer.paint` re-syncs the inner stack's size each paint, so notification modals render correctly after switching Band ↔ Full panel.
> - **View-model leak** — `MainViewModel` keeps its controller/settings unsubscribers and exposes `attach()`/`dispose()`; `main-page.ts` disposes on unload and re-attaches on load (re-attach is needed because suspend/resume fires unloaded/loaded without a navigation, and `subscribe` delivers a fresh snapshot so nothing is missed).
> - **`closeAssistant` no-op** — new `LayerStack.popThrough` closes the assistant overlay plus anything stacked above it (follow-up voice dialog, alert); the watch ack now says "The assistant was not open." when there was nothing to close.
> - **Watchless-phone IPC churn** — assistant stream events and alerts are skipped when no watch is reachable, so a streaming reply no longer triggers a CapabilityClient lookup every 250 ms.
> - **Backgrounded preview floor bypass** — the 150 ms floor check (and timestamp) in `updateCompositePreview` now runs before the foreground-activity check, so backgrounded per-frame refreshes actually throttle.
> - **Full-panel hardcodes** — the shell escape menu and tool-debug dialogs position at `sidebarWidth() + 8` (0 in full-panel mode) instead of the fixed 64 px strip.
> - **Cleanups** — the strip-visible predicate is now one `sidebarStripVisible()` helper in geometry.ts (used in three places); sidebar slot math is a single `slotPosition()` shared by drawing and hit-testing; dead `padPointers` removed; landscape preview sizing updated to the XML's 360 dp panel; `wear/PROTOCOL.md` documents the `display-mode` command and `displayMode` state field.
>
> Verification: `./build.sh` (webpack + Gradle) succeeds, `npx tsc --noEmit` is clean, the wear `:app:assembleDebug` builds, and all 59 tests pass. The behavioral fixes — especially mirror-tap coordinates, the two long-press-release paths, and the watch state cache — still need a hardware pass to confirm on device.
</details>