Skip to content

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

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions