@firstpick/pi-package-webui 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -143,7 +143,7 @@ Optional Natural Conversation server-side voice fallback variables:
143
143
 
144
144
  - Pathless `pi-webui` startup: the server opens first, then the browser prompts for the first terminal CWD.
145
145
  - Multi-tab Pi sessions with isolated processes, working directories, prompt drafts, activity state, per-tab settings, and a workspace dashboard for common actions.
146
- - Tracked subagent output can open in the existing non-blocking overlay/widget or in a dedicated **Subagent** terminal tab, selected from the Subagents side-panel section and saved in the browser. Subagent tabs are view-only, reuse the bounded live transcript at the normal full terminal width, show the pulsing **Agent is running:** card with current child activity, and close without stopping or interrupting the child run; use the parent terminal for interaction.
146
+ - Tracked subagent output can open in the existing non-blocking overlay/widget or in a dedicated **Subagent** terminal tab, selected from the Subagents side-panel section and saved in the browser. Side-panel rows and both output views show the effective model and reasoning effort (or an explicit `unknown` for legacy metadata). Subagent tabs are view-only, reuse the bounded live transcript at the normal full terminal width, show the pulsing **Agent is running:** card with current child activity, and close without stopping or interrupting the child run; use the parent terminal for interaction. The package also registers a generic `subagent_gate` tool that launches task slots through pi-subagents RPC v1, enforces a required success quorum, and performs bounded reason-aware retries only when declared safe; the side panel retains gate quorum, attempt, provider, and failure-class history after children finish.
147
147
  - Unified command palette (`Ctrl/Cmd+K`) for commands, tabs, models, sessions, settings, app controls, and frequent Web UI actions.
148
148
  - Automatic tab naming from the first prompt, with `--name <name>` still available for an explicit initial tab name.
149
149
  - Streaming chat transcript with Markdown, copy buttons for fenced code blocks, rendered Mermaid diagrams from fenced `mermaid`/`mmd` code blocks, thinking output, tool/bash cards, queue and compaction events, edit-and-retry from user prompts, transcript search, copy buttons, and guarded abort controls that require holding Esc or the Abort button for 3 seconds.
@@ -155,6 +155,7 @@ Optional Natural Conversation server-side voice fallback variables:
155
155
  - Runtime `/tools` and `/skills` selectors backed by the hidden Web UI RPC helper, with explicit **Session only** and **Global default** scopes. Session choices persist on the current branch and take precedence; global defaults are inherited by future sessions without rewriting existing branches. Disabled skills are removed from the system prompt, and tracked `SKILL.md` files can be opened/edited from skill tags.
156
156
  - Session resume/switch, metadata rename, and localhost-only safe delete with active/open-tab/session-directory guards.
157
157
  - Model, thinking, session, workspace, theme, optional-feature, Codex usage, optional Remote WebUI, update/restart/stop, event, notification, thinking-visibility, terminal-tab-layout, and custom-background controls in collapsible side-panel sections.
158
+ - A side-panel **Git** section mirrors the repositories represented by every open terminal tab/group. Repository cards are shown directly—without session-name parent disclosures—and always use the Git-root or cwd basename as their title. One repository can be expanded at a time, and first/stale expansion refreshes local status after a five-minute cache window without background polling or an automatic network `git fetch`. Its compact Changes tree groups conflicted, staged, modified, and untracked paths with additions/deletions; right-click a repository, folder, or file (or press Shift+F10/the Context Menu key) for View Diff, refresh, stage/unstage, and confirmed discard/delete actions. History lists the latest 30 commits and opens bounded read-only commit diffs.
158
159
  - Persistent context-window meter with manual compact and auto-compaction controls near the composer; side-panel thinking changes made while a tab is busy are queued for the next prompt.
159
160
  - Side-panel theme picker backed by optional `@firstpick/pi-themes-bundle` themes when loaded.
160
161
  - Per-tab cwd changes, a clickable footer cwd picker, directory creation/search in the picker, saved path fast picks, server-persisted fast picks, and restart-safe restoration of open tabs.
