Commit Graph
154 Commits
Author SHA1 Message Date
FilipAlexanderandClaude Opus 5.5 e2caf28392 Voice: self-hosted Whisper server provider; Transcribe on iOS
- "Whisper server (self-hosted)" transcription provider for OpenAI-compatible
  Whisper servers (vLLM, speaches, LocalAI) over plain HTTP batch requests,
  with URL, model, language and key settings (Voice). Pause-ended spans are
  one request each, finalized in audio order, with provisional text while a
  span is open. See notes/whisper-server.md.
- Transcribe (and other continuous capture) works on iOS with a cloud or
  Whisper-server provider; push-to-talk shares a running capture.
- Transcribe saves each session's audio as transcribe-<time>.wav in Downloads
  (setting "Save Transcribe audio", on by default), written as it is captured
  so a crash leaves a playable file; a saved transcript uses the same stamp.
- Calculator stops continuous listening when its window closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 16:43:18 +02:00
James Babcock 2bb7b3ea1a Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-10-14 02:17:56 -07:00
James Babcock 60c87521b0 Fix a bunch of microphones app reliability issues
<details>
<summary>Prompts Used</summary>
User: Review the Microphones app, focusing on error handling and reliability.

Opus 5.5:
> I've finished reading the Microphones code and its native pieces. The 2026-10-14 commit `b50898e` fixed a lot, and the main problem left is the same in most places: the app reports "Listening" or "captions on" but never checks that audio is actually arriving. When something fails partway, the session usually stops working with no visible sign.
>
> ## High: silent loss of function or data
>
> **1. In stock mode, other mic users can take the mic away for good.**
> - `stopRawCapture()` tears down the single shared audio tap no matter who started it (`app/native/voice-control.ts:257`).
> - The EvenHub mic router calls it whenever a mic-using EvenHub app goes to the background or closes (`app/apps/evenhub/mic-router.ts:88`). That kills Microphones' audio.
> - Transcribe takes the mic without setting `voiceActivity` (`voice-control.ts:269`), so Microphones is never told to get it back.
> - If capture starts while the session isn't ready, the native controller only records the request, so no audio ever flows.
> - `checkExtendedCapture` (`mic-session.ts:456`) only covers 4-mic mode. Its comment says the stock path "is resumed by the voice-control bridge", but that only covers the session-dropped-while-active case.
> - In 4-mic mode the problem runs the other way: Transcribe takes over the shared Kotlin listener (`GlassesSessionCore.kt:470`) while the glasses keep sending 4-mic frames, so Transcribe gets audio in the wrong format.
> - **Fix:** track who holds the raw tap (like `captureHolders`), add a stock-mode branch to the 3 s check, and have Transcribe set the same "mic in use" signal as the assistant.
>
> **2. One bad utterance ends captions for the rest of the session.**
> - The caption worker has no per-utterance error handling. Any exception from `recognize()` or `embed()` stops the worker for good (`CaptionEngineCore.kt:334`).
> - `started` stays true, so TypeScript still thinks captions are running and recording carries on. The only sign is a "Captions failed:" status string.
> - **Fix:** catch errors per utterance in `onUtterance` (`:367`). Report a fatal worker exit through its own callback so the session can restart the engine or mark captions inactive.
>
> **3. A crash or low-memory kill during recording leaves files that are never shown or deleted.**
> - The WAV header is written with a data size of 0 (`FaceclawWavRecorder.kt:26`) and only corrected in `finish()`.
> - The file is only linked to its conversation in `stopRecording` (`mic-session.ts:1200`), and the conversation row is never closed.
> - Nothing cleans up `mic-recordings/`, so after a crash you get the same never-expired orphan files the last commit fixed for the captions-off case.
> - **Fix:** link the file to its conversation when recording starts. In the boot-time cleanup: close conversations left open (`ended_at IS NULL`), repair the WAV header from the file length, and delete files no conversation points to.
>
> **4. When the transcoder's success callback fails, it deletes both copies of the recording.**
> - `FaceclawAudioTranscoder.kt:66-83` deletes the WAV before calling `onDone`. If `onDone` throws, the catch block deletes the M4A too, and the database still points at the deleted WAV.
> - Separately, the JS listener is referenced only from Java (`mic-session.ts:1208`). Under `markingMode: 'none'` that's the situation `mic-control.ts:74` warns about.
> - I haven't confirmed the garbage-collection risk. `asr-model.ts` does the same thing and its downloads seem to work. But the delete order is wrong either way.
> - `rediarize.ts` and `mic-models.ts` hold their listeners the same way.
>
> ## Medium
>
> 5. **The last utterance is lost when you close the app or turn captions off.** When the caption engine stops, it flushes the utterance in progress and posts it to the main thread. By the time it arrives, `stop()` has already run `finishSessionRow()` (`mic-session.ts:328`), so the line is never saved and is missing from the session insights. If decoding takes longer than the 2 s wait, the line can land in the *next* session with wrong times. Also, `stop()` can block the UI for up to 2 s.
> 6. **The beam filter can mute 4-mic captions permanently.** The direction and signal strength only update on frames with a non-zero angle or strength (`:685`), and they never go stale. If you turn off "Direction detection", the last direction stays frozen. If it was outside the beam, `deliverExtendedAudio` drops all audio from then on (`:751-757`). Stock mode avoids this because it updates the strength on every frame. **Fix:** timestamp the fused direction and treat it as unknown after `TEMPLE_STALE_MS`.
> 7. **The 4-mic health check looks at a phone-side flag, not at whether audio is arriving.**
>    - The check only re-arms when `isAudioCaptureActive()` is false.
>    - A configure command can be skipped while the session isn't ready even though `send()` returns true (`mic-control.ts:155`, `GlassesSessionCore.kt:890`).
>    - A temple can reboot on its own, or `apply()` can refuse to arm when the developer setting is turned off mid-session.
>    - Each of these leaves forwarding "active" with no frames arriving.
>    - **Fix:** you already track `templeFrameAtMs`. Re-send the config when an enabled temple has gone quiet, and show that in the status instead of "Listening (4-mic array)".
> 8. **A failed start is permanent.** `start()` returns before installing any timers (`:280`). A failed mode switch mid-session (`:376`) leaves `forwardingProxy` null, so the health check exits at `:457` every time. **Fix:** stay in a "waiting for glasses" state and let the timer retry.
> 9. **The caption feed can flip between left and right on every frame.** The choice at `:744` doesn't take the current side into account, and `strongerChanged` is just a `!==` check. Near the 1.5× threshold, each flip splices about 25 ms from the other temple (which runs on its own clock) into captions and the recording, either repeating or skipping audio.
>
> ## Lower
> - **Unguarded speaker call (`:1034`):** the speaker rename for a pending introduction runs before the line is added. A database error drops the line and leaves the introduction pending, so the next 2 minutes of lines from unnamed speakers fail the same way. Add the line first, then do the extra steps each with its own error handling.
> - **Speaker list grows forever:** every unknown voice adds a permanent "Speaker N" with a voiceprint. Retention never prunes them. `assign()` reloads and decodes every profile on every utterance, on the main thread.
> - **Translation:** there's no timeout, so lines can wait indefinitely while a model download is stuck offline. The detected language is only saved after translation finishes (`:1132`). The "hysteresis" comment at `:1120` describes logic that doesn't exist: `conversationLang` is written but never read.
> - **Frame fields ignored:** the sequence number (but `TempleAudioPipeline` assumes consecutive frames), the truncated flag, and `sampleRateHz`. The UI offers 8–48 kHz while the code assumes 16 kHz.
> - **Duplicated model path:** `moonshineModelDir()` (`:1337`) copies `asr-model.ts`'s directory name. A model version bump there would quietly drop captions to "no ASR model".
> - **Silent recording gaps:** `WavRecorder.append` swallows each write error, so a full disk means log spam and silent gaps in the recording.
>
> The startup order with cleanup on failure, the 90 s lease that recovers on its own from a lost STOP, and keeping the last good speaker cache all hold up well.
>
> I worked from the code only; nothing was tested on hardware. #6 relies on the protocol comment saying the angle is 0 when direction detection is off.
>
> I'd fix #1, #2, #5 and #6 first, since those are the ones you'd hit in normal use. Want me to start on them?

