Skip to content

copilot: session detection misses v0.0.342+ session directory #741

@mafredri

Description

@mafredri

Problem

check_existing_session() in start.sh only checks the legacy session directory ~/.copilot/history-session-state/ with glob pattern session_*_*.json. Copilot v0.0.342+ writes session state to ~/.copilot/session-state/ with a different naming convention. Sessions created by recent Copilot versions won't be detected, so the module starts a fresh session instead of resuming.

The rest of the resume logic is correct: --type copilot is present, --continue is passed when a session is found, and the prompt is correctly skipped on resume.

To reproduce: run the module with Copilot >= v0.0.342, create a conversation, stop/start. If the session was stored only in the new directory, check_existing_session() returns false and a fresh session starts despite state being on disk.

Desired outcome

  • Session detection works for both legacy and current Copilot versions.
  • Expose enable_state_persistence in main.tf (default true) and pass it through to the module "agentapi" block so the Coder UI preserves chat history across restarts, matching the agent's resumed session.

Worth noting: copilot --continue gracefully starts a new session when none exists. The implementer should consider whether the existence check is still necessary at all, or whether always passing --continue when resume_session=true is simpler and more future-proof.

Version bump

patch

Refs coder/internal#1258

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions