Skip to content

Add repo-scoped session listing for agents and the CLI - #753

Merged
alexeyzimarev merged 10 commits into
mainfrom
feat/repo-sessions-listing
Sep 3, 2026
Merged

alexeyzimarev merged 10 commits into
mainfrom
feat/repo-sessions-listing

Conversation

@alexeyzimarev

Copy link
Copy Markdown
Member

Closes #752 — AI-2430

What & why

An agent or a person who finds unexplained state in a checkout has no way to ask kcap "which session is doing this, and is it still running": recap returns ended sessions only, and the sessions MCP is keyed by an id you must already hold. This adds list_repo_sessions to kcap mcp sessions and a kcap sessions command, both over the server's GET /api/repositories/{hash}/sessions, listing a repository's sessions the caller may see, running first by last activity, with each row's access level and a stale flag. A repo is named as owner/name or a 16-hex hash through one shared parser, and both surfaces fail closed when the cwd has no origin.

Where to look

The server route ships in kurrent-io/kcap-server#1810, so this CLI must not be released before that deploy; against an older server kcap sessions prints one line asking for a newer server and the MCP tool returns the HTTP error envelope. list_repo_sessions is named apart from the review server's list_sessions because both load into one agent and Codex-style clients show bare tool names. A test pins the sessions server's advertised tools to the unattended-safe registry set, so a tool added without its registry entry fails a test rather than a reviewer's permission prompt.

Verification

Capacitor.Cli.Core.Tests.Unit 2679 passed; Capacitor.Cli.Tests.Unit 3881 passed (one PTY timing test flaked under load and passes in isolation); Capacitor.Cli.Tests.Integration 237 passed, including the stdio round trip for the tool and the table, --json, older-server 404 and no-origin paths for the command. scripts/check-linear-ids.sh exits 0; dotnet publish -c Release prints no IL warnings.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T09:37:15.255385Z 1c895d9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c895d9788

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +29 to +31
var parts = value.Split('/');

if (parts.Length != 2 || parts[0].Length == 0 || parts[1].Length == 0) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept nested GitLab owners in repository references

For GitLab repositories under nested groups, such as group/subgroup/project, this rejects the explicit repo reference even though GitUrlParser represents that repository as owner group/subgroup and name project, and cwd-based lookup hashes those same values successfully. Consequently, kcap sessions --repo group/subgroup/project and the MCP equivalent cannot target a supported repository unless the caller somehow knows its hash; split at the final slash rather than requiring exactly two segments.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 19c3927: the reference now splits on the last slash, so a nested-group owner such as group/subgroup keeps its slashes and hashes the same way the cwd lookup does; empty owner segments and whitespace are still rejected. Pinned by RepoRefTests.Nested_group_owner_keeps_the_group_path_in_the_hash plus the MCP builder and kcap sessions --repo tests.

string label;

if (options.Repo is null) {
var repo = await RepositoryDetection.DetectRepositoryAsync(config, Directory.GetCurrentDirectory());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip PR discovery while resolving the sessions repository

When this runs in a GitHub or GitLab checkout with the corresponding provider CLI available, the default overload also executes the provider probe and PR/MR detection path, potentially adding an unnecessary network-backed delay of up to two seconds before the sessions request. This command only consumes Owner and RepoName, so pass detectPullRequest: false as the other repository-scope-only callers do.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2993de8: kcap sessions now calls DetectRepositoryAsync with detectPullRequest: false, matching the other repository-scope-only callers.

@alexeyzimarev
alexeyzimarev merged commit 15a253a into main Sep 3, 2026
6 checks passed
@alexeyzimarev
alexeyzimarev deleted the feat/repo-sessions-listing branch September 3, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List a repository's sessions from the terminal and from agents

1 participant