@@ -335,6 +336,7 @@ Useful browser endpoints exposed by the local server include:
335
336
  - `GET /api/sessions`, `GET /api/session-tree`, `POST /api/switch-session`, `POST /api/session-rename`, and localhost-only `POST /api/session-delete` for resume/tree/session metadata flows.
336
337
  - `GET /api/auth-providers` and localhost-only `POST /api/auth-logout` for provider-auth status and stored-credential removal.
337
338
  - `GET /api/app-runners`, `POST /api/app-runner`, `POST /api/app-runner/input`, `POST /api/app-runner/stop`, `GET/POST/DELETE /api/app-runner-config`, and `GET /api/app-runner-files` for detected and custom project runners.
339
+ - `GET /api/git-root`, `GET /api/git-panel`, and `GET /api/git-commit?hash=<full-hash>` for compact per-terminal-group repository discovery, local status/history snapshots, and bounded read-only commit diffs. `POST /api/git-changes/stage-all` and `POST /api/git-changes/unstage-all` complement the guarded path-level staging routes.
338
340
  - `GET /api/git-changes`, `POST /api/git-changes/pull`, `GET /api/git-branches`, `POST /api/git-branch`, and `/api/git-workflow/*` for browser Git status, diff, branch, init, commit, push, and PR helpers.
339
341
  - `POST /api/action-feedback?tab=<tabId>` for feedback on final assistant output and action cards.
340
342
  - `GET /api/optional-features` for optional companion package install/update status.
package/bin/pi-webui.mjs CHANGED
@@ -106,6 +106,8 @@ const WEBUI_SUBAGENTS_STATUS_KEY = "webui-subagents";
106
106
  const WEBUI_SUBAGENTS_PAYLOAD_PREFIX = "PI_WEBUI_SUBAGENTS_V1 ";
107
107
  const WEBUI_SUBAGENT_RUN_LIMIT = 128;
108
108
  const WEBUI_SUBAGENT_AGENT_LIMIT = 256;
109
+ const WEBUI_SUBAGENT_GATE_LIMIT = 32;
110
+ const WEBUI_SUBAGENT_GATE_ATTEMPT_LIMIT = 100;
109
111
  const WEBUI_SUBAGENT_OUTPUT_LINE_LIMIT = 120;
110
112
  const WEBUI_SUBAGENT_OUTPUT_LINE_LENGTH = 1000;
111
113
  const PI_CODING_AGENT_PACKAGE = "@earendil-works/pi-coding-agent";
@@ -4907,6 +4909,144 @@ async function readGitChanges(cwd) {
4907
4909
  };
4908
4910
  }
4909
4911
 
