@firstpick/pi-package-webui 0.6.5 → 0.6.6

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/public/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="manifest" href="/manifest.webmanifest" />
13
13
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
14
14
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
15
- <link rel="stylesheet" href="/styles.css?v=66" />
15
+ <link rel="stylesheet" href="/styles.css?v=69" />
16
16
  </head>
17
17
  <body>
18
18
  <button id="sidePanelExpandButton" class="side-panel-expand-button" type="button" aria-controls="sidePanel" aria-expanded="false" aria-label="Expand side panel" title="Expand side panel">
@@ -174,7 +174,7 @@
174
174
  aria-controls="publishMenu"
175
175
  data-tooltip="Publish workflows: choose an npm or AUR release flow."
176
176
  ><svg class="composer-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 16V4m0 0 5 5m-5-5-5 5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 16v3a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
177
- <div id="publishMenu" class="composer-publish-menu-panel" role="menu" aria-label="Publish workflows">
177
+ <div id="publishMenu" class="composer-publish-menu-panel composer-auto-height-menu-panel" role="menu" aria-label="Publish workflows">
178
178
  <button id="releaseNpmButton" class="composer-publish-menu-item" type="button" role="menuitem" data-command="/release-npm">
179
179
  <span>NPM Release</span>
180
180
  </button>
@@ -195,7 +195,7 @@
195
195
  aria-controls="nativeCommandMenu"
196
196
  data-tooltip="Skills/tools setup: open skill or tool setup."
197
197
  ><svg class="composer-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 5h16v14H4z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="m7 10 2.5 2L7 14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 15h5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button>
198
- <div id="nativeCommandMenu" class="composer-publish-menu-panel composer-native-command-menu-panel" role="menu" aria-label="Skills and tools setup">
198
+ <div id="nativeCommandMenu" class="composer-publish-menu-panel composer-native-command-menu-panel composer-auto-height-menu-panel" role="menu" aria-label="Skills and tools setup">
199
199
  <button id="nativeSkillsButton" class="composer-publish-menu-item composer-native-command-menu-item" type="button" role="menuitem" data-command="/skills">
200
200
  <span>Skills Setup</span>
201
201
  </button>
@@ -214,9 +214,9 @@
214
214
  aria-haspopup="menu"
215
215
  aria-expanded="false"
216
216
  aria-controls="optionsMenu"
217
- data-tooltip="Options: command palette, Git-footer Visibility, natural conversation, resume, reload, remote, name, clone, settings, export, fork, or tree."
217
+ data-tooltip="Options: command palette, Guided Git Setup, Git-footer Visibility, natural conversation, resume, reload, remote, name, clone, settings, export, fork, or tree."
218
218
  ><svg class="composer-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7h16M4 12h16M4 17h16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="8" cy="7" r="1.6" fill="currentColor"/><circle cx="16" cy="12" r="1.6" fill="currentColor"/><circle cx="11" cy="17" r="1.6" fill="currentColor"/></svg></button>
219
- <div id="optionsMenu" class="composer-publish-menu-panel composer-options-menu-panel" role="menu" aria-label="Common Pi options">
219
+ <div id="optionsMenu" class="composer-publish-menu-panel composer-options-menu-panel composer-auto-height-menu-panel" role="menu" aria-label="Common Pi options">
220
220
  <button id="optionsCommandPaletteButton" class="composer-publish-menu-item composer-options-menu-item" type="button" role="menuitem">
221
221
  <span>Command Palette</span>
222
222
  </button>
@@ -241,6 +241,9 @@
241
241
  <button id="optionsSettingsButton" class="composer-publish-menu-item composer-options-menu-item" type="button" role="menuitem" data-command="/settings">
242
242
  <span>Settings</span>
243
243
  </button>
244
+ <button id="optionsGitWorkflowSetupButton" class="composer-publish-menu-item composer-options-menu-item" type="button" role="menuitem" data-command="/git-workflow-setup">
245
+ <span>Guided Git Setup</span>
246
+ </button>
244
247
  <button id="optionsCloneButton" class="composer-publish-menu-item composer-options-menu-item" type="button" role="menuitem" data-command="/clone">
245
248
  <span>Clone Session</span>
246
249
  </button>
@@ -280,7 +283,7 @@
280
283
  aria-controls="appRunnerMenuPanel"
281
284
  data-tooltip="App runners: run detected project commands in this tab's working directory."
