Skip to content

GUI: New conversation auto-fills with previous conversation's first instruction (workspace prompt not cleared) #34393

Closed

Description

@ngleoi

Bug Description

When creating a new conversation in the OpenCode GUI (desktop app), the input dialog automatically fills with the first instruction (first user message) from the previous conversation.

Root Cause Analysis

After investigating the desktop app source code (version 1.17.11), the root cause has been identified:

The workspace-level prompt state is not cleared after a session is created from it.

Technical Details

OpenCode uses a persisted prompt state system with different scopes:

  • Session scope: session:{sessionID}:prompt ¡ª used when on a session page (has params.id)
  • Workspace scope: workspace:prompt ¡ª used when on a new session page (no params.id)
  • Draft scope: draft:{draftID}:prompt ¡ª used in the new layout draft flow

The bug flow (old layout, and potentially new layout in some cases):

  1. User types in the new conversation input box ¡ú prompt saved under workspace:prompt
  2. User submits the message ¡ú a session is created, submission.retarget() switches the prompt target from workspace scope to the new session scope
  3. submission.clear() ¡ú only resets the session-scoped prompt, NOT the workspace-scoped prompt
  4. User clicks "New Conversation" ¡ú workspace page loads ¡ú workspace:prompt is restored from disk with the old content ¡ú input box is pre-filled!

Key Code Locations (desktop app v1.17.11)

  • out/renderer/assets/main-D_cwiNV1.js:
    • createPromptSubmissionState (around line 112895) ¡ª clear() only resets the retargeted target, not the original workspace prompt
    • promptTarget() (around line 85207) ¡ª determines storage key based on scope
    • Persist.serverScoped() (around line 62940) ¡ª routes to serverWorkspace when no session ID
    • Submission flow (around line 113160-113180) ¡ª retarget() switches target but doesn't clear workspace scope
    • Session compose submit handler (around line 113204-113208) ¡ª clearInput doesn't reset workspace prompt

Suggested Fix

The workspace-level prompt state should be reset after it's been used to create a session. Options:

  1. In the clearInput() callback after successful session creation, also call prompt.reset() for the workspace scope
  2. In SessionRoute/Page component when params.id transitions from undefined to a session ID, clear the workspace-level prompt
  3. When navigating back to a workspace page (no params.id), force-reset the workspace prompt if it was previously used

Steps to Reproduce

  1. Open OpenCode desktop GUI
  2. Click "New Conversation"
  3. Type a message in the input box
  4. Submit the message (wait for the AI response)
  5. Click "New Conversation" again
  6. Expected: Empty input box
  7. Actual: Input box is pre-filled with previously typed text

Environment

  • OpenCode version: 1.17.11 (desktop)
  • OS: Windows 11

Activity

  1. github-actions commented on Jun 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

  2. ngleoi commented on Jun 29, 2026

    @ngleoi
    Author

    Thanks for the heads-up! I looked into #34069, and while the symptom is similar (new session inheriting previous content), there are a few differences worth noting:

    • Interface difference: New session inherits and submits the current session's first prompt instead of starting blank #34069 is about the TUI (/new command), while this issue is about the GUI desktop app (Electron, "New Conversation" button).
    • Root cause analysis: This issue provides a detailed code-level root cause trace through createPromptSubmissionState ??promptTarget ??retarget ??clear, specifically identifying that workspace:prompt is the stale key that doesn't get reset after a session is created.

    That said, the underlying mechanism is likely the same shared state management bug ??both TUI and GUI rely on the same createPromptSubmissionState / promptTarget / Persist plumbing. A fix in the shared prompt-clearing logic would probably resolve both.

    Happy to close this as a duplicate of #34069 if the maintainers prefer, or keep it open as a companion tracking the GUI-specific manifestation. Either way, the root cause analysis here should help inform the fix. ??

  3. kagura-chen commented on Jun 29, 2026

    @kagura-chen
    Contributor

    Hi 👋 I'd like to work on this.

    The root cause analysis in the issue body is spot on — clearInput() resets the session-scoped prompt (after navigation changes the active scope), but the workspace-scoped prompt persists on disk and gets restored on the next "New Conversation" click.

    The fix is to also explicitly reset the workspace-scoped prompt when a new session is created from it, by calling prompt.reset({ dir: base64Encode(projectDirectory) }) in clearInput().

    Happy to submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions