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
Problem
check_existing_session()instart.shonly checks the legacy session directory~/.copilot/history-session-state/with glob patternsession_*_*.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 copilotis present,--continueis 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
enable_state_persistenceinmain.tf(defaulttrue) and pass it through to themodule "agentapi"block so the Coder UI preserves chat history across restarts, matching the agent's resumed session.Worth noting:
copilot --continuegracefully starts a new session when none exists. The implementer should consider whether the existence check is still necessary at all, or whether always passing--continuewhenresume_session=trueis simpler and more future-proof.Version bump
patchRefs coder/internal#1258