@firstpick/pi-package-webui 0.8.0 → 0.8.1

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.
Files changed (51) hide show
  1. package/README.md +22 -5
  2. package/bin/pi-webui.mjs +434 -100
  3. package/lib/npm-command.mjs +81 -0
  4. package/lib/queue-mutation.mjs +6 -0
  5. package/lib/workspace-files-live-watcher.mjs +138 -0
  6. package/package.json +8 -3
  7. package/public/app.js +2816 -314
  8. package/public/index.html +112 -27
  9. package/public/mobile-shell-state.mjs +166 -0
  10. package/public/service-worker.js +60 -13
  11. package/public/styles.css +1049 -371
  12. package/public/subagent-gate-visibility.mjs +16 -0
  13. package/public/subagent-launch-slot-state.mjs +16 -0
  14. package/public/transcript-renderer.mjs +433 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +739 -0
  17. package/tests/browser/mobile-foundation.spec.mjs +352 -0
  18. package/tests/browser/optimistic-prompt.spec.mjs +130 -0
  19. package/tests/chat-scroll-intent-static.test.mjs +6 -1
  20. package/tests/codex-fast-mode-static.test.mjs +8 -5
  21. package/tests/compact-sections-static.test.mjs +20 -2
  22. package/tests/compaction-mutation-contract.test.mjs +18 -4
  23. package/tests/compaction-static.test.mjs +1 -0
  24. package/tests/completion-signal-contract.test.mjs +13 -2
  25. package/tests/fast-mode-client-static.test.mjs +7 -4
  26. package/tests/fixtures/fake-pi.mjs +181 -2
  27. package/tests/git-panel-gitignore-static.test.mjs +104 -0
  28. package/tests/http-endpoints-harness.test.mjs +228 -2
  29. package/tests/interaction-state-stability-static.test.mjs +254 -0
  30. package/tests/mobile-continuity-tablet-static.test.mjs +55 -0
  31. package/tests/mobile-foundation-static.test.mjs +69 -0
  32. package/tests/mobile-phone-experience-static.test.mjs +65 -0
  33. package/tests/mobile-shell-state.test.mjs +69 -0
  34. package/tests/mobile-static.test.mjs +244 -38
  35. package/tests/mobile-transcript-cache-characterization.test.mjs +34 -0
  36. package/tests/npm-command.test.mjs +64 -1
  37. package/tests/open-issue-wizard-static.test.mjs +2 -1
  38. package/tests/queue-edit-reorder-static.test.mjs +9 -1
  39. package/tests/queue-mutation-contract.test.mjs +22 -0
  40. package/tests/service-worker-lifecycle.test.mjs +120 -0
  41. package/tests/sse-backpressure-harness.test.mjs +98 -0
  42. package/tests/streaming-ui-coupling.test.mjs +7 -1
  43. package/tests/subagent-gate-visibility.test.mjs +18 -2
  44. package/tests/subagent-launch-slot-state.test.mjs +32 -0
  45. package/tests/subagent-launch-slots-static.test.mjs +8 -2
  46. package/tests/subagents-helper.test.mjs +90 -0
  47. package/tests/terminal-tab-workspace-static.test.mjs +1 -1
  48. package/tests/update-commands.test.mjs +4 -0
  49. package/tests/workspace-files-live-updates-static.test.mjs +76 -0
  50. package/tests/workspace-files-live-watcher.test.mjs +95 -0
  51. package/webui-rpc-helper.mjs +175 -3
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=86" />
15
+ <link rel="stylesheet" href="/styles.css?v=92" />
16
16
  <script>
17
17
  // Public-only issue-bot runtime configuration. Keep disabled unless the gateway,
18
18
  // Turnstile site key, exact CORS origin, and private-report destination are approved.
@@ -126,6 +126,52 @@
126
126
  </div>
127
127
  </section>
128
128
 
