Use session working directory in loc-breakdown canvas#17862
Conversation
Forked extension processes inherit a cwd of ~/.copilot, which is not a git repo. With no explicit cwd input, buildReport ran git commands there and /data returned HTTP 500, surfacing as a load error in the canvas UI. Prefer the runtime-supplied ctx.session.workingDirectory (the user's worktree/repo) over process.cwd() in both the open handler and the refresh action's fallback path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17862Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17862" |
There was a problem hiding this comment.
Pull request overview
This PR fixes a runtime error when opening the LOC breakdown canvas by ensuring git operations run in the active session’s repository/worktree directory instead of the forked extension process’s default process.cwd() (often ~/.copilot, which is not a git repo).
Changes:
- Update the canvas
openhandler to preferctx.session?.workingDirectorywheninput.cwdis not provided. - Update the
refreshaction fallback to usectx.session?.workingDirectorybeforeprocess.cwd()when no server entry/options exist.
Show a summary per file
| File | Description |
|---|---|
.github/extensions/loc-breakdown/extension.mjs |
Uses the session working directory as the default/fallback cwd for report generation to avoid running git in a non-repo directory. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
radical
left a comment
There was a problem hiding this comment.
Left two small nits; no blocking concerns from my pass.
- Update inputSchema cwd description to reflect that the session working directory is the primary default, with process.cwd() as a last-resort fallback. - Soften the inline comment on the open handler: the issue is that the extension process cwd is not necessarily the target session repo, not that ~/.copilot is never a git repo. - Mirror the docs update in the README's optional-inputs section. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
❓ CLI E2E Tests unknown — 113 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26912651250 |
|
✅ No documentation update needed. docs_optional → No signals triggered (signal_count: 0). Both changed files are under
This is a bug fix to an internal Copilot canvas extension under |
Description
Fixes an error when opening the LOC breakdown canvas (
load@http://127.0.0.1:.../:98:34).Root cause
Forked extension processes inherit a
process.cwd()of~/.copilot, which is not a git repo. When the canvas was opened without an explicitcwdinput,buildReportrangitcommands in~/.copilot, the/dataendpoint returned HTTP 500, and the client-sideload()threw at thethrow new Error("HTTP " + ...)line.Fix
The Copilot SDK supplies
ctx.session.workingDirectoryto canvasopen/ action handlers (the active session's working directory — i.e. the user's worktree or repo). Theopenhandler and therefreshaction's fallback path now prefer that overprocess.cwd():Verification
Reloaded the extension and opened the canvas locally —
/datanow returns 200 with the expected report (resolved cwd is the worktree, base isorigin/main).