Fix canvas repo detection and shrink oversized preview images (#2227)

Canvas extensions (accessibility-kanban, where-was-i) resolved git state
against the extension's install directory or the session-state folder
instead of the repo the session was opened in. This broke repo/branch
detection for user-scoped installs and worktrees ("unknown/unknown",
"detached HEAD"). Both now read the active session's working directory
from the canvas request context on open and on each action, so they
follow whichever project/worktree opened them.

where-was-i also re-gathers context on open when the saved branch is
blank, so it never opens stuck on stale data.

Also compress oversized extension preview images (pngquant, with a mild
resize for the photographic arcade-canvas art) so every preview.png is
comfortably under the installer's inline-byte cap that was blocking
release-notes-showcase from installing.

Update release-notes-showcase author to Kayla Cinnamon.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
James Montemagno
2026-07-06 17:54:51 -07:00
committed by GitHub
parent 969d814f7e
commit e370b97107
9 changed files with 68 additions and 26 deletions
+36 -16
View File
@@ -14,10 +14,26 @@ const VALID_COLUMNS = new Set(COLUMNS);
let repoInfoCache = null;
let githubTokenCache;
let sessionRef = null;
let workspaceCwd = null;
// The canvas request context reports the active session's *working directory*
// (i.e. the repo checkout). Note this is different from `session.workspacePath`,
// which points at the session-state folder (~/.copilot/session-state/<id>) and is
// NOT a git repo — using it for git resolution is what caused the board to fail
// with "Unable to detect the current repository from this workspace."
function setWorkspaceCwd(dir) {
if (typeof dir !== "string" || !dir.trim() || dir === workspaceCwd) return;
workspaceCwd = dir;
repoInfoCache = null;
githubTokenCache = undefined;
}
function captureCwd(ctx) {
setWorkspaceCwd(ctx?.session?.workingDirectory);
}
function getWorkspaceCwd() {
return sessionRef?.workspacePath || process.cwd();
return workspaceCwd || process.cwd();
}
// ─── Repo resolution ───
@@ -61,12 +77,12 @@ function parseRepoFromRemoteUrl(remoteUrl) {
function candidateCwds(preferredCwd) {
const candidates = [
preferredCwd,
sessionRef?.workspacePath,
workspaceCwd,
process.cwd(),
__dirname,
path.dirname(__dirname),
path.dirname(path.dirname(__dirname)),
path.dirname(path.dirname(path.dirname(__dirname))),
process.cwd(),
].filter(Boolean);
return [...new Set(candidates)];
}
@@ -564,7 +580,8 @@ const canvas = createCanvas({
name: "get_state",
description: "Get the current board state including open repository issues and selected label filters.",
inputSchema: { type: "object", properties: {}, additionalProperties: false },
async handler() {
async handler(ctx) {
captureCwd(ctx);
return refreshIssuesSafe();
},
},
@@ -580,8 +597,9 @@ const canvas = createCanvas({
required: ["issue_number", "column"],
additionalProperties: false,
},
handler({ input }) {
const { issue } = moveIssue(input.issue_number, input.column);
handler(ctx) {
captureCwd(ctx);
const { issue } = moveIssue(ctx.input.issue_number, ctx.input.column);
return { issue, state: currentState() };
},
},
@@ -620,8 +638,9 @@ const canvas = createCanvas({
required: ["issues"],
additionalProperties: false,
},
handler({ input }) {
return replaceIssues(input.issues);
handler(ctx) {
captureCwd(ctx);
return replaceIssues(ctx.input.issues);
},
},
{
@@ -635,21 +654,24 @@ const canvas = createCanvas({
required: ["labels"],
additionalProperties: false,
},
handler({ input }) {
return setSelectedLabels(input.labels);
handler(ctx) {
captureCwd(ctx);
return setSelectedLabels(ctx.input.labels);
},
},
{
name: "reset_state",
description: "Reset all cards to backlog and clear label filters, then refresh from live repo issues.",
inputSchema: { type: "object", properties: {}, additionalProperties: false },
async handler() {
async handler(ctx) {
captureCwd(ctx);
resetBoard();
return refreshIssuesSafe();
},
},
],
async open() {
async open(ctx) {
captureCwd(ctx);
const state = await refreshIssuesSafe();
broadcast("state", state);
return {
@@ -662,7 +684,7 @@ const canvas = createCanvas({
// ─── Join session (tools + canvas) ───
const session = await joinSession({
await joinSession({
canvases: [canvas],
tools: [
{
@@ -702,5 +724,3 @@ const session = await joinSession({
},
],
});
sessionRef = session;