Skip to content

Improve Where Was I worktree context and Git history - #2342

Open
jamesmontemagno wants to merge 14 commits into
github:mainfrom
jamesmontemagno:motz-debug-where-was-i
Open

Improve Where Was I worktree context and Git history#2342
jamesmontemagno wants to merge 14 commits into
github:mainfrom
jamesmontemagno:motz-debug-where-was-i

Conversation

@jamesmontemagno

Copy link
Copy Markdown
Contributor

Summary

  • gather fresh branch-specific context from the active worktree, including ahead/behind state and staged, unstaged, and untracked changes
  • add a focused Git graph with collapsible base-branch history
  • add clickable in-canvas diffs for tracked and untracked changes, plus a resume prompt that includes the full worktree context
  • add integration coverage for Git context and diff collection and release the extension as 1.1.0

Validation

  • node --test extensions/where-was-i/git-context.test.mjs
  • npm run build
  • npm run plugin:validate -- --plugin where-was-i
  • exercised the canvas and diff drawer in Microsoft Edge

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2d224e01-e53f-46f8-beb2-0b8b64c5ee89
Copilot AI balanced review requested due to automatic review settings July 17, 2026 17:59
@github-actions github-actions Bot added the canvas-extension PR touches canvas extensions label Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🔴 Contributor Reputation Check: HIGH risk

Check Risk
Profile HIGH
Credential audit NONE

Maintainers: please review this contributor before merging.
See the workflow run for full details.
Automated check powered by AGT.

@github-actions github-actions Bot added the needs-review:HIGH Contributor reputation check flagged HIGH risk label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enhances the Where Was I canvas with richer Git worktree context and diff previews.

Changes:

  • Adds Git history, divergence, and worktree-change collection.
  • Adds interactive diff previews and expanded resume context.
  • Adds integration tests and releases version 1.1.0.
Show a summary per file
File Description
extensions/where-was-i/package.json Updates package version.
extensions/where-was-i/git-context.test.mjs Tests Git context and diff collection.
extensions/where-was-i/git-context.mjs Implements Git context and file diffs.
extensions/where-was-i/extension.mjs Adds graph, diff drawer, and resume behavior.
extensions/where-was-i/.github/plugin/plugin.json Updates extension metadata version.
.github/plugin/marketplace.json Publishes the updated marketplace version.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 5
  • Review effort level: Medium

Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/extension.mjs Outdated
Comment thread extensions/where-was-i/extension.mjs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c161d734-edb5-4707-a48c-966d4e83a2cf
Copilot AI review requested due to automatic review settings August 21, 2026 04:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c161d734-edb5-4707-a48c-966d4e83a2cf
@github-actions github-actions Bot added the plugin PR touches plugins label Aug 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 6 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 1
ℹ️ Info 0
Severity Rule File Line Match
🟠 unpinned-version-indicator extensions/where-was-i/package.json 16 "@​​github/copilot-sdk": "latest"

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (4)

Previously missed (3) — in code that hasn't changed since the last review.

extensions/where-was-i/extension.mjs:697

  • Splitting at the first hash outside branchHashes can hide branch work. When no base is resolved (for example, a local-only main repository), branchHashes is empty and the entire graph is mislabeled and collapsed as base history; merge graphs can also interleave a base commit before later branch commits. Only split when a base exists, and split after the last branch-specific commit so branch work remains visible.
  const firstBaseCommit = graph.findIndex(row => row.hash && !branchHashes.has(row.hash));
  const focusedGraph = firstBaseCommit >= 0 ? graph.slice(0, firstBaseCommit) : graph;
  const baseGraph = firstBaseCommit >= 0 ? graph.slice(firstBaseCommit) : [];

extensions/where-was-i/git-context.mjs:126

  • Every regular untracked file is emitted as mode 100644, so an executable script is presented with an inaccurate patch. Derive the new-file mode from the executable bits in fileStat.mode.

This issue also appears on line 135 of the same file.

    return renderNewFilePatch(relativePath, "100644", addedLines);

