Skip to content

fix(web,desktop,daemon,node-services): remediate UX, onboarding, local-model, and logging issues - #805

Open
oldwinter wants to merge 3 commits into
simplexai-labs:mainfrom
oldwinter:oldwinter/resume-interrupted-task
Open

oldwinter wants to merge 3 commits into
simplexai-labs:mainfrom
oldwinter:oldwinter/resume-interrupted-task

Conversation

@oldwinter

Copy link
Copy Markdown

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:

  • Web UX, a11y, cache, and onboarding gate (87f5a721):
    • Avoid false ?reason=session-expired redirects on cold / loads (router.tsx).
    • Remove duplicate login error alert banner, localize INVALID_CREDENTIALS (teamhub-api.ts, teamhub-error*), and expose a language switcher on AuthShell (auth-shell.tsx).
    • Collapse narrow-viewport Room header actions into a hamburger menu, fit secondary avatar cleanly, adapt PanelTabStrip widths (room-shell.tsx, room-surface.tsx, panel-tab-strip.tsx), and resolve 2 React Doctor errors (room-message-presentations.ts, message-row.tsx).
    • Invalidate Room Files cache on Remove from Room (room-queries.ts), add tabIndex={-1} to the hidden file input (message-composer.tsx), and restore trigger focus when closing ModalDialog (modal-dialog.tsx).
    • Pin LocalComputerGate header and Sign out footer 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).
  • Daemon & Node Services reliability (3788347b):
    • Strip Markdown JSON fences in Pi structured model invocations (pi_model_invoke.go) and add exponential backoff (2m -> 5m -> 15m) for repeated background timed_out/invalid_output failures plus tighter Pi retries (runtime-model-call.ts).
    • Add 15-minute idle local model auto-unload wired to Daemon busy counts/completions (localmodels/library.go, local_models.go, operations.go, model_invoke.go, main.go).
    • Add idempotent startup cleanup for stale localmodels-llm entries in Bifrost (bifrost_hygiene.go, creating one-time config.json.bak) and log a non-blocking storage summary.
    • Downgrade routine room_presence prepare_sent / received / already_ready logs to debug (remote-codex-provider.ts, provider_prepare.go) and add a single confirmation retry to the codex auth probe (runtime_monitor.go).
  • Desktop & Local Installation operational hygiene (9aeffa10):
    • Add bounded 10 MiB x 3 log rotation (native-log.ts, native-process-worker.mjs, and createRotatingLogStream via createWriteStream in computer-daemon.ts preserving disk-full resilience) plus 14-day Desktop log pruning (desktop/src/main/log.ts).
    • Make Desktop PowerGuard battery-aware (power-guard.ts) and surface sleep-guard status in the tray menu (tray.ts, tray-menu.ts).
    • Strip inherited GOROOT/GOBIN from mise environment when go is not installed (native-dependencies.ts) and document legacy ~/.simplexai migration/retention behavior (packages/local-installation/AGENTS.md).

How it was verified

  • Focused tests for the changed behavior
  • make check BASE=origin/<target-branch> or the fast checks of every touched app
  • Contracts regenerated if contracts/openapi/ changed (N/A — no contracts/openapi/ changes)

Post-rebase verification results on 9aeffa10 (rebased onto origin/main 6a511c15):

  • pnpm exec commitlint --from origin/main --to HEAD --verbose & make check-repository BASE=origin/main: passed (0 commitlint 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 Doctor 0 errors, 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/51 test files, 752 passed | 1 skipped, 24 packaging unit tests, build-daemon.mjs --all, typecheck, lint; realpath TMPDIR avoids a macOS /tmp symlink mismatch in untouched origin/main test bundle-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: host golangci-lint v2.8.0 could not parse go1.27.3 export data).
  • pnpm --filter @linger/local-installation typecheck, pnpm --filter @linger/local-installation lint, and pnpm --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/3 files, 52 passed | 3 skipped; sequential worker flags avoid macOS /bin/ps eww process-table contention on this host).
  • make check-node-services: typecheck (catalog:check + tsc --noEmit) and eslint --max-warnings=0 passed; tests/agent/runner-gateway/remote-codex-provider-prepare.test.ts (19/19) and both new tests in tests/runtime-model-call.test.ts passed (67/68 in that file). Across all Vitest suites, 274/276 test files passed (2908/2910 tests, 8 skipped files / 52 skipped tests); the 2 failures already exist on origin/main from fb729fd6 in untouched files/assertions (tests/agent/boundaries.test.ts:67 missing ../../sensitive-text.js for provider.ts, and tests/runtime-model-call.test.ts:1220 credential redaction length 78 vs 300).

