@swirls/shuttle 0.0.0-stage → 0.1.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 (298) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +5 -0
  4. package/README.md +42 -2
  5. package/dist/api/auth.d.ts +18 -0
  6. package/dist/api/auth.js +15 -0
  7. package/dist/api/common.d.ts +8 -0
  8. package/dist/api/common.js +4 -0
  9. package/dist/api/connections.d.ts +292 -0
  10. package/dist/api/connections.js +114 -0
  11. package/dist/api/github.d.ts +20 -0
  12. package/dist/api/github.js +13 -0
  13. package/dist/api/harness.d.ts +97 -0
  14. package/dist/api/harness.js +47 -0
  15. package/dist/api/index.d.ts +2059 -0
  16. package/dist/api/index.js +37 -0
  17. package/dist/api/runners.d.ts +93 -0
  18. package/dist/api/runners.js +45 -0
  19. package/dist/api/sandbox.d.ts +550 -0
  20. package/dist/api/sandbox.js +210 -0
  21. package/dist/api/sessions.d.ts +318 -0
  22. package/dist/api/sessions.js +154 -0
  23. package/dist/api/tenant.d.ts +54 -0
  24. package/dist/api/tenant.js +19 -0
  25. package/dist/api/timings.d.ts +36 -0
  26. package/dist/api/timings.js +48 -0
  27. package/dist/api/workspace.d.ts +738 -0
  28. package/dist/api/workspace.js +246 -0
  29. package/dist/core/pulls.d.ts +1001 -0
  30. package/dist/core/pulls.js +170 -0
  31. package/dist/core/workspace.d.ts +985 -0
  32. package/dist/core/workspace.js +174 -0
  33. package/dist/react/components/command-palette.d.ts +22 -0
  34. package/dist/react/components/command-palette.js +66 -0
  35. package/dist/react/components/follow-list.d.ts +20 -0
  36. package/dist/react/components/follow-list.js +98 -0
  37. package/dist/react/components/json-tree.d.ts +11 -0
  38. package/dist/react/components/json-tree.js +120 -0
  39. package/dist/react/components/markdown.d.ts +5 -0
  40. package/dist/react/components/markdown.js +29 -0
  41. package/dist/react/components/shuttle-mark.d.ts +7 -0
  42. package/dist/react/components/shuttle-mark.js +9 -0
  43. package/dist/react/components/status-dot.d.ts +9 -0
  44. package/dist/react/components/status-dot.js +27 -0
  45. package/dist/react/components/status.d.ts +6 -0
  46. package/dist/react/components/status.js +66 -0
  47. package/dist/react/components/ui/badge.d.ts +7 -0
  48. package/dist/react/components/ui/badge.js +19 -0
  49. package/dist/react/components/ui/button.d.ts +10 -0
  50. package/dist/react/components/ui/button.js +40 -0
  51. package/dist/react/components/ui/dialog.d.ts +19 -0
  52. package/dist/react/components/ui/dialog.js +34 -0
  53. package/dist/react/components/ui/dropdown-menu.d.ts +14 -0
  54. package/dist/react/components/ui/dropdown-menu.js +33 -0
  55. package/dist/react/components/ui/input.d.ts +3 -0
  56. package/dist/react/components/ui/input.js +6 -0
  57. package/dist/react/components/ui/panel.d.ts +18 -0
  58. package/dist/react/components/ui/panel.js +22 -0
  59. package/dist/react/components/ui/popover.d.ts +7 -0
  60. package/dist/react/components/ui/popover.js +16 -0
  61. package/dist/react/components/ui/resizable.d.ts +7 -0
  62. package/dist/react/components/ui/resizable.js +14 -0
  63. package/dist/react/components/ui/scroll-area.d.ts +14 -0
  64. package/dist/react/components/ui/scroll-area.js +12 -0
  65. package/dist/react/components/ui/select.d.ts +10 -0
  66. package/dist/react/components/ui/select.js +20 -0
  67. package/dist/react/components/ui/sheet.d.ts +8 -0
  68. package/dist/react/components/ui/sheet.js +20 -0
  69. package/dist/react/components/ui/tabs.d.ts +7 -0
  70. package/dist/react/components/ui/tabs.js +16 -0
  71. package/dist/react/components/ui/textarea.d.ts +3 -0
  72. package/dist/react/components/ui/textarea.js +6 -0
  73. package/dist/react/components/ui/tooltip.d.ts +8 -0
  74. package/dist/react/components/ui/tooltip.js +17 -0
  75. package/dist/react/features/artifacts/artifact-links.d.ts +9 -0
  76. package/dist/react/features/artifacts/artifact-links.js +38 -0
  77. package/dist/react/features/artifacts/artifact-pane.d.ts +19 -0
  78. package/dist/react/features/artifacts/artifact-pane.js +75 -0
  79. package/dist/react/features/artifacts/artifact-types.d.ts +59 -0
  80. package/dist/react/features/artifacts/artifact-types.js +69 -0
  81. package/dist/react/features/artifacts/browser-viewer.d.ts +5 -0
  82. package/dist/react/features/artifacts/browser-viewer.js +60 -0
  83. package/dist/react/features/artifacts/diff-style.d.ts +10 -0
  84. package/dist/react/features/artifacts/diff-style.js +21 -0
  85. package/dist/react/features/artifacts/file-pane.d.ts +13 -0
  86. package/dist/react/features/artifacts/file-pane.js +305 -0
  87. package/dist/react/features/artifacts/file-quick-open.d.ts +15 -0
  88. package/dist/react/features/artifacts/file-quick-open.js +74 -0
  89. package/dist/react/features/artifacts/file-search.d.ts +12 -0
  90. package/dist/react/features/artifacts/file-search.js +90 -0
  91. package/dist/react/features/artifacts/media-viewer.d.ts +8 -0
  92. package/dist/react/features/artifacts/media-viewer.js +41 -0
  93. package/dist/react/features/artifacts/review-diff.d.ts +19 -0
  94. package/dist/react/features/artifacts/review-diff.js +59 -0
  95. package/dist/react/features/artifacts/review-viewer.d.ts +4 -0
  96. package/dist/react/features/artifacts/review-viewer.js +337 -0
  97. package/dist/react/features/artifacts/sandbox.d.ts +43 -0
  98. package/dist/react/features/artifacts/sandbox.js +109 -0
  99. package/dist/react/features/artifacts/tab-strip.d.ts +11 -0
  100. package/dist/react/features/artifacts/tab-strip.js +55 -0
  101. package/dist/react/features/artifacts/terminal-theme.d.ts +34 -0
  102. package/dist/react/features/artifacts/terminal-theme.js +62 -0
  103. package/dist/react/features/artifacts/terminal-viewer.d.ts +5 -0
  104. package/dist/react/features/artifacts/terminal-viewer.js +209 -0
  105. package/dist/react/features/artifacts/unified-diff.d.ts +16 -0
  106. package/dist/react/features/artifacts/unified-diff.js +55 -0
  107. package/dist/react/features/artifacts/workspace-viewer.d.ts +16 -0
  108. package/dist/react/features/artifacts/workspace-viewer.js +275 -0
  109. package/dist/react/features/connections/agent-sign-in.d.ts +71 -0
  110. package/dist/react/features/connections/agent-sign-in.js +251 -0
  111. package/dist/react/features/connections/connections-panel.d.ts +8 -0
  112. package/dist/react/features/connections/connections-panel.js +42 -0
  113. package/dist/react/features/connections/login.d.ts +24 -0
  114. package/dist/react/features/connections/login.js +35 -0
  115. package/dist/react/features/connections/places.d.ts +20 -0
  116. package/dist/react/features/connections/places.js +27 -0
  117. package/dist/react/features/connections/queries.d.ts +28 -0
  118. package/dist/react/features/connections/queries.js +8 -0
  119. package/dist/react/features/events/event-cache.d.ts +4 -0
  120. package/dist/react/features/events/event-cache.js +29 -0
  121. package/dist/react/features/events/event-catalog.d.ts +17 -0
  122. package/dist/react/features/events/event-catalog.js +261 -0
  123. package/dist/react/features/events/event-inspector.d.ts +7 -0
  124. package/dist/react/features/events/event-inspector.js +29 -0
  125. package/dist/react/features/events/event-row.d.ts +21 -0
  126. package/dist/react/features/events/event-row.js +34 -0
  127. package/dist/react/features/events/event-stream.d.ts +18 -0
  128. package/dist/react/features/events/event-stream.js +58 -0
  129. package/dist/react/features/events/global-events.d.ts +122 -0
  130. package/dist/react/features/events/global-events.js +329 -0
  131. package/dist/react/features/events/shuttle-events.d.ts +7 -0
  132. package/dist/react/features/events/shuttle-events.js +1 -0
  133. package/dist/react/features/playbook/playbook-page.d.ts +2 -0
  134. package/dist/react/features/playbook/playbook-page.js +36 -0
  135. package/dist/react/features/playbook/playbook-query.d.ts +111 -0
  136. package/dist/react/features/playbook/playbook-query.js +17 -0
  137. package/dist/react/features/pulls/linked-session.d.ts +12 -0
  138. package/dist/react/features/pulls/linked-session.js +22 -0
  139. package/dist/react/features/pulls/pull-detail-sheet.d.ts +10 -0
  140. package/dist/react/features/pulls/pull-detail-sheet.js +41 -0
  141. package/dist/react/features/pulls/pull-fixtures.d.ts +8 -0
  142. package/dist/react/features/pulls/pull-fixtures.js +258 -0
  143. package/dist/react/features/pulls/pull-glyphs.d.ts +24 -0
  144. package/dist/react/features/pulls/pull-glyphs.js +89 -0
  145. package/dist/react/features/pulls/pull-inbox-list.d.ts +13 -0
  146. package/dist/react/features/pulls/pull-inbox-list.js +230 -0
  147. package/dist/react/features/pulls/pull-inbox-pref.d.ts +2 -0
  148. package/dist/react/features/pulls/pull-inbox-pref.js +19 -0
  149. package/dist/react/features/pulls/pull-inbox.d.ts +30 -0
  150. package/dist/react/features/pulls/pull-inbox.js +110 -0
  151. package/dist/react/features/pulls/pull-threads.d.ts +39 -0
  152. package/dist/react/features/pulls/pull-threads.js +145 -0
  153. package/dist/react/features/pulls/pulls.d.ts +120 -0
  154. package/dist/react/features/pulls/pulls.js +414 -0
  155. package/dist/react/features/pulls/session-pull-groups.d.ts +14 -0
  156. package/dist/react/features/pulls/session-pull-groups.js +29 -0
  157. package/dist/react/features/pulls/stack-ladder.d.ts +9 -0
  158. package/dist/react/features/pulls/stack-ladder.js +32 -0
  159. package/dist/react/features/sessions/agent-tree.d.ts +16 -0
  160. package/dist/react/features/sessions/agent-tree.js +100 -0
  161. package/dist/react/features/sessions/agents.d.ts +34 -0
  162. package/dist/react/features/sessions/agents.js +146 -0
  163. package/dist/react/features/sessions/attention.d.ts +32 -0
  164. package/dist/react/features/sessions/attention.js +42 -0
  165. package/dist/react/features/sessions/composer-attachments.d.ts +33 -0
  166. package/dist/react/features/sessions/composer-attachments.js +126 -0
  167. package/dist/react/features/sessions/composer.d.ts +15 -0
  168. package/dist/react/features/sessions/composer.js +327 -0
  169. package/dist/react/features/sessions/context-usage-meter.d.ts +5 -0
  170. package/dist/react/features/sessions/context-usage-meter.js +122 -0
  171. package/dist/react/features/sessions/context-usage.d.ts +54 -0
  172. package/dist/react/features/sessions/context-usage.js +206 -0
  173. package/dist/react/features/sessions/conversation.d.ts +21 -0
  174. package/dist/react/features/sessions/conversation.js +549 -0
  175. package/dist/react/features/sessions/harness-switcher.d.ts +26 -0
  176. package/dist/react/features/sessions/harness-switcher.js +118 -0
  177. package/dist/react/features/sessions/intake-heuristic.d.ts +5 -0
  178. package/dist/react/features/sessions/intake-heuristic.js +28 -0
  179. package/dist/react/features/sessions/interjection-routes.d.ts +13 -0
  180. package/dist/react/features/sessions/interjection-routes.js +72 -0
  181. package/dist/react/features/sessions/llm-models.d.ts +128 -0
  182. package/dist/react/features/sessions/llm-models.js +174 -0
  183. package/dist/react/features/sessions/media-strip.d.ts +25 -0
  184. package/dist/react/features/sessions/media-strip.js +56 -0
  185. package/dist/react/features/sessions/media.d.ts +43 -0
  186. package/dist/react/features/sessions/media.js +115 -0
  187. package/dist/react/features/sessions/model-search.d.ts +6 -0
  188. package/dist/react/features/sessions/model-search.js +16 -0
  189. package/dist/react/features/sessions/model-switcher.d.ts +16 -0
  190. package/dist/react/features/sessions/model-switcher.js +262 -0
  191. package/dist/react/features/sessions/open-pull-request.d.ts +20 -0
  192. package/dist/react/features/sessions/open-pull-request.js +92 -0
  193. package/dist/react/features/sessions/pull-publish-card.d.ts +14 -0
  194. package/dist/react/features/sessions/pull-publish-card.js +88 -0
  195. package/dist/react/features/sessions/recent-sessions.d.ts +11 -0
  196. package/dist/react/features/sessions/recent-sessions.js +29 -0
  197. package/dist/react/features/sessions/seen-sessions.d.ts +16 -0
  198. package/dist/react/features/sessions/seen-sessions.js +108 -0
  199. package/dist/react/features/sessions/session-activity.d.ts +95 -0
  200. package/dist/react/features/sessions/session-activity.js +785 -0
  201. package/dist/react/features/sessions/session-context.d.ts +8 -0
  202. package/dist/react/features/sessions/session-context.js +98 -0
  203. package/dist/react/features/sessions/session-feed.d.ts +243 -0
  204. package/dist/react/features/sessions/session-feed.js +883 -0
  205. package/dist/react/features/sessions/session-header.d.ts +24 -0
  206. package/dist/react/features/sessions/session-header.js +97 -0
  207. package/dist/react/features/sessions/session-layout.d.ts +7 -0
  208. package/dist/react/features/sessions/session-layout.js +87 -0
  209. package/dist/react/features/sessions/session-panes.d.ts +49 -0
  210. package/dist/react/features/sessions/session-panes.js +142 -0
  211. package/dist/react/features/sessions/session-parts.d.ts +35 -0
  212. package/dist/react/features/sessions/session-parts.js +74 -0
  213. package/dist/react/features/sessions/session-place.d.ts +9 -0
  214. package/dist/react/features/sessions/session-place.js +109 -0
  215. package/dist/react/features/sessions/session-pr-pills.d.ts +7 -0
  216. package/dist/react/features/sessions/session-pr-pills.js +28 -0
  217. package/dist/react/features/sessions/session-queries.d.ts +172 -0
  218. package/dist/react/features/sessions/session-queries.js +90 -0
  219. package/dist/react/features/sessions/session-repos.d.ts +8 -0
  220. package/dist/react/features/sessions/session-repos.js +15 -0
  221. package/dist/react/features/sessions/session-share.d.ts +8 -0
  222. package/dist/react/features/sessions/session-share.js +112 -0
  223. package/dist/react/features/sessions/session-tabs.d.ts +38 -0
  224. package/dist/react/features/sessions/session-tabs.js +191 -0
  225. package/dist/react/features/sessions/session.d.ts +103 -0
  226. package/dist/react/features/sessions/session.js +216 -0
  227. package/dist/react/features/sessions/signals.d.ts +13 -0
  228. package/dist/react/features/sessions/signals.js +34 -0
  229. package/dist/react/features/sessions/tab-set.d.ts +20 -0
  230. package/dist/react/features/sessions/tab-set.js +58 -0
  231. package/dist/react/features/sessions/team.d.ts +16 -0
  232. package/dist/react/features/sessions/team.js +35 -0
  233. package/dist/react/features/sessions/timeline.d.ts +53 -0
  234. package/dist/react/features/sessions/timeline.js +153 -0
  235. package/dist/react/features/sessions/use-session-tabs.d.ts +18 -0
  236. package/dist/react/features/sessions/use-session-tabs.js +119 -0
  237. package/dist/react/features/sessions/vendor-models.d.ts +23 -0
  238. package/dist/react/features/sessions/vendor-models.js +61 -0
  239. package/dist/react/features/workspace/activity-dot.d.ts +15 -0
  240. package/dist/react/features/workspace/activity-dot.js +36 -0
  241. package/dist/react/features/workspace/app-sidebar.d.ts +16 -0
  242. package/dist/react/features/workspace/app-sidebar.js +227 -0
  243. package/dist/react/features/workspace/fixture-toggle.d.ts +2 -0
  244. package/dist/react/features/workspace/fixture-toggle.js +72 -0
  245. package/dist/react/features/workspace/folder-group.d.ts +18 -0
  246. package/dist/react/features/workspace/folder-group.js +83 -0
  247. package/dist/react/features/workspace/inline-name-input.d.ts +10 -0
  248. package/dist/react/features/workspace/inline-name-input.js +33 -0
  249. package/dist/react/features/workspace/link-repo-dialog.d.ts +9 -0
  250. package/dist/react/features/workspace/link-repo-dialog.js +76 -0
  251. package/dist/react/features/workspace/repo-chip.d.ts +13 -0
  252. package/dist/react/features/workspace/repo-chip.js +15 -0
  253. package/dist/react/features/workspace/session-row.d.ts +20 -0
  254. package/dist/react/features/workspace/session-row.js +23 -0
  255. package/dist/react/features/workspace/use-debounced.d.ts +2 -0
  256. package/dist/react/features/workspace/use-debounced.js +10 -0
  257. package/dist/react/features/workspace/workspace-context.d.ts +45 -0
  258. package/dist/react/features/workspace/workspace-context.js +245 -0
  259. package/dist/react/features/workspace/workspace-fixtures.d.ts +16 -0
  260. package/dist/react/features/workspace/workspace-fixtures.js +175 -0
  261. package/dist/react/features/workspace/workspace-tree.d.ts +30 -0
  262. package/dist/react/features/workspace/workspace-tree.js +69 -0
  263. package/dist/react/features/workspace/workspace.d.ts +107 -0
  264. package/dist/react/features/workspace/workspace.js +458 -0
  265. package/dist/react/index.d.ts +33 -0
  266. package/dist/react/index.js +35 -0
  267. package/dist/react/lib/cn.d.ts +6 -0
  268. package/dist/react/lib/cn.js +20 -0
  269. package/dist/react/lib/initials.d.ts +6 -0
  270. package/dist/react/lib/initials.js +32 -0
  271. package/dist/react/lib/json.d.ts +33 -0
  272. package/dist/react/lib/json.js +101 -0
  273. package/dist/react/lib/time.d.ts +8 -0
  274. package/dist/react/lib/time.js +57 -0
  275. package/dist/react/lib/use-media-query.d.ts +1 -0
  276. package/dist/react/lib/use-media-query.js +9 -0
  277. package/dist/react/lib/use-now.d.ts +2 -0
  278. package/dist/react/lib/use-now.js +10 -0
  279. package/dist/react/lib/use-width-bucket.d.ts +6 -0
  280. package/dist/react/lib/use-width-bucket.js +28 -0
  281. package/dist/react/parts/index.d.ts +43 -0
  282. package/dist/react/parts/index.js +43 -0
  283. package/dist/react/shuttle/device.d.ts +42 -0
  284. package/dist/react/shuttle/device.js +10 -0
  285. package/dist/react/shuttle/host.d.ts +1126 -0
  286. package/dist/react/shuttle/host.js +93 -0
  287. package/dist/react/shuttle/identity.d.ts +31 -0
  288. package/dist/react/shuttle/identity.js +20 -0
  289. package/dist/react/shuttle/index.d.ts +14 -0
  290. package/dist/react/shuttle/index.js +13 -0
  291. package/dist/react/shuttle/provider.d.ts +41 -0
  292. package/dist/react/shuttle/provider.js +59 -0
  293. package/dist/react/shuttle/router.d.ts +43 -0
  294. package/dist/react/shuttle/router.js +1 -0
  295. package/dist/react/theme.css +456 -0
  296. package/dist/react/ui.d.ts +19 -0
  297. package/dist/react/ui.js +19 -0
  298. package/package.json +100 -4