4912
+ const GIT_PANEL_HISTORY_LIMIT = 30;
4913
+ const GIT_PANEL_MAX_OUTPUT = 240_000;
4914
+
4915
+ function parseGitNumstatZ(text = "") {
4916
+ const stats = new Map();
4917
+ for (const record of String(text || "").split("\0")) {
4918
+ if (!record) continue;
4919
+ const firstTab = record.indexOf("\t");
4920
+ const secondTab = firstTab < 0 ? -1 : record.indexOf("\t", firstTab + 1);
4921
+ if (firstTab < 0 || secondTab < 0) continue;
4922
+ const additionsText = record.slice(0, firstTab);
4923
+ const deletionsText = record.slice(firstTab + 1, secondTab);
4924
+ const filePath = normalizeGitStatusPath(record.slice(secondTab + 1));
4925
+ if (!filePath) continue;
4926
+ const binary = additionsText === "-" || deletionsText === "-";
4927
+ stats.set(filePath, {
4928
+ additions: binary ? 0 : Number.parseInt(additionsText || "0", 10) || 0,
4929
+ deletions: binary ? 0 : Number.parseInt(deletionsText || "0", 10) || 0,
4930
+ binary,
4931
+ });
4932
+ }
4933
+ return stats;
4934
+ }
4935
+
4936
+ function gitPanelPathStats(entry, stagedStats, unstagedStats) {
4937
+ const paths = [entry.path, entry.oldPath].map(normalizeGitStatusPath).filter(Boolean);
4938
+ const aggregate = (stats) => {
4939
+ const value = { additions: 0, deletions: 0, binary: false };
4940
+ for (const filePath of paths) {
4941
+ const current = stats.get(filePath);
4942
+ if (!current) continue;
4943
+ value.additions += Number(current.additions || 0) || 0;
4944
+ value.deletions += Number(current.deletions || 0) || 0;
4945
+ value.binary ||= current.binary === true;
4946
+ }
4947
+ return value;
4948
+ };
4949
+ const staged = aggregate(stagedStats);
4950
+ const unstaged = aggregate(unstagedStats);
4951
+ return {
4952
+ additions: staged.additions + unstaged.additions,
4953
+ deletions: staged.deletions + unstaged.deletions,
4954
+ binary: staged.binary || unstaged.binary,
4955
+ stagedAdditions: staged.additions,
4956
+ stagedDeletions: staged.deletions,
4957
+ stagedBinary: staged.binary,
4958
+ unstagedAdditions: unstaged.additions,
4959
+ unstagedDeletions: unstaged.deletions,
4960
+ unstagedBinary: unstaged.binary,
4961
+ };
4962
+ }
4963
+
4964
+ function gitPanelChangeEntry(entry, stagedStats, unstagedStats) {
4965
+ const x = entry.x || " ";
4966
+ const y = entry.y || " ";
4967
+ const untracked = x === "?" && y === "?";
4968
+ const conflicted = x === "U" || y === "U" || (x === "A" && y === "A") || (x === "D" && y === "D");
4969
+ return {
4970
+ path: normalizeGitStatusPath(entry.path),
4971
+ oldPath: normalizeGitStatusPath(entry.oldPath || ""),
4972
+ status: `${x}${y}`,
4973
+ staged: !untracked && x !== " " && x !== "?",
4974
+ unstaged: !untracked && y !== " " && y !== "?",
4975
+ untracked,
4976
+ conflicted,
4977
+ ...gitPanelPathStats(entry, stagedStats, unstagedStats),
4978
+ };
4979
+ }
4980
+
4981
+ function parseGitPanelHistory(text = "") {
4982
+ const fields = String(text || "").split("\0").filter(Boolean);
4983
+ const history = [];
4984
+ for (let index = 0; index + 4 < fields.length && history.length < GIT_PANEL_HISTORY_LIMIT; index += 5) {
4985
+ const [hash, shortHash, author, authoredAt, subject] = fields.slice(index, index + 5);
4986
+ if (!hash) continue;
4987
+ history.push({ hash, shortHash, author, authoredAt, subject });
4988
+ }
4989
+ return history;
4990
+ }
4991
+
4992
+ async function readGitPanel(cwd) {
4993
+ const root = await getGitRoot(cwd);
4994
+ const historyPromise = runGitReadCommand(root, [
4995
+ "log", `-n${GIT_PANEL_HISTORY_LIMIT}`, "-z", "--date=iso-strict", "--format=%H%x00%h%x00%an%x00%aI%x00%s",
4996
+ ], { maxOutputLength: GIT_PANEL_MAX_OUTPUT }).catch(() => "");
4997
+ const [statusText, porcelainStatusText, stagedNumstatText, unstagedNumstatText, historyText] = await Promise.all([
4998
+ runGitReadCommand(root, ["status", "--porcelain=v1", "-z", "--untracked-files=all"], { maxOutputLength: GIT_PANEL_MAX_OUTPUT }),
4999
+ runGitReadCommand(root, ["status", "--porcelain=2", "--branch", "--untracked-files=all"], { maxOutputLength: GIT_PANEL_MAX_OUTPUT }),
5000
+ runGitReadCommand(root, ["diff", "--cached", "--numstat", "-z", "--no-renames", "--"], { maxOutputLength: GIT_PANEL_MAX_OUTPUT }),
5001
+ runGitReadCommand(root, ["diff", "--numstat", "-z", "--no-renames", "--"], { maxOutputLength: GIT_PANEL_MAX_OUTPUT }),
5002
+ historyPromise,
5003
+ ]);
5004
+ const stagedStats = parseGitNumstatZ(stagedNumstatText);
5005
+ const unstagedStats = parseGitNumstatZ(unstagedNumstatText);
5006
+ const changes = parseGitPorcelainZEntries(statusText)
5007
+ .map((entry) => gitPanelChangeEntry(entry, stagedStats, unstagedStats))
5008
+ .filter((entry) => entry.path);
5009
+ return {
5010
+ cwd,
5011
+ root,
5012
+ branch: gitBranchFromPorcelainStatus(porcelainStatusText),
5013
+ generatedAt: new Date().toISOString(),
5014
+ summary: summarizeGitPorcelainStatus(porcelainStatusText),
5015
+ changes,
5016
+ history: parseGitPanelHistory(historyText),
5017
+ };
5018
+ }
5019
+
5020
+ async function readGitCommit(cwd, requestedHash) {
5021
+ const hash = String(requestedHash || "").trim().toLowerCase();
5022
+ if (!/^[a-f0-9]{40}([a-f0-9]{24})?$/.test(hash)) throw makeHttpError(400, "A full Git commit hash is required");
5023
+ const root = await getGitRoot(cwd);
5024
+ const verified = (await runGitReadCommand(root, ["rev-parse", "--verify", `${hash}^{commit}`], { maxOutputLength: 1000 })).trim();
5025
+ if (verified.toLowerCase() !== hash) throw makeHttpError(404, "Git commit not found in this repository");
5026
+ const [metaText, diff] = await Promise.all([
5027
+ runGitReadCommand(root, ["show", "-s", "-z", "--date=iso-strict", "--format=%H%x00%h%x00%an%x00%aI%x00%s", hash], { maxOutputLength: 20_000 }),
5028
+ runGitReadCommandDetailed(root, ["show", "--format=", "--no-ext-diff", "--no-color", "--find-renames", "--unified=0", "--src-prefix=a/", "--dst-prefix=b/", hash]),
5029
+ ]);
5030
+ const [commit] = parseGitPanelHistory(metaText);
5031
+ return {
5032
+ root,
5033
+ branch: "",
5034
+ generatedAt: new Date().toISOString(),
5035
+ commit: commit || { hash, shortHash: hash.slice(0, 12), author: "", authoredAt: "", subject: "" },
5036
+ summary: { staged: 0, unstaged: 0, untracked: 0, conflicted: 0, ahead: 0, behind: 0 },
5037
+ remote: { upstream: "", ahead: 0, behind: 0, diverged: false, canPull: false },
5038
+ sections: [{
5039
+ key: "commit",
5040
+ label: `Commit ${commit?.shortHash || hash.slice(0, 12)}`,
5041
+ command: `git show --unified=0 ${hash}`,
5042
+ diff: diff.output.trimEnd(),
5043
+ truncated: diff.truncated,
5044
+ capBytes: diff.capBytes,
5045
+ }],
5046
+ untracked: [],
5047
+ };
5048
+ }
5049
+
4910
5050
  const GIT_LOCK_RETRY_ATTEMPTS = 3;
