Repository navigation
feat: identify the host in /state and default EMBER_SOURCE to the hostname - #213
Conversation
Thin clients (cinder knob, ESP32) had to re-run PickWinning over sessions[] to learn which host needs attention. Part of #208.
A fresh install on a second Mac got the template placeholder and needed hand-editing. Empty or placeholder values now resolve to the lowercased LocalHostName, and the installer seeds that value. Part of #208.
tarakanof
left a comment
There was a problem hiding this comment.
Review (read-only; go vet + go test ./... -race green in the worktree). Mergeable, based on current main 5d17c3f. Auth unaffected (/state stays open). Swift Models.swift does not decode render, as the PR says.
Medium: the default host name makes every Mac look the same on the clock. normalizeHostName keeps the macOS default LocalHostName (Dmitrys-MacBook-Pro), but sourceCardText (internal/render/render.go:414) fits about 4 glyphs. I checked: dmitrys-macbook-pro, dmitrys-macbook-air and dmitrys-mac-mini all render as DMIT. On a fresh second Mac, the clock card and attention label show the same text for both machines, which is the problem #208 is meant to solve. Fix options:
- strip the default
<owner>s-possessive prefix (^[a-z0-9]+s-(?=mac)) so it readsmacbook-pro/mac-mini; - or have install/doctor print the resolved value with a hint to set a short id (
m4). Also mention the 4-glyph card in RUNBOOK.
Low: render.source names one host when the text is an aggregate. In the aggregate.json golden, text AI R2 D1 with source:"a" also covers host b's running session. A thin client showing "on a" next to the aggregate is wrong. Either blank Source when v.Count(win.State) >= 2 and the sources differ (sessions.go:87), or document that source is the tie-break winner only.
Low: scutil is forked on every hook for old installs. loadConfig runs on every Claude hook (hook.go:40) and tick. With the old placeholder or an empty value, ResolveSource execs scutil each time (installs keep their existing producer.env, so every pre-#208 machine hits this). Suggestion: have install/doctor rewrite a placeholder or empty EMBER_SOURCE in place once (producer.ReadEnvFile + set), so the hot path sees an explicit value.
Nits
producers/claude-code/config/producer.env.examplestill says# Required:aboveEMBER_SOURCE=, which is now empty and optional. The README sentence "defaults to the short host name when empty. SetEMBER_SOURCE…" contradicts itself.- The macOS Connection pane (
ConnectionSettings(reading:)) shows the raw value (blank or placeholder), not the name the producers actually send. TestLoadConfig_SourceDefaultsFromHostOnPlaceholderpasses trivially whenDefaultSource()=="". The codex producer has no equivalent test.
Checked and fine: unicode or empty host names strip to "" and fall through. A missing scutil falls back to os.Hostname. The server (Docker) never calls DefaultSource. 24-char truncation re-trims -/_.
An aggregate text like 'AI R2' covers several sessions; naming one host beside it misled thin clients.
… once macOS default names (Dmitrys-MacBook-Pro/-Air/Mac-mini) all collapsed to DMIT on the 4-glyph clock card; map to mbp/mba/mini. install/configure/doctor now rewrite an empty or placeholder EMBER_SOURCE once (0600 kept) so hooks stop forking scutil, and print the resolved value with a hint.
|
Review fixes pushed (3 commits):
|
|
Re-review of ba55051: fixes verified. Every finding is fixed in code, and the tests fail without the fixes (I mutated the aggregate blanking, shortHostID and claude configure's EnsureSourceInEnv, and each one fails). Mergeable; gofmt/vet/ Minor, non-blocking:
Cross-PR: after this merges, #215's T3 producer still reads EMBER_SOURCE raw (cmd/ember-t3-producer/config.go:80, daemon.go:53). It needs |
The possessive-prefix strip turned names like ops-1 into 1. Now the owner prefix goes only when followed by a known model word (macbook, imac, mac-mini, mbp...), and a bare number is never returned. Akitaka-mbp-14 -> mbp-14. Adds codex configure test.
|
Follow-up: owner prefix now stripped only before a known Mac model word (incl. mbp/mba); ops-1, build-box, dmitrys-laptop unchanged; never bare digits. This Mac's Akitaka-mbp-14 -> mbp-14. Added codex configureAt EnsureSourceInEnv test. Tests green. |
Closes #208
Tests: gofmt, go vet, go test ./... -race green. Swift untouched (Models.swift does not decode render).