Commit Graph

32 Commits

Author SHA1 Message Date
gsxdsm
70e7a6b30a FN-5852: persist queued chat messages across navigation
Keep queued follow-up chat drafts across session switches, reloads, and view re-entry.

- persist queued pending-message text per chat session in shared localStorage helpers
- restore and flush queued follow-up messages in full Chat when returning to an active session
- restore and flush queued follow-up messages in Quick Chat and cover the recovery path with tests
- document queued-message persistence behavior in the dashboard guide

Files changed:
 docs/dashboard-guide.md                            |   2 +
 .../dashboard/app/hooks/__tests__/useChat.test.ts  | 119 +++++++++++++++++-
 .../app/hooks/__tests__/useQuickChat.test.ts       | 135 +++++++++++++++++++++
 .../app/hooks/chatPendingMessageStorage.ts         |  48 ++++++++
 packages/dashboard/app/hooks/useChat.ts            |  38 ++++++
 packages/dashboard/app/hooks/useQuickChat.ts       |  35 ++++++
 6 files changed, 376 insertions(+), 1 deletion(-)

Fusion-Task-Id: FN-5852

Fusion-Task-Lineage: 1cddfb19-7e02-40e5-b373-5d593dfcfe2a
2026-06-01 22:11:30 -07:00
gsxdsm
1207dac52d FN-5710: flush queued first quick chat send after session init
Ensure the first Quick Chat message reliably streams even when a stale sendMessage closure sees no active session.

- trigger a microtask flush for queued pre-session sends when a session is already active and no stream is running
- preserve existing streaming guards so flush only runs when safe
- add regression coverage for stale-closure first-send flow to verify stream start and completion behavior

Files changed:
 .../app/hooks/__tests__/useQuickChat.test.ts       | 47 ++++++++++++++++++++++
 packages/dashboard/app/hooks/useQuickChat.ts       | 12 ++++++
 2 files changed, 59 insertions(+)

Fusion-Task-Id: FN-5710

Fusion-Task-Lineage: a4b32867-dedd-40f5-b6a8-3c71b9f7dee1
2026-05-29 22:36:45 -07:00
gsxdsm
b78736ce58 FN-5709: queue initial quick chat send until session is ready
Ensure a user's first quick-chat message is preserved and sent once session initialization finishes.

- queue pre-session text sends as promise-backed pending work instead of returning early
- flush queued text after session activation and wire completion/rejection to the original send promise
- clear queued completion state on stream reset paths and add regression coverage for first-send-before-init flow

Files changed:
 .../app/hooks/__tests__/useQuickChat.test.ts       | 34 ++++++++++++++++++++
 packages/dashboard/app/hooks/useQuickChat.ts       | 37 ++++++++++++++++++++--
 2 files changed, 69 insertions(+), 2 deletions(-)

Fusion-Task-Id: FN-5709

Fusion-Task-Lineage: 7598aa93-d127-4602-9571-02bc2a0cc5da
2026-05-29 21:56:53 -07:00
Josemi Liebana
6e9ab0e989 feat(dashboard): load latest messages first with order=desc pagination
- Add order?: 'asc' | 'desc' to ChatMessagesFilter (core)
- Route handler passes order param from query string
- Initial load requests order=desc and reverses for display
- loadMoreMessages uses before cursor instead of offset
- hasMoreMessages starts false (prevents IntersectionObserver race)
- ChatView IntersectionObserver guards against messagesLoading
2026-05-27 11:57:21 +02:00
Fusion (runfusion.ai)
0e30f85de7 test(FN-5104): complete Step 5 — add reattach regression coverage
Fusion-Task-Id: FN-5104
Fusion-Task-Lineage: e92a26cb-a930-442a-98be-6ace9f376e73
2026-05-19 01:09:30 -07:00
Fusion (runfusion.ai)
c6687bec09 feat(FN-4943): complete Step 2 — mirror stop flush behavior in useQuickChat
Fusion-Task-Id: FN-4943
Fusion-Task-Lineage: 67dd5c2b-0b44-43dd-a016-0bff858ec4b9
2026-05-18 02:06:32 -07:00
Fusion (runfusion.ai)
f8457d1130 test(FN-4835): cover streamed-text precedence in chat hooks
Fusion-Task-Id: FN-4835
Fusion-Task-Lineage: 09eb6339-a476-4cf1-b7e5-e60fa6c263ce
2026-05-17 00:14:58 -07:00
Fusion
1abbf2f992 feat(FN-4381): flush queued chat messages on recovery completion
Fixes chat hooks to flush queued messages when recovery completes, preventing stale messages from lingering in useChat and useQuickChat; includes tests for both hooks.

