Commit Graph

18 Commits

Author SHA1 Message Date
gsxdsm
b312ca4122 fix(dashboard): null WebSocket handlers before close to stop terminal tab doubling
Creating a new terminal tab caused every pty data chunk (including
keystroke echo) to render twice in xterm. The connect-effect's
`contextChanged` dep flips true→false in the same render cycle as
the new connection: the effect re-runs, React calls cleanup which
closed the still-CONNECTING WS without nulling its handlers, then
connect() opens a fresh WS. The ghost socket's onmessage continued
firing on the shared `onDataCallbacksRef` Set, delivering each chunk
twice (and producing the "WebSocket is closed before the connection
is established" warning). Null onopen/onmessage/onclose/onerror in
both cleanup() and connect()'s pre-close branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 00:05:55 -07:00
gsxdsm
7e3c68249e feat(dashboard): bearer-token auth with browser persistence + MIT license
Pre-release polish. Two related changes bundled because they both land the
project on public-release footing:

Dashboard auth
- fn dashboard now gates the HTTP API + terminal/badge WebSockets behind a
  bearer token by default. Token resolution order: --token flag,
  FUSION_DASHBOARD_TOKEN env, FUSION_DAEMON_TOKEN env (back-compat), or an
  auto-generated fn_<32 hex>. --no-auth disables. The startup banner prints
  a click-to-open URL with ?token=<token> embedded.
- Auth middleware now also accepts fn_token=<token> as a query-string
  fallback so EventSource and WebSocket clients (which can't set custom
  headers) still authenticate.
- setupTerminalWebSocket / setupBadgeWebSocket now refuse unauthenticated
  upgrades with a proper 401 + socket close.
- Frontend: new auth.ts module captures ?token= off the URL into
  localStorage (key fn.authToken), strips it from the visible URL via
  replaceState, and installs a window.fetch wrapper that injects
  Authorization: Bearer <token> on every same-origin /api/* request.
  EventSource/WebSocket URL builders (api.ts, sse-bus.ts, useTerminal,
  useBadgeWebSocket) route through appendTokenQuery().

MIT license
- LICENSE file at repo root.
- license: "MIT" on root package.json and every packages/*/package.json,
  plus description/bugs metadata on the CLI package.

Docs
- docs/cli-reference.md documents --token / --no-auth / FUSION_DASHBOARD_TOKEN
  and the click-to-open auth flow.
- docs/getting-started.md, docs/docker.md, README.md point at the new flow
  and the CLI reference section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 20:12:00 -07:00
gsxdsm
208062b8b4 feat(FN-1765): merge fusion/fn-1765 2026-04-15 01:01:08 -07:00
gsxdsm
8c798952c4 feat(FN-1746): merge fusion/fn-1746 2026-04-14 10:58:57 -07:00
gsxdsm
4097d9d250 feat(FN-1021): stabilize terminal first-open bootstrap and WebSocket recovery
- Harden TerminalModal bootstrap to handle invalid/expired sessions on first open
- Add WebSocket reconnection logic for terminal sessions that become invalid mid-stream
- Create useTerminal hook with robust session lifecycle management
- Create useTerminalSessions hook for multi-session terminal coordination
- Add comprehensive tests for TerminalModal, useTerminal, and useTerminalSessions
- Document terminal first-open reliability behavior in dashboard README
2026-04-07 00:20:12 -07:00
gsxdsm
ec33691033 feat(FN-1019): reflow Changes-tab header stats and fix terminal scrollback
- Reflow Changes-tab header stats to a second line for better layout
- Add CSS styles for two-line header stats display
- Fix useTerminal hook to clear buffered scrollback after first subscriber replay
- Add tests for TaskChangesTab header stats rendering
- Update README description for Changes tab header
2026-04-05 22:58:28 -07:00
gsxdsm
b670d8b3e3 chore: update stuck task handling and dashboard tweaks 2026-04-05 21:36:18 -07:00
gsxdsm
bf1cb5df5c fix(FN-958): fix terminal idle disconnect with heartbeat tolerance
- Add heartbeat tolerance window to prevent false idle disconnects on terminal connections
- Increase client heartbeat interval from 30s to 45s for better idle tolerance
- Add session staleness detection on reconnect with idle state logging
- Add tests for heartbeat tolerance and client interval configuration
- Add changeset for patch release
2026-04-04 23:43:20 -07:00
gsxdsm
1ab1981557 fix(FN-912): move scrollback buffer reset to WebSocket onopen handler
Move initialBufferRef reset from the beginning of connect() to inside
ws.onopen to ensure the buffer is fresh only when the new connection is
established. This prevents a race condition where the buffer could be
cleared before the WebSocket is ready, causing scrollback data to be
lost when terminal tabs are switched.
2026-04-04 11:48:38 -07:00
gsxdsm
057bd30645 feat(FN-772): fix terminal startup and prompt delivery reliability
- Fix terminal service to ensure prompt is reliably delivered on startup and reconnect
- Add regression tests for terminal reconnect and first-paint behavior
- Remove dead code: unused global-settings tests, styles.css, Header/MissionManager tests
- Update terminal README with reliable prompt delivery guarantee documentation
- Add useTerminal hook tests and TerminalModal component tests
2026-04-03 09:16:34 -07:00
gsxdsm
df73a82917 fix(FN-771): reset disclosure state on task creation and preserve terminal sessions across reconnects
- Reset isDisclosureExpanded in QuickEntryBox resetForm so disclosure collapses after task creation
- Remove sticky disclosure persistence from QuickEntryBox component
- Preserve terminal sessions across transient WebSocket disconnects with buffer/replay
- Buffer and replay initial terminal state for prompt visibility on reconnect
- Update tests for non-persistent disclosure, terminal reconnect, and server routes
- Remove unused UsageIndicator tests and TaskDetailModal test cleanup
2026-04-03 06:47:40 -07:00
gsxdsm
ddf06bb7cf fix(FN-730): add missing ping handler in useTerminal WebSocket hook
- Add ping/pong heartbeat handler to useTerminal WebSocket hook
- Add tests for WebSocket heartbeat ping/pong behavior
- Remove unused usage tracking module and its tests
- Simplify usage.ts by removing dead code
2026-04-02 19:12:24 -07:00
gsxdsm
bf4b3429c7 feat(KB-058): complete Step 4 — create useTerminal hook with WebSocket support 2026-03-29 23:27:21 -07:00
gsxdsm
bfd3343be4 feat(KB-057): add interactive terminal to dashboard
- Add backend terminal API with SSE streaming for real-time output
- Create useTerminal hook with command history and navigation
- Refactor TerminalModal into interactive shell component
- Update App and Header for standalone terminal button
- Add CSS styles for terminal UI (prompts, output, spinner, welcome screen)
- Update tests for new terminal behavior
2026-03-29 21:09:57 -07:00
gsxdsm
0cbba475c2 feat(KB-057): complete Step 4 - Update App Integration for interactive terminal 2026-03-29 21:08:43 -07:00
gsxdsm
61303f1438 docs(KB-041): complete Step 6 — add refine feature to README and create changeset 2026-03-29 21:05:19 -07:00
gsxdsm
b8de98cc6d feat(KB-057): complete Step 3 — TerminalModal component with interactive shell UI 2026-03-29 20:59:31 -07:00
gsxdsm
287ce1d6d2 feat(KB-057): complete Step 2 — useTerminal hook with history, SSE streaming, and command execution 2026-03-29 20:57:18 -07:00