Repository navigation
fix(web,desktop,daemon,node-services): remediate UX, onboarding, local-model, and logging issues - #805
fix(web,desktop,daemon,node-services): remediate UX, onboarding, local-model, and logging issues#805oldwinter wants to merge 3 commits into
Conversation
…ackoff, idle model unload, and probe smoothing
…are sleep guard, and Go env isolation
There was a problem hiding this comment.
Request changes (3 P1, 6 P2, 1 P3)
Scope: main at merge base 6a511c15, 3 commits, 66 files reviewed at 9aeffa10. Loaded coderbook (sections 2, 3, 5), ponytail-review (sections 1–3) and karpathy-guidelines (sections 2–3). Ran in a separate session.
Findings
P1
-
The Daemon rewrites the localmodels tool's Bifrost
config.jsonwithout the installer lock (apps/computer/local-daemon/internal/localmodels/bifrost_hygiene.go:137-239, triggered byscheduleHygieneon the firstRefresh,library.go:292,485).- Problem: Until now the Daemon only read Bifrost's
config.json(tool.go:560). The externallocalmodelstool owns that file and writes provider entries into it when it loads a model (that is whatbifrostConfigHasAnyProviderchecks). The new code reads the file, edits it and renames it over the original. It does not hold the installer lock (operation.sqlite,installer_lock.go:35) and does not check that the file is unchanged. - Failure case: The Daemon starts and the first Run calls
EnsureLoaded, so the tool registerslocalmodels-lib-*inconfig.json. At the same moment, the hygiene goroutine started by the firstRefreshreads the old file. Its rename then drops the provider that was just registered. Pi calls to that model fail until the next load. - Also unverified: whether a running Bifrost re-reads
config.jsonor keeps serving the stalelocalmodels-llmentry from memory or its config store. - Fix: Stop the stale
localmodels-llmentry from being written in the first place, in thelocalmodelstool. If a Daemon-side cleanup has to stay, run it under the installer lock, while no load job or probe is running.
- Problem: Until now the Daemon only read Bifrost's
-
Idle auto-unload puts a full model reload on the user-message →
provider_readypath, and the docs are not updated (library.go:321-371,daemon/local_models.go:101).- Problem: After 15 idle minutes the Daemon unloads every loaded model on its own. The next Run reaches
ensureLocalModelinoperation_start_prepare.go:75and has to load the model again, whichdefaultEnsureLoadTimeoutallows to take up to 10 minutes (library.go:42). This is the first message after a pause, which is the common case. - What the PR body claims: "adds no network round trip or file walk while the user waits". The body does not mention this cost.
- Docs:
apps/computer/AGENTS.md:19-24still says the Daemon only runs the library actions the owner chose and never unloads a model on its own. A model the owner loaded by hand is now unloaded without their choice. - Fix: Disclose and justify the latency in the PR, or make the behavior opt-in. In either case, update
apps/computer/AGENTS.md.
- Problem: After 15 idle minutes the Daemon unloads every loaded model on its own. The next Run reaches
-
The PR claims a narrow-viewport hamburger menu that the diff doesn't add (
apps/web/src/features/rooms/room-surface.tsx:790).- Problem: The body says "Collapse narrow-viewport Room header actions into a hamburger menu". The diff only changes the header's grid columns and makes the existing
MobileNavigationButtonslotshrink-0. No menu is added; the room-surface test only checks class names. - Fix: Implement the menu, or correct the description.
- Problem: The body says "Collapse narrow-viewport Room header actions into a hamburger menu". The diff only changes the header's grid columns and makes the existing
P2
-
A second background circuit breaker copies the existing one (
apps/node-services/src/runtime-model-call.ts:922-991).- Problem:
admitBackgroundTaskCall,recordBackgroundTaskBreakerFailureandreleaseBackgroundTaskProbemirroradmitBackgroundCallandrecordBackgroundBreakerFailure(:869-920): same fingerprint reset, threshold,probeInFlightandopenUntillogic. To feed it,executeCallnow passes state back through a mutableentry.lastAttemptand needs atry/finallyto release probes. The loop grows by roughly 100 lines. - Fix: Use one breaker keyed by
(computer, runtime, kind), with a per-kind threshold and backoff table.
- Problem:
-
Log rotation is implemented twice (
apps/desktop/src/main/computer-daemon.ts:618-747andpackages/local-installation/src/native-log.ts).- Problem:
shiftRotatedLogsandshiftBackupsSyncare the same backup-shifting code. Desktop already depends on@linger/local-installationand imports its subpaths (for example@linger/local-installation/redaction). - Fix: Export the rotation once from
native-log.tsand use it for the daemon stdio log too.
- Problem:
-
The Daemon now strips Markdown JSON fences that Node already strips (
apps/computer/local-daemon/internal/provider/pi_model_invoke.go:67).- Problem:
executeCallalready runsunfence(text)on every structured answer (runtime-model-call.ts:1752), and the Daemon does no JSON validation of its own for Pi (daemon/model_invoke.go:132-156). That leaves two parsers for one rule. - Fix: Keep one. If Node's regex misses a real case, extend it there.
- Problem:
-
The idle-unload tests depend on
time.Sleeptiming (apps/computer/local-daemon/internal/localmodels/idle_unload_test.go:78,105,129).- Problem: "TouchActivity defers idle unload" uses a 120 ms idle window with 50 ms sleeps. On a loaded CI host one late wakeup is enough to trigger the unload and fail the test.
- Fix:
Libraryalready has an injectablenow; drive the test with a fake clock. Also,IdleCheckIntervaland a negativeIdleUnloadAfterare only set by tests.
-
useRoomMessagePresentationsre-implements the resolve loop (apps/web/src/features/rooms/chat/room-message-presentations.ts:30-84).- Problem: The exported
resolveRoomMessagePresentationsis now called only fromroom-chat.test.tsx, so those tests cover code that production no longer runs. - Fix: Have the hook reuse one loop, with the per-message cache inside it.
- Problem: The exported
-
The language picker on the auth page copies the settings picker (
apps/web/src/features/auth/auth-shell.tsx:31-47).- Problem: It duplicates
LanguageSettingsPage(features/settings/language-settings-page.tsx:15-55) using a native<select>. It also drops that page's pending and failure handling:setLanguageerrors are swallowed silently. - Fix: Extract one
LanguageSelectand use it in both places.
- Problem: It duplicates
P3
- The
Publishcomment is stale, andIsBusyreads a variable across goroutines without synchronization (apps/computer/local-daemon/cmd/linger-computer-daemon/main.go:393-399).- Problem: The idle goroutine now calls
Actitself, which publishes, so "publishes only from Act and Refresh, which the Daemon calls once it runs" is no longer true.localDaemonis assigned afterlocalmodels.Newhas already started that goroutine, with no synchronization between the write and its reads. - Fix: Update the comment, or start the idle loop only once the Daemon is running.
- Problem: The idle goroutine now calls
Verified as fine
- The quiet-auth header is removed before the request is sent, and a 401 on it is not reported as a lost session.
teamhub-api.ts:53-73handles this, andteamhub-client.test.tsexercises it through the real client. - Accepted Runs count as busy before they load a model. They are registered in
activeOperations(operation_start.go:139) beforestartAcceptedOperationreachesensureLocalModel, andIsBusychecksActiveOperationCountagain before each unload (library.go:362). - The native supervisor keeps its owner-only and no-follow checks on the log file.
openPrivateLogSync(native-log.ts:38-56) does the sameO_NOFOLLOWopen and private-owner check as before. When a write fails, the line is counted as dropped and the pipes keep draining. - No CJK in added lines outside the locale catalogs, and none in commit messages.
Process notes
- No merge commits and no fixup commits. The branch is not behind
main.
CI
- All reported checks pass (computer-go, computer-go-windows, desktop, installer, packages, web, web tests 1/2 and 2/2, web-static, repository-gate). Contracts, TeamHub and TeamHub CLI checks were skipped.
- CI runs the Daemon's Go tests without
-race, so I rango test -race -count=2 -run 'Idle|Hygiene|Bifrost|Prune|Storage' ./internal/localmodels/. It passed (63 s).
Automated review by Claude Code
Automated review of 9aeffa1 by Claude Code.
What and why
Remediates user-facing UX, accessibility, onboarding, local-model lifecycle, and operational logging issues identified during end-to-end health-check testing across Web, Desktop, Local Computer Daemon, Node Services, and
@linger/local-installation:87f5a721):?reason=session-expiredredirects on cold/loads (router.tsx).INVALID_CREDENTIALS(teamhub-api.ts,teamhub-error*), and expose a language switcher onAuthShell(auth-shell.tsx).PanelTabStripwidths (room-shell.tsx,room-surface.tsx,panel-tab-strip.tsx), and resolve 2 React Doctor errors (room-message-presentations.ts,message-row.tsx).Filescache onRemove from Room(room-queries.ts), addtabIndex={-1}to the hidden file input (message-composer.tsx), and restore trigger focus when closingModalDialog(modal-dialog.tsx).LocalComputerGateheader andSign outfooter on narrow viewports while preserving/settings/*exemption and allowing CLI command wrapping (local-computer-gate.tsx,computer-setup-instructions.tsx,computer-app-setup-dialog.tsx,globals.css).3788347b):pi_model_invoke.go) and add exponential backoff (2m -> 5m -> 15m) for repeated backgroundtimed_out/invalid_outputfailures plus tighter Pi retries (runtime-model-call.ts).localmodels/library.go,local_models.go,operations.go,model_invoke.go,main.go).localmodels-llmentries in Bifrost (bifrost_hygiene.go, creating one-timeconfig.json.bak) and log a non-blocking storage summary.room_presenceprepare_sent/received/already_readylogs todebug(remote-codex-provider.ts,provider_prepare.go) and add a single confirmation retry to thecodexauth probe (runtime_monitor.go).9aeffa10):10 MiB x 3log rotation (native-log.ts,native-process-worker.mjs, andcreateRotatingLogStreamviacreateWriteStreamincomputer-daemon.tspreserving disk-full resilience) plus 14-day Desktop log pruning (desktop/src/main/log.ts).PowerGuardbattery-aware (power-guard.ts) and surface sleep-guard status in the tray menu (tray.ts,tray-menu.ts).GOROOT/GOBINfrommiseenvironment whengois not installed (native-dependencies.ts) and document legacy~/.simplexaimigration/retention behavior (packages/local-installation/AGENTS.md).How it was verified
make check BASE=origin/<target-branch>or the fast checks of every touched appcontracts/openapi/changed (N/A — nocontracts/openapi/changes)Post-rebase verification results on
9aeffa10(rebased ontoorigin/main6a511c15):pnpm exec commitlint --from origin/main --to HEAD --verbose&make check-repository BASE=origin/main: passed (0commitlint issues; Prettier, ESLint, env inventory, and English-only checks passed).make check-web BASE=origin/main&pnpm --filter @linger/web run build:assets: passed (tsc,eslint,vitest, React Doctor0errors, initial JS budget check).TMPDIR=$(node -e 'import("node:fs").then(f=>console.log(f.realpathSync(process.env.TMPDIR || "/tmp")))') make check-desktop: passed (51/51test files,752 passed | 1 skipped,24packaging unit tests,build-daemon.mjs --all,typecheck,lint; realpathTMPDIRavoids a macOS/tmpsymlink mismatch in untouchedorigin/maintestbundle-node-services.test.ts:654).go vet -C apps/computer/local-daemon ./...&go test -C apps/computer/local-daemon ./internal/localmodels/... ./internal/provider/... ./internal/daemon/... ./cmd/linger-computer-daemon/... -count=1: passed across all 6 tested Go packages (note: hostgolangci-lint v2.8.0could not parsego1.27.3export data).pnpm --filter @linger/local-installation typecheck,pnpm --filter @linger/local-installation lint, andpnpm --filter @linger/local-installation exec vitest run --no-file-parallelism --maxWorkers=1 --maxConcurrency=1 src/native-dependencies.test.ts src/native-log.test.ts src/native-process.test.ts: passed (3/3files,52 passed | 3 skipped; sequential worker flags avoid macOS/bin/ps ewwprocess-table contention on this host).make check-node-services:typecheck(catalog:check+tsc --noEmit) andeslint --max-warnings=0passed;tests/agent/runner-gateway/remote-codex-provider-prepare.test.ts(19/19) and both new tests intests/runtime-model-call.test.tspassed (67/68in that file). Across all Vitest suites,274/276test files passed (2908/2910tests,8skipped files /52skipped tests); the 2 failures already exist onorigin/mainfromfb729fd6in untouched files/assertions (tests/agent/boundaries.test.ts:67missing../../sensitive-text.jsforprovider.ts, andtests/runtime-model-call.test.ts:1220credential redaction length78vs300).Boundary
packages/local-installation/AGENTS.mdregarding legacy~/.simplexaihandling; no OpenAPI contracts or database schemas were modified.user message -> provider_ready): adds no network round trip or file walk while the user waits. Bifrost hygiene and storage summary run off-path in a tracked background goroutine at daemon startup, and theroom_presenceadjustment only changes log severity todebug.Merge Danger
apps/web,apps/desktop,apps/computer/local-daemon,apps/node-services,packages/local-installation); no database migrations or breaking wire changes. Bifrost startup cleanup creates a one-timeconfig.json.bakand is idempotent.