129
+ <!-- Flagged phone/tablet shell: route content reuses the canonical nodes below. -->
130
+ <div id="mobileShellV2" class="mobile-shell-v2" hidden>
131
+ <p id="mobileLifecycleAnnouncer" class="sr-only" role="status" aria-live="polite" aria-atomic="true"></p>
132
+ <p id="mobileContinuityNotice" class="mobile-continuity-notice" role="status" hidden></p>
133
+ <header class="mobile-shell-appbar" aria-label="Phone app bar">
134
+ <button id="mobileSessionButton" class="mobile-shell-session-button" type="button" aria-label="Open Sessions"><span id="mobileSessionStatus" aria-hidden="true">○</span><span id="mobileSessionTitle">Session</span></button>
135
+ <div id="mobileShellIndicators" class="mobile-shell-indicators" role="group" aria-label="Connection and attention status"></div>
136
+ <button id="mobileSearchButton" class="mobile-shell-icon-button" type="button" aria-label="Open command palette">Search</button>
137
+ <button id="mobileMoreButton" class="mobile-shell-icon-button" type="button" aria-expanded="false" aria-controls="mobileShellSurface">More</button>
138
+ </header>
139
+ <div id="mobileShellDestination" class="mobile-shell-destination" tabindex="-1">
140
+ <section id="mobileSessionsRoute" class="mobile-route" data-mobile-route="sessions" aria-labelledby="mobileSessionsTitle" hidden>
141
+ <header class="mobile-route-header"><h1 id="mobileSessionsTitle" tabindex="-1">Sessions</h1><button id="mobileSessionsCloseAllButton" type="button">Close all</button></header>
142
+ <div class="mobile-session-actions" aria-label="New session actions">
143
+ <button id="mobileNewCurrentDirectoryButton" class="primary" type="button">New here</button><button id="mobileNewDirectoryButton" type="button">Choose folder</button><button id="mobileNewWorktreeButton" type="button">Worktree</button><button id="mobileResumeSessionButton" type="button">Resume</button>
144
+ </div>
145
+ <label class="mobile-search-field" for="mobileSessionsSearchInput">Search sessions<input id="mobileSessionsSearchInput" type="search" placeholder="Search sessions" autocomplete="off" /></label>
146
+ <p id="mobileSessionsStatus" class="mobile-route-status muted" role="status"></p>
147
+ <div id="mobileSessionsList" class="mobile-session-list"></div>
148
+ </section>
149
+ <section id="mobileActivityRoute" class="mobile-route" data-mobile-route="activity" aria-labelledby="mobileActivityTitle" hidden>
150
+ <header class="mobile-route-header"><h1 id="mobileActivityTitle" tabindex="-1">Activity</h1><button id="mobileActivityRefreshButton" type="button">Refresh</button></header>
151
+ <p id="mobileActivityStatus" class="mobile-route-status muted" role="status"></p>
152
+ <div id="mobileActivityList" class="mobile-activity-list"></div>
153
+ </section>
154
+ <section id="mobileProjectRoute" class="mobile-route" data-mobile-route="project" aria-labelledby="mobileProjectTitle" hidden>
155
+ <header class="mobile-route-header"><h1 id="mobileProjectTitle" tabindex="-1">Project</h1><span id="mobileProjectName" class="muted"></span></header>
156
+ <div id="mobileProjectTopics" class="mobile-topic-tabs" role="tablist" aria-label="Project topics">
157
+ <button type="button" role="tab" data-mobile-project-topic="files">Files</button><button type="button" role="tab" data-mobile-project-topic="git">Git</button><button type="button" role="tab" data-mobile-project-topic="queue">Queue</button><button type="button" role="tab" data-mobile-project-topic="workflows">Workflows</button>
158
+ </div>
159
+ <section id="mobileProjectContent" class="mobile-canonical-host" aria-live="off"></section>
160
+ </section>
161
+ </div>
162
+ <nav class="mobile-shell-nav" aria-label="Phone destinations">
163
+ <button type="button" data-mobile-route-button="chat"><span aria-hidden="true">●</span>Chat</button>
164
+ <button type="button" data-mobile-route-button="sessions"><span aria-hidden="true">▤</span>Sessions<span id="mobileSessionsBadge" class="mobile-nav-badge" hidden></span></button>
165
+ <button type="button" data-mobile-route-button="activity"><span aria-hidden="true">◌</span>Activity<span id="mobileActivityBadge" class="mobile-nav-badge" hidden></span></button>
166
+ <button type="button" data-mobile-route-button="project"><span aria-hidden="true">▣</span>Project<span id="mobileProjectBadge" class="mobile-nav-badge" hidden></span></button>
167
+ </nav>
168
+ <section id="mobileShellSurface" class="mobile-shell-surface" aria-label="Mobile actions" hidden>
169
+ <header class="mobile-surface-header"><button id="mobileSurfaceBackButton" type="button" hidden>Back</button><h1 id="mobileSurfaceTitle" tabindex="-1">More</h1><button id="mobileSurfaceCloseButton" type="button">Close</button></header>
170
+ <div id="mobileSurfaceRoot" class="mobile-surface-root"></div>
171
+ <section id="mobileSurfaceContent" class="mobile-canonical-host" aria-live="off"></section>
172
+ </section>
173
+ </div>
174
+
129
175
  <main class="layout">
130
176
  <section class="chat-panel">
131
177
  <header class="terminal-tabs-shell">
@@ -141,10 +187,10 @@
141
187
  </div>
142
188
  </div>
143
189
  <div class="terminal-sidebar-actions" aria-label="Tab and workspace actions">
