Skip to content

/resume doesn't show recent sessions — initializeWorkspace() skips git context detection #2446

@longyuan1996

Description

@longyuan1996

Describe the bug

/resume (and copilot --resume) filters sessions by the current git repository, but newly created sessions are missing git_root, repository, and branch fields in their workspace.yaml. This causes them to be invisible in the session picker.

Root cause

In the CLI source, initializeWorkspace() only passes {cwd: workingDir} when creating a new session — it does not call git detection (the jF() function that runs git rev-parse, etc.). Git context is only populated on the resume path via updateContext().

As a result, every new session's workspace.yaml looks like:

id: 257baeb7-2c85-4c1c-870f-9cf2dd1b704d
cwd: /root/copilot-workspace
summary: Add Root Directories To Allow List
created_at: 2026-04-01T13:24:42.022Z

Missing: git_root, repository, branch, host_type.

When /resume filters by the current repository, these sessions don't match and are excluded from the list.

Affected version

GitHub Copilot CLI 1.0.14 (confirmed also present in earlier versions).

Steps to reproduce

  1. cd into a git repository
  2. Run copilot — a new session starts
  3. Have a conversation (so the session is non-empty)
  4. Exit the session
  5. Run copilot again, then /resume
  6. The session from step 2 may not appear in the picker (depending on how many older sessions with correct git fields exist)

Alternatively, inspect ~/.copilot/session-state/<session-id>/workspace.yaml for any recently created session — git_root, repository, and branch will be absent even though the working directory is inside a git repo.

Expected behavior

New sessions should have git context populated in workspace.yaml at creation time, so /resume can find them.

Workaround

Manually patch workspace.yaml for affected sessions:

cd ~/.copilot/session-state
for dir in */; do
  yaml="$dir/workspace.yaml"
  if [ -f "$yaml" ] && ! grep -q "git_root:" "$yaml"; then
    cat >> "$yaml" << EOF
git_root: /path/to/your/repo
repository: owner/repo-name
branch: main
host_type: github
EOF
  fi
done

Metadata

Metadata

Assignees

Labels

area:context-memoryContext window, memory, compaction, checkpoints, and instruction loadingarea:sessionsSession management, resume, history, session picker, and session state

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions