Store session state under project `.copilot/` directory to support ephemeral home directories (Docker, CI, devcontainers)
- 主要語言
- Shell
- 星號
- 11.2k
- 分支
- 1.9k
- 平均合併
- 14 小時 16 分鐘
- 30 天內合併 PR
- 6
描述
### Problem
When running Copilot CLI inside a Docker container, devcontainer, or CI runner, the home directory (`~/.copilot/session-state/`) is ephemeral — it is lost when the container exits. This makes `/session restore SESSION_ID` permanently unavailable after the container shuts down, even if the working project directory is a persistent volume mount or git checkout.
The session state that gets lost includes:
- The event log (`events.jsonl`) needed for session restore
- Checkpoints and their index
- Any session artifacts written to the session folder
### Proposed solution
Allow the runtime to store (or mirror) session state under a `.copilot/session-state/` directory inside the project working directory, rather than exclusively under `~/.copilot/session-state/`.
A reasonable implementation:
1. If a `.copilot/` directory exists in the current working directory when a session starts, store session state there instead of (or in addition to) `~/.copilot/session-state/`.
2. When resolving a session ID for `/session restore`, also search `.copilot/session-state/` in the cwd.
3. Optionally: support a config option or environment variable (e.g. `COPILOT_SESSION_DIR`) to explicitly override the storage root.
The `.copilot/` directory in the project can already be used as home for agent-created artifacts (like `plan.md`). Keeping session state there as well makes the whole session context co-located with the code it relates to, and committable to git if desired.
### Relation to existing issues
Issue #1947 requests cloud-synced sessions for cross-device continuity. This request is narrower — it only requires the runtime to look in an additional local directory, with no network dependency.
### Environment
Any environment where `$HOME` is not persistent: Docker containers, GitHub Codespaces rebuilds, CI runners, devcontainers.
Suggested label: area:sessions
貢獻指南
研究方向
先找出工作階段狀態寫入器和 `/session restore` 查找邏輯;issue 未指出任何原始碼檔案或測試。在持久化的專案目錄和暫時性的 home 目錄中檢查行為,包括既有的 `.copilot/session-state/` 以及提議的 `COPILOT_SESSION_DIR` 覆寫。完成的標準是:工作階段狀態依指定方式儲存或被找到,並且在 home 目錄被捨棄後 restore 仍能正常運作。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- docker, shell
- 領域
- cli, devops, infrastructure
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100