web: Clear stale submitted prompts on session reload#50
Merged
Conversation
Devaipod hosts the OpenCode web UI in an iframe that is destroyed when the user switches to a different pod. If the switch happens while the agent is still processing, the per-session prompt state persisted in localStorage may retain the already-submitted text. When the user returns and the iframe is recreated, the stale prompt reappears in the input box. This is specific to devaipod's iframe-based pod switching -- upstream OpenCode does not encounter this because the page is not torn down mid-processing. The workaround lives in the vendored UI code for now because that is where the per-session prompt persistence lives. Extract isStaleSubmittedPrompt() into helpers.ts as a pure function: on session mount, if the session is idle, the prompt has content, and that content matches the last user message text, treat it as leftover from a prior submission and clear it. Legitimate unsent drafts are preserved because they won't match any sent message. Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: arewm <arewm@users.noreply.github.com>
The agent health check uses `nc -z` in the workspace container to detect whether the opencode server is listening. When a custom image is used that lacks netcat (e.g. the devaipod image itself), every poll silently fails, the 60-second timeout fires, and the initial task message is never sent — leaving the agent idle with zero sessions despite being healthy. Fall back to `curl` when `nc` is unavailable, since curl is present in a wider range of images. Assisted-by: Claude Code (Opus 4.6) Signed-off-by: arewm <arewm@users.noreply.github.com>
Collaborator
Author
|
@cgwalters, I know that this is a patch on the vendored opencode code, but I am proposing this because it is more of an issue with our use of opencode than it is with opencode itself -- I don't know if we are using opencode as they intended. |
cgwalters
approved these changes
Apr 8, 2026
cgwalters
left a comment
Owner
There was a problem hiding this comment.
Yeah, makes sense. Bigger picture...what I'm thinking here is we may need to head towards a more custom frontend using agent-client-protocol.
Collaborator
Author
|
I proposed something in #52 . I am going to kick off an implementation of the first couple phases of that to see how it looks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Devaipod hosts the OpenCode web UI in an iframe that is destroyed when the user switches to a different pod. If the switch happens while the agent is still processing, the per-session prompt state persisted in localStorage may retain the already-submitted text. When the user returns and the iframe is recreated, the stale prompt reappears in the input box.
This is specific to devaipod's iframe-based pod switching -- upstream OpenCode does not encounter this because the page is not torn down mid-processing. The workaround lives in the vendored UI code for now because that is where the per-session prompt persistence lives.
Extract isStaleSubmittedPrompt() into helpers.ts as a pure function: on session mount, if the session is idle, the prompt has content, and that content matches the last user message text, treat it as leftover from a prior submission and clear it. Legitimate unsent drafts are preserved because they won't match any sent message.
Assisted-by: OpenCode (claude-opus-4-6)