144
- <button id="splitTabButton" class="terminal-split-button" type="button" aria-label="Split the active terminal to the right" aria-pressed="false"><svg class="terminal-split-icon terminal-split-icon-split" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12 5v14M15 12h4m0 0-2-2m2 2-2 2" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg class="terminal-split-icon terminal-split-icon-unsplit" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12 5v14M19 12h-4m0 0 2-2m-2 2 2 2" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><span class="terminal-sidebar-action-label terminal-sidebar-action-label-split">Split</span><span class="terminal-sidebar-action-label terminal-sidebar-action-label-unsplit">Unsplit</span></button>
145
- <button id="workspaceSaveButton" class="terminal-workspace-save-button" type="button" aria-label="Save workspace" data-tooltip="Save workspace:&#10;• Captures all open tabs, sessions, order, custom groups, and the active tab.&#10;• Available when at least one tab is open."><svg class="terminal-workspace-save-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 4h11l3 3v13H5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M8 4v6h7V4M8 19v-5h8v5" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></svg><span class="terminal-sidebar-action-label">Save workspace</span></button>
146
- <button id="commandPaletteButton" class="terminal-command-palette-button" type="button" aria-label="Open command palette" data-tooltip="Command palette:&#10;• Search and run actions, slash commands, models, and tabs.&#10;• Shortcut: Ctrl/Cmd+K."><svg class="composer-icon command-palette-launcher-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 7.5h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 12h9" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 16.5h5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M17 14.5 19.5 17 17 19.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><span class="terminal-sidebar-action-label">Commands</span></button>
147
- <button id="workspaceDashboardToggleButton" class="terminal-dashboard-button" type="button" aria-controls="workspaceDashboard" aria-expanded="false" aria-label="Show workspace overview" data-tooltip="Workspace overview:&#10;• Shows current tab, cwd, model, context, session, and queue.&#10;• Opens common workspace/session actions from one place."><svg class="composer-icon workspace-overview-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 11.4 12 4l8 7.4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.5 10.5V20h11v-9.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M10 20v-5h4v5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><span class="terminal-sidebar-action-label">Overview</span></button>
190
+ <button id="splitTabButton" class="terminal-split-button" type="button" aria-label="Split the active terminal to the right" aria-pressed="false"><svg class="terminal-split-icon terminal-split-icon-split" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12 5v14M15 12h4m0 0-2-2m2 2-2 2" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><svg class="terminal-split-icon terminal-split-icon-unsplit" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M12 5v14M19 12h-4m0 0 2-2m-2 2 2 2" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
191
+ <button id="workspaceSaveButton" class="terminal-workspace-save-button" type="button" aria-label="Save workspace" data-tooltip="Save workspace:&#10;• Captures all open tabs, sessions, order, custom groups, and the active tab.&#10;• Available when at least one tab is open."><svg class="terminal-workspace-save-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 4h11l3 3v13H5z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><path d="M8 4v6h7V4M8 19v-5h8v5" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/></svg></button>
192
+ <button id="commandPaletteButton" class="terminal-command-palette-button" type="button" aria-label="Open command palette" data-tooltip="Command palette:&#10;• Search and run actions, slash commands, models, and tabs.&#10;• Shortcut: Ctrl/Cmd+K."><svg class="composer-icon command-palette-launcher-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M5 7.5h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 12h9" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M5 16.5h5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M17 14.5 19.5 17 17 19.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
193
+ <button id="workspaceDashboardToggleButton" class="terminal-dashboard-button" type="button" aria-controls="workspaceDashboard" aria-expanded="false" aria-label="Show workspace overview" data-tooltip="Workspace overview:&#10;• Shows current tab, cwd, model, context, session, and queue.&#10;• Opens common workspace/session actions from one place."><svg class="composer-icon workspace-overview-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 11.4 12 4l8 7.4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.5 10.5V20h11v-9.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M10 20v-5h4v5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
148
194
  </div>
149
195
  <div id="remoteAccessIndicator" class="remote-access-indicator" role="status" aria-live="polite" hidden>Remote access open</div>
150
196
  <button id="closeAllTabsButton" class="terminal-close-all-button" type="button" aria-label="Close all terminal tabs">Close all Tabs</button>
@@ -166,6 +212,40 @@
166
212
  </header>
167
213
  <div id="subagentTerminalTranscript" class="subagent-terminal-transcript" role="log" aria-live="polite"></div>
168
214
  <p id="subagentTerminalStatus" class="subagent-terminal-status muted" aria-live="off"></p>
215
+ <footer id="subagentTerminalCards" class="subagent-terminal-cards" aria-label="Subagent session telemetry">
216
+ <dl class="subagent-terminal-card-list">
217
+ <div class="subagent-terminal-card" data-subagent-card="pi" title="Initial Pi prompt tokens injected into this child session.">
218
+ <span class="subagent-terminal-card-icon" aria-hidden="true">π</span>
219
+ <dt class="subagent-terminal-card-label">PI</dt>
220
+ <dd id="subagentTerminalCardPi" class="subagent-terminal-card-value">—</dd>
221
+ </div>
222
+ <div class="subagent-terminal-card" data-subagent-card="speed" title="Output tokens per second across completed child responses.">
223
+ <span class="subagent-terminal-card-icon" aria-hidden="true">⚡</span>
224
+ <dt class="subagent-terminal-card-label">Speed</dt>
225
+ <dd id="subagentTerminalCardSpeed" class="subagent-terminal-card-value">—</dd>
226
+ </div>
227
+ <div class="subagent-terminal-card" data-subagent-card="context" title="Latest child context load over its model context window.">
228
+ <span class="subagent-terminal-card-icon" aria-hidden="true">🧠</span>
229
+ <dt class="subagent-terminal-card-label">Context</dt>
230
+ <dd id="subagentTerminalCardContext" class="subagent-terminal-card-value">—</dd>
231
+ </div>
232
+ <div class="subagent-terminal-card" data-subagent-card="model" title="Effective model for this child run.">
233
+ <span class="subagent-terminal-card-icon" aria-hidden="true">🤖</span>
234
+ <dt class="subagent-terminal-card-label">Model</dt>
235
+ <dd id="subagentTerminalCardModel" class="subagent-terminal-card-value">unknown</dd>
236
+ </div>
237
+ <div class="subagent-terminal-card" data-subagent-card="effort" title="Effective reasoning effort for this child run.">
238
+ <span class="subagent-terminal-card-icon" aria-hidden="true">⚙</span>
239
+ <dt class="subagent-terminal-card-label">Effort</dt>
240
+ <dd id="subagentTerminalCardEffort" class="subagent-terminal-card-value">unknown</dd>
241
+ </div>
242
+ <div class="subagent-terminal-card" data-subagent-card="tokens" title="Input and output tokens found in the bounded recent child-session scan.">
243
+ <span class="subagent-terminal-card-icon" aria-hidden="true">🪙</span>
244
+ <dt class="subagent-terminal-card-label">Tokens</dt>
245
+ <dd id="subagentTerminalCardTokens" class="subagent-terminal-card-value">—</dd>
246
+ </div>
247
+ </dl>
248
+ </footer>
169
249
  <div class="subagent-terminal-composer" aria-label="Subagent input unavailable">
