Commit Graph
518 Commits
Author SHA1 Message Date
James BabcockandKalani Helekunihi e8d2f5ade9 Fix argument order, sizing, and interleaving bugs in microphone handling
Adapted from commit dd43d476b023acfcaab4bdee942c98fd30d83f50 in
https://github.com/jimrandomh/g2flash/pull/4.

Co-Authored-By: Kalani Helekunihi <i@am.guru>
2026-09-26 11:57:40 -07:00
James Babcock 51edaee883 Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-09-25 23:53:23 -07:00
James Babcock c9447a1056 Tweak the layout of the voice input dialog 2026-09-25 23:53:10 -07:00
James Babcock 1dd86cd0cf Merge pull request #35 from jmomakesstuff/fix-flash-upgrade-unreachable
Refuse the flash prompt with a reason when the glasses are in silent mode
2026-09-25 22:37:26 -07:00
James BabcockandClaude Opus 5.5 1812818ae2 Stop leaking the remaining JS ArrayBuffers passed to Java
The same NativeScript conversion leak as the frame path (see
java-direct-buffer.ts) applied to every other ArrayBuffer handed to a
Java ByteBuffer parameter:

- Shell scenes (submitShellScene on the bridge and the preview display),
  submitted on every shell render, which the frame-path fix predates.
  These now go through a reused JavaDirectBuffer like frames do.
- Glyph, firmware-glyph and image atlas registration, Mapbox image
  decode, the preview placeholder bitmap, firmware hash/write, binary
  file writes and the EvenHub privacy-policy download, plus the Kotlin
  protocol smoke test. These are rare or large, so they cross through a
  new copyToJavaByteBuffer: a fresh Java direct buffer per call that is
  freed normally, rather than one pinned for the life of the isolate.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 22:28:45 -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
Chris LeeandClaude Opus 5 54eae0c6b9 Stop leaking every submitted frame's pixel buffer in native memory
Passing a JS ArrayBuffer to a Java ByteBuffer parameter leaks it in
@nativescript/android 9.0.4 through 9.1.1: JsArgConverter wraps the backing store with
NewDirectByteBuffer and takes a JNI global ref that it never deletes. The
ref keeps the ByteBuffer reachable, so makeInstanceWeakAndCheckIfAlive
always answers "alive", the JS finalizer re-arms, and V8 never frees the
ArrayBuffer. submitSurfaceFrame passed a fresh copy of each frame this way,
so every frame leaked a full surface (576x260, 640x452 or 640x480 bytes)
plus one global ref, including frames that Java then discards as unchanged.
The draw-list buffer and buzzer payloads leaked the same way.

Each payload now goes through a reused Java direct ByteBuffer
(app/native/java-direct-buffer.ts): JS writes into it through an
ArrayBuffer.from view, and the Java object itself is passed, which takes
NativeScript's ordinary object path. Every consumer (SurfaceCompositor
applyAndComposite, playBuzzerSequence) copies before returning, so one
buffer per JS context is safe.

Covered: the communicator bridge (frames, draw lists, buzzer, which also
carries EvenHub tones), the preview-only display, and all eight worker
apps. Workers submit through the Android getActiveDisplay() (frames) and
worker-buzzer (tones), so the reused buffers live there rather than in
each worker; the worker sources are shared with iOS, whose active display
takes the ArrayBuffer itself. The
smaller one-off crossings (glyph and image atlas registration, the gray
preview helper, firmware and file writes) are left as they are.

tests/java-direct-buffer.test.cjs covers the helper against a fake
ByteBuffer, and the Android worker-buzzer test stubs it.