Fusion-Task-Id: FN-4381
2026-05-13 13:50:03 -07:00
Fusion
c3e87e5eec feat(FN-4350): complete Step 3 — mirror reconnect logic in useQuickChat
Fusion-Task-Id: FN-4350
Fusion-Task-Lineage: 11fff2c2-1cd1-4562-9b01-032a15217479
2026-05-13 12:26:07 -07:00
Fusion
9b531dab65 feat(FN-4056): remove queued warning toasts
Removed queued warning toasts from chat queueing flows in `useChat` and `useQuickChat` hooks, with corresponding test coverage for the queueing behavior without the toast.

Fusion-Task-Id: FN-4056
2026-05-11 21:48:26 -07:00
Fusion
d5f12a5c95 feat(FN-3927): persist and restore durable chat recovery state
- Persist in-flight chat generation snapshots in core chat store types and DB plumbing
- Restore durable recovery state through dashboard chat manager and chat hooks on reload
- Add coverage for chat store persistence and chat/useQuickChat recovery behavior
- Document durable chat recovery architecture and dashboard behavior

Fusion-Task-Id: FN-3927
2026-05-10 15:33:24 -07:00
Fusion
80f65de994 feat(FN-3843): add chat stream reattach support
Adds the changeset for FN-3843, completing the chat stream reattach feature for the `@runfusion/fusion` CLI package.

Fusion-Task-Id: FN-3843
2026-05-09 10:44:29 -07:00
Fusion
ed6d2e2423 fix(FN-3838): suppress suspended-tab chat load failure toasts
- Add visibility suspension hook to detect tab-hidden periods during chat loading
- Update useChat and useQuickChat to suppress load-failed toasts triggered by tab suspension resumes
- Expand hook test coverage for suspension timing and toast suppression behavior
- Add plugin authoring documentation updates and include FN-3838 changeset

Fusion-Task-Id: FN-3838
2026-05-09 10:31:05 -07:00
Fusion
b080ea0bc5 fix(FN-3760): add SSE first-event watchdog for legacy chat streams
- Add a first-event watchdog in legacy chat SSE handling to prevent hangs before initial stream data
- Cover watchdog behavior with legacy chat stream API tests
- Add hook-level regression tests for useChat and useQuickChat first-send stream scenarios
- Include a changeset for @runfusion/fusion patch release

Fusion-Task-Id: FN-3760
2026-05-08 20:45:48 -07:00
Fusion
1011dc5eab feat(FN-3759): fix stale refs in useChat and useQuickChat queue flush handl
Merged branch adds FN-3759 queue flush ref fixes for `useChat` and `useQuickChat` hooks (with expanded regression test coverage), extracts the roadmap UI into a standalone plugin with schema hook and store bootstrap, ships FN-3281 review revisions with dashboard/plugin integration updates, and resol

Fusion-Task-Id: FN-3759
2026-05-08 17:52:27 -07:00
Timothy Laurent
8853472c2c test(dashboard): add regression tests for quick chat init fixes
Six new tests covering the three bugs fixed in the previous commit:

- Retry limit: stops showing toasts after 3 consecutive failures,
  resets counter on success
- Skip flag: startFreshSession sets/clears skipNextSessionInitRef,
  creates new session even when existing one exists
- Ref stability: switchSession reads activeSession from ref so it
  correctly detects "same session" and skips re-initialization

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-05 16:43:54 -07:00
Fusion
b8a32f8765 feat(FN-3430): preserve and consume final assistant done payload
This merge adds done-payload snapshot handling across the chat system (FN-3430), normalizing how final assistant messages are preserved and consumed in the dashboard hooks, plus it normalizes dashboard mailbox and user identity for inter-agent messaging (FN-3484) and introduces plugin workflow step