Boundary

  • Updated packages/local-installation/AGENTS.md regarding legacy ~/.simplexai handling; no OpenAPI contracts or database schemas were modified.
  • Critical path (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 the room_presence adjustment only changes log severity to debug.

Merge Danger

  • Door: two-way
  • Blast Radius: cross-app (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-time config.json.bak and is idempotent.

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. The Daemon rewrites the localmodels tool's Bifrost config.json without the installer lock (apps/computer/local-daemon/internal/localmodels/bifrost_hygiene.go:137-239, triggered by scheduleHygiene on the first Refresh, library.go:292,485).

    • Problem: Until now the Daemon only read Bifrost's config.json (tool.go:560). The external localmodels tool owns that file and writes provider entries into it when it loads a model (that is what bifrostConfigHasAnyProvider checks). 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 registers localmodels-lib-* in config.json. At the same moment, the hygiene goroutine started by the first Refresh reads 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.json or keeps serving the stale localmodels-llm entry from memory or its config store.
    • Fix: Stop the stale localmodels-llm entry from being written in the first place, in the localmodels tool. If a Daemon-side cleanup has to stay, run it under the installer lock, while no load job or probe is running.
  2. Idle auto-unload puts a full model reload on the user-message → provider_ready path, 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 ensureLocalModel in operation_start_prepare.go:75 and has to load the model again, which defaultEnsureLoadTimeout allows 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-24 still 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.
  3. 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 MobileNavigationButton slot shrink-0. No menu is added; the room-surface test only checks class names.
    • Fix: Implement the menu, or correct the description.

P2

  1. A second background circuit breaker copies the existing one (apps/node-services/src/runtime-model-call.ts:922-991).

    • Problem: admitBackgroundTaskCall, recordBackgroundTaskBreakerFailure and releaseBackgroundTaskProbe mirror admitBackgroundCall and recordBackgroundBreakerFailure (:869-920): same fingerprint reset, threshold, probeInFlight and openUntil logic. To feed it, executeCall now passes state back through a mutable entry.lastAttempt and needs a try/finally to 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.
  2. Log rotation is implemented twice (apps/desktop/src/main/computer-daemon.ts:618-747 and packages/local-installation/src/native-log.ts).

    • Problem: shiftRotatedLogs and shiftBackupsSync are the same backup-shifting code. Desktop already depends on @linger/local-installation and imports its subpaths (for example @linger/local-installation/redaction).
    • Fix: Export the rotation once from native-log.ts and use it for the daemon stdio log too.
  3. The Daemon now strips Markdown JSON fences that Node already strips (apps/computer/local-daemon/internal/provider/pi_model_invoke.go:67).

    • Problem: executeCall already runs unfence(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.
  4. The idle-unload tests depend on time.Sleep timing (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: Library already has an injectable now; drive the test with a fake clock. Also, IdleCheckInterval and a negative IdleUnloadAfter are only set by tests.
  5. useRoomMessagePresentations re-implements the resolve loop (apps/web/src/features/rooms/chat/room-message-presentations.ts:30-84).

    • Problem: The exported resolveRoomMessagePresentations is now called only from room-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.
  6. 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: setLanguage errors are swallowed silently.
    • Fix: Extract one LanguageSelect and use it in both places.

P3

  1. The Publish comment is stale, and IsBusy reads a variable across goroutines without synchronization (apps/computer/local-daemon/cmd/linger-computer-daemon/main.go:393-399).
    • Problem: The idle goroutine now calls Act itself, which publishes, so "publishes only from Act and Refresh, which the Daemon calls once it runs" is no longer true. localDaemon is assigned after localmodels.New has 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.

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-73 handles this, and teamhub-client.test.ts exercises it through the real client.
  • Accepted Runs count as busy before they load a model. They are registered in activeOperations (operation_start.go:139) before startAcceptedOperation reaches ensureLocalModel, and IsBusy checks ActiveOperationCount again 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 same O_NOFOLLOW open 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 ran go 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant