Commit Graph

45 Commits

Author SHA1 Message Date
gsxdsm
9e00a72d7d FN-5884: preserve quick chat session across reopens
Keep quick chat warm and restore the last opened conversation per project.

- persist the active quick chat session id in per-project local storage and restore it before falling back to latest activity
- retain in-memory quick chat state across close/reopen while resetting chat state correctly when the project changes
- add storage, hook, and FAB coverage for restored sessions, warm reopen behavior, and project switching; document the updated quick chat behavior

Files changed:
 docs/dashboard-guide.md                            |   3 +-
 packages/dashboard/app/components/QuickChatFAB.tsx |  29 ++++--
 .../app/components/__tests__/QuickChatFAB.test.tsx | 112 +++++++++++++++++++--
 .../__tests__/quickChatLastSessionStorage.test.ts  |  55 ++++++++++
 .../app/hooks/__tests__/useQuickChat.test.ts       |  70 +++++++++++++
 .../app/hooks/quickChatLastSessionStorage.ts       |  41 ++++++++
 packages/dashboard/app/hooks/useQuickChat.ts       |  25 +++++
 7 files changed, 319 insertions(+), 16 deletions(-)

Fusion-Task-Id: FN-5884

Fusion-Task-Lineage: 4d689611-1824-41db-8fc2-d543407316ff
2026-06-02 09:34:19 -07:00
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
Josemi Liebana
e018701fed fix(dashboard): wire scroll-to-top pagination instead of loading all messages
- Remove fetchAllMessagesInChat/fetchAllMessages helpers
- Keep limit:50 for initial load in useChat and useQuickChat
- Add IntersectionObserver sentinel at top of ChatView message list to
  trigger loadMoreMessages() when user scrolls to the top
- Keep stale-session guards (activeSessionRef checks) from original PR
- Tests: revert assertions back to { limit: 50 }
2026-05-26 21:48:35 +02:00
Josemi Liebana
64056b380d fix(dashboard): load all messages in chat on initial open (useChat + useQuickChat)
Both useChat (full ChatView) and useQuickChat (FAB) loaded only the first 50
messages on open and never paginated further. In useChat, loadMoreMessages
exists but ChatView never calls it — dead code. In useQuickChat, there was
no pagination at all.

Fix: add fetchAllMessagesInChat / fetchAllMessages helpers (paginate through
the API 200-msg cap), replace all limit:50 initial-load call sites, and
add stale-session guards via activeSessionRef before calling setMessages.
hasMoreMessages is set to false after a full initial load.

Forward-pagination path in useChat (isPaginationRequest=true) is preserved
for backward compat.
2026-05-22 14:51:46 +02:00
Fusion (runfusion.ai)
3fdd7775a1 fix(FN-5104): stabilize quickchat selectSession refresh and lint
Fusion-Task-Id: FN-5104
Fusion-Task-Lineage: e92a26cb-a930-442a-98be-6ace9f376e73
2026-05-19 01:09:30 -07:00
Fusion (runfusion.ai)
8540a0186d fix(FN-5104): complete Step 4 — mirror reattach recovery in useQuickChat
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)
7351852a61 feat(FN-4835): complete Step 4 — prefer streamed accumulator on done
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
8f5cf45e77 feat(FN-3855): add chat stream reattach, hybrid room responder policy, mesh
This merge introduces a model selector to the Insights view with favorites, provider filtering, and configured-only options (FN-3842/3843), alongside chat stream reattach support for dashboard chat recovery. It adds mesh lease recovery semantics and a manager to the engine for improved node resilien

Fusion-Task-Id: FN-3855
2026-05-09 13:21:47 -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
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
Fusion
c95517af31 feat(FN-3608): update dashboard chat documentation
Updated the dashboard chat documentation in the user guide with a minor addition.

Fusion-Task-Id: FN-3608
2026-05-06 19:55:55 -07:00
Timothy Laurent
be43bbb8ad fix(dashboard): prevent quick chat init race condition and infinite retry loop
Three interacting bugs caused "Failed to initialize chat" toast spam and
prevented fresh session creation:

1. Race condition in handleCreateFreshSession — setting chatMode/
   selectedAgentId before startFreshSession triggered the session-init
   useEffect, which called switchSession and resumed the old session
   instead of creating a new one. Fixed with skipNextSessionInitRef.

2. Infinite retry loop — shouldRetrySessionInit retried indefinitely
   when initializeSession failed, producing unbounded toast spam.
   Fixed with a 3-retry cap (initRetryCountRef).

3. Cascading re-renders — switchSession depended on activeSession in
   its closure, getting a new identity on every state change and
   re-triggering the consumer's useEffect. Fixed by reading
   activeSession from a ref instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-05 16:31:49 -07:00
