fix(acp): Optimistic user messages and PATH fix for macOS#50
Conversation
User messages sent via `sendPrompt` did not appear in the chat history because the frontend relied entirely on the `acp:user-message-saved` Tauri event. If the event was lost or delayed, the message never showed. - Add `addOptimisticUserMessage` to `useSessionMessages` that immediately appends a user message with a temp `optimistic-` prefixed ID - Replace optimistic message with persisted version when the backend event arrives (dedup by content match) - Call optimistic add in `sendPrompt` before backend invoke, skip for slash commands
The previous approach removed the optimistic message and appended the persisted version at the end of the array, which broke chronological order when assistant messages had already been added after it. Now uses `findIndex` + in-place replacement to keep the message at its correct position in the chat history.
GUI apps on macOS inherit a minimal PATH that doesn't include Homebrew, nvm, or fnm paths. This caused `node` not to be found when spawning copilot/claude binaries (exit code 127). Add `fix-path-env` crate from tauri-apps which sources the user's login shell PATH at startup, fixing all 7 spawn points at once.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis pull request introduces optimistic message handling to the Tauri application. It adds a path environment fix dependency, applies environment corrections at startup, and implements optimistic user message creation that reconciles with persisted messages when they arrive from the server. Changes
Sequence DiagramsequenceDiagram
participant User
participant ActiveSessionView
participant useSessionMessages
participant MessageState as Message State
participant Server
User->>ActiveSessionView: Type & submit message
ActiveSessionView->>useSessionMessages: addOptimisticUserMessage(text)
useSessionMessages->>MessageState: Add optimistic message<br/>(id: "optimistic-*")
MessageState-->>ActiveSessionView: Update UI immediately
ActiveSessionView-->>User: Display message in chat
par Send to Server
ActiveSessionView->>Server: POST message
and Wait for Response
Server-->>useSessionMessages: Persisted message arrives<br/>(real id, content)
end
useSessionMessages->>MessageState: Find & replace matching<br/>optimistic message
MessageState-->>User: Update with persisted message ID
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
acp:user-message-savedTauri event (which could be lost or delayed). When the backend event arrives, the optimistic message is replaced in-place to preserve chronological order.node(and copilot/claude binaries) not to be found (exit code 127). Addedfix-path-envcrate from tauri-apps to source the user's login shell PATH at startup.Test plan
end_turnnpm testpasses (115 tests)Summary by CodeRabbit
Release Notes
New Features
Bug Fixes