170
250
  <textarea id="subagentTerminalInput" rows="1" placeholder="View only — send messages from the parent terminal" aria-describedby="subagentTerminalInputHint" disabled></textarea>
171
251
  <button type="button" disabled>View only</button>
@@ -203,6 +283,11 @@
203
283
  <div id="gitWorkflowActions" class="git-workflow-actions"></div>
204
284
  </section>
205
285
  <form id="composer" class="composer">
286
+ <section id="mobileFailedSendRecovery" class="mobile-failed-send-recovery" role="status" hidden>
287
+ <span><strong>Not sent.</strong> Pi did not confirm this request. It will never retry automatically.</span>
288
+ <button id="mobileFailedSendRetryButton" type="button">Retry</button>
289
+ <button id="mobileFailedSendDiscardButton" type="button">Discard</button>
290
+ </section>
206
291
  <div id="commandSuggest" class="command-suggest" role="listbox" aria-label="Command and path suggestions" hidden></div>
207
292
  <div class="composer-input-row">
208
293
  <div id="workflowModeControls" class="composer-workflow-mode-dock" role="group" aria-label="Workflow Mode controls" hidden>
@@ -544,13 +629,13 @@
544
629
  </h2>
545
630
  <div id="sidePanelSectionControls" class="side-panel-section-content" hidden>
546
631
  <div class="side-panel-controls">
547
- <p class="controls-intro">Session controls affect the active Pi tab. Interface preferences are saved in this browser. Output processing is a shared server default.</p>
632
+ <p class="controls-intro">Settings apply to this tab, this browser, or the server.</p>
548
633
 
549
634
  <section class="control-group" aria-labelledby="sessionControlsTitle">
550
635
  <div class="control-group-header">
551
636
  <div class="control-group-heading">
552
637
  <h3 id="sessionControlsTitle">Active session</h3>
553
- <p>Choose how Pi responds in the current tab.</p>
638
+ <p>Model, effort, and transcript.</p>
554
639
  </div>
555
640
  <span class="control-scope-badge">This tab</span>
556
641
  </div>
@@ -603,7 +688,7 @@
603
688
  <div class="control-group-header">
604
689
  <div class="control-group-heading">
605
690
  <h3 id="interfaceControlsTitle">Interface</h3>
606
- <p>Personalise layout, appearance, and alerts.</p>
691
+ <p>Layout, theme, and alerts.</p>
607
692
  </div>
608
693
  <span class="control-scope-badge">This browser</span>
609
694
  </div>
@@ -658,7 +743,7 @@
658
743
  <div class="control-group-header">
659
744
  <div class="control-group-heading">
660
745
  <h3 id="outputProcessingControlsTitle">Output processing</h3>
661
- <p>Choose the default live-output path for auto-negotiated Web UI connections.</p>
746
+ <p>Default rendering for new Web UI connections.</p>
662
747
  </div>
663
748
  <span class="control-scope-badge">Server</span>
664
749
  </div>
@@ -682,7 +767,7 @@
682
767
  <div class="control-group-header">
683
768
  <div class="control-group-heading">
684
769
  <h3 id="remoteAccessControlsTitle">Remote access</h3>
685
- <p>Control trusted-LAN access and PIN protection.</p>
770
+ <p>LAN access and PIN protection.</p>
686
771
  </div>
687
772
  <span class="control-scope-badge warning">Network</span>
688
773
  </div>
@@ -704,7 +789,7 @@
704
789
  <div class="control-group-header">
705
790
  <div class="control-group-heading">
706
791
  <h3 id="serverControlsTitle">Server</h3>
707
- <p>Maintenance actions may interrupt every open tab.</p>
792
+ <p>Maintenance actions affect every open tab.</p>
708
793
  </div>
709
794
  <span class="control-scope-badge danger">System</span>