gsxdsm
32c19af7d3 feat(chat): unify QuickChat backend path and consolidate render toggle
Backend
- chat.ts now routes both regular chat and QuickChat through
  createResolvedAgentSession instead of branching to createFnAgent for
  the no-runtime-hint case. This removes the divergent path where
  pi-ai's cleanupSessionResources(sessionId) could tear down resources
  the next generation depends on.
- sendMessage's finally only disposes the agent if it still owns the
  activeGenerations slot. A newer generation that has pre-empted us
  cleans up its own agent in its own finally — disposing here would
  yank the underlying CLI process out from under it.
- __setCreateFnAgent test helper now mirrors its mock into the
  createResolvedAgentSession slot so existing test setups still work
  after the unification.

Frontend
- Extract createChatStreamHandlers (RAF coalescing, accumulators,
  tool-call dedup, fallback handling) — useChat and useQuickChat were
  duplicating ~85 LOC each. Both now compose the shared factory.
- Move shared chat types into chatTypes.ts. The hooks re-export them
  for backward compatibility with existing consumers.
- Removed per-message Markdown/plain-text eye toggles. A single
  thread-level toggle in the chat header now flips every assistant
  bubble (including the streaming one) between rendered Markdown and
  plain text.
- Model-only chats hide the per-message agent identity row entirely;
  the model name is already in the thread header.

Tests
- Updated ChatView tests to reflect the new render-toggle contract
  (single header toggle drives all bubbles) and the model-only avatar
  suppression.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 11:04:48 -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
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
cf429431cc feat(FN-3058): session-first quick chat with heartbeat prompt improvements
This merge completes the session-first quick chat FAB flow (Step 5), restores the quick chat hook after fixing a styling regression, and fixes heartbeat prompt composition for autonomous agents. It also adds the planning mode question display with new-session reset, introduces new Droid CLI settings

Fusion-Task-Id: FN-3058
2026-05-01 12:12:39 -07:00
gsxdsm
442238196e chore: remove changeset negation rules from .gitignore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-30 08:36:32 -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
bdfb08f380 feat(FN-2911): improve chat attachment compose and preview UX
- Add attachment-first chat compose flow with paperclip picker, drag-and-drop, and paste support in ChatView input
- Render pending attachment preview chips with per-file remove actions and drag-over visual affordance
- Display sent message attachments with image/file presentation and accessible focus/interaction styling
- Update ChatView tests and icon mocks to cover attachment-only sends, file selection, and preview behavior

Fusion-Task-Id: FN-2911
2026-04-28 23:11:22 -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
Fusion
9d2a86c2c0 feat(FN-2874): add failed-task retry action to dashboard cards
- Wire onRetryTask from App through Board/Column/WorktreeGroup/ListView into TaskCard
- Add a Retry button with loading/disabled state to failed task error boxes in TaskCard
- Update failed-card styles to use design tokens and add retry button visual states
- Add TaskCard tests covering retry visibility, callback invocation, loading, and error toast behavior
- Add a patch changeset for @runfusion/fusion documenting the dashboard retry shortcut
2026-04-28 14:25:56 -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
fd3ef35e0d feat(FN-2152): render collapsed tool call previews in chat
- Emit tool_start/tool_end SSE events from dashboard chat backend and parse them in streaming client helpers
- Track in-flight and completed tool calls in useChat/useQuickChat to preserve tool output summaries alongside assistant messages
- Render collapsed tool call preview blocks in ChatView and QuickChatFAB with dedicated tokenized styles for compact output summaries
- Expand frontend and backend test coverage for SSE tool events, hook state transitions, and collapsed preview rendering behavior
- Add a changeset for @gsxdsm/fusion documenting the new tool-call display behavior
2026-04-20 08:30:24 -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
d32db262fe fix(FN-1995): preserve backend chat message order
- Remove unnecessary .reverse() calls when setting messages in useChat.
- Keep paginated prepend behavior intact by using backend chronological ordering directly.
- Update useChat tests to provide message fixtures in oldest-first order.
2026-04-17 06:01:00 -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
Fusion
cb9a58e0b1 feat(FN-1887): merge fusion/fn-1887 2026-04-16 10:58:19 -07:00
gsxdsm
414297d63a feat(FN-1857): merge fusion/fn-1857 2026-04-14 18:46:34 -07:00
gsxdsm
70f2af665a feat(FN-1680): merge fusion/fn-1680 2026-04-13 15:29:41 -07:00
gsxdsm
d2e9aafff9 feat(FN-1465): merge fusion/fn-1465 2026-04-12 07:00:49 -07:00