Fusion-Task-Id: FN-3430
2026-05-05 06:42:18 -07:00
gsxdsm
a3ce8e1f8e fix(FN-XXX): unify codex auth and chat fallback 2026-05-03 23:08:05 -07:00
Fusion
1ff52a6f83 feat(FN-3336): recover chat isGenerating state on session load to prevent U
Merges FN-3336 to recover chat streaming state on page reload — adds `isGenerating()` and `getGeneratingSessionIds()` to `ChatManager`, enriches the session API to surface active-streaming sessions, and makes `useChat` and `useQuickChat` hooks restore the `isGenerating` flag when loading existing se

Fusion-Task-Id: FN-3336
2026-05-03 16:51:01 -07:00
Fusion
0948be42fd feat(FN-3212): remove runtime memory-backend side-load, add regression test
Merged FN-3207, FN-3212, and FN-3242: removed runtime memory-backend side-loading in core, added comprehensive regression tests for QuickChat, chat routes, and SSE streams, and documented compact mobile chat dialogs in the dashboard guide. The refactor in `project-memory.ts` reduces complexity while

Fusion-Task-Id: FN-3212
2026-05-03 07:37:03 -07:00
Fusion
c729527fcc feat(FN-3062): add /clear command to Chat and Quick Chat, fix session banne
The merge adds a `/clear` command to both the Chat view and Quick Chat that clears transient chat state on session resets, with tests for all new hooks and components. It also persists session banner dismissals via a new `useSessionBannerPref` hook, adds a hide-banner setting, and preserves planning

Fusion-Task-Id: FN-3062
2026-05-01 13:20:50 -07:00
Fusion
50d194e27b feat(FN-2910): merge fusion/fn-2910
Commits merged:
- merge fusion/fn-2910

Fusion-Task-Id: FN-2910
2026-04-29 10:20:34 -07:00
Fusion
b248ffc6e6 fix(FN-2904): preserve quick chat streaming state on resume
- Keep active streaming responses alive when resuming an existing quick chat session instead of resetting stream state
- Update useQuickChat session-resume logic to only restart waiting indicators when appropriate
- Adjust QuickChatFAB waiting indicator behavior so it reflects real in-flight assistant activity
- Add focused hook and component tests covering same-session resume and waiting-indicator regressions

Fusion-Task-Id: FN-2904
2026-04-28 19:43:29 -07:00
gsxdsm
3031d05a68 fix(dashboard): clear all 661 test-file type errors
Production typecheck (tsconfig.json + tsconfig.app.json) was already
clean, but a third config that includes test files surfaced 661 errors
across 60+ test files — accumulated drift between mock fixtures and
production types. Six parallel typescript-pro agents fixed every one
without touching production code.

Per-scope before/after (errors → 0):
  ChatView                                                     183
  Mailbox + Agent suite (5 files)                              156
  Task / Modal suite (6 files)                                 127
  App + small components (12 files)                             96
  Hooks + api/auth (8 files)                                    48
  Long tail (32 files)                                          51
  -----------------------------------------------------------------
  Total                                                        661

Major fix categories:
- Untyped state objects inferring `never[]` / `null` literals (root
  cause of ~120 errors in ChatView alone — added a single
  `UseChatReturn` annotation)
- Mock objects missing fields that became required: `WorkflowStep.mode`,
  `ChatMessage.thinkingOutput / metadata`, `ChatSession.projectId`,
  `Task.log`, `ProjectHealth` fields, `PtyTerminalSessionInfo.createdAt`,
  `Agent.metadata`, `InboxResponse.total`, etc.
- Mock objects with stale fields that no longer exist:
  `AgentBudgetStatus.budgetPeriod`, `truncated` on log responses,
  `OutboxResponse.unreadCount`, `MergeResult.source/target/details`
- Modal props that became required (e.g. `PlanningModeModal.onTasksCreated`)
- String literals not in narrowed unions (`Column`, `WorkflowStepPhase`,
  `InsightStatus`, `AgentLogType`, etc.)
- `querySelector` returning `Element` cast to `HTMLElement` for
  `@testing-library/react`'s `within()`
- Vitest mock typing: `.mock.calls` access needing `vi.mocked(...)`,
  zero-param tuple handling, generic `vi.fn(() => [])` inferring
  `never[]`

