@firstpick/pi-package-webui 0.11.1 → 0.11.3

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 (310) hide show
  1. package/DEVELOPMENT.md +151 -12
  2. package/README.md +34 -6
  3. package/TECHNICAL.md +75 -8
  4. package/bin/pi-webui.mjs +5390 -11423
  5. package/index.ts +10 -3
  6. package/lib/component-update-state.mjs +2 -2
  7. package/lib/git-workflow-preference-values.mjs +122 -0
  8. package/lib/git-workflow-preferences.mjs +35 -563
  9. package/lib/package-updates.mjs +260 -0
  10. package/lib/rpc-supervisor-client.mjs +8 -4
  11. package/lib/server/app-runners.mjs +1667 -0
  12. package/lib/server/codex-fast-mode.mjs +161 -0
  13. package/lib/server/conversation-mode.mjs +218 -0
  14. package/lib/server/conversation-voice.mjs +318 -0
  15. package/lib/server/extension-ui-requests.mjs +114 -0
  16. package/lib/server/git-generation.mjs +459 -0
  17. package/lib/server/git-mutations.mjs +1827 -0
  18. package/lib/server/git-reads.mjs +608 -0
  19. package/lib/server/git-worktree-sessions.mjs +408 -0
  20. package/lib/server/helper-requests.mjs +82 -0
  21. package/lib/server/no-project-workspaces.mjs +103 -0
  22. package/lib/server/rpc-transports.mjs +394 -0
  23. package/lib/server/settings-store.mjs +544 -0
  24. package/lib/server/sse-delivery.mjs +138 -0
  25. package/lib/server/workspace-files.mjs +563 -0
  26. package/lib/update/supervisor.mjs +4 -0
  27. package/lib/webui-workspaces.mjs +2 -0
  28. package/package.json +4 -4
  29. package/public/activity-agents-controller.mjs +269 -0
  30. package/public/activity-events-controller.mjs +236 -0
  31. package/public/activity-intercom-controller.mjs +627 -0
  32. package/public/activity-queue-controller.mjs +534 -0
  33. package/public/activity-todo-view.mjs +89 -0
  34. package/public/activity-usage-controller.mjs +589 -0
  35. package/public/app.js +3761 -3886
  36. package/public/conversation-overview.css +84 -0
  37. package/public/conversation-overview.mjs +193 -0
  38. package/public/draft-conversations.mjs +135 -0
  39. package/public/focused-composer-controls.css +111 -0
  40. package/public/focused-composer-controls.mjs +143 -0
  41. package/public/focused-composer-disclosure.mjs +223 -0
  42. package/public/focused-shell-adapter.css +264 -0
  43. package/public/focused-shell-adapter.mjs +257 -0
  44. package/public/index.html +137 -80
  45. package/public/model-catalog-order.mjs +63 -0
  46. package/public/platform-event-stream.mjs +64 -0
  47. package/public/project-artifact-controller.mjs +218 -0
  48. package/public/project-file-viewer-controller.mjs +383 -0
  49. package/public/project-git-tools-controller.mjs +181 -0
  50. package/public/project-runners-controller.mjs +220 -0
  51. package/public/service-worker.js +52 -1
  52. package/public/session-attention-scheduler.mjs +182 -0
  53. package/public/session-composer-store.mjs +56 -0
  54. package/public/session-context.mjs +51 -0
  55. package/public/session-extension-requests.mjs +63 -0
  56. package/public/session-shelf-state.mjs +151 -0
  57. package/public/session-shelves.css +171 -0
  58. package/public/session-shelves.mjs +95 -0
  59. package/public/settings-navigation-controller.mjs +249 -0
  60. package/public/settings-navigation.css +61 -0
  61. package/public/settings-resource-controller.mjs +232 -0
  62. package/public/settings-workspace.css +19 -0
  63. package/public/settings-workspace.mjs +175 -0
  64. package/public/shell-actions.mjs +87 -0
  65. package/public/shell-attention-inbox.css +72 -0
  66. package/public/shell-attention-inbox.mjs +198 -0
  67. package/public/shell-context-actions.css +61 -0
  68. package/public/shell-context-actions.mjs +168 -0
  69. package/public/shell-inspector-resize.mjs +124 -0
  70. package/public/shell-navigation-resize.mjs +107 -0
  71. package/public/shell-navigation.mjs +127 -0
  72. package/public/shell-preferences.mjs +108 -0
  73. package/public/shell-surfaces.mjs +99 -0
  74. package/public/shell-tools-launcher.css +97 -0
  75. package/public/shell-tools-launcher.mjs +222 -0
  76. package/public/shell-view-host.mjs +115 -0
  77. package/public/shell-workspace.css +266 -0
  78. package/public/shell-workspace.mjs +402 -0
  79. package/public/sidebar-update-menu.css +190 -0
  80. package/public/sidebar-update-menu.mjs +512 -0
  81. package/public/styles.css +322 -169
  82. package/public/subagent-launch-slot-state.mjs +2 -2
  83. package/public/themed-selects.css +156 -0
  84. package/public/workspace-choices.mjs +104 -0
  85. package/tests/activity-agents-controller.test.mjs +652 -0
  86. package/tests/activity-events-controller.test.mjs +511 -0
  87. package/tests/app-runner-terminal-static.test.mjs +3 -3
  88. package/tests/append-system-http.test.mjs +7 -6
  89. package/tests/append-system-selector-static.test.mjs +6 -6
  90. package/tests/aur-review-widget-static.test.mjs +11 -3
  91. package/tests/boot-failure-diagnostics.test.mjs +8 -3
  92. package/tests/browser/action-feedback-gutter.spec.mjs +251 -0
  93. package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
  94. package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
  95. package/tests/browser/activity-owner-integration.spec.mjs +201 -0
  96. package/tests/browser/activity-queue-controller.spec.mjs +405 -0
  97. package/tests/browser/activity-section-picker.spec.mjs +294 -0
  98. package/tests/browser/activity-todo-view.spec.mjs +60 -0
  99. package/tests/browser/activity-usage-controller.spec.mjs +416 -0
  100. package/tests/browser/compact-layout-integration.spec.mjs +58 -0
  101. package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
  102. package/tests/browser/composer-disclosure.spec.mjs +389 -0
  103. package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
  104. package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
  105. package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
  106. package/tests/browser/control-visibility.spec.mjs +5 -0
  107. package/tests/browser/controls-layout.spec.mjs +21 -2
  108. package/tests/browser/conversation-overview.spec.mjs +251 -0
  109. package/tests/browser/draft-conversations.spec.mjs +276 -0
  110. package/tests/browser/empty-startup-fixture.mjs +135 -0
  111. package/tests/browser/empty-startup.spec.mjs +282 -0
  112. package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
  113. package/tests/browser/focused-composer-more.spec.mjs +127 -0
  114. package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
  115. package/tests/browser/focused-navigation-fixture.mjs +32 -0
  116. package/tests/browser/focused-project-activity.spec.mjs +111 -0
  117. package/tests/browser/focused-shell-integration.spec.mjs +208 -0
  118. package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
  119. package/tests/browser/folder-picker-layout.spec.mjs +302 -0
  120. package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
  121. package/tests/browser/git-setup-cancel.spec.mjs +251 -0
  122. package/tests/browser/guided-git-fallback.spec.mjs +40 -21
  123. package/tests/browser/inspector-header.spec.mjs +221 -0
  124. package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
  125. package/tests/browser/inspector-resize.spec.mjs +227 -0
  126. package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
  127. package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
  128. package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
  129. package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
  130. package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
  131. package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
  132. package/tests/browser/interaction-continuity.spec.mjs +50 -26
  133. package/tests/browser/interaction-model-picker.spec.mjs +86 -0
  134. package/tests/browser/last-terminal-close.spec.mjs +280 -0
  135. package/tests/browser/mobile-foundation.spec.mjs +172 -20
  136. package/tests/browser/model-catalog-groups.spec.mjs +104 -0
  137. package/tests/browser/more-row-menus.spec.mjs +258 -0
  138. package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
  139. package/tests/browser/no-project-conversation.spec.mjs +113 -0
  140. package/tests/browser/optimistic-prompt.spec.mjs +3 -0
  141. package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
  142. package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
  143. package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
  144. package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
  145. package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
  146. package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
  147. package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
  148. package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
  149. package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
  150. package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
  151. package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
  152. package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
  153. package/tests/browser/project-artifact-controller.spec.mjs +324 -0
  154. package/tests/browser/project-artifact-integration.spec.mjs +103 -0
  155. package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
  156. package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
  157. package/tests/browser/session-fixture.mjs +118 -0
  158. package/tests/browser/session-ownership.spec.mjs +175 -0
  159. package/tests/browser/session-shelves-integration.spec.mjs +219 -0
  160. package/tests/browser/session-shelves.spec.mjs +340 -0
  161. package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
  162. package/tests/browser/session-summary.spec.mjs +17 -12
  163. package/tests/browser/settings-complete-home.spec.mjs +463 -0
  164. package/tests/browser/settings-entrypoint.spec.mjs +104 -0
  165. package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
  166. package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
  167. package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
  168. package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
  169. package/tests/browser/shell-ownership.spec.mjs +398 -0
  170. package/tests/browser/shell-rollout-fixture.mjs +259 -0
  171. package/tests/browser/shell-rollout.spec.mjs +357 -0
  172. package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
  173. package/tests/browser/shell-workspace.spec.mjs +433 -0
  174. package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
  175. package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
  176. package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
  177. package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
  178. package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
  179. package/tests/browser/stream-output-isolation.spec.mjs +6 -3
  180. package/tests/browser/themed-selects.spec.mjs +297 -0
  181. package/tests/browser/thread-start-flow.spec.mjs +481 -0
  182. package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
  183. package/tests/browser/ui-polish-features.spec.mjs +85 -0
  184. package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
  185. package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
  186. package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
  187. package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
  188. package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
  189. package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
  190. package/tests/browser/windows-drive-parent.spec.mjs +4 -2
  191. package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
  192. package/tests/codex-fast-mode-static.test.mjs +16 -11
  193. package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
  194. package/tests/codex-usage-source.test.mjs +4 -3
  195. package/tests/component-update-api-static.test.mjs +2 -2
  196. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  197. package/tests/control-deck-component-updates-static.test.mjs +9 -4
  198. package/tests/control-visibility-static.test.mjs +3 -3
  199. package/tests/controls-layout-static.test.mjs +5 -5
  200. package/tests/conversation-overview-adapter.test.mjs +100 -0
  201. package/tests/document-artifact-static.test.mjs +2 -1
  202. package/tests/draft-conversations.test.mjs +205 -0
  203. package/tests/empty-startup-launcher.test.mjs +197 -0
  204. package/tests/events-tree-context-menu-static.test.mjs +22 -18
  205. package/tests/fake-pi-session-ownership.test.mjs +302 -0
  206. package/tests/fast-mode-client-static.test.mjs +1 -1
  207. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  208. package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
  209. package/tests/file-viewer-image-static.test.mjs +15 -11
  210. package/tests/file-viewer-search-static.test.mjs +5 -5
  211. package/tests/fixtures/fake-pi.mjs +41 -9
  212. package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
  213. package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
  214. package/tests/git-footer-context-menu-static.test.mjs +1 -1
  215. package/tests/git-panel-file-preview-static.test.mjs +41 -48
  216. package/tests/git-panel-live-updates-static.test.mjs +2 -1
  217. package/tests/git-workflow-dispatch.test.mjs +66 -0
  218. package/tests/git-workflow-preferences.test.mjs +9 -1
  219. package/tests/guided-git-activation-static.test.mjs +14 -11
  220. package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
  221. package/tests/guided-git-message-reliability-static.test.mjs +10 -6
  222. package/tests/guided-git-publication-backend-static.test.mjs +16 -11
  223. package/tests/http-endpoints-harness.test.mjs +21 -9
  224. package/tests/interaction-state-stability-static.test.mjs +4 -3
  225. package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
  226. package/tests/intercom-tag-layout-static.test.mjs +13 -12
  227. package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
  228. package/tests/main-output-loading-static.test.mjs +4 -4
  229. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  230. package/tests/mobile-compact-layout.test.mjs +2 -2
  231. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  232. package/tests/mobile-foundation-static.test.mjs +10 -7
  233. package/tests/mobile-phone-experience-static.test.mjs +3 -2
  234. package/tests/mobile-static.test.mjs +173 -135
  235. package/tests/model-catalog-order.test.mjs +103 -0
  236. package/tests/native-parity.test.mjs +6 -4
  237. package/tests/native-session-choice-owner.test.mjs +102 -0
  238. package/tests/native-update-lifecycle.test.mjs +10 -5
  239. package/tests/no-project-http-harness.test.mjs +328 -0
  240. package/tests/no-project-navigation.test.mjs +54 -0
  241. package/tests/no-project-workspaces.test.mjs +77 -0
  242. package/tests/open-issue-wizard-static.test.mjs +1 -1
  243. package/tests/optional-feature-migration-frontend.test.mjs +4 -4
  244. package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
  245. package/tests/package-updates.test.mjs +630 -0
  246. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  247. package/tests/platform-event-stream.test.mjs +253 -0
  248. package/tests/project-file-viewer-controller.test.mjs +652 -0
  249. package/tests/project-git-tools-adapter.test.mjs +103 -0
  250. package/tests/project-git-tools-controller.test.mjs +577 -0
  251. package/tests/project-runners-controller.test.mjs +453 -0
  252. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  253. package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
  254. package/tests/questionnaire-dialog.test.mjs +6 -6
  255. package/tests/queue-edit-reorder-static.test.mjs +48 -51
  256. package/tests/rpc-supervisor-host.test.mjs +4 -1
  257. package/tests/safety-guard-auto-review-static.test.mjs +1 -1
  258. package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
  259. package/tests/server-app-runners.test.mjs +536 -0
  260. package/tests/server-codex-fast-mode.test.mjs +346 -0
  261. package/tests/server-conversation-mode.test.mjs +386 -0
  262. package/tests/server-conversation-voice.test.mjs +426 -0
  263. package/tests/server-extension-ui-requests.test.mjs +357 -0
  264. package/tests/server-git-generation.test.mjs +558 -0
  265. package/tests/server-git-mutations.test.mjs +729 -0
  266. package/tests/server-git-reads.test.mjs +381 -0
  267. package/tests/server-git-worktree-sessions.test.mjs +502 -0
  268. package/tests/server-helper-requests.test.mjs +364 -0
  269. package/tests/server-rpc-transports.test.mjs +553 -0
  270. package/tests/server-settings-store.test.mjs +132 -0
  271. package/tests/server-shell-rollout.test.mjs +478 -0
  272. package/tests/server-sse-delivery.test.mjs +410 -0
  273. package/tests/server-workspace-files.test.mjs +546 -0
  274. package/tests/session-attention-scheduler.test.mjs +514 -0
  275. package/tests/session-composer-store.test.mjs +153 -0
  276. package/tests/session-context.test.mjs +134 -0
  277. package/tests/session-extension-requests.test.mjs +193 -0
  278. package/tests/session-ownership-adapter.test.mjs +130 -0
  279. package/tests/session-sampling-ui-static.test.mjs +10 -4
  280. package/tests/session-send-lifetime.test.mjs +140 -0
  281. package/tests/session-shelf-state.test.mjs +348 -0
  282. package/tests/session-shelves-adapter.test.mjs +79 -0
  283. package/tests/session-summary-lifetime.test.mjs +54 -0
  284. package/tests/settings-resource-controller.test.mjs +548 -0
  285. package/tests/shell-action-adapter.test.mjs +169 -0
  286. package/tests/shell-actions.test.mjs +182 -0
  287. package/tests/shell-navigation.test.mjs +348 -0
  288. package/tests/shell-preferences.test.mjs +367 -0
  289. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  290. package/tests/stream-output-isolation-static.test.mjs +1 -1
  291. package/tests/subagent-gate-visibility.test.mjs +1 -1
  292. package/tests/subagent-launch-slot-state.test.mjs +2 -2
  293. package/tests/subagent-launch-slots-static.test.mjs +1 -1
  294. package/tests/subagent-observability-static.test.mjs +2 -2
  295. package/tests/subagent-reliability-integration.test.mjs +13 -30
  296. package/tests/syntax-highlighting-static.test.mjs +3 -3
  297. package/tests/tab-close-continuity-static.test.mjs +1 -1
  298. package/tests/tab-metadata-ordering.test.mjs +99 -0
  299. package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
  300. package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
  301. package/tests/terminal-tab-workspace-static.test.mjs +5 -4
  302. package/tests/terminal-tabs-resize-static.test.mjs +1 -1
  303. package/tests/theme-customizer-static.test.mjs +1 -1
  304. package/tests/thread-display-title.test.mjs +44 -0
  305. package/tests/update-api-harness.test.mjs +15 -14
  306. package/tests/update-tab-restore-harness.test.mjs +3 -0
  307. package/tests/webui-settings-locking.test.mjs +2 -2
  308. package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
  309. package/tests/workspace-choices.test.mjs +114 -0
  310. package/tests/workspace-save-load-static.test.mjs +7 -4