(Rebased onto main by James Babcock: worker changes moved into
active-display.ts and worker-buzzer.ts.)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 22:24:22 -07:00
James Babcock 833f9d97f0 Merge pull request #33 from jmomakesstuff/add-secret-scanning
Add a secret-scanning workflow
2026-09-25 22:15:08 -07:00
James Babcock f8bed915aa Merge pull request #37 from jmomakesstuff/fix-silent-mode-dead-end
Say how to leave silent mode
2026-09-25 22:14:24 -07:00
James Babcock efafcb0f0c Fix unit tests 2026-09-25 22:13:02 -07:00
James Babcock 2f88b108a8 Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-09-25 22:08:18 -07:00
James Babcock 419eef7cca Merge pull request #39 from jmomakesstuff/fix-test-build-events
Compile events.ts for the tests, and run the Kotlin tests in CI
2026-09-25 22:07:53 -07:00
James Babcock 459560cd72 Fix a frozen menu in the notification modal 2026-09-25 22:06:44 -07:00
James Babcock cc1ae93fde Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-09-25 14:55:58 -07:00
James Babcock 6ec050cc39 Compass calibration readiness visible by default 2026-09-25 14:40:11 -07:00
James Babcock 668e454fbb Terminal app: Tap host to launch a shell (alternative to app context menu) 2026-09-25 14:11:20 -07:00
James Babcock b0a98f5942 Add animations to launcher and Files app 2026-09-25 13:25:51 -07:00
James Babcock 7ad9fe10ad Calendar: Fix a timezone issue that could cause all-day events to appear on the preceding day 2026-09-25 11:56:29 -07:00
JMO 9de46878b0 Run the Kotlin tests in CI
npm run test:kotlin covers the shared Kotlin (protocol, flash prompt, OTA, compositor) and was not run by any workflow.
2026-09-25 08:22:25 -07:00
JMO 727a3c0378 Refuse the flash prompt with a reason when the glasses are in silent mode
Ported to the shared Kotlin FlashPromptFlow after the Java was converted. The settings ack the battery read already parses carries silentMode; read it before writing the prompt page, and refuse only on a positive report. An arm that does not answer, or an ack without the field, falls through to the prompt as before.
2026-09-25 08:16:55 -07:00
JMO fde0e8b53c Merge remote-tracking branch 'upstream/main' into pr35-merge
# Conflicts:
#	App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasher.java
#	App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFlashPromptCommunicator.java
2026-09-25 08:13:43 -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 a61897813d Merge remote-tracking branch 'upstream/main' into pr37-merge
# Conflicts:
#	app/g2/dashboard-controller.ts
2026-09-25 08:10:57 -07:00
JMO cd32aed849 Compile events.ts for the tests
tests/ios-glanceboard.test.cjs requires .test-build/app/g2/events.js, but events.ts was not in tests/tsconfig.json, so a clean build never produced it.
2026-09-25 08:09:56 -07:00
James Babcock a6291cf937 Fix missing rerender when EvenHub apps finish downloading 2026-09-25 02:02:16 -07:00
James Babcock d6ce2f4194 Fix an issue where brightness updates caused a 1 second flicker 2026-09-25 02:01:50 -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 90d60cee10 Dither when darkening for the system context menu 2026-09-25 01:30:26 -07:00
James Babcock 4f3ad37c20 Custom auto-brightness, and fade in/out effects 2026-09-25 00:57:43 -07:00
James Babcock f66e0b025f Add partial rows and a bounce effect to menus 2026-09-24 12:23:20 -07:00
James Babcock c801bd5185 Animate scrolling in menus 2026-09-24 11:04:10 -07:00
James Babcock 915f155819 Add Glanceboard depth setting 2026-09-24 02:26:20 -07:00
James Babcock 71c1971992 Use animated menus in a bunch more places 2026-09-23 23:57:50 -07:00
James Babcock 123c1142d6 Better menu class; use it in the Music app 2026-09-23 22:05:44 -07:00
James Babcock 440674b261 Animations are mainly on the typescript side, not kotlin 2026-09-23 22:05:06 -07:00
James Babcock 063d8a0b03 Clean up magic-numbers used in menu animation 2026-09-23 11:34:20 -07:00
JMO 67c0671b99 Log what the lens answers the prompt page with
An ack is not a render: the lens can accept the create-prompt page and display
nothing, so a null check on the reply throws away the only thing that can say
what it did. The page size going out and the ack payload coming back are both
logged now.
2026-09-23 08:46:56 -07:00
JMO 423f9fbcd1 Refuse the flash with a reason when the glasses are in silent mode
Silent mode blanks the display and stops the firmware dispatching input while
BLE and GATT stay up, so the create-prompt page is written, accepted, and never
rendered. There is no touchpad event available to answer it with, and the flash
ends after four attempts on "prompt page not acked", which tells the wearer
nothing about what is wrong or what to do about it.

readBattery was already performing a sid-0x09 settings read whose ack carries
silentMode next to the battery, and the field was being discarded. readSettings
is factored out so one read serves both callers, and requireNotSilent runs it
before the prompt page is written. A positive report throws, and the existing
error path turns the message into what the wearer sees: that the glasses are in
silent mode, and that long-pressing both touchpads leaves it.

