Skip to content

fix: agent WSS send while connecting + prompt input draft persistence - #6191

Merged
timothycarambat merged 2 commits into
masterfrom
fix/frontend-error-chore
Aug 26, 2026
Merged

fix: agent WSS send while connecting + prompt input draft persistence#6191
timothycarambat merged 2 commits into
masterfrom
fix/frontend-error-chore

Conversation

@timothycarambat

Copy link
Copy Markdown
Member

Pull Request Type

  • ✨ feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

none

Description

Fixes a handful of small frontend bugs around new agent chats and prompt input draft persistence:

Agent websocket InvalidStateError on new agent chat
Session start re-triggers fetchReply (via setLoadingResponse(true)) while the socket is still CONNECTING, causing websocket.send() to throw. The send was also redundant — the server begins working on the invocation prompt itself on connect. We now skip relaying feedback unless the socket is OPEN.

Cannot read properties of null (reading 'selectionStart')
The debounced undo-stack snapshot in PromptInput can fire after the component remounts (empty→chat transition), when textareaRef is null. Added a guard.

Prompt input draft persistence fixes

  • Drafts are now hydrated per thread/workspace key, so typed text no longer carries over when navigating between threads, and the first message on a new thread is no longer re-saved/restored into the input while the response streams.
  • The storage hook now accepts slug props for param-less routes (Home), where drafts were previously all saved under the literal key undefined.
  • Clearing a draft cancels any pending debounced write so a submit can no longer be raced by a stale write that resurrects the sent text.
  • Empty drafts are deleted instead of stored as "" (existing empty entries are pruned on the next write).
  • The Home page submit now clears its local draft since the message is replayed via PENDING_HOME_MESSAGE.

Visuals (if applicable)

Additional Information

Minor behavior change: drafts typed on the bare Home page before a workspace is selected are no longer persisted (they previously went into a shared undefined bucket).

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

- Skip relaying feedback over the agent websocket until it is OPEN - session
  start re-triggers fetchReply while the socket is still connecting and the
  server already handles the invocation prompt itself
- Guard debounced undo-stack snapshot against unmounted PromptInput
- Scope prompt drafts correctly per thread/workspace: hydrate input on key
  change so drafts don't leak across threads, accept slug props on param-less
  routes (Home), cancel pending writes on draft clear, and stop storing
  empty drafts
@timothycarambat timothycarambat added PR: Ready for QA Indicates that a PR is ready for QA and the GH image may build the image and removed PR: Ready for QA Indicates that a PR is ready for QA and the GH image may build the image labels Aug 26, 2026
@timothycarambat
timothycarambat merged commit 4ade840 into master Aug 26, 2026
4 checks passed
@timothycarambat
timothycarambat deleted the fix/frontend-error-chore branch August 26, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant