-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Summary
When developing Cooper with npm run dev, the app uses the default session folder (~/.copilot/session-state), which pollutes the main session state with test data and makes testing harder.
Proposal
Use a separate, isolated session folder during development:
npm run dev→ Use~/.copilot/session-state-dev(or branch-specific folder)- Git hooks + test scripts → Clean/refresh session folder before running
- Each branch gets a fresh session state on startup
Benefits
- Isolates dev sessions — Main session folder stays clean for production use
- Easier testing — Fresh state on every test run, no stale data from previous tests
- Prevents data pollution — Large test sessions don't affect performance profiling
- Branch isolation — Different branches can have separate test environments
Implementation Ideas
Option 1: Static dev folder via environment variable
Set COPILOT_SESSION_HOME when running dev:
bash COPILOT_SESSION_HOME=~/.copilot/session-state-dev npm run dev
Option 2: Branch-specific folder via environment variable (Recommended)
Set COPILOT_SESSION_HOME_SUFFIX to auto-append branch name. Cooper's code reads the env var and sanitizes the branch name for cross-platform compatibility:
json { "scripts": { "dev": "cross-env COPILOT_SESSION_HOME_SUFFIX=auto electron-vite dev" } }
In Cooper's main process:
``typescript
const homePath = app.getPath('home');
let sessionHome = join(homePath, '.copilot', 'session-state');
if (process.env.COPILOT_SESSION_HOME_SUFFIX === 'auto') {
const branch = execSync('git branch --show-current', { encoding: 'utf8' }).trim();
const safeBranch = branch.replace(/[^a-zA-Z0-9-]/g, '-');
sessionHome = join(homePath, '.copilot', session-state-dev-${safeBranch});
}
``
Benefits:
- Works on Windows, macOS, Linux
- Each branch automatically gets isolated folder
- Switch branches → fresh session state
- Sanitizes special characters (
feature/auto-models→feature-auto-models)
Option 3: Git branch-aware folder (code-based detection)
Auto-detect current branch in code without env var, use ~/.copilot/session-state-{branch-name}:
bash npm run dev # Uses ~/.copilot/session-state-feature-auto-models
Option 4: Clean on startup
Add flag to dev script to auto-clean session folder:
bash npm run dev -- --clean-sessions
Related
- Helps with manual testing and performance profiling
- Prevents contamination of production session data
- Makes it easier to test instruction discovery, MCP configs, etc. without side effects