[PR #4420] [MERGED] OK fix(chat): chat resource drop review follow-ups #6370

Closed
opened 2026-10-23 04:09:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4420
Author: @Gunterlie
Created: 8/1/2026
Status: ✅ Merged
Merged: 8/1/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/chat-resource-drop-review


📝 Commits (3)

  • 52fbf05 fix(chat): harden the chat resource assignment event boundary
  • 1e63559 fix(agents): remove the duplicate drag handle on agent cards
  • 5d7750b fix(chat): run both drop entry points through one assignment runner

📊 Changes

5 files changed (+26 additions, -28 deletions)

View changed files

📝 packages/client/src/components/chat/ChatArea.tsx (+5 -1)
📝 packages/client/src/components/chat/ChatResourceDropOverlay.tsx (+19 -7)
📝 packages/client/src/components/panels/AgentsPanel.tsx (+1 -18)
📝 packages/client/src/lib/chat-resource-drag.ts (+1 -1)
📝 packages/client/src/localization/locales/en.json (+0 -1)

📄 Description

Review follow-ups to #4413. Supersedes #4419, which is folded in here.

Why

Unhandled rejection at the event boundary. applyAction is kicked off from a window event listener with void ... .finally(...). Its own try/catch only wraps the mutations, so a rejection from showConfirmDialog or the available-resource lookups escaped as an unhandled rejection and the user saw nothing.

Agent handoff was not scoped to a chat. The setup handoff fired regardless of whether the drop's chat was still active. Switching chats between the drop and the metadata write dispatched a request that ChatArea acted on for the new chat, opening its settings drawer even though takePendingChatAgentSetupIds had nothing for it.

Two drag handles on agent cards. #4413 added a TouchDragHandle to agent cards, which already carried their own decorative grip — hover-revealed, [@media(pointer:coarse)]:hidden, no handler. Hovering an agent card on desktop showed both.

What

  • Catch rejections at the listener and surface them with the existing failed toast, keeping the setAssigning(false) cleanup in finally.
  • Only call requestChatAgentSetup while the drop's chat is still active.
  • Carry chatId on CHAT_RESOURCE_AGENT_SETUP_EVENT and have the ChatArea listener ignore handoffs for other chats.
  • Remove the decorative grip from agent cards and keep TouchDragHandle, which already covers fine and coarse pointers like the other six library panels. The handle reuses the existing ui.panels.agentcard.dragAgent key, so the duplicate key added in #4413 is dropped.

One small behavior difference from that last point: the old grip was hidden in selection mode, the shared handle is not — again matching the other panels.

Skipped from the review

  • Scoping the pending panel restore to a chat id. The right panel is not chat-scoped — it holds the global library — so reopening it after a chat switch shows the same panel the user was already dragging from. Adding a chat id to that state guards nothing user-visible.
  • Gating the agent card's native grip on !onTouchStart. The button is removed outright instead, which is less code and matches the other panels.

Validation

  • pnpm check
  • pnpm localization:check
  • pnpm regression:chat-resource-drop

Test plan

  • Manually verify a persona drop, then Cancel on the replacement dialog, leaves no console error and no stuck state
  • Manually verify a failed assignment surfaces an error toast rather than failing silently
  • Manually verify dropping an agent still opens the settings drawer with its setup modal
  • Manually verify switching chats immediately after an agent drop does not open the new chat's settings drawer
  • Manually verify hovering an agent card on desktop shows exactly one drag handle
  • Manually verify the native desktop drag of an agent card still works
  • Manually verify the handle is visible on a touch device and still starts a touch drag
  • Manually verify agent cards in selection mode look right with the handle present

Summary by CodeRabbit

  • Bug Fixes

    • Improved chat agent setup handling so requests apply only to the intended active chat.
    • Prevented setup handoffs when the assigned chat is no longer active.
    • Added clearer error notifications when chat assignment requests are rejected.
  • UI Improvements

    • Simplified agent cards by removing the desktop drag-handle button while retaining touch-based dragging.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4420 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/1/2026 **Status:** ✅ Merged **Merged:** 8/1/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/chat-resource-drop-review` --- ### 📝 Commits (3) - [`52fbf05`](https://github.com/Pasta-Devs/Marinara-Engine/commit/52fbf05cc35b9a6912672fd95dc93525efb3e83d) fix(chat): harden the chat resource assignment event boundary - [`1e63559`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e63559043f3661b6d11dc531a15c960ff2f67d5) fix(agents): remove the duplicate drag handle on agent cards - [`5d7750b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5d7750b973572b8f1fa9750ca909a3f68148eae1) fix(chat): run both drop entry points through one assignment runner ### 📊 Changes **5 files changed** (+26 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatArea.tsx` (+5 -1) 📝 `packages/client/src/components/chat/ChatResourceDropOverlay.tsx` (+19 -7) 📝 `packages/client/src/components/panels/AgentsPanel.tsx` (+1 -18) 📝 `packages/client/src/lib/chat-resource-drag.ts` (+1 -1) 📝 `packages/client/src/localization/locales/en.json` (+0 -1) </details> ### 📄 Description Review follow-ups to #4413. Supersedes #4419, which is folded in here. ## Why **Unhandled rejection at the event boundary.** `applyAction` is kicked off from a `window` event listener with `void ... .finally(...)`. Its own `try/catch` only wraps the mutations, so a rejection from `showConfirmDialog` or the available-resource lookups escaped as an unhandled rejection and the user saw nothing. **Agent handoff was not scoped to a chat.** The setup handoff fired regardless of whether the drop's chat was still active. Switching chats between the drop and the metadata write dispatched a request that `ChatArea` acted on for the *new* chat, opening its settings drawer even though `takePendingChatAgentSetupIds` had nothing for it. **Two drag handles on agent cards.** #4413 added a `TouchDragHandle` to agent cards, which already carried their own decorative grip — hover-revealed, `[@media(pointer:coarse)]:hidden`, no handler. Hovering an agent card on desktop showed both. ## What - Catch rejections at the listener and surface them with the existing `failed` toast, keeping the `setAssigning(false)` cleanup in `finally`. - Only call `requestChatAgentSetup` while the drop's chat is still active. - Carry `chatId` on `CHAT_RESOURCE_AGENT_SETUP_EVENT` and have the `ChatArea` listener ignore handoffs for other chats. - Remove the decorative grip from agent cards and keep `TouchDragHandle`, which already covers fine and coarse pointers like the other six library panels. The handle reuses the existing `ui.panels.agentcard.dragAgent` key, so the duplicate key added in #4413 is dropped. One small behavior difference from that last point: the old grip was hidden in selection mode, the shared handle is not — again matching the other panels. ## Skipped from the review - **Scoping the pending panel restore to a chat id.** The right panel is not chat-scoped — it holds the global library — so reopening it after a chat switch shows the same panel the user was already dragging from. Adding a chat id to that state guards nothing user-visible. - **Gating the agent card's native grip on `!onTouchStart`.** The button is removed outright instead, which is less code and matches the other panels. ## Validation - [ ] `pnpm check` - [ ] `pnpm localization:check` - [ ] `pnpm regression:chat-resource-drop` ## Test plan - [ ] Manually verify a persona drop, then Cancel on the replacement dialog, leaves no console error and no stuck state - [ ] Manually verify a failed assignment surfaces an error toast rather than failing silently - [ ] Manually verify dropping an agent still opens the settings drawer with its setup modal - [ ] Manually verify switching chats immediately after an agent drop does not open the new chat's settings drawer - [ ] Manually verify hovering an agent card on desktop shows exactly one drag handle - [ ] Manually verify the native desktop drag of an agent card still works - [ ] Manually verify the handle is visible on a touch device and still starts a touch drag - [ ] Manually verify agent cards in selection mode look right with the handle present <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved chat agent setup handling so requests apply only to the intended active chat. * Prevented setup handoffs when the assigned chat is no longer active. * Added clearer error notifications when chat assignment requests are rejected. * **UI Improvements** * Simplified agent cards by removing the desktop drag-handle button while retaining touch-based dragging. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09:45 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6370
No description provided.