@@ -0,0 +1,266 @@
1
+ #focusedWorkspace {
2
+ --focused-inspector-width: 320px;
3
+ display: grid;
4
+ grid-template-columns: 46px var(--focused-navigation-width, 202px) minmax(0, 1fr);
5
+ grid-template-rows: 47px minmax(0, 1fr);
6
+ width: 100%;
7
+ height: 100%;
8
+ min-width: 0;
9
+ min-height: 0;
10
+ overflow: hidden;
11
+ color: var(--text);
12
+ background: var(--panel);
13
+ font-family: inherit;
14
+ font-size: var(--text-sm, 0.875rem);
15
+ }
16
+
17
+ #focusedWorkspace[hidden],
18
+ #focusedWorkspace .focused-navigation[hidden],
19
+ #focusedWorkspace .focused-conversation[hidden],
20
+ #focusedWorkspace .focused-page[hidden],
21
+ #focusedWorkspace .focused-inspector[hidden],
22
+ #focusedWorkspace .focused-attention[hidden] { display: none; }
23
+
24
+ #focusedWorkspace .focused-inbox-button .focused-attention { position: absolute; }
25
+ #focusedWorkspace .focused-inbox-button .focused-finished {
26
+ position: absolute;
27
+ bottom: 0;
28
+ right: 0;
29
+ padding: 1px 2px;
30
+ border-radius: 4px;
31
+ background: var(--panel-3);
32
+ color: var(--muted);
33
+ font-size: 10px;
34
+ line-height: 1;
35
+ }
36
+ #focusedWorkspace .focused-inbox-button [hidden] { display: none; }
37
+
38
+ #focusedWorkspace .focused-rail {
39
+ grid-column: 1;
40
+ grid-row: 1 / -1;
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ gap: 5px;
45
+ padding: 7px 4px;
46
+ min-height: 0;
47
+ overflow-y: auto;
48
+ border-right: 1px solid var(--border);
49
+ background: var(--panel-3);
50
+ }
51
+
52
+ #focusedWorkspace .focused-button {
53
+ position: relative;
54
+ display: inline-flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ gap: 6px;
58
+ flex-shrink: 0;
59
+ min-width: 30px;
60
+ min-height: 30px;
61
+ margin: 0;
62
+ padding: 5px 7px;
63
+ border: 1px solid transparent;
64
+ border-radius: 6px;
65
+ box-shadow: none;
66
+ background: transparent;
67
+ color: var(--muted);
68
+ font: inherit;
69
+ font-size: var(--text-xs, 0.75rem);
70
+ line-height: 1.25;
71
+ cursor: pointer;
72
+ }
73
+
74
+ #focusedWorkspace .focused-button svg {
75
+ width: 18px;
76
+ height: 18px;
77
+ flex-shrink: 0;
78
+ fill: none;
79
+ stroke: currentColor;
80
+ stroke-width: 1.7;
81
+ stroke-linecap: round;
82
+ stroke-linejoin: round;
83
+ }
84
+
85
+ #focusedWorkspace .focused-button:hover,
86
+ #focusedWorkspace .focused-button[aria-current="page"] {
87
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
88
+ color: var(--accent);
89
+ border-color: color-mix(in srgb, var(--accent) 24%, transparent);
90
+ }
91
+
92
+ #focusedWorkspace :focus-visible {
93
+ outline: 2px solid var(--accent);
94
+ outline-offset: 2px;
95
+ }
96
+
97
+ #focusedWorkspace .focused-rail > .focused-button { width: 36px; min-height: 36px; }
98
+ #focusedWorkspace .focused-brand { font-size: 24px; font-weight: 650; color: var(--accent); }
99
+ #focusedWorkspace .focused-rail-spacer { flex: 1; min-height: 12px; }
100
+ #focusedWorkspace .focused-attention {
101
+ position: absolute;
102
+ top: 0;
103
+ right: 0;
104
+ min-width: 16px;
105
+ padding: 1px 3px;
106
+ border-radius: 7px;
107
+ color: var(--bg);
108
+ background: var(--warning);
109
+ font-size: var(--text-xs, 0.75rem);
110
+ font-weight: 650;
111
+ line-height: 1;
112
+ }
113
+
114
+ #focusedWorkspace .focused-navigation {
115
+ grid-column: 2;
116
+ grid-row: 1 / -1;
117
+ min-width: 0;
118
+ min-height: 0;
119
+ overflow: auto;
120
+ border-right: 1px solid var(--border);
121
+ background: var(--panel-3);
122
+ }
123
+
124
+ #focusedWorkspace .focused-header {
125
+ grid-column: 3;
126
+ grid-row: 1;
127
+ display: flex;
128
+ align-items: center;
129
+ gap: 8px;
130
+ min-width: 0;
131
+ min-height: 0;
132
+ padding: 0 12px;
133
+ border-bottom: 1px solid var(--border);
134
+ background: linear-gradient(100deg, var(--panel-3), var(--panel));
135
+ }
136
+
137
+ #focusedWorkspace .focused-heading { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; }
138
+ #focusedWorkspace .focused-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
139
+ #focusedWorkspace .focused-location { flex-shrink: 0; color: var(--muted); font-size: var(--text-xs, 0.75rem); }
140
+ #focusedWorkspace .focused-context { flex-shrink: 1; min-width: 30px; max-width: 24%; border-color: var(--border); }
141
+ #focusedWorkspace .focused-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
142
+ #focusedWorkspace .focused-run-controls {
143
+ display: flex;
144
+ align-items: center;
145
+ gap: 6px;
146
+ flex-shrink: 0;
147
+ max-width: 45%;
148
+ min-width: 0;
149
+ max-height: 45px;
150
+ overflow: auto;
151
+ }
152
+
153
+ #focusedWorkspace .focused-body { grid-column: 3; grid-row: 2; display: flex; min-width: 0; min-height: 0; overflow: hidden; }
154
+ #focusedWorkspace .focused-conversation { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
155
+ #focusedWorkspace .focused-page { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 20px 24px; }
156
+ #focusedWorkspace .focused-back { margin-bottom: 16px; }
157
+ #focusedWorkspace .focused-page-content { max-width: 980px; margin-inline: auto; }
158
+ #focusedWorkspace .focused-inspector {
159
+ position: relative;
160
+ box-sizing: border-box;
161
+ display: flex;
162
+ flex-direction: column;
163
+ flex: 0 0 var(--focused-inspector-width);
164
+ width: var(--focused-inspector-width);
165
+ max-width: min(45%, max(0px, calc(100% - 320px)));
166
+ min-width: 0;
167
+ min-height: 0;
168
+ border-left: 1px solid var(--border);
169
+ background: var(--panel-3);
170
+ }
171
+ #focusedWorkspace .focused-inspector-navigation { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0; padding: 5px 8px; border-bottom: 1px solid var(--border); }
172
+ #focusedWorkspace .focused-inspector-destinations { display: flex; flex: 1; gap: 4px; min-width: 0; }
173
+ #focusedWorkspace .focused-inspector-destinations .focused-button { flex: 1; min-width: 0; }
174
+ #focusedWorkspace .focused-inspector-destinations [aria-selected="true"],
175
+ #focusedWorkspace .focused-header .focused-button[aria-expanded="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: color-mix(in srgb, var(--accent) 24%, transparent); }
176
+ #focusedWorkspace .focused-inspector-panel { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
177
+ #focusedWorkspace .focused-inspector-header { display: flex; align-items: center; flex: 0 0 auto; min-width: 0; min-height: 42px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
178
+ #focusedWorkspace .focused-inspector-header strong { min-width: 0; padding: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm, 0.875rem); }
179
+ #focusedWorkspace .focused-inspector-section { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; min-height: 32px; margin: 0; padding-block: 4px; padding-left: 4px; color: var(--text); background-color: transparent; background-size: 0.34rem 0.34rem, 0.34rem 0.34rem, 0 0, 0 0; border: 1px solid transparent; border-radius: 4px; box-shadow: none; font: inherit; font-weight: 600; text-overflow: ellipsis; }
180
+ #focusedWorkspace .focused-inspector-section:hover { border-color: var(--border); box-shadow: none; }
181
+ #focusedWorkspace .focused-inspector-content { flex: 1; min-height: 0; min-width: 0; overflow: auto; padding: 12px; }
182
+ #focusedWorkspace .focused-overview-host { position: absolute; z-index: 14; top: 12px; right: 12px; max-width: calc(100% - 24px); max-height: calc(100% - 24px); pointer-events: none; }
183
+
184
+ #focusedWorkspace[data-nav-collapsed="true"],
185
+ #focusedWorkspace[data-navigation="top"] { grid-template-columns: 46px minmax(0, 1fr); }
186
+ #focusedWorkspace[data-nav-collapsed="true"] > .focused-header,
187
+ #focusedWorkspace[data-navigation="top"] > .focused-header,
188
+ #focusedWorkspace[data-nav-collapsed="true"] > .focused-body,
189
+ #focusedWorkspace[data-navigation="top"] > .focused-body { grid-column: 2; }
190
+ #focusedWorkspace[data-navigation="top"] { grid-template-rows: 47px auto minmax(0, 1fr); }
191
+ #focusedWorkspace[data-navigation="top"] > .focused-navigation {
192
+ grid-column: 2;
193
+ grid-row: 2;
194
+ max-height: 180px;
195
+ border-right: 0;
196
+ border-bottom: 1px solid var(--border);
197
+ }
198
+ #focusedWorkspace[data-navigation="top"] > .focused-body { grid-row: 3; }
199
+ #focusedWorkspace[data-navigation="top"][data-nav-collapsed="true"] { grid-template-rows: 47px minmax(0, 1fr); }
200
+ #focusedWorkspace[data-navigation="top"][data-nav-collapsed="true"] > .focused-body { grid-row: 2; }
201
+
202
+ /* Canonical views retain their controls, split columns and visibility owners. */
203
+ #focusedWorkspace .focused-conversation > .workspace-column { height: 100%; gap: 8px; }
204
+ #focusedWorkspace .chat-panel { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
205
+ #focusedWorkspace .chat-panel::before { background: none; }
206
+ #focusedWorkspace .terminal-tabs-shell { padding: 5px 8px; gap: 6px; box-shadow: none; }
207
+ /* The two adjacent actions need separate 24px targets inside their border. */
208
+ #focusedWorkspace #tabBar .terminal-tab-actions { flex-basis: 53px; min-width: 53px; }
209
+ #focusedWorkspace #tabBar .terminal-tab-actions > button { min-width: 26px; }
210
+ #focusedWorkspace #tabBar .terminal-tab-close { flex-basis: 28px; min-width: 28px; }
211
+
212
+ /* Expanded menus must escape the roster clip and stay above the sticky prompt. */
213
+ #focusedWorkspace[data-navigation="top"] > .focused-navigation {
214
+ position: relative;
215
+ z-index: 21;
216
+ }
217
+ #focusedWorkspace[data-navigation="top"] > .focused-navigation:has(.terminal-tab-group:is(:hover, :focus-within, .menu-open)) { overflow: visible; }
218
+ #focusedWorkspace[data-navigation="top"] .terminal-tabs:has(.terminal-tab-group:is(:hover, :focus-within, .menu-open)),
219
+ #focusedWorkspace[data-navigation="top"] .terminal-tab-group:is(:hover, :focus-within, .menu-open) .terminal-tab-group-menu { overflow: visible; }
220
+ #focusedWorkspace .composer { padding: 8px 12px; gap: 6px; border-radius: 10px; box-shadow: none; }
221
+ #focusedWorkspace .composer-input-row { gap: 6px; }
222
+ #focusedWorkspace .message { padding: 12px; margin-bottom: 12px; border-radius: 8px; box-shadow: none; }
223
+ #focusedWorkspace .message.assistant { border-color: transparent; background: transparent; }
224
+
225
+ #focusedWorkspace .focused-navigation-resize {
226
+ grid-column: 2;
227
+ grid-row: 1 / -1;
228
+ justify-self: end;
229
+ width: 8px;
230
+ margin-right: -4px;
231
+ z-index: 4;
232
+ cursor: col-resize;
233
+ touch-action: none;
234
+ border-radius: 3px;
235
+ background: transparent;
236
+ }
237
+ #focusedWorkspace .focused-navigation-resize[hidden] { display: none; }
238
+ #focusedWorkspace .focused-navigation-resize:hover,
239
+ #focusedWorkspace .focused-navigation-resize:focus-visible,
240
+ #focusedWorkspace.focused-navigation-resizing .focused-navigation-resize {
241
+ background: linear-gradient(to right, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px);
242
+ outline: none;
243
+ }
244
+ #focusedWorkspace.focused-navigation-resizing,
245
+ #focusedWorkspace.focused-navigation-resizing * { cursor: col-resize !important; user-select: none !important; }
246
+
247
+ #focusedWorkspace .focused-inspector-resize {
248
+ position: absolute;
249
+ top: 0;
250
+ bottom: 0;
251
+ left: -4px;
252
+ width: 8px;
253
+ z-index: 4;
254
+ cursor: col-resize;
255
+ touch-action: none;
256
+ border-radius: 3px;
257
+ }
258
+ #focusedWorkspace .focused-inspector-resize[hidden] { display: none; }
259
+ #focusedWorkspace .focused-inspector-resize:hover,
260
+ #focusedWorkspace .focused-inspector-resize:focus-visible,
261
+ #focusedWorkspace.focused-inspector-resizing .focused-inspector-resize {
262
+ background: linear-gradient(to right, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px);
263
+ outline: none;
264
+ }
265
+ #focusedWorkspace.focused-inspector-resizing,
266
+ #focusedWorkspace.focused-inspector-resizing * { cursor: col-resize !important; user-select: none !important; }
@@ -0,0 +1,402 @@
1
+ import { createNavigationResize } from './shell-navigation-resize.mjs';
2
+ import { createInspectorResize } from './shell-inspector-resize.mjs';
3
+
4
+ const DESTINATIONS = new Set(['conversation', 'home', 'project', 'activity', 'settings']);
5
+ const ICONS = {
6
+ conversation: 'M4 4h16v11H9l-5 4V4Z',
7
+ sessions: 'M4 5h16M4 12h16M4 19h10',
8
+ project: 'M3 7V4h6l2 3h10v13H3V7Z',
9
+ activity: 'M3 12h4l3-8 4 16 3-8h4',
10
+ overview: 'M4 4h16v16H4zM4 10h16M10 10v10',
11
+ inspector: 'M4 4h16v16H4zM15 4v16',
12
+ tools: 'M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z',
13
+ menu: 'M5 12h.01M12 12h.01M19 12h.01',
14
+ close: 'm6 6 12 12M6 18 18 6',
15
+ };
16
+
17
+ /** Creates presentation chrome. The caller owns mounting, slot contents and state. */
18
+ export function createFocusedWorkspace({
19
+ document, onNavigate, onHome, onTools, onToggleNavigation, onSessionMenu,
20
+ onProjectMenu, onInspectorClose, onConversation, onInspectorSelect, onAttention, onNavigationResize,
21
+ onToggleOverview, onToggleInspector, onInspectorResize,
22
+ }) {
23
+ const listeners = [];
24
+ const rememberedFocus = new Map();
25
+ let focusOrder = 0;
26
+ let tabTraversal = false;
27
+ let tabOrigin = null;
28
+ let disposed = false;
29
+ let state = {
30
+ destination: 'conversation', navigation: 'left', navCollapsed: false,
31
+ inspectorOpen: false, inspectorTitle: '', inspectorWidth: 320,
32
+ title: '', context: '', attentionCount: 0, overviewOpen: false,
33
+ };
34
+
35
+ function node(tag, className, text) {
36
+ const element = document.createElement(tag);
37
+ if (className) element.className = className;
38
+ if (text !== undefined) element.textContent = text;
39
+ return element;
40
+ }
41
+
42
+ function button(label, icon, callback) {
43
+ const control = node('button', 'focused-button');
44
+ control.type = 'button';
45
+ control.title = label;
46
+ control.setAttribute('aria-label', label);
47
+ if (icon) {
48
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
49
+ svg.setAttribute('viewBox', '0 0 24 24');
50
+ svg.setAttribute('aria-hidden', 'true');
51
+ svg.setAttribute('focusable', 'false');
52
+ const path = document.createElementNS(svg.namespaceURI, 'path');
53
+ path.setAttribute('d', ICONS[icon]);
54
+ svg.append(path);
55
+ control.append(svg);
56
+ }
57
+ const handleClick = () => callback?.();
58
+ control.addEventListener('click', handleClick);
59
+ listeners.push(() => control.removeEventListener('click', handleClick));
60
+ return control;
61
+ }
62
+
63
+ const element = node('div', 'focused-workspace');
64
+ element.id = 'focusedWorkspace';
65
+ const rail = node('nav', 'focused-rail');
66
+ rail.setAttribute('aria-label', 'Workspace destinations');
67
+ const homeButton = button(onHome ? 'New No Project conversation' : 'Home', null, () => onHome ? onHome() : onNavigate?.('home'));
68
+ homeButton.classList.add('focused-brand');
69
+ homeButton.append(node('span', '', 'π'));
70
+ const destinationButtons = new Map([['home', homeButton]]);
71
+ rail.append(homeButton);
72
+ const conversationButton = button('Conversation', 'conversation', () => onNavigate?.('conversation'));
73
+ destinationButtons.set('conversation', conversationButton);
74
+ const navigationToggle = button('Collapse sessions', 'sessions', onToggleNavigation);
75
+ navigationToggle.setAttribute('aria-controls', 'focusedWorkspaceNavigation');
76
+ rail.append(conversationButton, navigationToggle);
77
+ const attention = node('span', 'focused-attention');
78
+ attention.setAttribute('aria-hidden', 'true');
79
+ const inboxButton = button('Attention', 'activity', onAttention);
80
+ inboxButton.classList.add('focused-inbox-button');
81
+ const finished = node('span', 'focused-finished');
82
+ finished.setAttribute('aria-hidden', 'true');
83
+ inboxButton.append(attention, finished);
84
+ rail.append(node('div', 'focused-rail-spacer'), inboxButton, button('All tools', 'tools', onTools));
85
+
86
+ const navigation = node('aside', 'focused-navigation');
87
+ navigation.id = 'focusedWorkspaceNavigation';
88
+ navigation.setAttribute('aria-label', 'Session navigation');
89
+ const header = node('header', 'focused-header');
90
+ const heading = node('div', 'focused-heading');
91
+ const title = node('span', 'focused-title');
92
+ const location = node('span', 'focused-location');
93
+ heading.append(title, location);
94
+ const sessionMenu = button('Session actions', 'menu', onSessionMenu);
95
+ const contextButton = button('Project actions', null, onProjectMenu);
96
+ contextButton.classList.add('focused-context');
97
+ const context = node('span');
98
+ contextButton.append(context);
99
+ const runControls = node('div', 'focused-run-controls');
100
+ runControls.setAttribute('role', 'group');
101
+ runControls.setAttribute('aria-label', 'Active run controls');
102
+ const overviewToggle = button('Overview', 'overview', onToggleOverview);
103
+ overviewToggle.setAttribute('aria-controls', 'focusedWorkspaceOverview');
104
+ const inspectorToggle = button('Inspector', 'inspector', onToggleInspector);
105
+ inspectorToggle.setAttribute('aria-controls', 'focusedWorkspaceInspector');
106
+ header.append(heading, sessionMenu, contextButton, overviewToggle, inspectorToggle, runControls);
107
+
108
+ const body = node('div', 'focused-body');
109
+ const conversation = node('section', 'focused-conversation');
110
+ conversation.setAttribute('aria-label', 'Conversation');
111
+ const overview = node('div', 'focused-overview-host');
112
+ overview.id = 'focusedWorkspaceOverview';
113
+ conversation.append(overview);
114
+ const centralPages = {};
115
+ for (const [destination, label] of [['home', 'Home'], ['settings', 'Settings']]) {
116
+ const page = node('section', 'focused-page');
117
+ page.setAttribute('aria-label', label);
118
+ const back = button('Back to conversation', 'conversation', onConversation);
119
+ back.classList.add('focused-back');
120
+ back.append(node('span', '', 'Back to conversation'));
121
+ const content = node('div', 'focused-page-content');
122
+ page.append(back, content);
123
+ centralPages[destination] = { page, content };
124
+ }
125
+ const inspector = node('aside', 'focused-inspector');
126
+ inspector.id = 'focusedWorkspaceInspector';
127
+ const inspectorNavigation = node('div', 'focused-inspector-navigation');
128
+ const inspectorDestinations = node('div', 'focused-inspector-destinations');
129
+ inspectorDestinations.setAttribute('role', 'tablist');
130
+ inspectorDestinations.setAttribute('aria-label', 'Inspector destinations');
131
+ const inspectorPanel = node('div', 'focused-inspector-panel');
132
+ inspectorPanel.id = 'focusedWorkspaceInspectorDestinationPanel';
133
+ inspectorPanel.setAttribute('role', 'tabpanel');
134
+ for (const [destination, label] of [['project', 'Project'], ['activity', 'Activity']]) {
135
+ const control = button(label, destination, () => onNavigate?.(destination));
136
+ control.id = `focusedInspectorDestination-${destination}`;
137
+ control.setAttribute('role', 'tab');
138
+ control.setAttribute('aria-controls', inspectorPanel.id);
139
+ control.append(node('span', '', label));
140
+ destinationButtons.set(destination, control);
141
+ inspectorDestinations.append(control);
142
+ }
143
+ const focusDestination = event => {
144
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
145
+ const controls = [...inspectorDestinations.children];
146
+ const index = controls.indexOf(event.target);
147
+ if (index < 0) return;
148
+ event.preventDefault();
149
+ const next = event.key === 'Home' ? 0 : event.key === 'End' ? controls.length - 1
150
+ : (index + (event.key === 'ArrowRight' ? 1 : -1) + controls.length) % controls.length;
151
+ for (const control of controls) control.tabIndex = -1;
152
+ controls[next].tabIndex = 0;
153
+ controls[next].focus();
154
+ };
155
+ inspectorDestinations.addEventListener('keydown', focusDestination);
156
+ listeners.push(() => inspectorDestinations.removeEventListener('keydown', focusDestination));
157
+ inspectorNavigation.append(inspectorDestinations, button('Close inspector', 'close', onInspectorClose));
158
+ const inspectorHeader = node('header', 'focused-inspector-header');
159
+ const inspectorTitle = node('strong');
160
+ inspectorTitle.id = 'focusedWorkspaceInspectorTitle';
161
+ const sectionSelect = node('select', 'focused-inspector-section');
162
+ inspectorHeader.append(inspectorTitle, sectionSelect);
163
+ const inspectorContent = node('div', 'focused-inspector-content');
164
+ inspectorContent.id = 'focusedWorkspaceInspectorPanel';
165
+ const sectionOptions = new Map();
166
+ const activityGroups = [
167
+ ['Work', ['subagents', 'queue', 'progress']],
168
+ ['Conversations', ['conversations', 'extensions']],
169
+ ['Usage & diagnostics', ['codex-usage', 'claude-usage', 'events']],
170
+ ['Session', ['session', 'sampling', 'commands']],
171
+ ['More', []],
172
+ ].map(([label, ids]) => {
173
+ const group = node('optgroup');
174
+ group.label = label;
175
+ return { group, ids };
176
+ });
177
+ const selectSection = () => {
178
+ const option = sectionSelect.selectedOptions[0];
179
+ if (sectionSelect.disabled || !option || option.disabled) return;
180
+ onInspectorSelect?.(option.value);
181
+ };
182
+ sectionSelect.addEventListener('change', selectSection);
183
+ listeners.push(() => sectionSelect.removeEventListener('change', selectSection));
184
+ inspectorPanel.append(inspectorHeader, inspectorContent);
185
+ const inspectorResize = node('div', 'focused-inspector-resize');
186
+ inspectorResize.tabIndex = 0;
187
+ inspectorResize.setAttribute('role', 'separator');
188
+ inspectorResize.setAttribute('aria-orientation', 'vertical');
189
+ inspectorResize.setAttribute('aria-label', 'Resize inspector');
190
+ inspectorResize.setAttribute('aria-controls', inspector.id);
191
+ inspectorResize.title = 'Drag to resize inspector. Arrow keys adjust width; double-click resets.';
192
+ inspector.append(inspectorResize, inspectorNavigation, inspectorPanel);
193
+ body.append(conversation, centralPages.home.page, centralPages.settings.page, inspector);
194
+ const navigationResize = node('div', 'focused-navigation-resize');
195
+ navigationResize.tabIndex = 0;
196
+ navigationResize.setAttribute('role', 'separator');
197
+ navigationResize.setAttribute('aria-orientation', 'vertical');
198
+ navigationResize.setAttribute('aria-label', 'Resize session sidebar');
199
+ navigationResize.setAttribute('aria-controls', navigation.id);
200
+ navigationResize.title = 'Drag to resize sessions. Arrow keys adjust width; double-click resets.';
201
+ element.append(rail, navigation, navigationResize, header, body);
202
+ const resizer = createNavigationResize({ element, handle: navigationResize, onCommit: onNavigationResize });
203
+ const inspectorResizer = createInspectorResize({ element, body, handle: inspectorResize, onCommit: onInspectorResize });
204
+
205
+ const slots = Object.freeze({
206
+ navigation, conversation, home: centralPages.home.content,
207
+ settings: centralPages.settings.content, inspector: inspectorContent, runControls, overview,
208
+ });
209
+ const visibleHosts = [navigation, conversation, centralPages.home.page, centralPages.settings.page, inspector];
210
+
211
+ function rememberFocus(target) {
212
+ for (const host of visibleHosts) {
213
+ if (host.contains(target)) rememberedFocus.set(host, { target, order: ++focusOrder });
214
+ }
215
+ }
216
+ // Tab can pass through controls that redirect focus asynchronously. Keep its
217
+ // origin separately, and use it only when keyboard activation leaves a view
218
+ // through shell chrome. Pointer navigation retains the caller's latest focus.
219
+ const onKeydown = (event) => {
220
+ if (event.key === 'Tab') {
221
+ if (!tabTraversal) tabOrigin = document.activeElement;
222
+ tabTraversal = true;
223
+ } else {
224
+ const control = event.target.closest?.('button');
225
+ if (tabTraversal && ['Enter', ' '].includes(event.key) && control
226
+ && (control.matches('.terminal-settings-button')
227
+ || !Object.values(slots).some(slot => slot.contains(control)))) rememberFocus(tabOrigin);
228
+ tabTraversal = false;
229
+ tabOrigin = null;
230
+ }
231
+ };
232
+ const onPointerdown = () => {
233
+ tabTraversal = false;
234
+ tabOrigin = null;
235
+ rememberFocus(document.activeElement);
236
+ };
237
+ const onFocus = (event) => rememberFocus(event.target);
238
+ element.addEventListener('focusin', onFocus);
239
+ element.addEventListener('keydown', onKeydown, true);
240
+ element.addEventListener('pointerdown', onPointerdown, true);
241
+ listeners.push(
242
+ () => element.removeEventListener('focusin', onFocus),
243
+ () => element.removeEventListener('keydown', onKeydown, true),
244
+ () => element.removeEventListener('pointerdown', onPointerdown, true),
245
+ );
246
+
247
+ function updateInspectorTopics(topics = [], selectedId) {
248
+ const selected = topics.find(topic => topic.id === selectedId && topic.available !== false)
249
+ || topics.find(topic => topic.available !== false);
250
+ const isActivity = state.destination === 'activity';
251
+ const destination = isActivity ? 'activity' : 'project';
252
+ const destinationControl = destinationButtons.get(destination);
253
+ inspector.setAttribute('aria-labelledby', destinationControl.id);
254
+ inspectorPanel.setAttribute('aria-labelledby', destinationControl.id);
255
+ const tabStop = inspectorDestinations.contains(document.activeElement) ? document.activeElement : destinationControl;
256
+ for (const id of ['project', 'activity']) {
257
+ const control = destinationButtons.get(id);
258
+ const isSelected = id === destination;
259
+ control.setAttribute('aria-selected', String(isSelected));
260
+ // Retain an unactivated keyboard tab stop across status-only snapshots.
261
+ control.tabIndex = control === tabStop ? 0 : -1;
262
+ }
263
+ sectionSelect.setAttribute('aria-label', isActivity ? 'Activity section' : 'Project section');
264
+ sectionSelect.hidden = topics.length === 0;
265
+ inspectorTitle.hidden = topics.length !== 0;
266
+ const ids = new Set(topics.map(topic => topic.id));
267
+ for (const [id, option] of sectionOptions) {
268
+ if (!ids.has(id)) { option.remove(); sectionOptions.delete(id); }
269
+ }
270
+ for (const topic of topics) {
271
+ let option = sectionOptions.get(topic.id);
272
+ if (!option) {
273
+ option = node('option');
274
+ option.value = topic.id;
275
+ sectionOptions.set(topic.id, option);
276
+ }
277
+ const disabled = topic.available === false;
278
+ const reason = topic.unavailableReason || 'Unavailable';
279
+ const label = disabled ? `${topic.label} (${reason})` : topic.label;
280
+ if (option.textContent !== label) option.textContent = label;
281
+ option.disabled = disabled;
282
+ option.title = disabled ? reason : topic.label;
283
+ }
284
+ // Move only changed nodes so native selection and focus survive idle updates.
285
+ const knownIds = new Set(activityGroups.flatMap(({ ids }) => ids));
286
+ const groups = isActivity ? activityGroups.map(({ group, ids: groupIds }) => {
287
+ const members = groupIds.length ? groupIds.filter(id => ids.has(id))
288
+ : topics.filter(topic => !knownIds.has(topic.id)).map(topic => topic.id);
289
+ return { parent: group, ids: members };
290
+ }) : [{ parent: sectionSelect, ids: topics.map(topic => topic.id) }];
291
+ const visibleGroups = [];
292
+ for (const { parent, ids: memberIds } of groups) {
293
+ memberIds.forEach((id, index) => {
294
+ const option = sectionOptions.get(id);
295
+ if (parent.children[index] !== option) parent.insertBefore(option, parent.children[index] || null);
296
+ });
297
+ if (parent !== sectionSelect && memberIds.length) visibleGroups.push(parent);
298
+ }
299
+ if (isActivity) {
300
+ for (const child of [...sectionSelect.children]) {
301
+ if (!visibleGroups.includes(child)) child.remove();
302
+ }
303
+ visibleGroups.forEach((group, index) => {
304
+ if (sectionSelect.children[index] !== group) sectionSelect.insertBefore(group, sectionSelect.children[index] || null);
305
+ });
306
+ } else {
307
+ for (const { group } of activityGroups) group.remove();
308
+ }
309
+ sectionSelect.disabled = !selected;
310
+ if (selected) {
311
+ if (sectionSelect.value !== selected.id) sectionSelect.value = selected.id;
312
+ } else sectionSelect.selectedIndex = -1;
313
+ inspectorContent.setAttribute('role', 'region');
314
+ inspectorContent.setAttribute('aria-label', selected?.label || state.inspectorTitle || (isActivity ? 'Activity' : 'Project'));
315
+ }
316
+
317
+ function update(snapshot = {}) {
318
+ if (disposed) return;
319
+ const next = { ...state, ...snapshot };
320
+ if (!DESTINATIONS.has(next.destination)) throw new TypeError('Unknown focused workspace destination.');
321
+ if (!['left', 'top'].includes(next.navigation)) throw new TypeError('Unknown session navigation presentation.');
322
+ const active = document.activeElement;
323
+ const wasHidden = new Map(visibleHosts.map((host) => [host, host.hidden]));
324
+ rememberFocus(active);
325
+ state = next;
326
+ element.dataset.destination = state.destination;
327
+ element.dataset.navigation = state.navigation;
328
+ element.dataset.navCollapsed = String(Boolean(state.navCollapsed));
329
+ navigation.hidden = Boolean(state.navCollapsed);
330
+ resizer.update({ navigationWidth: state.navigationWidth, active: state.enabled !== false && state.navigation === 'left' && !state.navCollapsed });
331
+ navigationToggle.setAttribute('aria-expanded', String(!navigation.hidden));
332
+ const toggleLabel = navigation.hidden ? 'Expand sessions' : 'Collapse sessions';
333
+ navigationToggle.setAttribute('aria-label', toggleLabel);
334
+ navigationToggle.title = toggleLabel;
335
+ const central = state.destination === 'home' || state.destination === 'settings';
336
+ conversation.hidden = central;
337
+ centralPages.home.page.hidden = state.destination !== 'home';
338
+ centralPages.settings.page.hidden = state.destination !== 'settings';
339
+ inspector.hidden = central || !(state.inspectorOpen || state.destination === 'project' || state.destination === 'activity');
340
+ inspectorResizer.update({ inspectorWidth: state.inspectorWidth, active: state.enabled !== false && !inspector.hidden });
341
+ inspectorToggle.setAttribute('aria-expanded', String(!inspector.hidden));
342
+ if (overview.hidden !== !state.overviewOpen) overview.hidden = !state.overviewOpen;
343
+ overviewToggle.setAttribute('aria-expanded', String(!central && !overview.hidden));
344
+ title.textContent = String(state.title ?? '');
345
+ title.title = title.textContent;
346
+ location.textContent = state.destination[0].toUpperCase() + state.destination.slice(1);
347
+ context.textContent = String(state.context ?? '');
348
+ contextButton.title = context.textContent ? `Project actions: ${context.textContent}` : 'Project actions';
349
+ inspectorTitle.textContent = String(state.inspectorTitle ?? '');
350
+ updateInspectorTopics(state.inspectorTopics, state.inspector);
351
+ const count = Number.isSafeInteger(state.attentionCount) ? Math.max(0, state.attentionCount) : 0;
352
+ attention.hidden = count === 0;
353
+ attention.textContent = count > 99 ? '99+' : String(count);
354
+ const completed = Number.isSafeInteger(state.finishedCount) ? Math.max(0, state.finishedCount) : 0;
355
+ finished.hidden = completed === 0;
356
+ finished.textContent = completed > 99 ? '+99' : `+${completed}`;
357
+ const inboxLabel = `Attention, ${count} decisions waiting, ${completed} finished`;
358
+ inboxButton.setAttribute('aria-label', inboxLabel);
359
+ inboxButton.title = inboxLabel;
360
+ for (const [destination, control] of destinationButtons) {
361
+ if (destination === state.destination) control.setAttribute('aria-current', 'page');
362
+ else control.removeAttribute('aria-current');
363
+ }
364
+
365
+ // CSS can conceal a focused host. Remember its node and restore it only on
366
+ // return, without taking focus away from another caller-owned view.
367
+ const inSlot = Object.values(slots).some((slot) => slot.contains(active));
368
+ if (!inSlot || visibleHosts.some((host) => host.hidden && host.contains(active))) {
369
+ const revealed = visibleHosts.filter((host) => wasHidden.get(host) && !host.hidden)
370
+ .map((host) => ({ host, ...rememberedFocus.get(host) }))
371
+ .sort((a, b) => (b.order ?? 0) - (a.order ?? 0));
372
+ for (const { host, target } of revealed) {
373
+ const modal = document.querySelector('dialog:modal');
374
+ if (target?.isConnected && host.contains(target) && !target.closest('[hidden], [inert]')
375
+ && (!modal || modal.contains(target))
376
+ && (active === document.body || element.contains(active))) {
377
+ target.focus({ preventScroll: true });
378
+ break;
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ function dispose() {
385
+ if (disposed) return;
386
+ disposed = true;
387
+ resizer.dispose();
388
+ inspectorResizer.dispose();
389
+ for (const removeListener of listeners) removeListener();
390
+ listeners.length = 0;
391
+ rememberedFocus.clear();
392
+ tabOrigin = null;
393
+ sectionOptions.clear();
394
+ // The parent restores canonical views and owns removal of the root.
395
+ }
396
+
397
+ update();
398
+ return { element, slots, update, dispose,
399
+ cancelNavigationResize: () => resizer.update({ navigationWidth: state.navigationWidth, active: false }),
400
+ cancelInspectorResize: () => inspectorResizer.update({ inspectorWidth: state.inspectorWidth, active: false }),
401
+ };
402
+ }