Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Merge remote-tracking branch 'origin/main' into claim/issue-2387
Adam Eivy2e49810cfae0
diff --cc .changelog/NEXT.mdindex 0fbe8ec78d,301c918977..d50873b61a--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@@ -51,8 -51,8 +51,10 @@@## Fixed+- **[issue-2387] Theme initialization and switching now survive unavailable localStorage.** The `useTheme` and `useCitySettings` hooks read/wrote `localStorage` directly (persisted theme, and the CyberCity settings that render on the same theme path), so a browser where storage access throws (Safari private mode, blocked cookies, disabled storage) or is absent would throw inside a `useState` initializer and crash the initial render, and a failing `setItem` could break theme switching. Both hooks now route every read/write/remove through a shared, guarded `safeReadStorage`/`safeWriteStorage`/`safeRemoveStorage` helper (`client/src/lib/safeStorage.js`) that swallows access failures, and corrupt stored JSON falls back to defaults instead of throwing — so init always resolves to a valid default and in-memory switching keeps working when persistence fails. `setTheme` also applies the in-memory theme (DOM + state) before any persistence/side-effect work so a later failure can never leave the UI on the stale theme. Focused hook tests cover read-throws-on-init, corrupt/invalid stored value, and write-throws-on-switch for both hooks.++ - **[issue-2384] A usage-limit fallback signal now stops a direct-CLI CoS agent immediately even when an earlier transcript write is stalled, and the persisted transcript can no longer be reordered.** The direct-CLI spawn path (`spawnDirectly` in `server/services/agentCliSpawning.js`) let each stdout/stderr `data` event run its transcript-mutating body (`outputBuffer` append + `output.txt` write + batched live-tail push) as an independent async handler, so two chunks' interleaved `await`s could persist output out of order, and a blocked state/file write on an earlier chunk could sit in front of a later chunk that carried the `Now using extra usage` fallback marker. Fallback detection now runs **synchronously** in the raw listener — before any transcript work is enqueued — so the provider is killed the instant the signal arrives regardless of a stalled write, while the transcript body is serialized onto a single per-agent tail promise (mirroring `shell.js`'s `hookQueue` and `pipeline/issues.js`'s `issueWriteTail`) that the close/error/terminate paths drain before finalizing. A regression test blocks an earlier write, emits the fallback signal on a later chunk, and asserts termination stays immediate and final output stays ordered.+- **CoS agents (notably codex) now open their PR as the gh account that matches the repo owner, not gh's mutable active user.** PortOS's own `createPR` pins `GH_TOKEN` to the logged-in gh account whose login matches the repo owner (avoiding the multi-account "must be a collaborator" failure), but a spawned agent running its *own* `gh pr create` — a codex/Claude/CLI CoS agent finishing `/do:pr` — never received that pinning. TUI agents fared worst: `shell.js`'s `buildSafeEnv` strips `GH_TOKEN` from the inherited env entirely, so their `gh` fell back to whatever `hosts.yml` active user happened to be set. A new best-effort `resolveForgeTokenEnv(dir)` (in `server/services/git.js`) resolves just the owner-matched `GH_TOKEN` overlay and is injected into all three agent-spawn env paths — direct CLI (`spawnDirectly`), TUI shell session (`spawnTuiAgent`), and the CoS runner (`spawnViaRunner`). It's provider-agnostic (no codex special-case), returns `{}` when no owner-matched account exists (so single-account installs and GitLab repos are untouched), and is spread before `provider.envVars` so an explicit provider `GH_TOKEN` override still wins.- **Codex CoS agents no longer die `paste-not-rendered` while codex boots its MCP servers.** Codex boots any MCP servers configured in the user's global `~/.codex/config.toml` on every headless spawn — including heavyweight interactive ones like `playwright` (fetched via `npx`) or a `node_repl` with `startup_timeout_sec = 120`. That boot can run for tens of seconds up to ~2 minutes, during which codex swallows pastes, renders no `[Pasted Content N chars]` commit marker, and shows only the *tail* of a long paste in its input viewport (never the verified prefix) — so PortOS's paste-verify retry could not confirm delivery and killed the agent after only 3 short attempts (~19s), long before the boot finished (real incident 2026-07-10: `agent-c5a26b40` / `agent-3f4ae3b1`, both on gpt-5.6-sol; the same prompt succeeded days earlier when no MCP servers were configured and codex was ready in <10s). The spawner now detects codex's MCP-boot banner (`Booting MCP server` / `Starting MCP servers`) and extends the paste-retry budget from the fixed 3 attempts to a time budget (150s, covering `node_repl`'s 120s startup plus an `npx` cold download while staying under the idle-reap window), so a slow boot completes and the paste finally lands. If the boot genuinely never finishes, the failure now names the MCP-boot cause and points at the codex config instead of a misleading "still initializing" message. Non-codex TUIs and codex installs without MCP servers are unchanged.diff --cc client/eslint.config.jsindex 5236cd717b,5236cd717b..54fc8321ad--- a/client/eslint.config.js+++ b/client/eslint.config.js@@@ -14,6 -14,6 +14,7 @@@ const browserGlobals =EventSource: 'readonly',FormData: 'readonly', File: 'readonly', FileReader: 'readonly',Blob: 'readonly', Event: 'readonly', CustomEvent: 'readonly',++ DOMException: 'readonly',EventTarget: 'readonly', AbortController: 'readonly', AbortSignal: 'readonly',ReadableStream: 'readonly', WritableStream: 'readonly', TransformStream: 'readonly',DecompressionStream: 'readonly',