282
285
  ><svg class="composer-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8 5v14l11-7z" fill="currentColor"/></svg></button>
283
- <div id="appRunnerMenuPanel" class="composer-publish-menu-panel composer-app-runner-menu-panel" role="menu" aria-label="Detected app runners"></div>
286
+ <div id="appRunnerMenuPanel" class="composer-publish-menu-panel composer-app-runner-menu-panel composer-auto-height-menu-panel" role="menu" aria-label="Detected app runners"></div>
284
287
  </div>
285
288
  </div>
286
289
  <div class="spacer"></div>
@@ -411,6 +414,7 @@
411
414
  <option value="medium">medium</option>
412
415
  <option value="high">high</option>
413
416
  <option value="xhigh">xhigh</option>
417
+ <option value="max">max</option>
414
418
  </select>
415
419
  <button id="setThinkingButton" type="button">Set thinking</button>
416
420
  </div>
@@ -575,6 +579,21 @@
575
579
  <dl id="stateDetails" class="details"></dl>
576
580
  </div>
577
581
  </section>
582
+ <section class="side-panel-section collapsed" data-side-panel-section="subagents">
583
+ <h2>
584
+ <button id="sidePanelSectionToggleSubagents" class="side-panel-section-toggle" type="button" aria-expanded="false" aria-controls="sidePanelSectionSubagents" aria-label="Expand Subagents section" title="Expand Subagents section" data-side-panel-section-toggle="subagents">
585
+ <span class="side-panel-section-label">Subagents</span>
586
+ <span class="side-panel-section-trailing">
587
+ <span id="subagentCountBadge" class="side-panel-section-badge subagent-count-badge" hidden>0</span>
588
+ <span class="side-panel-section-chevron" aria-hidden="true">›</span>
589
+ </span>
590
+ </button>
591
+ </h2>
592
+ <div id="sidePanelSectionSubagents" class="side-panel-section-content" hidden>
593
+ <p id="subagentsStatus" class="subagents-status muted" role="status" aria-live="polite">Checking running subagents…</p>
594
+ <div id="subagentsBox" class="subagents-box muted">Checking running subagents…</div>
595
+ </div>
596
+ </section>
578
597
  <section class="side-panel-section collapsed" data-side-panel-section="queue">
579
598
  <h2>
580
599
  <button id="sidePanelSectionToggleQueue" class="side-panel-section-toggle" type="button" aria-expanded="false" aria-controls="sidePanelSectionQueue" aria-label="Expand Queue section" title="Expand Queue section" data-side-panel-section-toggle="queue">
@@ -882,6 +901,6 @@
882
901
  </form>
883
902
  </dialog>
884
903
 
885
- <script type="module" src="/app.js?v=66"></script>
904
+ <script type="module" src="/app.js?v=69"></script>
886
905
  </body>
887
906
  </html>
package/public/styles.css CHANGED
@@ -1786,6 +1786,164 @@ body.embedded-split .side-panel-backdrop {
1786
1786
  background: rgba(var(--ctp-crust-rgb), 0.46);
1787
1787
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 0 1rem rgba(148, 226, 213, 0.05);
1788
1788
  }