@@ -0,0 +1,227 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation } from '@tanstack/react-query';
3
+ import { Archive, BookOpen, FolderPlus, GitBranch, PanelLeftClose, PanelLeftOpen, Plug, Plus, Radio, SquarePen, } from 'lucide-react';
4
+ import { useEffect, useEffectEvent, useMemo, useState } from 'react';
5
+ import { z } from 'zod';
6
+ import { useProjection, useRunStore } from '@swirls/looms/react';
7
+ import { ShuttleMark } from '../../components/shuttle-mark.js';
8
+ import { Button } from '../../components/ui/button.js';
9
+ import { Kbd } from '../../components/ui/panel.js';
10
+ import { ScrollArea } from '../../components/ui/scroll-area.js';
11
+ import { Tooltip, TooltipContent, TooltipTrigger } from '../../components/ui/tooltip.js';
12
+ import { cn } from '../../lib/cn.js';
13
+ import { useMediaQuery } from '../../lib/use-media-query.js';
14
+ import { useNow } from '../../lib/use-now.js';
15
+ import { Link, useLocation, useNavigate, useShuttleHost, useTenant, } from '../../shuttle/index.js';
16
+ import { attentionPullCount, authoredPullCounts, pullInbox, pullsForFolder, usePullsRunId, } from '../pulls/pulls.js';
17
+ import { recentSessions } from '../sessions/recent-sessions.js';
18
+ import { isSessionUnread, markSessionSeen, useSeenSessions, } from '../sessions/seen-sessions.js';
19
+ import { resolveFolderIndicator, resolveSessionIndicator } from '../sessions/session-activity.js';
20
+ import { ActivityDot } from './activity-dot.js';
21
+ import { FixtureToggle } from './fixture-toggle.js';
22
+ import { FolderGroup } from './folder-group.js';
23
+ import { InlineNameInput } from './inline-name-input.js';
24
+ import { LinkRepoDialog } from './link-repo-dialog.js';
25
+ import { SessionRow } from './session-row.js';
26
+ import { createWorkspaceFolder, orderedFolders, rememberLastFolder, sessionsForFolder, } from './workspace.js';
27
+ import { useWorkspace, WorkspaceProvider } from './workspace-context.js';
28
+ const COLLAPSED_KEY = 'shuttle.sidebar-collapsed';
29
+ const EXPANDED_KEY = 'shuttle.sidebar-expanded';
30
+ const SHOW_ARCHIVED_KEY = 'shuttle.sidebar-show-archived';
31
+ const UNFILED_LIMIT = 8;
32
+ function readExpanded() {
33
+ try {
34
+ return z
35
+ .record(z.string(), z.boolean())
36
+ .parse(JSON.parse(localStorage.getItem(EXPANDED_KEY) ?? '{}'));
37
+ }
38
+ catch {
39
+ return {};
40
+ }
41
+ }
42
+ /**
43
+ * The frame Shuttle's pages sit in: the workspace's folders and sessions down the side, and
44
+ * the page beside them. It follows the workspace, so everything inside can read it.
45
+ */
46
+ export function AppSidebarShell({ children, status, account, background, }) {
47
+ const { fixtures } = useShuttleHost();
48
+ return (_jsxs(WorkspaceProvider, { children: [background, _jsxs("div", { className: "flex h-dvh min-h-0", children: [_jsx(AppSidebar, { status: status, account: account }), _jsx("div", { className: "min-w-0 flex-1", children: children })] }), fixtures ? _jsx(FixtureToggle, {}) : null] }));
49
+ }
50
+ function AppSidebar({ status, account }) {
51
+ const navigate = useNavigate();
52
+ const location = useLocation();
53
+ // Names the page on screen, to tell whether the drawer was opened from it.
54
+ const here = JSON.stringify(location);
55
+ const narrow = useMediaQuery('(max-width: 767px)');
56
+ const workspace = useWorkspace();
57
+ const seenSnapshot = useSeenSessions();
58
+ const activeRunId = location?.page === 'session' ? location.sessionId : null;
59
+ const activeSession = activeRunId ? workspace.tree.sessions[activeRunId] : undefined;
60
+ useEffect(() => {
61
+ if (!activeRunId) {
62
+ return;
63
+ }
64
+ const latestAt = Math.max(Date.now(), activeSession?.lastCompletedAt ?? 0, activeSession?.updatedAt ?? 0);
65
+ markSessionSeen(activeRunId, latestAt);
66
+ }, [activeRunId, activeSession?.lastCompletedAt, activeSession?.updatedAt]);
67
+ const [collapsedPref, setCollapsedPref] = useState(() => localStorage.getItem(COLLAPSED_KEY) === '1');
68
+ /** On narrow screens the drawer stays open only on the page it was opened from. */
69
+ const [drawerPath, setDrawerPath] = useState(null);
70
+ const drawerOpen = narrow && drawerPath === here;
71
+ const collapsed = narrow ? !drawerOpen : collapsedPref;
72
+ function toggle() {
73
+ if (narrow) {
74
+ setDrawerPath(drawerOpen ? null : here);
75
+ return;
76
+ }
77
+ const next = !collapsedPref;
78
+ localStorage.setItem(COLLAPSED_KEY, next ? '1' : '0');
79
+ setCollapsedPref(next);
80
+ }
81
+ /** ⌘N belongs to the browser, so new session lives on ⌘⇧O. */
82
+ const onKeyDown = useEffectEvent((event) => {
83
+ const mod = event.metaKey || event.ctrlKey;
84
+ const key = event.key.toLowerCase();
85
+ if (mod && !event.shiftKey && key === 'b') {
86
+ event.preventDefault();
87
+ toggle();
88
+ }
89
+ if (mod && event.shiftKey && key === 'o') {
90
+ event.preventDefault();
91
+ void navigate({ page: 'home' });
92
+ }
93
+ if (key === 'escape' && drawerOpen && !event.defaultPrevented) {
94
+ setDrawerPath(null);
95
+ }
96
+ });
97
+ useEffect(() => {
98
+ window.addEventListener('keydown', onKeyDown);
99
+ return () => window.removeEventListener('keydown', onKeyDown);
100
+ }, []);
101
+ const rail = (_jsx(SidebarRail, { location: location, activeRunId: activeRunId, workspace: workspace, seenSnapshot: seenSnapshot, onExpand: toggle }));
102
+ if (collapsed) {
103
+ return rail;
104
+ }
105
+ const panel = (_jsx(SidebarPanel, { status: status, account: account, location: location, activeRunId: activeRunId, seenSnapshot: seenSnapshot, onCollapse: toggle }));
106
+ if (narrow) {
107
+ return (_jsxs(_Fragment, { children: [rail, _jsx("div", { "aria-hidden": true, className: "drawer-scrim fixed inset-0 z-40 bg-black/50", onClick: () => setDrawerPath(null) }), _jsx("div", { className: "drawer-in fixed inset-y-0 left-0 z-50 flex shadow-2xl shadow-black/60", onClick: (event) => {
108
+ if (event.target instanceof Element && event.target.closest('a[href]')) {
109
+ setDrawerPath(null);
110
+ }
111
+ }, children: panel })] }));
112
+ }
113
+ return panel;
114
+ }
115
+ function SidebarRail({ location, activeRunId, workspace, seenSnapshot, onExpand, }) {
116
+ const pullsStore = useRunStore(usePullsRunId());
117
+ const inbox = useProjection(pullsStore, pullInbox);
118
+ const rollup = useMemo(() => {
119
+ const tones = Object.values(workspace.tree.sessions)
120
+ .filter((session) => !session.archived && !workspace.tree.folders[session.folderId]?.archived)
121
+ .map((session) => resolveSessionIndicator({
122
+ activity: session.activity,
123
+ status: session.status,
124
+ unread: isSessionUnread(session, { activeRunId, snapshot: seenSnapshot }),
125
+ }));
126
+ return resolveFolderIndicator(tones);
127
+ }, [workspace, activeRunId, seenSnapshot]);
128
+ const totalPullAttention = useMemo(() => {
129
+ return Object.values(workspace.tree.folders)
130
+ .filter((folder) => !folder.archived)
131
+ .reduce((sum, folder) => sum +
132
+ attentionPullCount(pullsForFolder(inbox, folder.repos.map((repo) => repo.fullName))), 0);
133
+ }, [workspace, inbox]);
134
+ const expandLabel = rollup
135
+ ? `Expand sidebar · ${rollup.label}`
136
+ : totalPullAttention > 0
137
+ ? `Expand sidebar · ${totalPullAttention} PRs need attention`
138
+ : 'Expand sidebar';
139
+ return (_jsxs("aside", { className: "bg-sidebar flex w-12 shrink-0 flex-col items-center gap-1 border-r py-2", children: [_jsx(IconTip, { label: expandLabel, shortcut: ['⌘', 'B'], side: "right", children: _jsxs(Button, { variant: "ghost", size: "icon-sm", "aria-label": expandLabel, onClick: onExpand, className: "relative", children: [_jsx(PanelLeftOpen, {}), rollup ? (_jsx("span", { className: "bg-sidebar absolute -top-0.5 -right-0.5 rounded-full p-px", children: _jsx(ActivityDot, { tone: rollup.tone, label: rollup.label, className: "size-3" }) })) : totalPullAttention > 0 ? (_jsx("span", { className: "bg-brand text-brand-foreground absolute -top-0.5 -right-0.5 flex size-3.5 items-center justify-center rounded-full text-[8px] font-semibold tabular-nums", children: totalPullAttention > 9 ? '9+' : totalPullAttention })) : null] }) }), _jsx("div", { className: "bg-border my-1 h-px w-5" }), _jsx(IconTip, { label: "New session", shortcut: ['⌘', '⇧', 'O'], side: "right", children: _jsx(Button, { variant: "ghost", size: "icon-sm", className: cn(location?.page === 'home' && 'bg-accent text-foreground'), asChild: true, children: _jsx(Link, { to: { page: 'home' }, "aria-label": "New session", children: _jsx(SquarePen, {}) }) }) }), _jsx(IconTip, { label: "Playbook", side: "right", children: _jsx(Button, { variant: "ghost", size: "icon-sm", className: cn(location?.page === 'playbook' && 'bg-accent text-foreground'), asChild: true, children: _jsx(Link, { to: { page: 'playbook' }, "aria-label": "Playbook", children: _jsx(BookOpen, {}) }) }) }), _jsx(IconTip, { label: "Events", side: "right", children: _jsx(Button, { variant: "ghost", size: "icon-sm", className: cn(location?.page === 'events' && 'bg-accent text-foreground'), asChild: true, children: _jsx(Link, { to: { page: 'events' }, "aria-label": "Events", children: _jsx(Radio, {}) }) }) }), _jsx(IconTip, { label: "Connections", side: "right", children: _jsx(Button, { variant: "ghost", size: "icon-sm", className: cn(location?.page === 'connections' && 'bg-accent text-foreground'), asChild: true, children: _jsx(Link, { to: { page: 'connections' }, "aria-label": "Connections", children: _jsx(Plug, {}) }) }) })] }));
140
+ }
141
+ function SidebarPanel({ location, activeRunId, seenSnapshot, onCollapse, status, account, }) {
142
+ const workspace = useWorkspace();
143
+ return (_jsxs("aside", { className: "bg-sidebar flex w-[260px] shrink-0 flex-col border-r", children: [_jsxs("div", { className: "flex h-12 shrink-0 items-center gap-2 border-b pr-2 pl-3", children: [_jsxs(Link, { to: { page: 'home' }, className: "focus-visible:ring-ring/50 flex min-w-0 flex-1 items-center gap-2 rounded-md outline-none focus-visible:ring-2", children: [_jsx("span", { className: "bg-brand/15 text-foreground ring-brand/25 flex size-6 shrink-0 items-center justify-center rounded-md ring-1 ring-inset", children: _jsx(ShuttleMark, { className: "size-3.5" }) }), _jsx("span", { className: "truncate text-[13px] font-semibold tracking-tight", children: "Shuttle" })] }), _jsx(IconTip, { label: "Collapse sidebar", shortcut: ['⌘', 'B'], children: _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": "Collapse sidebar", onClick: onCollapse, children: _jsx(PanelLeftClose, {}) }) })] }), _jsxs("nav", { className: "flex flex-col gap-px p-2", children: [_jsx(SidebarNavLink, { to: { page: 'home' }, icon: _jsx(SquarePen, {}), active: location?.page === 'home', shortcut: ['⌘', '⇧', 'O'], children: "New session" }), _jsx(SidebarNavLink, { to: { page: 'playbook' }, icon: _jsx(BookOpen, {}), active: location?.page === 'playbook', children: "Playbook" }), _jsx(SidebarNavLink, { to: { page: 'events' }, icon: _jsx(Radio, {}), active: location?.page === 'events', children: "Events" }), _jsx(SidebarNavLink, { to: { page: 'connections' }, icon: _jsx(Plug, {}), active: location?.page === 'connections', children: "Connections" })] }), _jsx(FolderTree, { workspace: workspace, location: location, activeRunId: activeRunId, seenSnapshot: seenSnapshot }), status, _jsx(GithubFooter, { installations: Object.values(workspace.tree.installations) }), account] }));
144
+ }
145
+ function FolderTree({ workspace, location, activeRunId, seenSnapshot, }) {
146
+ const host = useShuttleHost();
147
+ const { runId, tree, liveSessions } = workspace;
148
+ const navigate = useNavigate();
149
+ const now = useNow();
150
+ const pullsStore = useRunStore(usePullsRunId());
151
+ const inbox = useProjection(pullsStore, pullInbox);
152
+ const pullCounts = useMemo(() => authoredPullCounts(inbox), [inbox]);
153
+ const orgPrefix = `o-${useTenant().org.id}-`;
154
+ const [showArchived, setShowArchived] = useState(() => localStorage.getItem(SHOW_ARCHIVED_KEY) === '1');
155
+ const [expanded, setExpanded] = useState(readExpanded);
156
+ const [creating, setCreating] = useState(false);
157
+ const [linkFolderId, setLinkFolderId] = useState(null);
158
+ const folders = orderedFolders(tree, { includeArchived: showArchived });
159
+ const unfiled = useMemo(() => recentSessions()
160
+ // This browser may have opened sessions in another organization; those are not ours.
161
+ .filter((session) => session.runId.startsWith(orgPrefix) && !tree.sessions[session.runId])
162
+ .slice(0, UNFILED_LIMIT), [tree.sessions, orgPrefix]);
163
+ const linkFolder = linkFolderId ? tree.folders[linkFolderId] : undefined;
164
+ function toggleArchived() {
165
+ const next = !showArchived;
166
+ localStorage.setItem(SHOW_ARCHIVED_KEY, next ? '1' : '0');
167
+ setShowArchived(next);
168
+ }
169
+ function setFolderOpen(folderId, open) {
170
+ setExpanded((prev) => {
171
+ const next = { ...prev, [folderId]: open };
172
+ localStorage.setItem(EXPANDED_KEY, JSON.stringify(next));
173
+ return next;
174
+ });
175
+ }
176
+ const createFolder = useMutation({
177
+ mutationFn: (name) => createWorkspaceFolder(host, runId, name),
178
+ onSuccess(folderId) {
179
+ setFolderOpen(folderId, true);
180
+ rememberLastFolder(folderId);
181
+ void navigate({ page: 'folder', folderId });
182
+ },
183
+ });
184
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex h-7 shrink-0 items-center gap-0.5 pr-2 pl-3", children: [_jsx(SectionHeading, { children: "Folders" }), _jsx(IconTip, { label: showArchived ? 'Hide archived' : 'Show archived', children: _jsx(Button, { variant: "ghost", size: "icon-xs", className: "aria-pressed:bg-accent aria-pressed:text-foreground ml-auto", "aria-label": "Show archived", "aria-pressed": showArchived, onClick: toggleArchived, children: _jsx(Archive, {}) }) }), _jsx(IconTip, { label: "New folder", children: _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": "New folder", onClick: () => setCreating(true), children: _jsx(FolderPlus, {}) }) })] }), _jsx(ScrollArea, { className: "scroll-fade min-h-0 flex-1", children: _jsxs("div", { className: "px-1.5 pt-0.5 pb-5", children: [creating ? (_jsx("div", { className: "px-1 py-0.5", children: _jsx(InlineNameInput, { initialValue: "New folder", label: "Folder name", commitUnchanged: true, onCancel: () => setCreating(false), onCommit: (name) => {
185
+ setCreating(false);
186
+ createFolder.mutate(name);
187
+ } }) })) : null, folders.length === 0 && !creating ? (_jsxs("div", { className: "mx-1.5 my-1 rounded-lg border border-dashed px-3 py-3", children: [_jsx("p", { className: "text-muted-foreground text-[11.5px] leading-relaxed", children: "Folders group sessions and the GitHub repos their agents can work in." }), _jsxs(Button, { variant: "secondary", size: "xs", className: "mt-2", onClick: () => setCreating(true), children: [_jsx(FolderPlus, {}), "New folder"] })] })) : null, folders.map((folder) => {
188
+ const open = expanded[folder.folderId] ?? !folder.archived;
189
+ const pullAttention = attentionPullCount(pullsForFolder(inbox, folder.repos.map((repo) => repo.fullName)));
190
+ return (_jsx(FolderGroup, { runId: runId, folder: folder, sessions: sessionsForFolder(tree, folder.folderId, {
191
+ includeArchived: showArchived,
192
+ }), open: open, onToggle: () => setFolderOpen(folder.folderId, !open), location: location, activeRunId: activeRunId, seenSnapshot: seenSnapshot, now: now, pullAttention: pullAttention, pullCounts: pullCounts, onLinkRepo: () => setLinkFolderId(folder.folderId) }, folder.folderId));
193
+ }), unfiled.length > 0 ? (_jsxs("div", { className: "mt-4", children: [_jsx("div", { className: "flex h-7 items-center px-1.5", children: _jsx(SectionHeading, { children: "Unfiled" }) }), unfiled.map((session) => {
194
+ const live = liveSessions[session.runId];
195
+ return (_jsx(SessionRow, { runId: session.runId, title: session.goal, activity: live?.activity ?? 'idle', status: live?.status ?? 'unknown', updatedAt: session.openedAt, now: now, active: activeRunId === session.runId, pullCount: pullCounts.get(session.runId) }, session.runId));
196
+ })] })) : null] }) }), linkFolder ? (_jsx(LinkRepoDialog, { open: true, onOpenChange: (open) => {
197
+ if (!open) {
198
+ setLinkFolderId(null);
199
+ }
200
+ }, folderId: linkFolder.folderId, folderName: linkFolder.name, tree: tree, linked: linkFolder.repos })) : null] }));
201
+ }
202
+ function GithubFooter({ installations }) {
203
+ if (installations.length === 0) {
204
+ return (_jsx("div", { className: "shrink-0 border-t p-2", children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-full justify-start px-2 text-[12.5px]", asChild: true, children: _jsxs("a", { href: "/github/install", children: [_jsx(GitBranch, {}), "Connect GitHub"] }) }) }));
205
+ }
206
+ const logins = installations.map((installation) => installation.account.login).join(', ');
207
+ return (_jsxs("div", { className: "flex h-12 shrink-0 items-center gap-2 border-t pr-2 pl-3", children: [_jsx("div", { className: "flex shrink-0 -space-x-1.5", children: installations.slice(0, 3).map((installation) => (_jsx(GithubAvatar, { installation: installation }, installation.installationId))) }), _jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate text-[11px]", title: logins, children: logins }), _jsx(IconTip, { label: "Add GitHub organization", children: _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": "Add GitHub organization", asChild: true, children: _jsx("a", { href: "/github/install?add", children: _jsx(Plus, {}) }) }) })] }));
208
+ }
209
+ function GithubAvatar({ installation }) {
210
+ const { login, avatarUrl } = installation.account;
211
+ const [failed, setFailed] = useState(false);
212
+ if (!avatarUrl || failed) {
213
+ return (_jsx("span", { "aria-label": login, className: "bg-accent text-foreground ring-sidebar flex size-5 items-center justify-center rounded-full text-[9px] font-medium uppercase ring-2", children: Array.from(login)[0] ?? '?' }));
214
+ }
215
+ return (_jsx("img", { src: avatarUrl, alt: login, onError: () => setFailed(true), className: "ring-sidebar size-5 rounded-full object-cover ring-2" }));
216
+ }
217
+ function SectionHeading({ children }) {
218
+ return (_jsx("span", { className: "text-muted-foreground text-[11px] font-medium tracking-wide uppercase", children: children }));
219
+ }
220
+ function SidebarNavLink({ to, icon, active, shortcut, children, }) {
221
+ return (_jsxs(Link, { to: to, className: cn('group/nav focus-visible:ring-ring/50 flex h-8 items-center gap-2 rounded-md px-2 text-[12.5px] transition-colors duration-100 outline-none focus-visible:ring-2 [&>svg]:size-3.5 [&>svg]:shrink-0', active
222
+ ? 'bg-accent text-foreground'
223
+ : 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'), children: [icon, children, shortcut ? (_jsx("span", { "aria-hidden": true, className: "ml-auto flex gap-0.5 opacity-0 transition-opacity duration-100 group-hover/nav:opacity-100 pointer-coarse:hidden", children: shortcut.map((key) => (_jsx(Kbd, { children: key }, key))) })) : null] }));
224
+ }
225
+ function IconTip({ label, shortcut, side = 'bottom', children, }) {
226
+ return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: children }), _jsxs(TooltipContent, { side: side, className: "flex items-center gap-2", children: [label, shortcut ? (_jsx("span", { className: "flex gap-0.5", children: shortcut.map((key) => (_jsx(Kbd, { children: key }, key))) })) : null] })] }));
227
+ }
@@ -0,0 +1,2 @@
1
+ /** Dev-only chrome for stress-testing the workspace UI against fixture trees. */
2
+ export declare function FixtureToggle(): import("react").JSX.Element | null;
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { useFixtureMode } from './workspace-context.js';
4
+ const LABELS = {
5
+ live: 'Live data',
6
+ worst: 'Worst case',
7
+ empty: 'Empty',
8
+ huge: '1,284 sessions',
9
+ };
10
+ const HIDDEN_KEY = 'shuttle.fixture.bar';
11
+ function readHidden() {
12
+ try {
13
+ return sessionStorage.getItem(HIDDEN_KEY) !== '0';
14
+ }
15
+ catch {
16
+ return true;
17
+ }
18
+ }
19
+ function writeHidden(hidden) {
20
+ try {
21
+ sessionStorage.setItem(HIDDEN_KEY, hidden ? '1' : '0');
22
+ }
23
+ catch {
24
+ // Private mode / quota — dismiss is ephemeral anyway.
25
+ }
26
+ }
27
+ function isTypingTarget(target) {
28
+ if (!(target instanceof HTMLElement)) {
29
+ return false;
30
+ }
31
+ if (target.isContentEditable) {
32
+ return true;
33
+ }
34
+ const tag = target.tagName;
35
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
36
+ }
37
+ /** Dev-only chrome for stress-testing the workspace UI against fixture trees. */
38
+ export function FixtureToggle() {
39
+ const [mode, setMode] = useFixtureMode();
40
+ // Default hidden so the composer isn't covered; Shift+F reveals it.
41
+ const [hidden, setHidden] = useState(readHidden);
42
+ useEffect(() => {
43
+ const onKeyDown = (event) => {
44
+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) {
45
+ return;
46
+ }
47
+ if (event.key.toLowerCase() !== 'f' || !event.shiftKey) {
48
+ return;
49
+ }
50
+ if (isTypingTarget(event.target)) {
51
+ return;
52
+ }
53
+ event.preventDefault();
54
+ setHidden((prev) => {
55
+ const next = !prev;
56
+ writeHidden(next);
57
+ return next;
58
+ });
59
+ };
60
+ window.addEventListener('keydown', onKeyDown);
61
+ return () => window.removeEventListener('keydown', onKeyDown);
62
+ }, []);
63
+ if (hidden) {
64
+ return null;
65
+ }
66
+ return (_jsxs("div", { role: "radiogroup", "aria-label": "Workspace data (Shift+F to hide)", title: "Shift+F to hide", className: "fixed bottom-3 left-1/2 z-[60] flex -translate-x-1/2 items-center gap-0.5 rounded-full bg-neutral-300 p-0.5 font-[system-ui] text-[11px] whitespace-nowrap text-neutral-700 shadow-lg", children: [Object.keys(LABELS).map((option) => (_jsx("button", { type: "button", role: "radio", "aria-checked": mode === option, onClick: () => setMode(option), className: mode === option
67
+ ? 'rounded-full bg-white px-2.5 py-1 text-neutral-900 shadow-sm'
68
+ : 'rounded-full px-2.5 py-1 hover:text-neutral-900', children: LABELS[option] }, option))), _jsx("button", { type: "button", onClick: () => {
69
+ writeHidden(true);
70
+ setHidden(true);
71
+ }, className: "rounded-full px-2 py-1 text-neutral-500 hover:bg-neutral-200 hover:text-neutral-900", "aria-label": "Hide fixtures bar", title: "Hide (Shift+F)", children: "\u00D7" })] }));
72
+ }
@@ -0,0 +1,18 @@
1
+ import { type ShuttleDestination } from '../../shuttle/index.js';
2
+ import { type SeenSessionsSnapshot } from '../sessions/seen-sessions.js';
3
+ import { type WorkspaceFolder, type WorkspaceSession } from './workspace.js';
4
+ export declare function FolderGroup({ runId, folder, sessions, open, onToggle, location, activeRunId, seenSnapshot, now, pullAttention, pullCounts, onLinkRepo, }: {
5
+ runId: string;
6
+ folder: WorkspaceFolder;
7
+ sessions: readonly WorkspaceSession[];
8
+ open: boolean;
9
+ onToggle: () => void;
10
+ location: ShuttleDestination | null;
11
+ activeRunId: string | null;
12
+ seenSnapshot: SeenSessionsSnapshot;
13
+ now: number;
14
+ pullAttention?: number;
15
+ /** Open PRs per session run id. */
16
+ pullCounts: ReadonlyMap<string, number>;
17
+ onLinkRepo: () => void;
18
+ }): import("react").JSX.Element;
@@ -0,0 +1,83 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation } from '@tanstack/react-query';
3
+ import { Archive, ChevronRight, Folder, FolderOpen, GitBranch, GitPullRequest, MoreHorizontal, Plus, } from 'lucide-react';
4
+ import { useState } from 'react';
5
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../../components/ui/dropdown-menu.js';
6
+ import { cn } from '../../lib/cn.js';
7
+ import { Link, useApi, useShuttleHost } from '../../shuttle/index.js';
8
+ import { setPullInboxCollapsed } from '../pulls/pull-inbox-pref.js';
9
+ import { isSessionUnread } from '../sessions/seen-sessions.js';
10
+ import { resolveFolderIndicator, resolveSessionIndicator } from '../sessions/session-activity.js';
11
+ import { ActivityDot } from './activity-dot.js';
12
+ import { InlineNameInput } from './inline-name-input.js';
13
+ import { revealOnRowHover, SessionRow, sidebarRowClass, yieldOnRowHover } from './session-row.js';
14
+ import { archiveWorkspaceFolder, rememberLastFolder, renameWorkspaceFolder, repoCountLabel, } from './workspace.js';
15
+ const SESSION_PREVIEW = 5;
16
+ export function FolderGroup({ runId, folder, sessions, open, onToggle, location, activeRunId, seenSnapshot, now, pullAttention = 0, pullCounts, onLinkRepo, }) {
17
+ const host = useShuttleHost();
18
+ const api = useApi();
19
+ const [renaming, setRenaming] = useState(false);
20
+ const [renamingSessionId, setRenamingSessionId] = useState(null);
21
+ const [showAll, setShowAll] = useState(false);
22
+ // Nothing waits on these: the sidebar shows the new name, or the row gone, when the
23
+ // workspace's own events say so.
24
+ const renameFolder = useMutation({
25
+ mutationFn: (name) => renameWorkspaceFolder(host, runId, folder.folderId, name),
26
+ });
27
+ const archiveFolder = useMutation({
28
+ mutationFn: () => archiveWorkspaceFolder(host, runId, folder.folderId),
29
+ });
30
+ const renameSession = useMutation(api.sessions.rename.mutationOptions());
31
+ const archiveSession = useMutation(api.sessions.archive.mutationOptions());
32
+ const visible = showAll ? sessions : sessions.slice(0, SESSION_PREVIEW);
33
+ const hidden = sessions.length - visible.length;
34
+ const folderActive = location?.page === 'folder' && location.folderId === folder.folderId;
35
+ const FolderIcon = folder.archived ? Archive : open ? FolderOpen : Folder;
36
+ const repoCount = folder.repos.length;
37
+ const activeFolderSessions = folder.archived
38
+ ? []
39
+ : sessions.filter((session) => !session.archived);
40
+ const collapsedRollup = !open
41
+ ? resolveFolderIndicator(activeFolderSessions.map((session) => resolveSessionIndicator({
42
+ activity: session.activity,
43
+ status: session.status,
44
+ unread: isSessionUnread(session, { activeRunId, snapshot: seenSnapshot }),
45
+ })))
46
+ : null;
47
+ const hiddenRollup = open && !showAll && hidden > 0
48
+ ? resolveFolderIndicator(sessions
49
+ .slice(SESSION_PREVIEW)
50
+ .filter((session) => !session.archived)
51
+ .map((session) => resolveSessionIndicator({
52
+ activity: session.activity,
53
+ status: session.status,
54
+ unread: isSessionUnread(session, { activeRunId, snapshot: seenSnapshot }),
55
+ })))
56
+ : null;
57
+ return (_jsxs("div", { className: "mb-0.5", children: [_jsxs("div", { className: cn(sidebarRowClass(folderActive), folder.archived && 'opacity-60'), children: [_jsx("button", { type: "button", onClick: onToggle, "aria-expanded": open, "aria-label": `${open ? 'Collapse' : 'Expand'} ${folder.name}`, className: "text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 ml-0.5 flex size-6 shrink-0 items-center justify-center rounded-sm outline-none focus-visible:ring-2", children: _jsx(ChevronRight, { className: cn('ease-snappy size-3.5 transition-transform duration-150', open && 'rotate-90') }) }), renaming ? (_jsx("div", { className: "min-w-0 flex-1 pr-1", children: _jsx(InlineNameInput, { initialValue: folder.name, label: "Folder name", onCancel: () => setRenaming(false), onCommit: (name) => {
58
+ setRenaming(false);
59
+ renameFolder.mutate(name);
60
+ } }) })) : (_jsxs(_Fragment, { children: [_jsxs(Link, { to: { page: 'folder', folderId: folder.folderId }, title: folder.name, onClick: () => rememberLastFolder(folder.folderId), onDoubleClick: (event) => {
61
+ event.preventDefault();
62
+ setRenaming(true);
63
+ }, className: "focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md pr-1 outline-none focus-visible:ring-2", children: [_jsx(FolderIcon, { className: "text-muted-foreground size-3.5 shrink-0" }), _jsx("span", { className: "text-foreground/90 min-w-0 truncate font-medium", dir: "auto", children: folder.name })] }), _jsxs("div", { className: "relative mr-1 flex h-6 w-20 shrink-0 items-center justify-end", children: [_jsxs("div", { className: cn('inline-flex items-center gap-1.5', yieldOnRowHover), children: [collapsedRollup ? (_jsx(ActivityDot, { tone: collapsedRollup.tone, label: collapsedRollup.label })) : null, _jsx(FolderMeta, { folderId: folder.folderId, repoCount: repoCount, pullAttention: pullAttention })] }), _jsxs("div", { className: cn('absolute inset-y-0 right-0 flex items-center', revealOnRowHover), children: [folder.archived ? null : (_jsx(Link, { to: { page: 'folder', folderId: folder.folderId }, "aria-label": `New session in ${folder.name}`, title: "New session", onClick: () => rememberLastFolder(folder.folderId), className: "text-muted-foreground hover:text-foreground hover:bg-accent flex size-6 items-center justify-center rounded-sm", children: _jsx(Plus, { className: "size-3.5" }) })), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `Actions for ${folder.name}`, className: "text-muted-foreground hover:text-foreground hover:bg-accent data-[state=open]:bg-accent flex size-6 items-center justify-center rounded-sm outline-none", children: _jsx(MoreHorizontal, { className: "size-3.5" }) }) }), _jsxs(DropdownMenuContent, { align: "start", className: "min-w-40", children: [_jsx(DropdownMenuItem, { onSelect: () => setRenaming(true), children: "Rename" }), folder.archived ? null : (_jsxs(_Fragment, { children: [_jsx(DropdownMenuItem, { onSelect: onLinkRepo, children: "Link repository\u2026" }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => archiveFolder.mutate(), children: "Archive" })] }))] })] })] })] })] }))] }), open ? (_jsxs("div", { className: "ml-[1.125rem] border-l border-white/5 pl-1", children: [visible.map((session) => {
64
+ const unread = isSessionUnread(session, { activeRunId, snapshot: seenSnapshot });
65
+ return renamingSessionId === session.runId ? (_jsx("div", { className: "py-0.5 pr-1", children: _jsx(InlineNameInput, { initialValue: session.title, label: "Session title", onCancel: () => setRenamingSessionId(null), onCommit: (title) => {
66
+ setRenamingSessionId(null);
67
+ renameSession.mutate({ id: session.runId, title });
68
+ } }) }, session.runId)) : (_jsx(SessionRow, { runId: session.runId, title: session.title, activity: session.activity, status: session.status, unread: unread, updatedAt: session.updatedAt, now: now, active: activeRunId === session.runId, dimmed: session.archived, pullCount: pullCounts.get(session.runId), onRename: () => setRenamingSessionId(session.runId), onArchive: session.archived ? undefined : () => archiveSession.mutate({ id: session.runId }) }, session.runId));
69
+ }), sessions.length === 0 && !folder.archived ? (_jsxs(Link, { to: { page: 'folder', folderId: folder.folderId }, onClick: () => rememberLastFolder(folder.folderId), className: "text-muted-foreground/70 hover:text-foreground flex h-7 items-center gap-2 rounded-md px-2 text-[11.5px] transition-colors duration-100", children: [_jsx(Plus, { className: "size-3" }), "Start a session"] })) : null, sessions.length > SESSION_PREVIEW ? (_jsxs("button", { type: "button", onClick: () => setShowAll((value) => !value), className: "text-muted-foreground hover:text-foreground flex h-7 items-center gap-1.5 rounded-md px-1.5 text-[11px] transition-colors duration-100", children: [hiddenRollup ? (_jsx(ActivityDot, { tone: hiddenRollup.tone, label: hiddenRollup.label })) : null, showAll ? 'Show less' : `Show ${hidden} more`] })) : null] })) : null] }));
70
+ }
71
+ function compactCount(count) {
72
+ return count > 99 ? '99+' : String(count);
73
+ }
74
+ function FolderMeta({ folderId, repoCount, pullAttention, }) {
75
+ if (repoCount === 0) {
76
+ return null;
77
+ }
78
+ const pullLabel = `${pullAttention} pull request${pullAttention === 1 ? '' : 's'} need attention`;
79
+ return (_jsxs("span", { className: "inline-flex items-center gap-1 font-mono text-[10px] tabular-nums", children: [_jsxs("span", { title: repoCountLabel(repoCount), "aria-label": repoCountLabel(repoCount), className: "bg-muted text-muted-foreground inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5", children: [_jsx(GitBranch, { className: "size-2.5" }), compactCount(repoCount)] }), pullAttention > 0 ? (_jsxs(Link, { to: { page: 'folder', folderId: folderId }, title: pullLabel, "aria-label": pullLabel, onClick: () => {
80
+ rememberLastFolder(folderId);
81
+ setPullInboxCollapsed(false);
82
+ }, className: "bg-brand/15 text-brand hover:bg-brand/25 inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 transition-colors duration-100", children: [_jsx(GitPullRequest, { className: "size-2.5" }), compactCount(pullAttention)] })) : null] }));
83
+ }
@@ -0,0 +1,10 @@
1
+ export declare const NAME_MAX_LENGTH = 120;
2
+ /** Escape cancels even though unmounting the input blurs it afterwards. */
3
+ export declare function InlineNameInput({ initialValue, label, onCommit, onCancel, commitUnchanged, className, }: {
4
+ initialValue: string;
5
+ label: string;
6
+ onCommit: (value: string) => void;
7
+ onCancel: () => void;
8
+ commitUnchanged?: boolean;
9
+ className?: string;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { Input } from '../../components/ui/input.js';
4
+ import { cn } from '../../lib/cn.js';
5
+ export const NAME_MAX_LENGTH = 120;
6
+ /** Escape cancels even though unmounting the input blurs it afterwards. */
7
+ export function InlineNameInput({ initialValue, label, onCommit, onCancel, commitUnchanged = false, className, }) {
8
+ const settled = useRef(false);
9
+ function commit(value) {
10
+ if (settled.current) {
11
+ return;
12
+ }
13
+ settled.current = true;
14
+ const trimmed = value.replace(/\s+/g, ' ').trim();
15
+ if (trimmed && (commitUnchanged || trimmed !== initialValue)) {
16
+ onCommit(trimmed);
17
+ }
18
+ else {
19
+ onCancel();
20
+ }
21
+ }
22
+ return (_jsx(Input, { autoFocus: true, "aria-label": label, defaultValue: initialValue, maxLength: NAME_MAX_LENGTH, dir: "auto", onFocus: (event) => event.currentTarget.select(), onBlur: (event) => commit(event.currentTarget.value), onKeyDown: (event) => {
23
+ if (event.key === 'Enter') {
24
+ event.preventDefault();
25
+ commit(event.currentTarget.value);
26
+ }
27
+ if (event.key === 'Escape') {
28
+ event.preventDefault();
29
+ settled.current = true;
30
+ onCancel();
31
+ }
32
+ }, className: cn('h-7 px-2 text-[12.5px]', className) }));
33
+ }
@@ -0,0 +1,9 @@
1
+ import { type LinkedRepo, type WorkspaceTree } from './workspace.js';
2
+ export declare function LinkRepoDialog({ open, onOpenChange, folderId, folderName, tree, linked, }: {
3
+ open: boolean;
4
+ onOpenChange: (open: boolean) => void;
5
+ folderId: string;
6
+ folderName: string;
7
+ tree: WorkspaceTree;
8
+ linked: readonly LinkedRepo[];
9
+ }): import("react").JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { keepPreviousData, useMutation, useQuery } from '@tanstack/react-query';
3
+ import { Check, GitBranch, LoaderCircle, Lock, Plus, Search } from 'lucide-react';
4
+ import { useMemo, useState } from 'react';
5
+ import { Button } from '../../components/ui/button.js';
6
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '../../components/ui/dialog.js';
7
+ import { Input } from '../../components/ui/input.js';
8
+ import { cn } from '../../lib/cn.js';
9
+ import { useApi, useShuttleHost } from '../../shuttle/index.js';
10
+ import { RepoName } from './repo-chip.js';
11
+ import { useDebounced } from './use-debounced.js';
12
+ import { linkFolderRepos } from './workspace.js';
13
+ /** How long typing has to pause before GitHub is asked. */
14
+ const SEARCH_DELAY_MS = 200;
15
+ function linkLabel(count) {
16
+ if (count === 0) {
17
+ return 'Link';
18
+ }
19
+ return count === 1 ? 'Link 1 repository' : `Link ${count} repositories`;
20
+ }
21
+ export function LinkRepoDialog({ open, onOpenChange, folderId, folderName, tree, linked, }) {
22
+ const host = useShuttleHost();
23
+ const api = useApi();
24
+ const hasInstall = Object.keys(tree.installations).length > 0;
25
+ const [query, setQuery] = useState('');
26
+ const term = useDebounced(query, SEARCH_DELAY_MS);
27
+ const [selected, setSelected] = useState({});
28
+ const linkedNames = useMemo(() => new Set(linked.map((repo) => repo.fullName.toLowerCase())), [linked]);
29
+ // The last answer stays on screen, dimmed, while the next one is on its way. A search that
30
+ // fails shows as no matches.
31
+ const search = useQuery(api.github.repos.queryOptions({
32
+ input: { q: term },
33
+ enabled: open && hasInstall,
34
+ placeholderData: keepPreviousData,
35
+ }));
36
+ const repos = search.data?.repos ?? [];
37
+ const loading = search.isFetching;
38
+ const link = useMutation({
39
+ mutationFn: (picks) => linkFolderRepos(host, folderId, picks),
40
+ onSuccess: () => handleOpenChange(false),
41
+ });
42
+ function handleOpenChange(next) {
43
+ if (!next) {
44
+ setQuery('');
45
+ setSelected({});
46
+ link.reset();
47
+ }
48
+ onOpenChange(next);
49
+ }
50
+ function save() {
51
+ const picks = Object.values(selected);
52
+ if (picks.length === 0) {
53
+ handleOpenChange(false);
54
+ return;
55
+ }
56
+ link.mutate(picks);
57
+ }
58
+ return (_jsx(Dialog, { open: open, onOpenChange: handleOpenChange, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Link repositories" }), _jsxs(DialogDescription, { children: ["Agents spawned in", ' ', _jsx("span", { className: "text-foreground wrap-anywhere", dir: "auto", children: folderName }), ' ', "get worktrees of every linked repo."] })] }), !hasInstall ? (_jsxs("div", { className: "bg-card/50 flex flex-col items-start gap-3 rounded-lg border border-dashed p-4", children: [_jsx("p", { className: "text-muted-foreground text-xs leading-relaxed", children: "Connect a GitHub App installation to browse repositories you can link." }), _jsx(Button, { variant: "brand", size: "sm", asChild: true, children: _jsxs("a", { href: "/github/install", children: [_jsx(GitBranch, {}), "Connect GitHub"] }) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative", children: [_jsx(Search, { className: "text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2" }), _jsx(Input, { autoFocus: true, value: query, onChange: (event) => setQuery(event.target.value), placeholder: "Search repositories\u2026", className: "pr-8 pl-8", "aria-label": "Search repositories" }), loading ? (_jsx(LoaderCircle, { className: "text-muted-foreground absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 animate-spin" })) : null] }), _jsx("ul", { className: cn('h-64 overflow-y-auto overscroll-contain rounded-lg border transition-opacity duration-150', loading && repos.length > 0 && 'opacity-60'), children: repos.length === 0 ? (_jsx("li", { className: "text-muted-foreground flex h-full items-center justify-center px-3 text-center text-xs", children: loading
59
+ ? 'Searching…'
60
+ : query
61
+ ? `No repositories match “${query}”.`
62
+ : 'No repositories found.' })) : (repos.map((repo) => {
63
+ const already = linkedNames.has(repo.fullName.toLowerCase());
64
+ const checked = already || Boolean(selected[repo.fullName]);
65
+ return (_jsx("li", { children: _jsxs("button", { type: "button", disabled: already, onClick: () => setSelected((prev) => {
66
+ if (prev[repo.fullName]) {
67
+ const next = { ...prev };
68
+ delete next[repo.fullName];
69
+ return next;
70
+ }
71
+ return { ...prev, [repo.fullName]: repo };
72
+ }), role: "checkbox", "aria-checked": checked, className: cn('hover:bg-accent/60 flex w-full items-center gap-2.5 px-3 py-2 text-left transition-colors duration-100', checked && 'bg-accent/40', already && 'opacity-60'), children: [_jsx("span", { className: cn('flex size-4 shrink-0 items-center justify-center rounded border transition-colors duration-100', checked
73
+ ? 'bg-brand border-brand text-brand-foreground'
74
+ : 'border-input'), children: checked ? _jsx(Check, { className: "size-3" }) : null }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx(RepoName, { repo: repo, className: "text-[13px]" }), _jsxs("span", { className: "text-muted-foreground flex min-w-0 items-center gap-1.5 text-[11px]", children: [repo.private ? (_jsx(Lock, { className: "size-3 shrink-0", "aria-label": "Private" })) : null, _jsx("span", { className: "truncate font-mono text-[10px]", children: repo.defaultBranch }), already ? _jsx("span", { className: "shrink-0", children: "\u00B7 Linked" }) : null] })] })] }) }, repo.fullName));
75
+ })) })] })), link.error ? _jsx("p", { className: "text-status-failed text-xs", children: link.error.message }) : null, _jsxs(DialogFooter, { children: [hasInstall ? (_jsx(Button, { variant: "ghost", size: "sm", className: "text-muted-foreground mr-auto", asChild: true, children: _jsxs("a", { href: "/github/install?add", children: [_jsx(Plus, {}), "Add GitHub organization"] }) })) : null, _jsx(Button, { variant: "ghost", size: "sm", onClick: () => handleOpenChange(false), children: "Cancel" }), hasInstall ? (_jsxs(Button, { variant: "brand", size: "sm", disabled: link.isPending || Object.keys(selected).length === 0, onClick: save, children: [link.isPending ? _jsx(LoaderCircle, { className: "animate-spin" }) : null, linkLabel(Object.keys(selected).length)] })) : null] })] }) }));
76
+ }
@@ -0,0 +1,13 @@
1
+ import type { LinkedRepo } from './workspace.js';
2
+ type RepoSummary = Pick<LinkedRepo, 'owner' | 'name' | 'fullName' | 'private' | 'defaultBranch'>;
3
+ /** Repos sharing an org differ at the end, so the owner is shortened before the name is. */
4
+ export declare function RepoName({ repo, className }: {
5
+ repo: RepoSummary;
6
+ className?: string;
7
+ }): import("react").JSX.Element;
8
+ export declare function RepoChip({ repo, onRemove, className, }: {
9
+ repo: RepoSummary;
10
+ onRemove?: () => void;
11
+ className?: string;
12
+ }): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { GitBranch, Lock, X } from 'lucide-react';
3
+ import { cn } from '../../lib/cn.js';
4
+ const OWNER_MAX = 14;
5
+ function shortOwner(owner) {
6
+ const chars = Array.from(owner);
7
+ return chars.length > OWNER_MAX ? `${chars.slice(0, OWNER_MAX - 2).join('')}…` : owner;
8
+ }
9
+ /** Repos sharing an org differ at the end, so the owner is shortened before the name is. */
10
+ export function RepoName({ repo, className }) {
11
+ return (_jsxs("span", { className: cn('flex min-w-0 items-baseline', className), title: repo.fullName, children: [_jsxs("span", { className: "text-muted-foreground shrink-0", children: [shortOwner(repo.owner), "/"] }), _jsx("span", { className: "text-foreground min-w-0 truncate", children: repo.name })] }));
12
+ }
13
+ export function RepoChip({ repo, onRemove, className, }) {
14
+ return (_jsxs("span", { className: cn('bg-card/60 text-muted-foreground group/chip inline-flex h-6 max-w-64 min-w-0 items-center gap-1.5 rounded-full border pr-1 pl-2.5 text-[11px]', !onRemove && 'pr-2.5', className), children: [_jsx(GitBranch, { className: "size-3 shrink-0" }), _jsx(RepoName, { repo: repo }), repo.private ? _jsx(Lock, { className: "size-3 shrink-0", "aria-label": "Private" }) : null, _jsx("span", { className: "max-w-24 shrink-0 truncate font-mono text-[10px]", title: repo.defaultBranch, children: repo.defaultBranch }), onRemove ? (_jsx("button", { type: "button", onClick: onRemove, "aria-label": `Unlink ${repo.fullName}`, className: "hover:bg-accent hover:text-foreground flex size-4 shrink-0 items-center justify-center rounded-full opacity-0 transition-opacity duration-100 group-hover/chip:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100", children: _jsx(X, { className: "size-3" }) })) : null] }));
15
+ }
@@ -0,0 +1,20 @@
1
+ /** Hidden until the row is hovered or focused; always shown on touch, where hover never fires. */
2
+ export declare const revealOnRowHover = "opacity-0 transition-opacity duration-100 group-hover/row:opacity-100 group-has-[:focus-visible]/row:opacity-100 data-[state=open]:opacity-100 has-data-[state=open]:opacity-100 pointer-coarse:opacity-100";
3
+ /** Trailing metadata yields its slot to the row's actions. */
4
+ export declare const yieldOnRowHover = "transition-opacity duration-100 group-hover/row:opacity-0 group-has-[:focus-visible]/row:opacity-0 group-has-data-[state=open]/row:opacity-0 pointer-coarse:hidden";
5
+ export declare function sidebarRowClass(active: boolean): string;
6
+ export declare function SessionRow({ runId, title, activity, status, unread, updatedAt, now, active, dimmed, pullCount, onRename, onArchive, }: {
7
+ runId: string;
8
+ title: string;
9
+ activity: string;
10
+ status: string;
11
+ unread?: boolean;
12
+ updatedAt: number;
13
+ now: number;
14
+ active: boolean;
15
+ dimmed?: boolean;
16
+ /** Open PRs this session authored. */
17
+ pullCount?: number;
18
+ onRename?: () => void;
19
+ onArchive?: () => void;
20
+ }): import("react").JSX.Element;