Files
airc/docs/future-work.md
Tommi Kyntola 016f9e3277 Speak a prompt: a mic button that types into the viewed pane
The control bar can type, but a keypress at a time is all that is comfortable
in a car — and a prompt for a coding agent is a sentence. The Android app has
IME dictation; the car browser has none, so a spoken instruction today means
walking back to the laptop.

This pairs airc with dais, the local voice daemon on the same machine. The
browser sends the pane its viewer is on; dais records, transcribes locally and
types the transcript there. No audio crosses the network and the browser needs
no microphone permission — the mic that opens is the LAPTOP's.

Type only, on purpose: the text lands in the pane's input box and the user
submits it with the Enter button already in the bar, so a misheard prompt is
readable before an agent acts on it. The ✕ discards instead — dais throws the
recording away rather than typing it.

`src/dais.js` keeps the two channels apart. Control is one ndjson line over the
Unix socket with a 2s timeout, resolving and never rejecting, because a missing
daemon is an expected state. Status needs no dais op at all: the socket's
existence says the daemon is live, the mic-recording marker says the mic is
open, and state.json carries mode/target/muted/dry_run. Those files already
exist for statusline use, so the poll behind the button costs no socket traffic;
a state.json caught mid-rewrite is parsed in a try/catch, and the two
filesystem facts still answer the question the button must not get wrong.

$DAIS_SOCKET is deliberately ignored even though dais's own CLI honors it — if
airc read the env, a private test daemon exported in a shell could silently
re-aim the microphone of a running server.

The button reports the state of the pairing rather than failing mysteriously.
Not configured: no buttons at all, nothing to explain. Configured but the daemon
is down: visible and DISABLED with the reason in the title, because a control
that vanishes mid-drive is worse than one that says why it cannot help. Muted or
dry-run gets appended to the title, since otherwise the tap looks like it worked
and no text ever appears. The poll runs ~1/s while recording, ~4s otherwise, and
not at all while the control bar is closed — airc's own no-work-when-nobody-is-
watching rule. The browser always sends `toggle` and lets dais resolve it, so a
missed poll cannot invert the latch.

A mic tap drops auto mode, mirroring "the first keystroke drops auto": the
transcript is typed but not submitted, so auto must not slide the view — and the
user's Enter tap — to a different pane than the recording was aimed at.

Both routes are control-gated and 404 below that, and both are gated on
dais.enabled, which defaults to false. That default is a security decision, not
tidiness: the control token was already a remote-shell credential, but with this
on it also opens a microphone, which is a different class of capability. Status
is control-level too, unlike /api/attention — "the mic on that laptop is open
right now" is not something a read-only share link should report. /api/config
exposes only dais.enabled, never the socket path, and the pane goes through the
same resolveInputTarget as every keystroke so the ^%\d+$ trust boundary holds.
503 marks "could not reach dais" apart from 409 "dais refused", and refusals
surface in the strip's note area — which on a phone becomes a full-width line,
the first real use of that long-dormant element.

On mobile the mic and ✕ take a row of their own so the arrow row stays the tidy
six columns it was, and the mic gets four of those columns to the ✕'s two: one
is aimed at a driver and the other throws work away, so they should not be
equally easy to hit by accident.

Verified end to end against an isolated pair — a private tmux server, a test
dais daemon with its own runtime dirs, a test airc on another port — covering
both token levels, all four actions, the delivery landing unsubmitted in the
viewed pane, the button grey-out when the daemon is killed mid-session, and the
409/503 split. test/dais.test.js pins the socket-path precedence, the status
reads including a torn state.json, the exact ndjson line, and the fail-soft.

No Android change this round: app.js and MainActivity.kt are otherwise mirrors,
so docs/dais.md records the divergence as deliberate — the gap this fills does
not exist on a device that already has IME dictation.
2026-08-17 16:47:09 +03:00

88 lines
3.0 KiB
Markdown

# Future Work
## Endpoint Fallback
Android now remembers the last successful endpoint and periodically probes LAN
again when using public/ngrok. The websocket-streaming path already probes LAN
on a background thread; the remaining inline retry is the HTTP poll loop's own
LAN attempt. Further improvement: an event-driven `ConnectivityManager`
.NetworkCallback to probe immediately on a network change instead of waiting for
the next ~15s tick.
## Systemd
`tools/airc` currently manages a detached Node process with pid/state/log files.
A user systemd unit would be useful if Airc should survive shell/session cleanup
or start automatically.
Potential shape:
- `tools/airc install-service`
- `tools/airc service on|off|status|logs`
- optional templated unit only if separate instances become useful
## Fit and Sizing
Make the default Tesla viewport smooth and readable.
Questions:
- What exact cols/rows are comfortable in the normal `1180x919` viewport?
- Should Airc create/manage a dedicated tmux window size?
- Should `resizeToViewport` become a preset rather than a boolean?
- Should there be named display presets like `tesla-normal`, `tesla-park`,
`phone`, and `desktop`?
## Session Management
Potential tooling:
- create the tmux session if missing
- launch a configured command in that session
- set a viewer-friendly initial size
- show session status in `tools/airc status`
## Transport
WebSockets are now the browser's preferred transport, with HTTP polling kept as
a fallback. Further improvement: add explicit latency/transport indicators and
avoid capturing faster than the browser can render.
## Multi-Pane / Window View
Current viewer shows one pane.
Possible approaches:
1. capture every pane and reconstruct the tmux layout in HTML
2. attach a hidden tmux client to a pseudo-terminal and capture the whole drawn
window
3. keep one-pane view as primary and make pane switching fast
Approach 3 is good enough for now.
## Voice Dictation (dais)
The browser mic button ([dais.md](dais.md)) landed type-only and browser-only.
Left for later, in rough order of appeal:
- **Android mirror** of the button — not a parity bug (the app has IME
dictation), but local transcription buys dais's dry-run and audit log.
- **Auto-submit** — the `dictate` op could carry `submit`; typing-only was chosen
so a mis-transcribed prompt is readable before an agent acts on it.
- **Symmetry the other way** — dais telling airc to swing the view to the pane a
spoken "target two" selected. Cheap once this exists, but needs a tiebreak
between two writers of "the pane you're looking at".
- **Does the Tesla browser support `SpeechRecognition` at all?** `public/probe.html`
is the place to find out. Even if it does, that path is cloud transcription and
skips dais's local pipeline, dry-run and audit log — so it wouldn't replace this.
## Security
Potential hardening:
- token rotation command
- expiry/session token layer
- optional basic auth or ngrok/Cloudflare access policy
- explicit "public tunnel active" indicator in CLI/browser UI