4911
5051
  const GIT_LOCK_RETRY_DELAY_MS = 250;
4912
5052
  const GIT_FETCH_TIMEOUT_MS = 2 * 60 * 1000;
@@ -5415,6 +5555,23 @@ async function unstageGitFile(cwd, body = {}) {
5415
5555
  return payload;
5416
5556
  }
5417
5557
 
5558
+ async function stageAllGitChanges(cwd) {
5559
+ const root = await getGitRoot(cwd);
5560
+ const payload = await gitAddAllPayload(root);
5561
+ if (payload.data) payload.data.root = root;
5562
+ return payload;
5563
+ }
5564
+
5565
+ async function unstageAllGitChanges(cwd) {
5566
+ const root = await getGitRoot(cwd);
5567
+ let payload = await runGuardedGitMutation(["restore", "--staged", "--", "."], { cwd: root, label: "git restore --staged -- ." });
5568
+ if (!payload.ok && /HEAD/.test(payload.error || "")) {
5569
+ payload = await runGuardedGitMutation(["rm", "--cached", "-r", "--", "."], { cwd: root, label: "git rm --cached -r -- ." });
5570
+ }
5571
+ if (payload.data) payload.data.root = root;
5572
+ return payload;
5573
+ }
5574
+
5418
5575
  async function discardGitFile(cwd, body = {}) {
5419
5576
  requireConfirmed(body, "Discarding file changes is destructive and");
5420
5577
  const root = await getGitRoot(cwd);
@@ -7403,6 +7560,8 @@ function normalizeWebuiSubagentPayload(value) {
7403
7560
  index: Number.isInteger(rawAgent.index) ? rawAgent.index : agents.length,
7404
7561
  currentTool: normalizeWebuiSubagentText(rawAgent.currentTool, 120) || undefined,
7405
7562
  activityState: normalizeWebuiSubagentText(rawAgent.activityState, 80) || undefined,
7563
+ model: normalizeWebuiSubagentText(rawAgent.model, 240) || undefined,
7564
+ thinking: normalizeWebuiSubagentText(rawAgent.thinking, 40) || undefined,
7406
7565
  nested: rawAgent.nested === true,
7407
7566
  });