extensions/where-was-i/extension.mjs:844

  • Concurrent diff requests can complete out of order. If a user opens file A and then file B before A finishes, A's later response overwrites B's badge and content while the title still says B. Abort the previous request or assign each request a sequence ID and ignore stale responses before updating the dialog.
  try {
    const res = await fetch("/file-diff?path=" + encodeURIComponent(path));
    const data = await res.json();
    if (!res.ok) throw new Error(data.error || "Unable to load this diff.");
    const status = describeStatus(data.code);

extensions/where-was-i/git-context.mjs:135

  • A porcelain status can contain two records for the same path—for example, git rm --cached file leaves both a staged deletion and an untracked file. This path-only find always returns the first record, so the untracked row's diff button shows the staged deletion and the new file contents cannot be previewed. Preserve the selected record's status/identity through the UI and endpoint, or combine same-path records before lookup.
    const entry = parseStatusOutput(status).find((item) => item.path === relativePath);
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread extensions/where-was-i/extension.mjs
Copilot AI review requested due to automatic review settings August 21, 2026 05:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 7
  • Review effort level: Balanced

Comment thread extensions/where-was-i/git-context.mjs
Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/extension.mjs
Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/extension.mjs Outdated
Comment thread extensions/where-was-i/git-context.mjs Outdated
Comment thread extensions/where-was-i/extension.mjs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c161d734-edb5-4707-a48c-966d4e83a2cf
Copilot AI review requested due to automatic review settings August 21, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

extensions/where-was-i/extension.mjs:713

  • --topo-order does not guarantee that every HEAD-only commit appears before commits reachable only from baseRef; a newer base commit can occur first. Splitting at the first non-branch hash can therefore put later worktree commits inside the collapsed “base” section. Collapse only a suffix that starts after the final branch hash (and add a behind/diverged graph case to the test).
  const firstBaseCommit = canSplitGraph
    ? graph.findIndex(row => row.hash && !branchHashes.has(row.hash))
    : -1;
  const focusedGraph = firstBaseCommit >= 0 ? graph.slice(0, firstBaseCommit) : graph;
  const baseGraph = firstBaseCommit >= 0 ? graph.slice(firstBaseCommit) : [];
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread extensions/where-was-i/extension.mjs
…edge cases

- Remove inline onclick handlers; PR/issue cards are buttons wired with addEventListener
  from data, the refresh/resume buttons use ids, and the page is served with a nonce-based
  CSP (script-src 'nonce-...', default-src 'none'). escapeHtml now also escapes apostrophes.
- Collapse only the graph suffix after the final branch commit (splitCommitGraph, computed
  server-side as baseGraphStart) so --topo-order interleaving never hides worktree commits.
- Preserve the selected status record through the UI, /file-diff, and get_file_diff so a path
  that appears twice (e.g. staged deletion + untracked re-creation) previews the right record.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 18350039-5e2b-40f0-b537-bc22cabcbb1b
Copilot AI review requested due to automatic review settings August 21, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (5)

Previously missed (2) — in code that hasn't changed since the last review.

extensions/where-was-i/extension.mjs:283

  • --azure has only about 2.8:1 contrast against the white/azure-tinted row background. These graph characters communicate topology and need at least 3:1 even when treated as non-text graphics (and 4.5:1 if treated as text); use a darker blue.

This issue also appears in the following locations of the same file:

  • line 312
  • line 380
  color: var(--azure);

extensions/where-was-i/extension.mjs:290

  • --meta is approximately 2.6:1 against the card background, so these small commit hashes do not meet the 4.5:1 text contrast requirement. Use a darker metadata color here.

This issue also appears on line 665 of the same file.

  color: var(--meta);

extensions/where-was-i/extension.mjs:312

  • The azure text on --azure-tint is only about 2.5:1 contrast, below the 4.5:1 requirement for this 0.65rem ref label. Please use a darker foreground.
  color: var(--azure);

extensions/where-was-i/extension.mjs:380

  • This newly added rename badge repeats the same low-contrast azure-on-tint combination (about 2.5:1), making the small status text difficult to read. Use a darker blue foreground.
.status-badge.renamed { background: var(--azure-tint); color: var(--azure); }

extensions/where-was-i/extension.mjs:667

  • Checking R and A before a worktree deletion mislabels valid RD and AD states as “Renamed + edited” or “Added + edited.” Handle a D worktree column first so the canvas does not hide that the file was deleted after staging.
  if (index === "R") return { label: worktree === " " ? "Renamed" : "Renamed + edited", kind: "renamed" };
  if (index === "A") return { label: worktree === " " ? "Staged add" : "Added + edited", kind: "added" };
  if (index === "D" || worktree === "D") return { label: index !== " " && worktree !== " " ? "Staged + deleted" : "Deleted", kind: "deleted" };
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@jamesmontemagno

Copy link
Copy Markdown
Contributor Author

Addressed the two additional findings listed only in the reviewer’s suppressed-comments summary (so they did not have replyable inline threads) in 21524f11:

  • Duplicate status records for one path: the selected porcelain code is now carried from the change button through /file-diff (and optionally through get_file_diff) into getFileDiff, which selects the matching (path, code) record. This correctly distinguishes cases such as a staged deletion plus an untracked re-creation of the same file. Added a regression test covering both previews.
  • Interleaved diverged graph history: splitCommitGraph now collapses only the suffix after the final current-branch commit, rather than splitting at the first base-only row. This keeps all current-branch commits visible even when --topo-order interleaves a newer base commit. Added deterministic layout coverage plus an integration test using a diverged repository.

The title-injection/CSP finding was also fixed in 21524f11 and replied to on its inline thread. All 10 Where Was I Git-context tests pass, all 17 PR checks are green, and all review threads are resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

canvas-extension PR touches canvas extensions needs-review:HIGH Contributor reputation check flagged HIGH risk plugin PR touches plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants