Context Manager for Persistent Sessions Per Folder
- Ngôn ngữ chính
- Shell
- Star
- 11.2k
- Fork
- 1.9k
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
## Summary
Add a **context manager** to GitHub Copilot CLI that persists and restores conversation sessions on a per-folder (workspace) basis. Currently, every time a user opens Copilot in the same directory, a brand new session is created — discarding all previous context and reducing memory efficiency.
---
## Problem
When a user runs `copilot` (or the Copilot CLI) in a project folder, a fresh session is always started regardless of whether they've worked in that folder before. This means:
- All previously established context (e.g., codebase understanding, ongoing tasks, open discussions) is **lost**.
- Users must **re-explain** their project, goals, and progress in every new session.
- Memory and productivity efficiency is significantly reduced, especially on long-running projects.
### Example Scenario
> A developer is working on a feature across multiple days. Each morning, they open their terminal, navigate to the project folder, and start Copilot — only to find zero memory of what was discussed or decided the day before. They repeat the same context-setting prompts every single session.
---
## Proposed Solution
Implement a **folder-scoped context manager** that:
1. **Saves session context** to a local JSON file (e.g., `.copilot/session.json`) inside the current working directory when a session ends or is paused.
2. **Detects existing session files** on startup by checking if a `.copilot/session.json` exists in the current folder.
3. **Prompts the user** when a previous session is found:
```
🔁 A previous Copilot session was found for this folder.
Last active: 2026-03-07 at 10:32 AM
Summary: Working on user authentication module (JWT implementation)
Would you like to:
[1] Continue last session
[2] Start a new session
```
4. If the user chooses to **continue**, the session context is loaded from the JSON file and Copilot resumes from where it left off.
5. If the user chooses **new session**, a fresh session starts and the old file is archived or overwritten.
---
### Example prompts or workflows
## Session JSON Structure (Proposed)
```json
{
"version": "1.0",
"folder": "/Users/dev/my-project",
"created_at": "2026-03-06T09:00:00Z",
"last_active": "2026-03-07T10:32:00Z",
"summary": "Working on user authentication module (JWT implementation)",
"messages": [
{
"role": "user",
"content": "Help me implement JWT authentication in Go",
"timestamp": "2026-03-06T09:01:00Z"
},
{
"role": "assistant",
"content": "Sure! Here's how to implement JWT in Go...",
"timestamp": "2026-03-06T09:01:05Z"
}
],
"metadata": {
"model": "claude-sonnet-4.6",
"total_turns": 24
}
}
```
---
## User Experience Flow
```
User navigates to /my-project
│
▼
Run `copilot`
│
▼
Does .copilot/session.json exist?
│
┌────┴────┐
YES NO
│ │
▼ ▼
Prompt Start fresh
user session
│
├─ [1] Continue → Load context → Resume session
└─ [2] New → Archive old → Start fresh session
```
### Additional context
---
## Additional Considerations
- **Privacy**: The `.copilot/` folder should be automatically added to `.gitignore` to prevent accidental commit of conversation history.
- **Multiple sessions**: Support named sessions or branches (e.g., `--session feature-auth`) for users working on multiple parallel workstreams in the same folder.
---
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.