7408
7567
  }
@@ -7416,12 +7575,56 @@ function normalizeWebuiSubagentPayload(value) {
7416
7575
  agents: agents.sort((a, b) => a.index - b.index || a.name.localeCompare(b.name)),
7417
7576
  });
7418
7577
  }
7578
+ const gates = [];
7579
+ for (const rawGate of Array.isArray(value.gates) ? value.gates.slice(-WEBUI_SUBAGENT_GATE_LIMIT) : []) {
7580
+ if (!rawGate || typeof rawGate !== "object") continue;
7581
+ const id = normalizeWebuiSubagentText(rawGate.id, 160);
7582
+ if (!id) continue;
7583
+ const attempts = [];
7584
+ for (const rawAttempt of Array.isArray(rawGate.attempts) ? rawGate.attempts.slice(-WEBUI_SUBAGENT_GATE_ATTEMPT_LIMIT) : []) {
7585
+ if (!rawAttempt || typeof rawAttempt !== "object") continue;
7586
+ const attemptId = normalizeWebuiSubagentText(rawAttempt.id || `${id}:${attempts.length}`, 240);
7587
+ const agent = normalizeWebuiSubagentText(rawAttempt.agent, 160) || "subagent";
7588
+ attempts.push({
7589
+ id: attemptId,
7590
+ taskIndex: Number.isInteger(rawAttempt.taskIndex) ? rawAttempt.taskIndex : attempts.length,
7591
+ attempt: Number.isInteger(rawAttempt.attempt) ? Math.max(1, rawAttempt.attempt) : 1,
7592
+ maxAttempts: Number.isInteger(rawAttempt.maxAttempts) ? Math.max(1, rawAttempt.maxAttempts) : 1,
7593
+ agent,
7594
+ label: normalizeWebuiSubagentText(rawAttempt.label, 200) || undefined,
7595
+ phase: normalizeWebuiSubagentText(rawAttempt.phase, 120) || undefined,
7596
+ retrySafety: rawAttempt.retrySafety === "read-only" ? "read-only" : "may-write",
7597
+ runId: normalizeWebuiSubagentText(rawAttempt.runId, 160) || undefined,
7598
+ retryOf: normalizeWebuiSubagentText(rawAttempt.retryOf, 160) || undefined,
7599
+ model: normalizeWebuiSubagentText(rawAttempt.model, 240) || undefined,
7600
+ provider: normalizeWebuiSubagentText(rawAttempt.provider, 80) || undefined,
7601
+ status: ["launching", "running", "succeeded", "failed", "not-qualifying", "cancelled"].includes(rawAttempt.status) ? rawAttempt.status : "failed",
7602
+ failureKind: normalizeWebuiSubagentText(rawAttempt.failureKind, 80) || undefined,
7603
+ error: normalizeWebuiSubagentText(rawAttempt.error, 1000) || undefined,
7604
+ startedAt: Number.isFinite(rawAttempt.startedAt) ? rawAttempt.startedAt : undefined,
7605
+ endedAt: Number.isFinite(rawAttempt.endedAt) ? rawAttempt.endedAt : undefined,
7606
+ });
7607
+ }
7608
+ gates.push({
7609
+ version: 1,
7610
+ id,
7611
+ status: ["running", "satisfied", "failed", "cancelled"].includes(rawGate.status) ? rawGate.status : "failed",
7612
+ requiredSuccesses: Number.isInteger(rawGate.requiredSuccesses) ? Math.max(1, rawGate.requiredSuccesses) : 1,
7613
+ qualifyingSuccesses: Number.isInteger(rawGate.qualifyingSuccesses) ? Math.max(0, rawGate.qualifyingSuccesses) : 0,
7614
+ requireDistinctProviders: rawGate.requireDistinctProviders === true,
7615
+ startedAt: Number.isFinite(rawGate.startedAt) ? rawGate.startedAt : Date.now(),
7616
+ updatedAt: Number.isFinite(rawGate.updatedAt) ? rawGate.updatedAt : Date.now(),
7617
+ endedAt: Number.isFinite(rawGate.endedAt) ? rawGate.endedAt : undefined,
7618
+ attempts,
7619
+ });
7620
+ }
7419
7621
  return {
7420
7622
  version: 1,
7421
7623
  available: value.available === true,
7422
7624
  updatedAt: Number.isFinite(value.updatedAt) ? value.updatedAt : Date.now(),
7423
7625
  receivedAt: Date.now(),
7424
7626
  runs: runs.sort((a, b) => a.startedAt - b.startedAt || a.id.localeCompare(b.id)),
7627
+ gates: gates.sort((a, b) => a.startedAt - b.startedAt || a.id.localeCompare(b.id)),
7425
7628
  };
