Handle failed optimistic user messages - #388
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6902063bc8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,18 @@ | |||
| import { MessageType } from "@/types/messages"; | |||
There was a problem hiding this comment.
Import existing message type to avoid build failure
The new utility imports MessageType from @/types/messages, but that module only exports Message (see src/frontend/src/types/messages/index.ts). Because this is a value import (not import type) and the project uses isolatedModules/noEmit, bundlers like Vite/esbuild will treat it as a runtime import and error with “export not found,” and TypeScript will also fail the build. Use the existing Message type (ideally via import type { Message }) or add a real MessageType export.
Useful? React with 👍 / 👎.
Motivation
Description
src/frontend/src/utils/optimisticMessageUtils.tswithmarkOptimisticMessageFailedto setoptimistic: falseandfailed: trueon a message object.src/frontend/src/modals/IOModal/playground-modal.tsxto create an optimistic user message (usinguuid) andaddMessageit before sending, and to callmarkOptimisticMessageFailedon catch to preserve the message state on error.addMessagelogic insrc/frontend/src/stores/messagesStore.tsto replace an existing optimistic/failed user message when the real user message arrives by matchingsender,session_id, andtext, preventing duplicate messages.setIsBuildingselector and updatesendMessagedependencies accordingly.Testing
Codex Task