Helpers introduced in test files (no shared infra):
- `makeSettings(overrides)` in ModelSelectorTab.test.tsx
- `makePromptOverrides(overrides)` in AgentPromptsManager.test.tsx
- `FileBrowserTestOverrides` type alias in FileBrowser.test.tsx
- `makeInboxResponse / makeOutboxResponse` in MailboxView.test.tsx

Verification:
- tsc -p tsconfig.json:        exit 0
- tsc -p tsconfig.app.json:    exit 0
- tsc -p tsconfig.test-check.json (new — includes test files): exit 0
- vitest run:                  9639 / 9641 (2 pre-existing failures
                               in terminal-mobile-keyboard-layout.test.ts
                               unrelated to this work; verified via
                               `git stash` + run on clean HEAD)

Adds packages/dashboard/tsconfig.test-check.json to keep this regression
guard available locally — same as tsconfig.app.json minus the test
exclude.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 19:59:52 -07:00
gsxdsm
83630a5193 feat(FN-2449): merge fusion/fn-2449 2026-04-24 08:55:02 -07:00
Fusion
ad9224c9b9 feat(FN-2306): add fresh quick-chat thread creation flow
- Add startFreshSession to useQuickChat so users can explicitly create a new persisted session for the current agent/model target
- Refactor session creation into a shared helper and track current session target to support fresh-thread creation without changing selection
- Add a New chat action to the QuickChatFAB header that starts a fresh thread while preserving active model/agent context
- Update quick chat hook/component tests to verify new-session behavior and message streaming targets
- Add header action styling for the new quick-chat controls
2026-04-23 10:24:19 -07:00
Fusion
19d62b41f5 refactor(FN-2162): rename kb-agent identifiers to fn-agent
- Rename core loader, dashboard server chat/planning routes, and frontend agent IDs/storage keys from kb-agent to fn-agent naming
- Update dashboard hooks and components (agent list, chat view, quick chat) to use the new fn agent key prefixes consistently
- Refresh engine, dashboard, core, and CLI tests/mocks to remove remaining kb-agent route and temp prefix references
- Update storage/gap-analysis docs to reflect fn agent key names and add a @gsxdsm/fusion patch changeset for the rename
2026-04-19 20:48:14 -07:00
gsxdsm
49fea9ede7 feat(FN-2017): merge fusion/fn-2017 2026-04-18 23:22:20 -07:00
Fusion
a63bca856e fix(FN-2060): preserve quick chat state on streaming errors
- Trigger onError for unexpected AbortError failures in streamChatResponse while ignoring user-initiated closes
- Keep quick chat user messages on send errors, reset streaming state, and reload messages from the server
- Persist partial assistant output (including thinking-only fallbacks) when AI processing fails mid-stream
- Add regression coverage for stream abort handling, quick chat error UX, and partial-response persistence
2026-04-18 20:56:12 -07:00
Fusion
57736beb06 fix(FN-2011): keep chat input responsive during streaming
- Make useChat and useQuickChat sendMessage synchronous and update consumers to call it without awaiting
- Allow ChatView and QuickChatFAB inputs to remain editable while responses stream
- Keep quick chat send disabled during active streaming to prevent concurrent sends
- Add hook and component tests for synchronous sendMessage and non-blocking input behavior
2026-04-17 15:38:32 -07:00
Fusion
43f0e279f5 feat(FN-2006): split quick chat flows into agent and model modes
- Add explicit agent/model mode toggles to QuickChatFAB and NewChatDialog
- Update session target logic so model mode starts chats with the KB agent while agent mode uses selected agents
- Clear opposite selections when switching modes and adjust placeholders/disabled states to match active mode
- Expand ChatView and QuickChatFAB tests to cover toggle visibility, mode switching, and session payload behavior
- Add useQuickChat coverage to verify agent-only switchSession calls omit model parameters
2026-04-17 15:02:54 -07:00
Fusion
214a831c2f feat(FN-1993): enable model-targeted quick chat sessions
- Add KB agent fallback support in useQuickChat and allow switching sessions by agent plus model override
- Introduce session target key matching so same target reloads messages while different model selections create distinct sessions
- Update QuickChatFAB to lazy-load models, show model override UI, and keep quick chat usable for model-only conversations
- Add and expand hook/component tests to cover model selection flows, KB session creation, and default-model reset behavior
2026-04-17 03:47:21 -07:00