7426
7629
  }
7427
7630
 
@@ -8142,8 +8345,9 @@ function listTabs() {
8142
8345
  function webuiSubagentsData() {
8143
8346
  const sortedTabs = [...tabs.values()].sort((a, b) => a.index - b.index || a.title.localeCompare(b.title));
8144
8347
  const tabSummaries = sortedTabs.map((tab) => {
8145
- const status = tab.webuiSubagents || { version: 1, available: false, updatedAt: null, receivedAt: null, runs: [] };
8348
+ const status = tab.webuiSubagents || { version: 1, available: false, updatedAt: null, receivedAt: null, runs: [], gates: [] };
8146
8349
  const runs = Array.isArray(status.runs) ? status.runs : [];
8350
+ const gates = Array.isArray(status.gates) ? status.gates : [];
8147
8351
  return {
8148
8352
  tabId: tab.id,
8149
8353
  tabIndex: tab.index,
@@ -8156,7 +8360,9 @@ function webuiSubagentsData() {
8156
8360
  updatedAt: status.updatedAt || null,
8157
8361
  receivedAt: status.receivedAt || null,
8158
8362
  runs,
8363
+ gates,
8159
8364
  agentCount: runs.reduce((count, run) => count + run.agents.length, 0),
8365
+ gateCount: gates.length,
8160
8366
  };
8161
8367
  });
8162
8368
  return {
@@ -8165,6 +8371,7 @@ function webuiSubagentsData() {
8165
8371
  available: tabSummaries.some((tab) => tab.available),
8166
8372
  totalRuns: tabSummaries.reduce((count, tab) => count + tab.runs.length, 0),
8167
8373
  totalAgents: tabSummaries.reduce((count, tab) => count + tab.agentCount, 0),
8374
+ totalGates: tabSummaries.reduce((count, tab) => count + tab.gateCount, 0),
8168
8375
  tabs: tabSummaries,
8169
8376
  };
8170
8377
  }
@@ -8274,6 +8481,8 @@ function normalizeWebuiSubagentOutput(value, selection) {
8274
8481
  turnCount: Number.isFinite(rawAgent.turnCount) ? rawAgent.turnCount : undefined,
8275
8482
  toolCount: Number.isFinite(rawAgent.toolCount) ? rawAgent.toolCount : undefined,
8276
8483
  tokens: Number.isFinite(rawAgent.tokens) ? rawAgent.tokens : undefined,
8484
+ model: normalizeWebuiSubagentText(rawAgent.model, 240) || selection.agent.model || undefined,
8485
+ thinking: normalizeWebuiSubagentText(rawAgent.thinking, 40) || selection.agent.thinking || undefined,
8277
8486
  recentTools,
8278
8487
  recentOutput,
8279
8488
  transcript,
@@ -12423,6 +12632,37 @@ const server = createServer(async (req, res) => {
12423
12632
  return;
12424
12633
  }
12425
12634
 
12635
+ if (url.pathname === "/api/git-root" && req.method === "GET") {
12636
+ const tab = getRequestedTab(req, url);
12637
+ try {
12638
+ sendJson(res, 200, { ok: true, data: { cwd: tab.cwd, root: await getGitRoot(tab.cwd) } });
12639
+ } catch (error) {
12640
+ sendJson(res, 200, { ok: false, error: sanitizeError(error) });
12641
+ }
12642
+ return;
12643
+ }
12644
+
12645
+ if (url.pathname === "/api/git-panel" && req.method === "GET") {
12646
+ const tab = getRequestedTab(req, url);
12647
+ try {
12648
+ sendJson(res, 200, { ok: true, data: await readGitPanel(tab.cwd) });
12649
+ } catch (error) {
12650
+ sendJson(res, 200, { ok: false, error: sanitizeError(error) });
12651
+ }
12652
+ return;
12653
+ }
12654
+
12655
+ if (url.pathname === "/api/git-commit" && req.method === "GET") {
12656
+ const tab = getRequestedTab(req, url);
12657
+ try {
12658
+ sendJson(res, 200, { ok: true, data: await readGitCommit(tab.cwd, url.searchParams.get("hash") || "") });
12659
+ } catch (error) {
12660
+ const statusCode = Number(error?.statusCode || error?.status || 200) || 200;
12661
+ sendJson(res, statusCode, { ok: false, error: sanitizeError(error) });
12662
+ }
12663
+ return;
12664
+ }
12665
+
12426
12666
  if (url.pathname === "/api/git-changes/untracked-file" && req.method === "GET") {
12427
12667
  const tab = getRequestedTab(req, url);
12428
12668
  try {
@@ -12544,6 +12784,8 @@ const server = createServer(async (req, res) => {
12544
12784
  "/api/git-changes/integrate": (cwd, body) => integrateGitUpstream(cwd, body),
12545
12785
  "/api/git-changes/stage-file": (cwd, body) => stageGitFile(cwd, body),
12546
12786
  "/api/git-changes/unstage-file": (cwd, body) => unstageGitFile(cwd, body),
12787
+ "/api/git-changes/stage-all": (cwd) => stageAllGitChanges(cwd),
12788
+ "/api/git-changes/unstage-all": (cwd) => unstageAllGitChanges(cwd),
12547
12789
  "/api/git-changes/discard-file": (cwd, body) => discardGitFile(cwd, body),
12548
12790
  "/api/git-changes/delete-untracked": (cwd, body) => deleteGitUntrackedFile(cwd, body),
12549
12791
  "/api/git-operation/continue": (cwd, body) => gitOperationAction(cwd, "continue", body),
package/index.ts CHANGED
@@ -6,6 +6,7 @@ import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-c
6
6
  import { delay, takeValue, tokenizeArgs } from "@firstpick/pi-utils";
7
7
  import { detachChildProcess as releaseStartedChild, isProcessRunning, terminateChildProcess as terminateFailedChild } from "@firstpick/pi-utils/process";
8
8
  import { fetchJsonWithTimeout as fetchJsonWithTimeoutBase } from "@firstpick/pi-utils/http";
9
+ import { registerSubagentGate } from "./lib/subagent-gate.mjs";
9
10
  import {
10
11
  gitWorkflowPreferencesSummary,
11
12
  readGitWorkflowPreferences,
@@ -849,6 +850,9 @@ async function runGitWorkflowSetup(ctx: ExtensionCommandContext): Promise<void>
849
850
  }
850
851
 
851
852
  export default function (pi: ExtensionAPI) {
853
+ const subagentGate = registerSubagentGate(pi);
854
+ pi.on("session_shutdown", () => subagentGate.dispose());
855
+
852
856
  const startWebuiHandler = async (args: string, ctx: ExtensionCommandContext) => {
853
857
  let options: StartWebuiOptions;
854
858
  try {