It refuses only on a positive report. An arm that does not answer, and firmware
whose ack omits the field, both fall through to the prompt exactly as before, so
older firmware is unaffected and a missing answer can never block a flash.

This replaces the phone-side confirmation fallback that was here before. An
unacked page is not by itself evidence that the prompt was never displayed, and
the on-lens step is what proves the glasses being flashed are the ones in front
of you, so overriding it on a timeout gave up more than it was worth.
2026-09-23 08:12:19 -07:00
James Babcock 08f1b9a2a2 Optimize on-glasses animation 2026-09-23 02:58:29 -07:00
James Babcock c8d835176f Display-list based menu slide animation 2026-09-23 01:13:03 -07:00
JMO b361cdd934 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.
2026-09-22 22:09:40 -07:00
JMO a7916a5479 Make the firmware upgrade reachable from older custom firmware
Glasses running an older Faceclaw firmware revision cannot be upgraded at all.
The flash asks for confirmation on the lens first, and that firmware never
shows the prompt, so the one path off it is closed. Measured on revision 13
(base 2.2.9.22).

showPrompt writes the EvenHub create-prompt page to the right arm and waits for
an ack. The lens accepts the write at the GATT layer and then answers nothing
and displays nothing: four attempts, four onWriteCharacteristic status=0
length=165, no reply. buildCreatePromptPage documents its geometry as
stock-firmware-safe "so this works before flashing", and that does not hold
there.

Three faults, each only visible once the previous one is fixed.

An unacked prompt page was fatal. Flashing is the only way off that firmware,
so failing here leaves the glasses permanently unupgradable. An unacked page
now falls back to the phone-side confirmation that the low-battery retry
already uses, on a screen that says what is being given up: the on-lens step is
what proves the glasses are the wearer's.

connectArm made a single attempt. The lens is routinely unavailable for a
moment just after a previous link to it closed, which is exactly the state a
retry is in, so the fallback failed instantly with "could not connect to the
right arm". FaceclawFirmwareFlasher.connectLensResilient already retries within
a window for this reason; connectArmResilient mirrors it and reports each
attempt.

That retry then tripped the lost-connection latch. Disconnecting between
attempts fires onConnectionStateChange, which set rightLost AND finished and
counted down the selection latch, so a successful second attempt still aborted
with "Lost connection to the glasses". The callback now ignores drops while the
arms are still being established.

Logging, because a failed flash used to leave almost nothing to read. emitLog
reached logcat, but emitState, emitProgress and emitComplete on the flasher,
and emitState and emitResult on the prompt communicator, went only to the
in-app listener, so the line carrying the reason existed only on the phone
screen. Seven `catch (Exception ignored)` blocks across the two classes now log
with the Throwable, matching the call sites elsewhere that already do.

tests/flash-prompt-fallback.test.cjs covers the decision at its seam through
the existing load-typescript loader. The first test fails against the current
view model and passes with this change; the second is a regression guard and
passes either way, so an unrelated failure cannot quietly skip the on-lens
confirmation.

Verified on hardware: both lenses flashed through this path after it had been a
dead end.
2026-09-22 22:09:11 -07:00
James Babcock 92e8def0f0 Merge branch 'main' of https://github.com/jimrandomh/faceclaw 2026-09-22 21:40:55 -07:00
James Babcock be20b24985 Merge pull request #34 from jmomakesstuff/fix/evenhub-signin-form
Fix the EvenHub sign-in form reopening every launch and never closing
2026-09-22 21:40:49 -07:00
James Babcock 4a194e37bb Refactor iOS version to use a bunch more shared code 2026-09-22 21:26:51 -07:00
James Babcock c3a0ba9f56 Refactor Kotlin for iOS commonality 2026-09-22 19:55:08 -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 587364e5e6 Convert most Android-specific kotlin to shared or shareable 2026-09-22 18:43:55 -07:00
James Babcock f9724ddcab Convert remaining Java to Kotlin 2026-09-22 17:26:09 -07:00
JMO c2dbd33e6d Add a secret-scanning workflow
Runs gitleaks on pushes to main and on pull requests. The settings file
pull_config.sh produces holds API keys in plain text, and .gitignore covers the
default filename, but nothing catches a rename or a key in a test fixture.

.gitleaks.toml allowlists one path: the constant in app/apps/evenhub/even-api.ts
that matches the generic-api-key rule. Scoped by path rather than disabling the
rule, so everything else is still scanned.
2026-09-22 16:28:16 -07:00