710
795
  </div>
@@ -795,13 +880,14 @@
795
880
  </button>
796
881
  </h2>
797
882
  <div id="sidePanelSectionCodexUsage" class="side-panel-section-content" hidden>
883
+ <div class="codex-usage-actions">
884
+ <button id="refreshCodexUsageButton" type="button">Refresh usage</button>
885
+ </div>
886
+ <div id="codexUsageBox" class="codex-usage-box muted">Checking Codex usage…</div>
798
887
  <div class="control-field codex-fast-mode-control" aria-labelledby="codexFastModeLabel">
799
- <div class="control-field-header">
800
- <label id="codexFastModeLabel" for="codexFastModeSelect">Fast mode</label>
801
- <span class="control-field-context">Subscription-backed Codex requests · This tab</span>
802
- </div>
803
- <div class="control-action-row">
804
- <select id="codexFastModeSelect" title="Codex subscription request tier" aria-describedby="codexFastModeStatus" disabled>
888
+ <div class="codex-fast-mode-row">
889
+ <label id="codexFastModeLabel" for="codexFastModeSelect" title="Fast mode for subscription-backed Codex requests on this tab">Fast mode</label>
890
+ <select id="codexFastModeSelect" title="Codex subscription request tier for this tab" aria-describedby="codexFastModeStatus" disabled>
805
891
  <option value="normal">Normal</option>
806
892
  <option value="fast">Fast</option>
807
893
  </select>
@@ -809,10 +895,6 @@
809
895
  </div>
810
896
  <div id="codexFastModeStatus" class="toggle-control-hint" role="status" aria-live="polite">Checking Codex Fast mode…</div>
811
897
  </div>
812
- <div class="codex-usage-actions">
813
- <button id="refreshCodexUsageButton" type="button">Refresh usage</button>
814
- </div>
815
- <div id="codexUsageBox" class="codex-usage-box muted">Checking Codex usage…</div>
816
898
  </div>
817
899
  </section>
818
900
  <section class="side-panel-section collapsed" data-side-panel-section="claude-usage">
@@ -862,8 +944,8 @@
862
944
  </summary>
863
945
  <div class="subagent-launch-slots-body">
864
946
  <div class="subagent-launch-slots-intro">
865
- <p>Choose model and thinking presets for future same-role launches. Running children are not changed.</p>
866
- <button id="subagentLaunchSlotsRefresh" type="button">Refresh models</button>
947
+ <p>Presets for future launches; running children stay unchanged.</p>
948
+ <button id="subagentLaunchSlotsRefresh" type="button" aria-label="Refresh available agent models">Refresh</button>
867
949
  </div>
868
950
  <div class="subagent-launch-slot-scope">
869
951
  <label for="subagentLaunchSlotScope">Apply to</label>
@@ -877,8 +959,8 @@
877
959
  <p id="subagentLaunchSlotsStatus" class="subagent-launch-slots-status muted" role="status" aria-live="polite">Loading agent models…</p>
878
960
  <div id="subagentLaunchSlotRoles" class="subagent-launch-slot-roles" aria-busy="true"></div>
879
961
  <div class="subagent-launch-slots-actions">
880
- <button id="subagentLaunchSlotsSave" class="primary" type="button" disabled>Save agent models</button>
881
- <span id="subagentLaunchSlotsDirty" class="muted">No unsaved changes</span>
962
+ <button id="subagentLaunchSlotsSave" class="primary" type="button" aria-describedby="subagentLaunchSlotsDirty" disabled>Save agent models</button>
963
+ <span id="subagentLaunchSlotsDirty" class="muted" role="status" aria-live="polite">Agent model configuration is not available for this tab.</span>
882
964
  </div>
883
965
  <div id="subagentLaunchSlotsReloadActions" class="subagent-launch-slots-reload-actions" hidden>
884
966
  <span>Saved changes apply to future launches after this tab reloads.</span>
@@ -896,7 +978,10 @@
896
978
  </select>
897
979
  <span id="subagentOpenModeStatus" class="muted">Overlay · saved in this browser</span>
898
980
  </div>
899
- <p id="subagentsStatus" class="subagents-status muted" role="status" aria-live="polite">Checking running subagents…</p>
981
+ <div class="subagents-status-row">
982
+ <p id="subagentsStatus" class="subagents-status muted" role="status" aria-live="polite">Checking running subagents…</p>
983
+ <button id="subagentsClearFinishedButton" class="subagents-clear-finished-button" type="button" aria-describedby="subagentsStatus" disabled>Clear finished</button>
984
+ </div>
900
985
  <div id="subagentsBox" class="subagents-box muted">Checking running subagents…</div>
901
986
  </div>
902
987
  </section>
@@ -1383,7 +1468,7 @@
1383
1468
  </form>
1384
1469
  </dialog>
1385
1470
 