<hr>

User: Thanks. Let's fix all of the high and medium issues you found now.

Opus 5.5:
> All nine high and medium issues are fixed. TS typecheck, lint, 813 TS tests, the Kotlin host tests (4 new), the iOS Kotlin compile and `build.sh` all pass, and I confirmed the new code is in the APK. Nothing has been tested on the glasses yet, and nothing is committed.
>
> **High**
> 1. **Mic taken by other apps:**
>    - The shared audio tap now tracks who's using it, so an EvenHub app backgrounding no longer cuts off Microphones.
>    - Transcribe now marks the mic as in use, like the assistant does, so Microphones and EvenHub apps step aside while it runs.
>    - A check every 3 s now covers both modes. It restarts a dead stock tap and switches back to stock mode if the developer setting is turned off mid-session.
> 2. **One bad utterance ending captions:** a decode error now skips that utterance instead of stopping the caption engine (`CaptionEngineCore.kt`). If the engine dies anyway, it's restarted on the same conversation up to 3 times. After that, the Captions toggle shows off and the view says why; turning it on retries.
> 3. **Recordings orphaned by a crash:** the recording is linked to its conversation as soon as it starts. At boot, the app closes conversations a crash left open, repairs their WAV headers (`FaceclawWavRecorder.repairHeader`), transcodes them, and deletes files no conversation points to. That cleanup matches by file name, so moving the app to other storage can't delete live recordings.
> 4. **Transcoder deleting both copies:** a failure while recording the new file no longer deletes both files. The app now deletes the WAV itself, only after the conversation points at the M4A. The transcoder, re-diarize and model-download callbacks are now held by the app until they fire.
>
> **Medium**
> 5. **Last utterance lost:** stopping captions no longer blocks the UI. The engine finishes the audio still queued, then sends a new `onStopped` callback, and the conversation stays open until that arrives (20 s fallback). A late line from a previous session won't show up in a newly reopened one.
> 6. **Beam filter muting captions:** the direction of arrival only filters audio while it's under 1 s old, and it resets when "Direction detection" changes.
> 7. **4-mic health check:** a temple that sends no audio for 5 s gets its config re-sent, to that temple only. Mic-control sends now report when they weren't actually queued. The status line says when no audio is arriving, but not after routine restarts like the voice dialog closing.
> 8. **Start failures being permanent:** the session now waits ("Waiting for the glasses microphone...") and the 3 s check retries. Captions start only once the mic is up, so waiting doesn't create empty conversations.
> 9. **Left/right flapping:** the caption feed only switches temples when the other one is clearly louder for 500 ms.
>
> Behaviour changes you'll notice:
> - The watch shows "Listening…" during Transcribe.
> - EvenHub mic apps get no audio while Transcribe runs.
> - In 4-mic mode, an EvenHub mic app still takes over the single native audio listener. Fixing that needs a change on the Kotlin side, so I left it.
>
> On hardware, I'd test:
> - The assistant, Transcribe and an EvenHub mic app taking the mic while Microphones is open, then giving it back.
> - Reconnecting in both stock and 4-mic modes.
> - Killing the app mid-recording, then checking the conversation is recovered at the next start.
>
> I saved these notes to memory as `microphones-reliability.md`.
</details>
2026-10-14 02:17:05 -07:00
James Babcock bf92a5a2ce Clear notification popups when they're dismissed on the phone, and avoid showing some notifications that are spurious 2026-10-14 02:05:23 -07:00
James Babcock 132b90c21d Status bar widgets are selectable 2026-10-14 01:31:10 -07:00
James Babcock f01214f4a0 Phone screen input shows gesture help for wake (and not random other gesture-help) 2026-10-14 01:01:41 -07:00
James Babcock ea9249422c Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-10-13 00:21:12 -07:00
James Babcock 26e4396972 Multi-row status/app-switcher bar layouts 2026-10-13 00:21:01 -07:00
James Babcock 96e3bd95f7 Center the phone screen preview 2026-10-12 17:12:36 -07:00
James Babcock 5a9ca08921 Unify vertical position and display mode settings; add to onboarding 2026-10-10 22:48:26 -07:00
James Babcock 406cefe0c5 Add stats collection and first-run on-glasses onboarding app 2026-10-10 17:33:32 -07:00
James Babcock 38da8e6168 Fix several bugs that could lead to reconnect-looping
Fix misinterpretation of EvenHub event type 5.
Notification modals stacked, in a way that's O(n) in device resource memory; replace with a queue.
2026-10-05 01:36:40 -07:00
James Babcock 6db913af48 Weather app on glanceboard system card and status bar, and has an image 2026-10-04 03:08:37 -07:00
James Babcock 4234d3e9e9 Fix an issue where animations on the phone preview stopped prematurely 2026-10-03 15:54:57 -07:00
James Babcock 66ca06f584 Refactor iOS glasses connection handling to shared code, fixing incompatible-version-detection and other error cases 2026-10-03 15:08:37 -07:00
James Babcock 71fade31f9 Notifications in the bottom bar are focusable 2026-10-03 01:15:42 -07:00
James Babcock 96e155ebb0 Add centered/popup version of app switcher; plus various UI tweaks 2026-10-02 23:36:51 -07:00
James Babcock 756e21feb8 Option to combine top bar with the app switcher 2026-10-02 00:45:17 -07:00
James Babcock 8f99779f98 Add an option to move the app switcher to the right or bottom, and adjust screen depth if bottom 2026-10-01 02:40:13 -07:00
James Babcock 06146c2b08 Introduce oxlint, and fix lint warnings 2026-09-29 11:54:22 -07:00
James Babcock deaa93fead Wake the screen on wear faster after charging 2026-09-28 12:04:15 -07:00
James Babcock 2052e268b0 Add touch-down event to simulated and watch inputs 2026-09-28 02:34:08 -07:00
James Babcock 45d2ece0d2 Optimize phone CPU usage 2026-09-27 23:16:41 -07:00
James Babcock e879c58d9c EvenHub phone UI: add top bar, add open icon 2026-09-27 21:38:04 -07:00
James Babcock 48a2bd1757 Putting on the glasses auto-wakes the screen 2026-09-27 18:27:38 -07:00
JMO fb2a6a3759 Merge remote-tracking branch 'upstream/main' into pr36-revive 2026-09-26 19:29:19 -07:00
Chris LeeandClaude Opus 5 8cdee83ff4 Windows: decide a surface's visibility when the call is queued, not before
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>
2026-09-25 22:24:22 -07:00
JMO 0459f34e5b Drop the silent-mode clearing, keep only the exit instruction
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.
2026-09-25 08:11:31 -07:00
JMO 6a3f5640d5 Merge remote-tracking branch 'upstream/main' into pr36-merge
# Conflicts:
#	app/g2/dashboard-controller.ts
2026-09-25 08:08:31 -07:00
James Babcock 09a59b9821 Fix the EvenHub login form sizing and missing cancel button 2026-09-25 01:56:52 -07:00
James Babcock 4f3ad37c20 Custom auto-brightness, and fade in/out effects 2026-09-25 00:57:43 -07:00
JMO df77b672f5 Stop the shell render loop spinning when there is no display target
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.
2026-09-22 22:09:35 -07:00
James Babcock 92e8def0f0 Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-09-22 21:40:55 -07:00
JMO 662cbd75dc Fix the EvenHub sign-in form reopening every launch and never closing
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.
2026-09-22 19:07:22 -07:00
James Babcock f9724ddcab Convert remaining Java to Kotlin 2026-09-22 17:26:09 -07:00
James Babcock 2e4d20e130 Clean up unused worker threads for closed apps; other performance optimizations 2026-09-22 14:56:54 -07:00
James Babcock 9560f3ac8d Phone CPU usage optimization 2026-09-22 14:19:23 -07:00
James Babcock 4320021222 Display lists 2026-09-22 00:25:40 -07:00
James Babcock ccb320c66f Add tokens and faceclaw-input script, which allows using a CLI utility as an input device for the glasses 2026-09-20 00:34:58 -07:00
James Babcock 7b19c00443 Forward ring input events before filtering, and include swipe info 2026-09-19 19:02:11 -07:00
James Babcock e2b35ada1a Port lock screen to iOS 2026-09-19 02:55:13 -07:00
James Babcock 25c398d60f Wait for final results from Whisper before completing
<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>
2026-09-17 22:12:33 -07:00
James Babcock dfde776016 Voice input tells you if it can't record due to microphone permissions 2026-09-12 00:47:27 -07:00
James Babcock 70d782a4f1 Build out the glanceboard settings app and widgets
<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>
2026-09-11 16:56:55 -07:00
James Babcock 8a340fc4ad First iteration of glanceboard 2026-09-11 10:47:19 -07:00
James Babcock b0cf1e4f67 Switch from capability strings to numeric versioning for firmwares 2026-09-11 00:22:36 -07:00
James Babcock adf9fa89c4 Add R1 ring battery indicator 2026-09-09 11:31:44 -07:00
James Babcock 0765e943fb Add "AI Chat" app. 2026-09-09 01:15:19 -07:00
James Babcock 3d39d27456 Add notification filters 2026-09-08 02:21:50 -07:00
James Babcock 1524766996 Add screen-size setting to Navigate and Terminal apps 2026-09-05 10:45:39 -07:00