1789
+ .subagent-count-badge {
1790
+ background: linear-gradient(135deg, var(--ctp-teal), var(--ctp-green));
1791
+ box-shadow: 0 0 0.8rem rgba(148, 226, 213, 0.24);
1792
+ }
1793
+ .subagents-status {
1794
+ margin: 0 0 0.48rem;
1795
+ font-size: 0.72rem;
1796
+ line-height: 1.35;
1797
+ }
1798
+ .subagents-box {
1799
+ display: grid;
1800
+ gap: 0.58rem;
1801
+ padding: 0.64rem;
1802
+ border: 1px solid rgba(180, 190, 254, 0.16);
1803
+ border-radius: 0.85rem;
1804
+ background: rgba(var(--ctp-crust-rgb), 0.50);
1805
+ box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), 0 0 1rem rgba(148, 226, 213, 0.05);
1806
+ }
1807
+ .subagents-box.has-items {
1808
+ border-color: rgba(148, 226, 213, 0.26);
1809
+ background:
1810
+ radial-gradient(circle at 0 0, rgba(148, 226, 213, 0.08), transparent 10rem),
1811
+ rgba(var(--ctp-crust-rgb), 0.54);
1812
+ }
1813
+ .subagents-empty,
1814
+ .subagents-stale {
1815
+ color: rgba(var(--ctp-subtext-rgb), 0.72);
1816
+ font-size: 0.74rem;
1817
+ line-height: 1.4;
1818
+ }
1819
+ .subagent-tab-group {
1820
+ display: grid;
1821
+ min-width: 0;
1822
+ overflow: hidden;
1823
+ border: 1px solid rgba(180, 190, 254, 0.14);
1824
+ border-radius: 0.76rem;
1825
+ background: rgba(var(--ctp-base-rgb), 0.26);
1826
+ }
1827
+ .subagent-tab-group.active {
1828
+ border-color: rgba(137, 180, 250, 0.30);
1829
+ }
1830
+ .subagent-tab-header {
1831
+ display: flex;
1832
+ justify-content: space-between;
1833
+ gap: 0.55rem;
1834
+ align-items: center;
1835
+ width: 100%;
1836
+ min-height: 42px;
1837
+ padding: 0.48rem 0.56rem;
1838
+ border: 0;
1839
+ border-bottom: 1px solid rgba(180, 190, 254, 0.11);
1840
+ border-radius: 0;
1841
+ color: rgba(var(--ctp-text-rgb), 0.94);
1842
+ background: rgba(var(--ctp-surface-rgb), 0.20);
1843
+ text-align: left;
1844
+ }
1845
+ .subagent-tab-header:hover,
1846
+ .subagent-tab-header:focus-visible {
1847
+ transform: none;
1848
+ color: var(--ctp-blue);
1849
+ background: rgba(137, 180, 250, 0.10);
1850
+ }
1851
+ .subagent-tab-title {
1852
+ display: grid;
1853
+ gap: 0.12rem;
1854
+ min-width: 0;
1855
+ }
1856
+ .subagent-tab-title strong,
1857
+ .subagent-tab-session {
1858
+ overflow: hidden;
1859
+ text-overflow: ellipsis;
1860
+ white-space: nowrap;
1861
+ }
1862
+ .subagent-tab-title strong {
1863
+ font-size: 0.78rem;
1864
+ }
1865
+ .subagent-tab-session {
1866
+ color: rgba(var(--ctp-subtext-rgb), 0.66);
1867
+ font-size: 0.64rem;
1868
+ font-weight: 650;
1869
+ }
1870
+ .subagent-tab-count {
1871
+ display: inline-flex;
1872
+ align-items: center;
1873
+ justify-content: center;
1874
+ min-width: 1.45rem;
1875
+ min-height: 1.45rem;
1876
+ padding: 0 0.35rem;
1877
+ border: 1px solid rgba(148, 226, 213, 0.24);
1878
+ border-radius: 999px;
1879
+ color: var(--ctp-teal);
1880
+ background: rgba(148, 226, 213, 0.08);
1881
+ font-size: 0.68rem;
1882
+ font-weight: 900;
1883
+ }
1884
+ .subagent-agent-list {
1885
+ display: grid;
1886
+ gap: 0.38rem;
1887
+ padding: 0.5rem;
1888
+ }
1889
+ .subagent-agent-row {
1890
+ display: grid;
1891
+ grid-template-columns: auto minmax(0, 1fr);
1892
+ gap: 0.48rem;
1893
+ align-items: start;
1894
+ width: 100%;
1895
+ min-width: 0;
1896
+ min-height: 0;
1897
+ padding: 0.42rem 0.48rem;
1898
+ border: 1px solid transparent;
1899
+ border-radius: 0.62rem;
1900
+ color: inherit;
1901
+ background: rgba(var(--ctp-surface-rgb), 0.16);
1902
+ text-align: left;
1903
+ }
1904
+ .subagent-agent-row:hover,
1905
+ .subagent-agent-row:focus-visible {
1906
+ border-color: rgba(148, 226, 213, 0.38);
1907
+ background: rgba(148, 226, 213, 0.09);
1908
+ box-shadow: 0 0 0.8rem rgba(148, 226, 213, 0.08);
1909
+ transform: none;
1910
+ }
1911
+ .subagent-agent-row.nested {
1912
+ margin-left: 0.68rem;
1913
+ border-left: 2px solid rgba(203, 166, 247, 0.32);
1914
+ }
1915
+ .subagent-running-dot {
1916
+ width: 0.52rem;
1917
+ height: 0.52rem;
1918
+ margin-top: 0.22rem;
1919
+ border-radius: 999px;
1920
+ background: var(--ctp-green);
1921
+ box-shadow: 0 0 0.6rem rgba(166, 227, 161, 0.62);
1922
+ animation: subagent-running-pulse 1.35s ease-in-out infinite;
1923
+ }
1924
+ .subagent-agent-content {
1925
+ display: grid;
1926
+ gap: 0.13rem;
1927
+ min-width: 0;
1928
+ }
1929
+ .subagent-agent-name {
1930
+ overflow: hidden;
1931
+ color: rgba(var(--ctp-text-rgb), 0.94);
1932
+ font-size: 0.76rem;
1933
+ text-overflow: ellipsis;
1934
+ white-space: nowrap;
1935
+ }
1936
+ .subagent-agent-meta {
1937
+ color: rgba(var(--ctp-subtext-rgb), 0.67);
1938
+ font-size: 0.64rem;
1939
+ line-height: 1.35;
1940
+ overflow-wrap: anywhere;
1941
+ }
1942
+ @keyframes subagent-running-pulse {
1943
+ 0%, 100% { opacity: 0.58; transform: scale(0.86); }
1944
+ 50% { opacity: 1; transform: scale(1); }
1945
+ }
1946
+
1789
1947
  .optional-feature-section {
1790
1948
  display: grid;
1791
1949
  gap: 0.48rem;
@@ -6577,8 +6735,13 @@ button.composer-skill-tag:focus-visible {
6577
6735
  .composer-publish-menu.open .composer-publish-menu-panel {
6578
6736
  display: flex;
6579
6737
  }
6580
- .composer-options-menu-panel {
6581
- max-height: min(calc(var(--visual-viewport-height, 100dvh) - 2rem), 48rem);
6738
+ .composer-auto-height-menu-panel {
6739
+ height: auto;
6740
+ max-height: none;
6741
+ overflow: visible;
6742
+ overflow-y: visible;
6743
+ overscroll-behavior: auto;
6744
+ -webkit-overflow-scrolling: auto;
6582
6745
  }
6583
6746
  .composer-publish-menu.open .composer-publish-button {
6584
6747
  border-color: rgba(250, 179, 135, 0.58);
@@ -7637,6 +7800,51 @@ button.composer-skill-tag:focus-visible {
7637
7800
  font-weight: 700;
7638
7801
  line-height: 1.45;
7639
7802
  }
7803
+ .subagent-overlay-widget {
7804
+ min-height: 0;
7805
+ margin: 0;
7806
+ border-color: rgba(166, 227, 161, 0.62);
7807
+ border-left-color: rgba(166, 227, 161, 0.92);
7808
+ box-shadow: 0 0 1rem rgba(166, 227, 161, 0.10), inset 0 1px 0 rgba(255,255,255,0.04);
7809
+ }
7810
+ .subagent-overlay-widget .release-npm-output-details {
7811
+ min-height: 0;
7812
+ }
7813
+ .subagent-overlay-terminal {
7814
+ min-height: min(12rem, 30dvh);
7815
+ max-height: min(24rem, 46dvh);
7816
+ }
7817
+ .subagent-output-waiting {
7818
+ display: inline-flex;
7819
+ width: fit-content;
7820
+ min-width: 2.1rem;
7821
+ gap: 0.12rem;
7822
+ color: var(--ctp-green);
7823
+ font-weight: 900;
7824
+ letter-spacing: 0.08em;
7825
+ }
7826
+ .subagent-output-waiting-dot {
7827
+ animation: subagent-output-waiting-pulse 1.15s ease-in-out infinite;
7828
+ }
7829
+ .subagent-output-waiting-dot:nth-child(2) { animation-delay: 140ms; }
7830
+ .subagent-output-waiting-dot:nth-child(3) { animation-delay: 280ms; }
7831
+ @keyframes subagent-output-waiting-pulse {
7832
+ 0%, 70%, 100% { opacity: 0.22; transform: translateY(0); }
7833
+ 35% { opacity: 1; transform: translateY(-0.12rem); }
7834
+ }
7835
+ .subagent-overlay-output-controls {
7836
+ min-width: 0;
7837
+ }
7838
+ .subagent-overlay-output-controls .app-runner-output-meta {
7839
+ overflow-wrap: anywhere;
7840
+ }
7841
+ .subagent-overlay-output-controls .warning {
7842
+ color: var(--ctp-yellow);
7843
+ }
7844
+ .subagent-overlay-close-action {
7845
+ color: var(--ctp-yellow);
7846
+ border-color: rgba(249, 226, 175, 0.34);
7847
+ }
7640
7848
  .extension-dialog.stats-overlay-dialog {
7641
7849
  width: min(92rem, calc(100vw - 1.5rem));
7642
7850
  height: min(54rem, calc(var(--visual-viewport-height, 100dvh) - 1.5rem));
@@ -9359,6 +9567,14 @@ button.composer-skill-tag:focus-visible {
9359
9567
  .composer-actions-panel > .composer-app-runner-menu .composer-publish-menu-panel {
9360
9568
  inset-inline: auto 0;
9361
9569
  }
9570
+ .composer-actions-panel > .composer-publish-menu .composer-auto-height-menu-panel {
9571
+ height: auto;
9572
+ max-height: none;
9573
+ overflow: visible;
9574
+ overflow-y: visible;
9575
+ overscroll-behavior: auto;
9576
+ -webkit-overflow-scrolling: auto;
9577
+ }
9362
9578
  .composer-actions-panel > .composer-publish-menu .composer-publish-menu-item {
9363
9579
  width: 100%;
9364
9580
  min-width: 0;
@@ -207,12 +207,64 @@ function handleWebuiHelperPrompt(command, base) {
207
207
  case "skills-state":
208
208
  respondHelper({ requestId, ok: true, data: { skills: [] } });
209
209
  return true;
210
+ case "subagent-output":
211
+ respondHelper({
212
+ requestId,
213
+ ok: true,
214
+ data: {
215
+ version: 1,
216
+ runId: request.payload?.runId || "fixture-run",
217
+ source: "async",
218
+ mode: "parallel",
219
+ startedAt: Date.now() - 3000,
220
+ updatedAt: Date.now(),
221
+ agent: {
222
+ id: request.payload?.agentId || "fixture-run:0",
223
+ name: String(request.payload?.agentId || "").endsWith(":1") ? "scout" : "reviewer",
224
+ index: String(request.payload?.agentId || "").endsWith(":1") ? 1 : 0,
225
+ status: "running",
226
+ currentTool: "read",
227
+ currentToolArgs: "README.md",
228
+ recentTools: [{ tool: "grep", args: "Subagents", endMs: Date.now() - 200 }],
229
+ recentOutput: ["Inspecting current implementation", "Waiting for the next tool result"],
230
+ turnCount: 2,
231
+ toolCount: 3,
232
+ tokens: 420,
233
+ },
234
+ },
235
+ });
236
+ return true;
210
237
  default:
211
238
  respondHelper({ requestId, ok: false, error: `Unknown webui-helper action: ${String(request.action || "")}` });
212
239
  return true;
213
240
  }
214
241
  }
215
242
 
243
+ function handleSubagentFixturePrompt(command, base) {
244
+ const message = String(command.message || "").trim();
245
+ if (message !== "fixture subagents running" && message !== "fixture subagents clear") return false;
246
+ const runs = message.endsWith("clear") ? [] : [{
247
+ id: "fixture-run",
248
+ source: "async",
249
+ mode: "parallel",
250
+ status: "running",
251
+ startedAt: Date.now() - 2500,
252
+ agents: [
253
+ { id: "fixture-run:0", name: "reviewer", status: "running", index: 0, currentTool: "read", nested: false },
254
+ { id: "fixture-run:1", name: "scout", status: "running", index: 1, nested: false },
255
+ ],
256
+ }];
257
+ respond({ ...base, data: { output: "fake subagent status emitted" } });
258
+ emitEvent({
259
+ type: "extension_ui_request",
260
+ id: randomUUID(),
261
+ method: "setStatus",
262
+ statusKey: "webui-subagents",
263
+ statusText: `PI_WEBUI_SUBAGENTS_V1 ${JSON.stringify({ version: 1, available: true, updatedAt: Date.now(), runs })}`,
264
+ });
265
+ return true;
266
+ }
267
+
216
268
  function handleTalkPrompt(command, base) {
217
269
  const message = String(command.message || "").trim();
218
270
  const match = message.match(/^\/(talk|voice|conversation)(?:\s+(\S+))?/i);
@@ -315,6 +367,7 @@ rl.on("line", (line) => {
315
367
  }
316
368
  case "prompt":
317
369
  if (handleWebuiHelperPrompt(command, base)) return;
370
+ if (handleSubagentFixturePrompt(command, base)) return;
318
371
  if (handleTalkPrompt(command, base)) return;
319
372
  if (handleVoiceScriptPrompt(command, base)) return;
320
373
  respond({ ...base, data: { output: "fake prompt accepted" } });
@@ -0,0 +1,67 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import {
6
+ GIT_WORKFLOW_SETUP_VERSION,
7
+ gitWorkflowPreferencesSummary,
8
+ isGitWorkflowSetupComplete,
9
+ readGitWorkflowPreferences,
10
+ readWebuiSettings,
11
+ supportedGitWorkflowThinkingLevels,
12
+ writeGitWorkflowPreferences,
13
+ } from "../lib/git-workflow-preferences.mjs";
14
+
15
+ assert.deepEqual(supportedGitWorkflowThinkingLevels({ reasoning: false }), ["off"]);
16
+ assert.deepEqual(
17
+ supportedGitWorkflowThinkingLevels({ reasoning: true }),
18
+ ["off", "minimal", "low", "medium", "high"],
19
+ "models without an explicit map should expose standard levels but not opt-in extended levels",
20
+ );
21
+ assert.deepEqual(
22
+ supportedGitWorkflowThinkingLevels({ reasoning: true, thinkingLevelMap: { minimal: null, xhigh: null, max: "max" } }),
23
+ ["off", "low", "medium", "high", "max"],
24
+ "null map entries should be hidden while explicit extended levels remain available",
25
+ );
26
+
27
+ const root = await mkdtemp(path.join(tmpdir(), "pi-webui-git-preferences-"));
28
+ const settingsFile = path.join(root, "settings.json");
29
+
30
+ try {
31
+ await writeFile(settingsFile, `${JSON.stringify({ version: 1, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
32
+ const migrated = await readWebuiSettings(settingsFile);
33
+ assert.equal(migrated.version, 2);
34
+ assert.equal(migrated.remoteAuthEnabled, true, "legacy Remote PIN state should survive schema migration");
35
+ assert.equal(isGitWorkflowSetupComplete(migrated.gitWorkflow), false);
36
+ assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
37
+ assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
38
+
39
+ const saved = await writeGitWorkflowPreferences({
40
+ generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off", unavailablePolicy: "ask" },
41
+ commit: { language: "de", defaultVariant: "long", scope: "required" },
42
+ stagingPolicy: "preserve",
43
+ deliveryMode: "pr-worktree",
44
+ verificationPolicy: "none",
45
+ }, settingsFile);
46
+ assert.equal(saved.setupVersion, GIT_WORKFLOW_SETUP_VERSION);
47
+ assert.equal(isGitWorkflowSetupComplete(saved), true);
48
+ assert.equal(saved.commit.language, "de");
49
+ assert.equal(saved.commit.defaultVariant, "long");
50
+ assert.equal(saved.stagingPolicy, "preserve");
51
+
52
+ const partiallyUpdated = await writeGitWorkflowPreferences({ deliveryMode: "current" }, settingsFile);
53
+ assert.equal(partiallyUpdated.generation.modelId, "fake-model", "partial updates should preserve the selected model");
54
+ assert.equal(partiallyUpdated.commit.language, "de", "partial updates should preserve nested commit preferences");
55
+ assert.equal(partiallyUpdated.deliveryMode, "current");
56
+
57
+ const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
58
+ assert.equal(persisted.version, 2);
59
+ assert.equal(persisted.remoteAuthEnabled, true);
60
+ assert.equal(persisted.gitWorkflow.generation.provider, "fake");
61
+ assert.match(gitWorkflowPreferencesSummary(await readGitWorkflowPreferences(settingsFile)), /fake\/fake-model/);
62
+ if (process.platform !== "win32") assert.equal((await stat(settingsFile)).mode & 0o777, 0o600);
63
+
64
+ console.log("git-workflow-preferences.test.mjs passed");
65
+ } finally {
66
+ await rm(root, { recursive: true, force: true });
67
+ }
@@ -217,6 +217,34 @@ try {
217
217
  const tabId = tabList[0].id;
218
218
  assert.ok(tabId, "tab should have an id");
219
219
 
220
+ const subagentFixtureStart = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents running" } });
221
+ assert.equal(subagentFixtureStart.status, 200, "subagent fixture status should be accepted");
222
+ let subagentsResponse;
223
+ for (let attempt = 0; attempt < 20; attempt++) {
224
+ subagentsResponse = await request("127.0.0.1", "/api/subagents");
225
+ if (subagentsResponse.body?.data?.totalAgents === 2) break;
226
+ await delay(50);
227
+ }
228
+ assert.equal(subagentsResponse?.status, 200, "subagent overview endpoint should respond");
229
+ assert.equal(subagentsResponse.body?.data?.totalAgents, 2, "subagent overview should count all running agents");
230
+ assert.equal(subagentsResponse.body?.data?.tabs?.[0]?.tabId, tabId, "subagent overview should group agents under their terminal tab");
231
+ assert.deepEqual(subagentsResponse.body?.data?.tabs?.[0]?.runs?.[0]?.agents?.map((agent) => agent.name), ["reviewer", "scout"], "subagent overview should preserve agent order within the session run");
232
+ const subagentOutputResponse = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=${encodeURIComponent("fixture-run")}&agent=${encodeURIComponent("fixture-run:0")}`);
233
+ assert.equal(subagentOutputResponse.status, 200, "running subagent output endpoint should respond");
234
+ assert.equal(subagentOutputResponse.body?.data?.agent?.name, "reviewer", "subagent output should target the selected child agent");
235
+ assert.deepEqual(subagentOutputResponse.body?.data?.agent?.recentOutput, ["Inspecting current implementation", "Waiting for the next tool result"], "subagent output should preserve bounded live output lines");
236
+ assert.equal(subagentOutputResponse.body?.data?.agent?.currentToolArgs, "README.md", "subagent output should include current tool state");
237
+ const unknownSubagentOutput = await request("127.0.0.1", `/api/subagents/output?tab=${encodeURIComponent(tabId)}&run=missing&agent=missing`);
238
+ assert.equal(unknownSubagentOutput.status, 404, "subagent output endpoint should reject untracked selections");
239
+ const subagentFixtureClear = await request("127.0.0.1", "/api/prompt", { method: "POST", body: { tab: tabId, message: "fixture subagents clear" } });
240
+ assert.equal(subagentFixtureClear.status, 200, "subagent fixture clear should be accepted");
241
+ for (let attempt = 0; attempt < 20; attempt++) {
242
+ subagentsResponse = await request("127.0.0.1", "/api/subagents");
243
+ if (subagentsResponse.body?.data?.totalAgents === 0) break;
244
+ await delay(50);
245
+ }
246
+ assert.equal(subagentsResponse.body?.data?.totalAgents, 0, "completed subagents should disappear from the running overview");
247
+
220
248
  const state = await request("127.0.0.1", `/api/state?tab=${encodeURIComponent(tabId)}`);
221
249
  assert.equal(state.status, 200);
222
250
  assert.equal(state.body?.data?.model?.provider, "fake", "state should come from the fake pi RPC");
@@ -0,0 +1,113 @@
1
+ import assert from "node:assert/strict";
2
+ import vm from "node:vm";
3
+ import { readFile } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath, URL } from "node:url";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const app = await readFile(join(root, "public", "app.js"), "utf8");
9
+
10
+ function findFunctionSource(source, name) {
11
+ const signature = new RegExp(`function\\s+${name}\\s*\\(`, "m");
12
+ const match = signature.exec(source);
13
+ assert.ok(match, `${name} should be defined`);
14
+ let parenDepth = 0;
15
+ let openBrace = -1;
16
+ for (let index = match.index + match[0].length - 1; index < source.length; index += 1) {
17
+ const char = source[index];
18
+ if (char === "(") parenDepth += 1;
19
+ else if (char === ")") parenDepth -= 1;
20
+ else if (char === "{" && parenDepth === 0) {
21
+ openBrace = index;
22
+ break;
23
+ }
24
+ }
25
+ assert.notEqual(openBrace, -1, `${name} body should open`);
26
+ let depth = 0;
27
+ for (let index = openBrace; index < source.length; index += 1) {
28
+ const char = source[index];
29
+ if (char === "{") depth += 1;
30
+ else if (char === "}") {
31
+ depth -= 1;
32
+ if (depth === 0) return source.slice(match.index, index + 1);
33
+ }
34
+ }
35
+ assert.fail(`${name} body should close`);
36
+ }
37
+
38
+ const helperNames = [
39
+ "markdownFilePathFromHref",
40
+ "safeMarkdownLinkHref",
41
+ "normalizeMarkdownWorkspacePath",
42
+ "markdownWorkspaceFilePath",
43
+ ];
44
+ const context = { URL };
45
+ vm.runInNewContext(
46
+ `${helperNames.map((name) => findFunctionSource(app, name)).join("\n\n")}\nthis.markdownLinkHelpers = { ${helperNames.join(", ")} };`,
47
+ context,
48
+ );
49
+ const {
50
+ markdownFilePathFromHref,
51
+ safeMarkdownLinkHref,
52
+ markdownWorkspaceFilePath,
53
+ } = context.markdownLinkHelpers;
54
+
55
+ for (const href of [
56
+ "https://example.com/docs",
57
+ "mailto:dev@example.com",
58
+ "#details",
59
+ "docs/README.md",
60
+ "./docs/README.md",
61
+ "../README.md",
62
+ "/home/dev/project/README.md",
63
+ "C:/Users/dev/project/README.md",
64
+ String.raw`C:\Users\dev\project\README.md`,
65
+ "file:///C:/Users/dev/project/README.md",
66
+ ]) {
67
+ assert.equal(safeMarkdownLinkHref(href), href, `safe Markdown link should be accepted: ${href}`);
68
+ }
69
+
70
+ for (const href of [
71
+ "javascript:alert(1)",
72
+ "data:text/html,unsafe",
73
+ "vbscript:msgbox(1)",
74
+ "//example.com/unsafe",
75
+ String.raw`\\server\share\README.md`,
76
+ "file://server/share/README.md",
77
+ ]) {
78
+ assert.equal(safeMarkdownLinkHref(href), "", `unsafe or remote-file Markdown link should be rejected: ${href}`);
79
+ }
80
+
81
+ assert.equal(markdownFilePathFromHref("README.md#overview"), "README.md");
82
+ assert.equal(markdownFilePathFromHref("file:///C:/My%20Project/README.md#overview"), "C:/My Project/README.md");
83
+ assert.equal(markdownFilePathFromHref(String.raw`C:\My Project\README.md`), "C:/My Project/README.md");
84
+ assert.equal(markdownFilePathFromHref("https://example.com/README.md"), "");
85
+
86
+ assert.equal(
87
+ markdownWorkspaceFilePath("C:/Users/Dev/Project/docs/README.md", String.raw`c:\users\dev\project`),
88
+ "docs/README.md",
89
+ "Windows workspace matching should be case-insensitive",
90
+ );
91
+ assert.equal(
92
+ markdownWorkspaceFilePath("file:///C:/Users/Dev/Project/My%20Doc.md", "C:/Users/Dev/Project"),
93
+ "My Doc.md",
94
+ "file URLs should resolve to a workspace-relative path",
95
+ );
96
+ assert.equal(
97
+ markdownWorkspaceFilePath("/home/dev/project/docs/README.md", "/home/dev/project"),
98
+ "docs/README.md",
99
+ "POSIX absolute paths should resolve inside the workspace",
100
+ );
101
+ assert.equal(markdownWorkspaceFilePath("docs/../README.md", "/unused"), "README.md");
102
+ assert.equal(markdownWorkspaceFilePath("../README.md", "/unused", "docs/guides"), "docs/README.md");
103
+ assert.equal(markdownWorkspaceFilePath("../../secret.txt", "/unused", "docs"), "", "relative traversal outside the workspace should be rejected");
104
+ assert.equal(markdownWorkspaceFilePath("D:/secret.txt", "C:/Users/Dev/Project"), "", "absolute paths outside the workspace should be rejected");
105
+ assert.equal(markdownWorkspaceFilePath("/home/dev/other/secret.txt", "/home/dev/project"), "", "POSIX paths outside the workspace should be rejected");
106
+
107
+ const configureMarkdownLinkSource = findFunctionSource(app, "configureMarkdownLink");
108
+ assert.match(configureMarkdownLinkSource, /link\.dataset\.markdownFileHref = href/, "local Markdown links should retain their file target");
109
+ assert.match(configureMarkdownLinkSource, /markdownWorkspaceFilePath\(href, cwd, basePath\)/, "local Markdown links should be scoped to the active workspace");
110
+ assert.match(configureMarkdownLinkSource, /openFileInViewer\(workspacePath\)/, "local Markdown links should open in the WebUI file viewer");
111
+ assert.match(app, /configureMarkdownLink\(link, href\);/, "inline Markdown rendering should configure every accepted link");
112
+
113
+ console.log("markdown link tests passed");