1386
- <script id="webuiBootLoader" data-app-src="/app.js?v=94">
1471
+ <script id="webuiBootLoader" data-app-src="/app.js?v=103">
1387
1472
  (() => {
1388
1473
  "use strict";
1389
1474
 
@@ -0,0 +1,166 @@
1
+ // Pure, browser-independent state helpers for the opt-in Mobile Experience v2
2
+ // shell. Rendering remains in app.js until functional mobile destinations land.
3
+
4
+ export const MOBILE_SHELL_V2_DEFAULT = false;
5
+ export const TABLET_SHELL_V2_DEFAULT = false;
6
+ export const MOBILE_SHELL_STORAGE_KEY = "pi-webui-mobile-shell-v2";
7
+ export const TABLET_SHELL_STORAGE_KEY = "pi-webui-tablet-shell-v2";
8
+ export const MOBILE_ROUTES = new Set(["chat", "sessions", "activity", "project"]);
9
+ export const MOBILE_SURFACES = new Set(["none", "more", "actionSheet", "file", "dialog"]);
10
+ export const MOBILE_TARGET_VERSION = 1;
11
+
12
+ const OPAQUE_ID = /^[A-Za-z0-9_-]{8,128}$/;
13
+ const FEATURE_MODES = new Set(["legacy", "preview", "v2"]);
14
+
15
+ function safeString(value) {
16
+ return typeof value === "string" ? value : "";
17
+ }
18
+
19
+ function opaqueId(value) {
20
+ const normalized = safeString(value);
21
+ return OPAQUE_ID.test(normalized) ? normalized : null;
22
+ }
23
+
24
+ export function classifyMobileViewport({ width = 0, height = 0, coarsePointer = false, hover = true } = {}) {
25
+ const safeWidth = Number.isFinite(width) ? width : 0;
26
+ const safeHeight = Number.isFinite(height) ? height : 0;
27
+ const compactLandscapePhone = coarsePointer === true && hover === false && safeHeight <= 500 && safeWidth <= 950;
28
+ if (safeWidth <= 720 || compactLandscapePhone) {
29
+ return { viewportMode: "phone", posture: compactLandscapePhone ? "compactLandscapePhone" : "regular" };
30
+ }
31
+ if (safeWidth <= 1050) return { viewportMode: "tablet", posture: "regular" };
32
+ return { viewportMode: "desktop", posture: "regular" };
33
+ }
34
+
35
+ export function resolveMobileShellFeatureMode({ urlValue, storedValue, defaultEnabled = MOBILE_SHELL_V2_DEFAULT } = {}) {
36
+ if (urlValue === "legacy") return "legacy";
37
+ if (urlValue === "v2") return "v2";
38
+ if (storedValue === "legacy") return "legacy";
39
+ if (storedValue === "preview") return "preview";
40
+ return defaultEnabled === true ? "v2" : "legacy";
41
+ }
42
+
43
+ export function resolveTabletShellFeatureMode({ urlValue, storedValue, defaultEnabled = TABLET_SHELL_V2_DEFAULT } = {}) {
44
+ return resolveMobileShellFeatureMode({ urlValue, storedValue, defaultEnabled });
45
+ }
46
+
47
+ export function isMobileShellV2Enabled(featureMode, viewportMode, tabletFeatureMode = "legacy") {
48
+ if (viewportMode === "phone") return featureMode === "preview" || featureMode === "v2";
49
+ if (viewportMode === "tablet") return tabletFeatureMode === "preview" || tabletFeatureMode === "v2";
50
+ return false;
51
+ }
52
+
53
+ export function createMobileShellState({ viewport = {}, featureMode = "legacy", tabletFeatureMode = "legacy", route = "chat" } = {}) {
54
+ const { viewportMode, posture } = classifyMobileViewport(viewport);
55
+ return {
56
+ viewportMode,
57
+ posture,
58
+ featureMode: FEATURE_MODES.has(featureMode) ? featureMode : "legacy",
59
+ tabletFeatureMode: FEATURE_MODES.has(tabletFeatureMode) ? tabletFeatureMode : "legacy",
60
+ route: MOBILE_ROUTES.has(route) ? route : "chat",
61
+ surface: "none",
62
+ surfacePage: "root",
63
+ routeHistory: [],
64
+ };
65
+ }
66
+
67
+ function normalizedState(state) {
68
+ const next = state && typeof state === "object" ? state : {};
69
+ return {
70
+ viewportMode: ["phone", "tablet", "desktop"].includes(next.viewportMode) ? next.viewportMode : "desktop",
71
+ posture: ["regular", "compactLandscapePhone"].includes(next.posture) ? next.posture : "regular",
72
+ featureMode: FEATURE_MODES.has(next.featureMode) ? next.featureMode : "legacy",
73
+ tabletFeatureMode: FEATURE_MODES.has(next.tabletFeatureMode) ? next.tabletFeatureMode : "legacy",
74
+ route: MOBILE_ROUTES.has(next.route) ? next.route : "chat",
75
+ surface: MOBILE_SURFACES.has(next.surface) ? next.surface : "none",
76
+ surfacePage: safeString(next.surfacePage) || "root",
77
+ routeHistory: Array.isArray(next.routeHistory) ? next.routeHistory.filter((route) => MOBILE_ROUTES.has(route)).slice(-16) : [],
78
+ };
79
+ }
80
+
81
+ function closeSurface(state) {
82
+ return { ...state, surface: "none", surfacePage: "root" };
83
+ }
84
+
85
+ export function reduceMobileShellState(state, event = {}) {
86
+ const current = normalizedState(state);
87
+ switch (event.type) {
88
+ case "viewport": {
89
+ const viewport = classifyMobileViewport(event.viewport);
90
+ const next = { ...current, ...viewport };
91
+ if (!isMobileShellV2Enabled(next.featureMode, next.viewportMode, next.tabletFeatureMode)) return closeSurface(next);
92
+ return next;
93
+ }
94
+ case "feature": {
95
+ const next = { ...current, featureMode: FEATURE_MODES.has(event.featureMode) ? event.featureMode : "legacy" };
96
+ return isMobileShellV2Enabled(next.featureMode, next.viewportMode, next.tabletFeatureMode) ? next : closeSurface(next);
97
+ }
98
+ case "tablet-feature": {
99
+ const next = { ...current, tabletFeatureMode: FEATURE_MODES.has(event.featureMode) ? event.featureMode : "legacy" };
100
+ return isMobileShellV2Enabled(next.featureMode, next.viewportMode, next.tabletFeatureMode) ? next : closeSurface(next);
101
+ }
102
+ case "route": {
103
+ const route = MOBILE_ROUTES.has(event.route) ? event.route : current.route;
104
+ const routeHistory = event.replace === true || route === current.route
105
+ ? current.routeHistory
106
+ : [...current.routeHistory, current.route].slice(-16);
107
+ return { ...closeSurface(current), route, routeHistory };
108
+ }
109
+ case "surface": {
110
+ if (!MOBILE_SURFACES.has(event.surface) || event.surface === "none") return closeSurface(current);
111
+ return { ...current, surface: event.surface, surfacePage: event.page || "root" };
112
+ }
113
+ case "surface-page": {
114
+ if (current.surface === "none" || !safeString(event.page)) return current;
115
+ return { ...current, surfacePage: event.page };
116
+ }
117
+ case "back": {
118
+ if (current.surface === "dialog") return closeSurface(current);
119
+ if (current.surface !== "none" && current.surfacePage !== "root") return { ...current, surfacePage: "root" };
120
+ if (current.surface !== "none") return closeSurface(current);
121
+ const previousRoute = current.routeHistory.at(-1);
122
+ if (!previousRoute) return current;
123
+ return { ...current, route: previousRoute, routeHistory: current.routeHistory.slice(0, -1) };
124
+ }
125
+ default:
126
+ return current;
127
+ }
128
+ }
129
+
130
+ export function normalizeMobileNavigationTarget(value) {
131
+ const target = value && typeof value === "object" && !Array.isArray(value) ? value : {};
132
+ if (target.v !== MOBILE_TARGET_VERSION || !MOBILE_ROUTES.has(target.route)) return null;
133
+ const tabId = opaqueId(target.tabId);
134
+ const runId = opaqueId(target.runId);
135
+ const blockerId = opaqueId(target.blockerId);
136
+ if (!tabId && !runId && !blockerId) return null;
137
+ return {
138
+ v: MOBILE_TARGET_VERSION,
139
+ route: target.route,
140
+ ...(tabId ? { tabId } : {}),
141
+ ...(runId ? { runId } : {}),
142
+ ...(blockerId ? { blockerId } : {}),
143
+ };
144
+ }
145
+
146
+ export function mobileNavigationTargetFromSearch(search = "") {
147
+ const params = new URLSearchParams(search);
148
+ const target = {
149
+ v: MOBILE_TARGET_VERSION,
150
+ route: params.get("mobileRoute"),
151
+ tabId: params.get("tab"),
152
+ runId: params.get("run"),
153
+ blockerId: params.get("blocker"),
154
+ };
155
+ return normalizeMobileNavigationTarget(target);
156
+ }
157
+
158
+ export function mobileNavigationTargetSearch(target) {
159
+ const normalized = normalizeMobileNavigationTarget(target);
160
+ if (!normalized) return "";
161
+ const params = new URLSearchParams({ mobileRoute: normalized.route });
162
+ if (normalized.tabId) params.set("tab", normalized.tabId);
163
+ if (normalized.runId) params.set("run", normalized.runId);
164
+ if (normalized.blockerId) params.set("blocker", normalized.blockerId);
165
+ return params.toString();
166
+ }
@@ -1,4 +1,4 @@
1
- const CACHE_NAME = "pi-webui-pwa-v50";
1
+ const CACHE_NAME = "pi-webui-pwa-v61";
2
2
  const APP_SHELL = [
3
3
  "/",
4
4
  "/index.html",
@@ -6,10 +6,12 @@ const APP_SHELL = [
6
6
  "/app.js",
7
7
  "/issue-wizard-state.mjs",
8
8
  "/issue-bot-client.mjs",
9
+ "/mobile-shell-state.mjs",
9
10
  "/aur-review-payload.mjs",
10
11
  "/guided-git-command-state.mjs",
11
12
  "/guided-git-review-state.mjs",
12
13
  "/fast-output-live.mjs",
14
+ "/transcript-renderer.mjs",
13
15
  "/subagent-launch-slot-state.mjs",
14
16
  "/subagent-gate-visibility.mjs",
15
17
  "/workflow-status-stack.mjs",
@@ -35,13 +37,43 @@ self.addEventListener("activate", (event) => {
35
37
  );
36
38
  });
37
39
 
40
+ const OPAQUE_TARGET_ID = /^[A-Za-z0-9_-]{8,128}$/;
41
+ const MOBILE_NAVIGATION_MESSAGE_TYPE = "pi-webui:navigate:v1";
42
+
43
+ function notificationTarget(data) {
44
+ const target = data?.target;
45
+ if (!target || target.v !== 1 || !["chat", "sessions", "activity", "project"].includes(target.route)) return null;
46
+ const normalized = { v: 1, route: target.route };
47
+ for (const key of ["tabId", "runId", "blockerId"]) {
48
+ if (typeof target[key] === "string" && OPAQUE_TARGET_ID.test(target[key])) normalized[key] = target[key];
49
+ }
50
+ return Object.keys(normalized).length > 2 ? normalized : null;
51
+ }
52
+
53
+ function notificationTargetUrl(data) {
54
+ const target = notificationTarget(data);
55
+ if (!target) return `${self.location.origin}/`;
56
+ const url = new URL("/", self.location.origin);
57
+ url.searchParams.set("mobileRoute", target.route);
58
+ if (target.tabId) url.searchParams.set("tab", target.tabId);
59
+ if (target.runId) url.searchParams.set("run", target.runId);
60
+ if (target.blockerId) url.searchParams.set("blocker", target.blockerId);
61
+ return url.href;
62
+ }
63
+
38
64
  self.addEventListener("notificationclick", (event) => {
39
65
  event.notification.close();
40
- const targetUrl = event.notification.data?.url || `${self.location.origin}/`;
66
+ const target = notificationTarget(event.notification.data);
67
+ const targetUrl = notificationTargetUrl(event.notification.data);
41
68
  event.waitUntil(
42
69
  self.clients.matchAll({ type: "window", includeUncontrolled: true }).then((clients) => {
43
70
  const webuiClient = clients.find((client) => client.url.startsWith(self.location.origin));
44
- if (webuiClient) return webuiClient.focus();
71
+ if (webuiClient) {
72
+ return webuiClient.focus().then((client) => {
73
+ if (target) client.postMessage({ type: MOBILE_NAVIGATION_MESSAGE_TYPE, target });
74
+ return client;
75
+ });
76
+ }
45
77
  return self.clients.openWindow?.(targetUrl);
46
78
  }),
47
79
  );
@@ -49,14 +81,29 @@ self.addEventListener("notificationclick", (event) => {
49
81
 
50
82
  // Network-first keeps the app shell fresh after deploys regardless of
51
83
  // CACHE_NAME or ?v= cache-buster drift; the cache only serves offline clients.
52
- function fetchThenCache(request) {
53
- return fetch(request).then((response) => {
54
- if (response.ok) {
55
- const copy = response.clone();
56
- caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
57
- }
58
- return response;
59
- });
84
+ // A bounded request prevents a stalled browser network service from blocking
85
+ // startup forever. Cache writes extend the event lifetime without delaying a
86
+ // usable network response, so a stalled CacheStorage service cannot block boot.
87
+ const APP_SHELL_NETWORK_TIMEOUT_MS = 8_000;
88
+
89
+ function fetchWithTimeout(request) {
90
+ const controller = new AbortController();
91
+ const timeout = setTimeout(() => controller.abort(), APP_SHELL_NETWORK_TIMEOUT_MS);
92
+ return fetch(request, { signal: controller.signal }).finally(() => clearTimeout(timeout));
93
+ }
94
+
95
+ function fetchThenCache(event) {
96
+ const { request } = event;
97
+ const networkResponse = fetchWithTimeout(request);
98
+ event.waitUntil(
99
+ networkResponse
100
+ .then((response) => {
101
+ if (!response.ok) return undefined;
102
+ return caches.open(CACHE_NAME).then((cache) => cache.put(request, response.clone()));
103
+ })
104
+ .catch(() => undefined),
105
+ );
106
+ return networkResponse;
60
107
  }
61
108
 
62
109
  // ignoreSearch lets precached bare paths satisfy ?v= cache-busted requests offline.
@@ -75,10 +122,10 @@ self.addEventListener("fetch", (event) => {
75
122
  if (url.origin !== self.location.origin || url.pathname.startsWith("/api/")) return;
76
123
 
77
124
  if (request.mode === "navigate") {
78
- event.respondWith(fetchThenCache(request).catch(() => cachedAppShell(request, "/index.html")));
125
+ event.respondWith(fetchThenCache(event).catch(() => cachedAppShell(request, "/index.html")));
79
126
  return;
80
127
  }
81
128
 
82
129
  if (!APP_SHELL.includes(url.pathname)) return;
83
- event.respondWith(fetchThenCache(request).catch(() => cachedAppShell(request)));
130
+ event.respondWith(fetchThenCache(event).catch(() => cachedAppShell(request)));
84
131
  });