@swirls/shuttle 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE +190 -0
- package/NOTICE +5 -0
- package/README.md +42 -2
- package/dist/api/auth.d.ts +18 -0
- package/dist/api/auth.js +15 -0
- package/dist/api/common.d.ts +8 -0
- package/dist/api/common.js +4 -0
- package/dist/api/connections.d.ts +292 -0
- package/dist/api/connections.js +114 -0
- package/dist/api/github.d.ts +20 -0
- package/dist/api/github.js +13 -0
- package/dist/api/harness.d.ts +97 -0
- package/dist/api/harness.js +47 -0
- package/dist/api/index.d.ts +2059 -0
- package/dist/api/index.js +37 -0
- package/dist/api/runners.d.ts +93 -0
- package/dist/api/runners.js +45 -0
- package/dist/api/sandbox.d.ts +550 -0
- package/dist/api/sandbox.js +210 -0
- package/dist/api/sessions.d.ts +318 -0
- package/dist/api/sessions.js +154 -0
- package/dist/api/tenant.d.ts +54 -0
- package/dist/api/tenant.js +19 -0
- package/dist/api/timings.d.ts +36 -0
- package/dist/api/timings.js +48 -0
- package/dist/api/workspace.d.ts +738 -0
- package/dist/api/workspace.js +246 -0
- package/dist/core/pulls.d.ts +1001 -0
- package/dist/core/pulls.js +170 -0
- package/dist/core/workspace.d.ts +985 -0
- package/dist/core/workspace.js +174 -0
- package/dist/react/components/command-palette.d.ts +22 -0
- package/dist/react/components/command-palette.js +66 -0
- package/dist/react/components/follow-list.d.ts +20 -0
- package/dist/react/components/follow-list.js +98 -0
- package/dist/react/components/json-tree.d.ts +11 -0
- package/dist/react/components/json-tree.js +120 -0
- package/dist/react/components/markdown.d.ts +5 -0
- package/dist/react/components/markdown.js +29 -0
- package/dist/react/components/shuttle-mark.d.ts +7 -0
- package/dist/react/components/shuttle-mark.js +9 -0
- package/dist/react/components/status-dot.d.ts +9 -0
- package/dist/react/components/status-dot.js +27 -0
- package/dist/react/components/status.d.ts +6 -0
- package/dist/react/components/status.js +66 -0
- package/dist/react/components/ui/badge.d.ts +7 -0
- package/dist/react/components/ui/badge.js +19 -0
- package/dist/react/components/ui/button.d.ts +10 -0
- package/dist/react/components/ui/button.js +40 -0
- package/dist/react/components/ui/dialog.d.ts +19 -0
- package/dist/react/components/ui/dialog.js +34 -0
- package/dist/react/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/react/components/ui/dropdown-menu.js +33 -0
- package/dist/react/components/ui/input.d.ts +3 -0
- package/dist/react/components/ui/input.js +6 -0
- package/dist/react/components/ui/panel.d.ts +18 -0
- package/dist/react/components/ui/panel.js +22 -0
- package/dist/react/components/ui/popover.d.ts +7 -0
- package/dist/react/components/ui/popover.js +16 -0
- package/dist/react/components/ui/resizable.d.ts +7 -0
- package/dist/react/components/ui/resizable.js +14 -0
- package/dist/react/components/ui/scroll-area.d.ts +14 -0
- package/dist/react/components/ui/scroll-area.js +12 -0
- package/dist/react/components/ui/select.d.ts +10 -0
- package/dist/react/components/ui/select.js +20 -0
- package/dist/react/components/ui/sheet.d.ts +8 -0
- package/dist/react/components/ui/sheet.js +20 -0
- package/dist/react/components/ui/tabs.d.ts +7 -0
- package/dist/react/components/ui/tabs.js +16 -0
- package/dist/react/components/ui/textarea.d.ts +3 -0
- package/dist/react/components/ui/textarea.js +6 -0
- package/dist/react/components/ui/tooltip.d.ts +8 -0
- package/dist/react/components/ui/tooltip.js +17 -0
- package/dist/react/features/artifacts/artifact-links.d.ts +9 -0
- package/dist/react/features/artifacts/artifact-links.js +38 -0
- package/dist/react/features/artifacts/artifact-pane.d.ts +19 -0
- package/dist/react/features/artifacts/artifact-pane.js +64 -0
- package/dist/react/features/artifacts/artifact-types.d.ts +59 -0
- package/dist/react/features/artifacts/artifact-types.js +69 -0
- package/dist/react/features/artifacts/browser-viewer.d.ts +5 -0
- package/dist/react/features/artifacts/browser-viewer.js +60 -0
- package/dist/react/features/artifacts/diff-style.d.ts +10 -0
- package/dist/react/features/artifacts/diff-style.js +21 -0
- package/dist/react/features/artifacts/file-pane.d.ts +13 -0
- package/dist/react/features/artifacts/file-pane.js +305 -0
- package/dist/react/features/artifacts/file-quick-open.d.ts +15 -0
- package/dist/react/features/artifacts/file-quick-open.js +74 -0
- package/dist/react/features/artifacts/file-search.d.ts +12 -0
- package/dist/react/features/artifacts/file-search.js +90 -0
- package/dist/react/features/artifacts/media-viewer.d.ts +8 -0
- package/dist/react/features/artifacts/media-viewer.js +41 -0
- package/dist/react/features/artifacts/review-diff.d.ts +19 -0
- package/dist/react/features/artifacts/review-diff.js +59 -0
- package/dist/react/features/artifacts/review-viewer.d.ts +4 -0
- package/dist/react/features/artifacts/review-viewer.js +337 -0
- package/dist/react/features/artifacts/sandbox.d.ts +43 -0
- package/dist/react/features/artifacts/sandbox.js +109 -0
- package/dist/react/features/artifacts/tab-strip.d.ts +11 -0
- package/dist/react/features/artifacts/tab-strip.js +55 -0
- package/dist/react/features/artifacts/terminal-theme.d.ts +34 -0
- package/dist/react/features/artifacts/terminal-theme.js +62 -0
- package/dist/react/features/artifacts/terminal-viewer.d.ts +5 -0
- package/dist/react/features/artifacts/terminal-viewer.js +209 -0
- package/dist/react/features/artifacts/unified-diff.d.ts +16 -0
- package/dist/react/features/artifacts/unified-diff.js +55 -0
- package/dist/react/features/artifacts/workspace-viewer.d.ts +16 -0
- package/dist/react/features/artifacts/workspace-viewer.js +275 -0
- package/dist/react/features/connections/agent-sign-in.d.ts +71 -0
- package/dist/react/features/connections/agent-sign-in.js +251 -0
- package/dist/react/features/connections/connections-panel.d.ts +8 -0
- package/dist/react/features/connections/connections-panel.js +42 -0
- package/dist/react/features/connections/login.d.ts +24 -0
- package/dist/react/features/connections/login.js +35 -0
- package/dist/react/features/connections/places.d.ts +20 -0
- package/dist/react/features/connections/places.js +27 -0
- package/dist/react/features/connections/queries.d.ts +28 -0
- package/dist/react/features/connections/queries.js +8 -0
- package/dist/react/features/events/event-cache.d.ts +4 -0
- package/dist/react/features/events/event-cache.js +29 -0
- package/dist/react/features/events/event-catalog.d.ts +17 -0
- package/dist/react/features/events/event-catalog.js +261 -0
- package/dist/react/features/events/event-inspector.d.ts +7 -0
- package/dist/react/features/events/event-inspector.js +29 -0
- package/dist/react/features/events/event-row.d.ts +21 -0
- package/dist/react/features/events/event-row.js +34 -0
- package/dist/react/features/events/event-stream.d.ts +18 -0
- package/dist/react/features/events/event-stream.js +58 -0
- package/dist/react/features/events/global-events.d.ts +122 -0
- package/dist/react/features/events/global-events.js +329 -0
- package/dist/react/features/events/shuttle-events.d.ts +7 -0
- package/dist/react/features/events/shuttle-events.js +1 -0
- package/dist/react/features/playbook/playbook-page.d.ts +2 -0
- package/dist/react/features/playbook/playbook-page.js +36 -0
- package/dist/react/features/playbook/playbook-query.d.ts +111 -0
- package/dist/react/features/playbook/playbook-query.js +17 -0
- package/dist/react/features/pulls/linked-session.d.ts +12 -0
- package/dist/react/features/pulls/linked-session.js +22 -0
- package/dist/react/features/pulls/pull-detail-sheet.d.ts +10 -0
- package/dist/react/features/pulls/pull-detail-sheet.js +41 -0
- package/dist/react/features/pulls/pull-fixtures.d.ts +8 -0
- package/dist/react/features/pulls/pull-fixtures.js +258 -0
- package/dist/react/features/pulls/pull-glyphs.d.ts +24 -0
- package/dist/react/features/pulls/pull-glyphs.js +89 -0
- package/dist/react/features/pulls/pull-inbox-list.d.ts +13 -0
- package/dist/react/features/pulls/pull-inbox-list.js +230 -0
- package/dist/react/features/pulls/pull-inbox-pref.d.ts +2 -0
- package/dist/react/features/pulls/pull-inbox-pref.js +19 -0
- package/dist/react/features/pulls/pull-inbox.d.ts +30 -0
- package/dist/react/features/pulls/pull-inbox.js +110 -0
- package/dist/react/features/pulls/pull-threads.d.ts +39 -0
- package/dist/react/features/pulls/pull-threads.js +145 -0
- package/dist/react/features/pulls/pulls.d.ts +120 -0
- package/dist/react/features/pulls/pulls.js +414 -0
- package/dist/react/features/pulls/session-pull-groups.d.ts +14 -0
- package/dist/react/features/pulls/session-pull-groups.js +29 -0
- package/dist/react/features/pulls/stack-ladder.d.ts +9 -0
- package/dist/react/features/pulls/stack-ladder.js +32 -0
- package/dist/react/features/sessions/agent-tree.d.ts +16 -0
- package/dist/react/features/sessions/agent-tree.js +100 -0
- package/dist/react/features/sessions/agents.d.ts +34 -0
- package/dist/react/features/sessions/agents.js +146 -0
- package/dist/react/features/sessions/attention.d.ts +32 -0
- package/dist/react/features/sessions/attention.js +42 -0
- package/dist/react/features/sessions/composer-attachments.d.ts +33 -0
- package/dist/react/features/sessions/composer-attachments.js +126 -0
- package/dist/react/features/sessions/composer.d.ts +15 -0
- package/dist/react/features/sessions/composer.js +327 -0
- package/dist/react/features/sessions/context-usage-meter.d.ts +5 -0
- package/dist/react/features/sessions/context-usage-meter.js +122 -0
- package/dist/react/features/sessions/context-usage.d.ts +54 -0
- package/dist/react/features/sessions/context-usage.js +206 -0
- package/dist/react/features/sessions/conversation.d.ts +21 -0
- package/dist/react/features/sessions/conversation.js +549 -0
- package/dist/react/features/sessions/harness-switcher.d.ts +26 -0
- package/dist/react/features/sessions/harness-switcher.js +118 -0
- package/dist/react/features/sessions/intake-heuristic.d.ts +5 -0
- package/dist/react/features/sessions/intake-heuristic.js +28 -0
- package/dist/react/features/sessions/interjection-routes.d.ts +13 -0
- package/dist/react/features/sessions/interjection-routes.js +72 -0
- package/dist/react/features/sessions/llm-models.d.ts +128 -0
- package/dist/react/features/sessions/llm-models.js +174 -0
- package/dist/react/features/sessions/media-strip.d.ts +25 -0
- package/dist/react/features/sessions/media-strip.js +56 -0
- package/dist/react/features/sessions/media.d.ts +43 -0
- package/dist/react/features/sessions/media.js +115 -0
- package/dist/react/features/sessions/model-search.d.ts +6 -0
- package/dist/react/features/sessions/model-search.js +16 -0
- package/dist/react/features/sessions/model-switcher.d.ts +16 -0
- package/dist/react/features/sessions/model-switcher.js +262 -0
- package/dist/react/features/sessions/open-pull-request.d.ts +20 -0
- package/dist/react/features/sessions/open-pull-request.js +92 -0
- package/dist/react/features/sessions/pull-publish-card.d.ts +14 -0
- package/dist/react/features/sessions/pull-publish-card.js +88 -0
- package/dist/react/features/sessions/recent-sessions.d.ts +11 -0
- package/dist/react/features/sessions/recent-sessions.js +29 -0
- package/dist/react/features/sessions/seen-sessions.d.ts +16 -0
- package/dist/react/features/sessions/seen-sessions.js +108 -0
- package/dist/react/features/sessions/session-activity.d.ts +95 -0
- package/dist/react/features/sessions/session-activity.js +785 -0
- package/dist/react/features/sessions/session-context.d.ts +8 -0
- package/dist/react/features/sessions/session-context.js +98 -0
- package/dist/react/features/sessions/session-feed.d.ts +243 -0
- package/dist/react/features/sessions/session-feed.js +883 -0
- package/dist/react/features/sessions/session-header.d.ts +24 -0
- package/dist/react/features/sessions/session-header.js +97 -0
- package/dist/react/features/sessions/session-layout.d.ts +7 -0
- package/dist/react/features/sessions/session-layout.js +87 -0
- package/dist/react/features/sessions/session-panes.d.ts +49 -0
- package/dist/react/features/sessions/session-panes.js +142 -0
- package/dist/react/features/sessions/session-parts.d.ts +35 -0
- package/dist/react/features/sessions/session-parts.js +74 -0
- package/dist/react/features/sessions/session-place.d.ts +9 -0
- package/dist/react/features/sessions/session-place.js +109 -0
- package/dist/react/features/sessions/session-pr-pills.d.ts +7 -0
- package/dist/react/features/sessions/session-pr-pills.js +28 -0
- package/dist/react/features/sessions/session-queries.d.ts +172 -0
- package/dist/react/features/sessions/session-queries.js +90 -0
- package/dist/react/features/sessions/session-repos.d.ts +8 -0
- package/dist/react/features/sessions/session-repos.js +15 -0
- package/dist/react/features/sessions/session-share.d.ts +8 -0
- package/dist/react/features/sessions/session-share.js +112 -0
- package/dist/react/features/sessions/session-tabs.d.ts +38 -0
- package/dist/react/features/sessions/session-tabs.js +191 -0
- package/dist/react/features/sessions/session.d.ts +103 -0
- package/dist/react/features/sessions/session.js +216 -0
- package/dist/react/features/sessions/signals.d.ts +13 -0
- package/dist/react/features/sessions/signals.js +34 -0
- package/dist/react/features/sessions/tab-set.d.ts +20 -0
- package/dist/react/features/sessions/tab-set.js +58 -0
- package/dist/react/features/sessions/team.d.ts +16 -0
- package/dist/react/features/sessions/team.js +35 -0
- package/dist/react/features/sessions/timeline.d.ts +53 -0
- package/dist/react/features/sessions/timeline.js +153 -0
- package/dist/react/features/sessions/use-session-tabs.d.ts +18 -0
- package/dist/react/features/sessions/use-session-tabs.js +119 -0
- package/dist/react/features/sessions/vendor-models.d.ts +23 -0
- package/dist/react/features/sessions/vendor-models.js +61 -0
- package/dist/react/features/workspace/activity-dot.d.ts +15 -0
- package/dist/react/features/workspace/activity-dot.js +36 -0
- package/dist/react/features/workspace/app-sidebar.d.ts +16 -0
- package/dist/react/features/workspace/app-sidebar.js +227 -0
- package/dist/react/features/workspace/fixture-toggle.d.ts +2 -0
- package/dist/react/features/workspace/fixture-toggle.js +72 -0
- package/dist/react/features/workspace/folder-group.d.ts +18 -0
- package/dist/react/features/workspace/folder-group.js +83 -0
- package/dist/react/features/workspace/inline-name-input.d.ts +10 -0
- package/dist/react/features/workspace/inline-name-input.js +33 -0
- package/dist/react/features/workspace/link-repo-dialog.d.ts +9 -0
- package/dist/react/features/workspace/link-repo-dialog.js +76 -0
- package/dist/react/features/workspace/repo-chip.d.ts +13 -0
- package/dist/react/features/workspace/repo-chip.js +15 -0
- package/dist/react/features/workspace/session-row.d.ts +20 -0
- package/dist/react/features/workspace/session-row.js +23 -0
- package/dist/react/features/workspace/use-debounced.d.ts +2 -0
- package/dist/react/features/workspace/use-debounced.js +10 -0
- package/dist/react/features/workspace/workspace-context.d.ts +45 -0
- package/dist/react/features/workspace/workspace-context.js +245 -0
- package/dist/react/features/workspace/workspace-fixtures.d.ts +16 -0
- package/dist/react/features/workspace/workspace-fixtures.js +175 -0
- package/dist/react/features/workspace/workspace-tree.d.ts +30 -0
- package/dist/react/features/workspace/workspace-tree.js +69 -0
- package/dist/react/features/workspace/workspace.d.ts +107 -0
- package/dist/react/features/workspace/workspace.js +458 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.js +35 -0
- package/dist/react/lib/cn.d.ts +6 -0
- package/dist/react/lib/cn.js +20 -0
- package/dist/react/lib/initials.d.ts +6 -0
- package/dist/react/lib/initials.js +32 -0
- package/dist/react/lib/json.d.ts +33 -0
- package/dist/react/lib/json.js +101 -0
- package/dist/react/lib/time.d.ts +8 -0
- package/dist/react/lib/time.js +57 -0
- package/dist/react/lib/use-media-query.d.ts +1 -0
- package/dist/react/lib/use-media-query.js +9 -0
- package/dist/react/lib/use-now.d.ts +2 -0
- package/dist/react/lib/use-now.js +10 -0
- package/dist/react/lib/use-width-bucket.d.ts +6 -0
- package/dist/react/lib/use-width-bucket.js +28 -0
- package/dist/react/parts/index.d.ts +43 -0
- package/dist/react/parts/index.js +43 -0
- package/dist/react/shuttle/device.d.ts +42 -0
- package/dist/react/shuttle/device.js +10 -0
- package/dist/react/shuttle/host.d.ts +1126 -0
- package/dist/react/shuttle/host.js +93 -0
- package/dist/react/shuttle/identity.d.ts +31 -0
- package/dist/react/shuttle/identity.js +20 -0
- package/dist/react/shuttle/index.d.ts +14 -0
- package/dist/react/shuttle/index.js +13 -0
- package/dist/react/shuttle/provider.d.ts +41 -0
- package/dist/react/shuttle/provider.js +59 -0
- package/dist/react/shuttle/router.d.ts +43 -0
- package/dist/react/shuttle/router.js +1 -0
- package/dist/react/theme.css +456 -0
- package/dist/react/ui.d.ts +19 -0
- package/dist/react/ui.js +19 -0
- package/package.json +100 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GitPullRequest, MoreHorizontal } from 'lucide-react';
|
|
3
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '../../components/ui/dropdown-menu.js';
|
|
4
|
+
import { cn } from '../../lib/cn.js';
|
|
5
|
+
import { compactRelativeTime, fullDateTime } from '../../lib/time.js';
|
|
6
|
+
import { Link } from '../../shuttle/index.js';
|
|
7
|
+
import { resolveSessionIndicator } from '../sessions/session-activity.js';
|
|
8
|
+
import { ActivityDot } from './activity-dot.js';
|
|
9
|
+
/** Hidden until the row is hovered or focused; always shown on touch, where hover never fires. */
|
|
10
|
+
export 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';
|
|
11
|
+
/** Trailing metadata yields its slot to the row's actions. */
|
|
12
|
+
export 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';
|
|
13
|
+
export function sidebarRowClass(active) {
|
|
14
|
+
return cn('group/row relative flex h-8 items-center rounded-md text-[12.5px] transition-colors duration-100', active
|
|
15
|
+
? 'bg-accent text-foreground'
|
|
16
|
+
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground');
|
|
17
|
+
}
|
|
18
|
+
export function SessionRow({ runId, title, activity, status, unread, updatedAt, now, active, dimmed, pullCount = 0, onRename, onArchive, }) {
|
|
19
|
+
const hasMenu = Boolean(onRename || onArchive);
|
|
20
|
+
const tone = resolveSessionIndicator({ activity, status, unread });
|
|
21
|
+
const needsAttention = !active && (tone === 'needs_input' || tone === 'ready');
|
|
22
|
+
return (_jsxs("div", { className: cn(sidebarRowClass(active), 'float-in', dimmed && 'opacity-60'), children: [_jsxs(Link, { to: { page: 'session', sessionId: runId }, title: title, className: "focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md pr-1 pl-1.5 outline-none focus-visible:ring-2", children: [_jsx(ActivityDot, { tone: tone }), _jsx("span", { className: cn('min-w-0 flex-1 truncate', needsAttention && 'text-foreground/90'), dir: "auto", children: title }), pullCount > 0 ? (_jsxs("span", { title: `${pullCount} open pull ${pullCount === 1 ? 'request' : 'requests'}`, className: "text-muted-foreground inline-flex shrink-0 items-center gap-0.5 font-mono text-[10px] tabular-nums", children: [_jsx(GitPullRequest, { "aria-hidden": true, className: "size-3" }), pullCount, _jsxs("span", { className: "sr-only", children: ["open pull ", pullCount === 1 ? 'request' : 'requests'] })] })) : null] }), _jsxs("div", { className: "relative mr-1 flex h-6 w-8 shrink-0 items-center justify-end", children: [_jsx("time", { dateTime: new Date(updatedAt).toISOString(), title: fullDateTime(updatedAt), className: cn('text-muted-foreground font-mono text-[10px] tabular-nums', hasMenu && yieldOnRowHover), children: compactRelativeTime(updatedAt, now) }), hasMenu ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `Actions for ${title}`, className: cn('text-muted-foreground hover:text-foreground hover:bg-accent absolute inset-y-0 right-0 flex w-6 items-center justify-center rounded-sm outline-none focus-visible:opacity-100', revealOnRowHover), children: _jsx(MoreHorizontal, { className: "size-3.5" }) }) }), _jsxs(DropdownMenuContent, { align: "start", className: "min-w-36", children: [onRename ? _jsx(DropdownMenuItem, { onSelect: onRename, children: "Rename" }) : null, onArchive ? _jsx(DropdownMenuItem, { onSelect: onArchive, children: "Archive" }) : null] })] })) : null] })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
/** A value that follows `value` once it has stopped changing for `delayMs`. */
|
|
3
|
+
export function useDebounced(value, delayMs) {
|
|
4
|
+
const [settled, setSettled] = useState(value);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const timer = window.setTimeout(() => setSettled(value), delayMs);
|
|
7
|
+
return () => window.clearTimeout(timer);
|
|
8
|
+
}, [value, delayMs]);
|
|
9
|
+
return settled;
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SessionActivity } from '../sessions/session-activity.js';
|
|
2
|
+
import { type SessionTabsState, type WorkspaceTree } from './workspace.js';
|
|
3
|
+
import { type FixtureMode } from './workspace-fixtures.js';
|
|
4
|
+
export interface LiveSessionStatus {
|
|
5
|
+
readonly status: string;
|
|
6
|
+
readonly activity: SessionActivity;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspaceValue {
|
|
9
|
+
/** The organization's workspace run, which holds the folders. */
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
/** Both workspaces merged: every folder, and every session this person can see. */
|
|
12
|
+
readonly tree: WorkspaceTree;
|
|
13
|
+
readonly tabs: SessionTabsState;
|
|
14
|
+
readonly liveSessions: Readonly<Record<string, LiveSessionStatus>>;
|
|
15
|
+
/** The workspace run that lists a session, and so keeps its tabs. */
|
|
16
|
+
readonly listingRunId: (sessionRunId: string) => string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Follows the two workspaces a person sees and shows them as one: the organization's, with its
|
|
20
|
+
* folders and public sessions, and their own, with the sessions private to them or shared with
|
|
21
|
+
* them.
|
|
22
|
+
*
|
|
23
|
+
* Each hydrates from the server's authoritative `/workspace` projection snapshot (which preserves
|
|
24
|
+
* server-only fields like `idempotencyKey` and avoids replaying the entire historical log),
|
|
25
|
+
* then folds live delta events strictly past `tail`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function WorkspaceProvider({ children }: {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}): import("react").JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* The workspace run and its folder tree. The signed-in layout's loader reads the snapshot before
|
|
32
|
+
* anything under it renders, so there is always one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useWorkspace(): WorkspaceValue;
|
|
35
|
+
/**
|
|
36
|
+
* The same, or null where nothing above keeps a workspace. A session shown on its own, in a
|
|
37
|
+
* host that has no folders, is still a whole session: it only has no folder to name and keeps
|
|
38
|
+
* its open tabs to itself.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useOptionalWorkspace(): WorkspaceValue | null;
|
|
41
|
+
/** Which made-up workspace is showing. Always the real one where nothing keeps a workspace. */
|
|
42
|
+
export declare function useFixtureMode(): [FixtureMode, (mode: FixtureMode) => void];
|
|
43
|
+
/** The sessions the workspace lists, by run. None where nothing keeps a workspace. */
|
|
44
|
+
export declare function useWorkspaceSessions(): WorkspaceTree['sessions'];
|
|
45
|
+
export declare function useReportLiveSession(): (runId: string, live: LiveSessionStatus) => void;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { useRunEvents, useRunStore, useRunSummary } from '@swirls/looms/react';
|
|
5
|
+
import { useApi, useShuttleHost } from '../../shuttle/index.js';
|
|
6
|
+
import { emptySessionTabs, emptyWorkspaceTree, sessionTabs, workspaceTree, } from './workspace.js';
|
|
7
|
+
import { FIXTURE_MODES, workspaceFixture } from './workspace-fixtures.js';
|
|
8
|
+
const WorkspaceContext = createContext(null);
|
|
9
|
+
const FIXTURE_KEY = 'shuttle.fixture';
|
|
10
|
+
function initialFixtureMode(offered) {
|
|
11
|
+
if (!offered) {
|
|
12
|
+
return 'live';
|
|
13
|
+
}
|
|
14
|
+
const requested = new URLSearchParams(window.location.search).get('data') ?? sessionStorage.getItem(FIXTURE_KEY);
|
|
15
|
+
return FIXTURE_MODES.find((mode) => mode === requested) ?? 'live';
|
|
16
|
+
}
|
|
17
|
+
function mergeLiveSessions(tree, liveSessions) {
|
|
18
|
+
const entries = Object.entries(liveSessions);
|
|
19
|
+
if (entries.length === 0) {
|
|
20
|
+
return tree;
|
|
21
|
+
}
|
|
22
|
+
let changed = false;
|
|
23
|
+
const sessions = { ...tree.sessions };
|
|
24
|
+
for (const [sessionRunId, live] of entries) {
|
|
25
|
+
const existing = sessions[sessionRunId];
|
|
26
|
+
if (!existing) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const nextStatus = live.status === 'completed' || live.status === 'failed' || live.status === 'cancelled'
|
|
30
|
+
? live.status
|
|
31
|
+
: existing.status === 'requested'
|
|
32
|
+
? 'running'
|
|
33
|
+
: existing.status;
|
|
34
|
+
if (existing.activity !== live.activity || existing.status !== nextStatus) {
|
|
35
|
+
changed = true;
|
|
36
|
+
sessions[sessionRunId] = {
|
|
37
|
+
...existing,
|
|
38
|
+
status: nextStatus,
|
|
39
|
+
activity: live.activity,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return changed ? { ...tree, sessions } : tree;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One workspace run the page follows: its snapshot, then the live tree and tabs folded from it.
|
|
47
|
+
* The tree is null only when the Worker could not read the workspace and the run's own events
|
|
48
|
+
* have not arrived yet.
|
|
49
|
+
*/
|
|
50
|
+
function useWorkspaceSource(snapshot) {
|
|
51
|
+
const seed = useMemo(() => snapshot.tree
|
|
52
|
+
? { tail: snapshot.tail, tree: snapshot.tree, tabs: snapshot.tabs ?? emptySessionTabs }
|
|
53
|
+
: null, [snapshot]);
|
|
54
|
+
// What the event stream has folded so far. Until it reports, the snapshot is what there is.
|
|
55
|
+
const [tree, setTree] = useState(null);
|
|
56
|
+
const [tabs, setTabs] = useState(null);
|
|
57
|
+
return {
|
|
58
|
+
runId: snapshot.runId,
|
|
59
|
+
seed,
|
|
60
|
+
tree: tree ?? seed?.tree ?? null,
|
|
61
|
+
tabs: tabs ?? seed?.tabs ?? emptySessionTabs,
|
|
62
|
+
setTree,
|
|
63
|
+
setTabs,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Follows the two workspaces a person sees and shows them as one: the organization's, with its
|
|
68
|
+
* folders and public sessions, and their own, with the sessions private to them or shared with
|
|
69
|
+
* them.
|
|
70
|
+
*
|
|
71
|
+
* Each hydrates from the server's authoritative `/workspace` projection snapshot (which preserves
|
|
72
|
+
* server-only fields like `idempotencyKey` and avoids replaying the entire historical log),
|
|
73
|
+
* then folds live delta events strictly past `tail`.
|
|
74
|
+
*/
|
|
75
|
+
export function WorkspaceProvider({ children }) {
|
|
76
|
+
const api = useApi();
|
|
77
|
+
const host = useShuttleHost();
|
|
78
|
+
// The signed-in layout's loader read the snapshot before this rendered. It is only where the
|
|
79
|
+
// event stream starts from, and the stream keeps it current from then on, so it is never read
|
|
80
|
+
// again for being old. If something does read it again, the fold starts over from the new one.
|
|
81
|
+
const { data: snapshot } = useSuspenseQuery(api.workspace.get.queryOptions({ staleTime: Infinity }));
|
|
82
|
+
const shared = useWorkspaceSource(snapshot);
|
|
83
|
+
const personal = useWorkspaceSource(snapshot.personal);
|
|
84
|
+
const [liveSessions, setLiveSessions] = useState({});
|
|
85
|
+
const [stalled, setStalled] = useState(null);
|
|
86
|
+
const [fixture, setFixture] = useState(() => ({
|
|
87
|
+
mode: initialFixtureMode(host.fixtures),
|
|
88
|
+
at: Date.now(),
|
|
89
|
+
}));
|
|
90
|
+
const fixtureMode = fixture.mode;
|
|
91
|
+
const setLiveSessionStatus = useCallback((sessionRunId, next) => {
|
|
92
|
+
setLiveSessions((prev) => {
|
|
93
|
+
const current = prev[sessionRunId];
|
|
94
|
+
if (current && current.activity === next.activity && current.status === next.status) {
|
|
95
|
+
return prev;
|
|
96
|
+
}
|
|
97
|
+
return { ...prev, [sessionRunId]: next };
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
100
|
+
const fixtureTree = useMemo(() => host.fixtures && fixture.mode !== 'live' ? workspaceFixture(fixture.mode, fixture.at) : null, [host.fixtures, fixture]);
|
|
101
|
+
const sharedTree = shared.tree;
|
|
102
|
+
const personalTree = personal.tree;
|
|
103
|
+
const tree = useMemo(() => {
|
|
104
|
+
if (fixtureTree) {
|
|
105
|
+
return fixtureTree;
|
|
106
|
+
}
|
|
107
|
+
if (!sharedTree) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return mergeLiveSessions({ ...sharedTree, sessions: { ...sharedTree.sessions, ...personalTree?.sessions } }, liveSessions);
|
|
111
|
+
}, [fixtureTree, sharedTree, personalTree, liveSessions]);
|
|
112
|
+
const tabs = useMemo(() => ({ ...shared.tabs, ...personal.tabs }), [shared.tabs, personal.tabs]);
|
|
113
|
+
const sharedRunId = shared.runId;
|
|
114
|
+
const personalRunId = personal.runId;
|
|
115
|
+
const value = useMemo(() => tree
|
|
116
|
+
? {
|
|
117
|
+
workspace: {
|
|
118
|
+
runId: sharedRunId,
|
|
119
|
+
tree,
|
|
120
|
+
tabs,
|
|
121
|
+
liveSessions,
|
|
122
|
+
listingRunId: (sessionRunId) => personalTree?.sessions[sessionRunId] ? personalRunId : sharedRunId,
|
|
123
|
+
},
|
|
124
|
+
fixtureMode,
|
|
125
|
+
setFixtureMode(mode) {
|
|
126
|
+
sessionStorage.setItem(FIXTURE_KEY, mode);
|
|
127
|
+
setFixture({ mode, at: Date.now() });
|
|
128
|
+
},
|
|
129
|
+
setLiveSessionStatus,
|
|
130
|
+
}
|
|
131
|
+
: null, [
|
|
132
|
+
sharedRunId,
|
|
133
|
+
personalRunId,
|
|
134
|
+
personalTree,
|
|
135
|
+
tree,
|
|
136
|
+
tabs,
|
|
137
|
+
liveSessions,
|
|
138
|
+
fixtureMode,
|
|
139
|
+
setLiveSessionStatus,
|
|
140
|
+
]);
|
|
141
|
+
return (_jsxs(_Fragment, { children: [_jsx(WorkspaceSubscription, { runId: sharedRunId, seed: shared.seed, onTree: shared.setTree, onTabs: shared.setTabs, onStalled: setStalled }, sharedRunId), _jsx(WorkspaceSubscription, { runId: personalRunId, seed: personal.seed, onTree: personal.setTree, onTabs: personal.setTabs, onStalled: setStalled }, personalRunId), value ? (_jsx(WorkspaceContext.Provider, { value: value, children: children })) : (_jsx("div", { className: "text-muted-foreground flex h-dvh items-center justify-center px-6 text-center text-sm", children: stalled ?? 'Loading workspace…' }))] }));
|
|
142
|
+
}
|
|
143
|
+
const STALL_MS = 3000;
|
|
144
|
+
function WorkspaceSubscription({ runId, seed, onTree, onTabs, onStalled, }) {
|
|
145
|
+
// The snapshot covers the log up to its tail, so only what follows is downloaded. The first
|
|
146
|
+
// snapshot decides where: a later one folds from the same events, without connecting again.
|
|
147
|
+
const [fromSeq] = useState(() => (seed ? seed.tail + 1 : undefined));
|
|
148
|
+
const store = useRunStore(runId, { includeEphemeral: false, fromSeq });
|
|
149
|
+
const events = useRunEvents(store);
|
|
150
|
+
const summary = useRunSummary(store);
|
|
151
|
+
const hydrated = Boolean(seed) || summary.startedAt !== undefined;
|
|
152
|
+
const live = summary.connection === 'live';
|
|
153
|
+
const foldRef = useRef({
|
|
154
|
+
cursor: 0,
|
|
155
|
+
tree: emptyWorkspaceTree,
|
|
156
|
+
tabs: emptySessionTabs,
|
|
157
|
+
seededTail: null,
|
|
158
|
+
});
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!hydrated) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const baseTail = seed?.tail ?? null;
|
|
164
|
+
if (foldRef.current.seededTail !== baseTail) {
|
|
165
|
+
foldRef.current = {
|
|
166
|
+
cursor: seed?.tail ?? 0,
|
|
167
|
+
tree: seed?.tree ?? emptyWorkspaceTree,
|
|
168
|
+
tabs: seed?.tabs ?? emptySessionTabs,
|
|
169
|
+
seededTail: baseTail,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
let { cursor, tree, tabs } = foldRef.current;
|
|
173
|
+
let changed = false;
|
|
174
|
+
for (const event of events) {
|
|
175
|
+
if (event.ephemeral || event.seq <= cursor) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
cursor = event.seq;
|
|
179
|
+
const nextTree = workspaceTree.reduce(tree, event);
|
|
180
|
+
const nextTabs = sessionTabs.reduce(tabs, event);
|
|
181
|
+
if (nextTree !== tree || nextTabs !== tabs) {
|
|
182
|
+
changed = true;
|
|
183
|
+
}
|
|
184
|
+
tree = nextTree;
|
|
185
|
+
tabs = nextTabs;
|
|
186
|
+
}
|
|
187
|
+
foldRef.current = {
|
|
188
|
+
cursor,
|
|
189
|
+
tree,
|
|
190
|
+
tabs,
|
|
191
|
+
seededTail: baseTail,
|
|
192
|
+
};
|
|
193
|
+
if (changed || cursor === (seed?.tail ?? 0)) {
|
|
194
|
+
onTree(tree);
|
|
195
|
+
onTabs(tabs);
|
|
196
|
+
}
|
|
197
|
+
}, [events, hydrated, seed, onTree, onTabs]);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (hydrated || !live) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const timer = window.setTimeout(() => onStalled(`Workspace run "${runId}" is connected but was never started.`), STALL_MS);
|
|
203
|
+
return () => window.clearTimeout(timer);
|
|
204
|
+
}, [hydrated, live, runId, onStalled]);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
function useWorkspaceState() {
|
|
208
|
+
const state = useContext(WorkspaceContext);
|
|
209
|
+
if (!state) {
|
|
210
|
+
throw new Error('useWorkspace must be used inside WorkspaceProvider');
|
|
211
|
+
}
|
|
212
|
+
return state;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The workspace run and its folder tree. The signed-in layout's loader reads the snapshot before
|
|
216
|
+
* anything under it renders, so there is always one.
|
|
217
|
+
*/
|
|
218
|
+
export function useWorkspace() {
|
|
219
|
+
return useWorkspaceState().workspace;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The same, or null where nothing above keeps a workspace. A session shown on its own, in a
|
|
223
|
+
* host that has no folders, is still a whole session: it only has no folder to name and keeps
|
|
224
|
+
* its open tabs to itself.
|
|
225
|
+
*/
|
|
226
|
+
export function useOptionalWorkspace() {
|
|
227
|
+
return useContext(WorkspaceContext)?.workspace ?? null;
|
|
228
|
+
}
|
|
229
|
+
const noFixture = () => { };
|
|
230
|
+
/** Which made-up workspace is showing. Always the real one where nothing keeps a workspace. */
|
|
231
|
+
export function useFixtureMode() {
|
|
232
|
+
const state = useContext(WorkspaceContext);
|
|
233
|
+
return state ? [state.fixtureMode, state.setFixtureMode] : ['live', noFixture];
|
|
234
|
+
}
|
|
235
|
+
const noSessions = {};
|
|
236
|
+
/** The sessions the workspace lists, by run. None where nothing keeps a workspace. */
|
|
237
|
+
export function useWorkspaceSessions() {
|
|
238
|
+
return useContext(WorkspaceContext)?.workspace.tree.sessions ?? noSessions;
|
|
239
|
+
}
|
|
240
|
+
export function useReportLiveSession() {
|
|
241
|
+
const state = useContext(WorkspaceContext);
|
|
242
|
+
return useCallback((runId, live) => {
|
|
243
|
+
state?.setLiveSessionStatus(runId, live);
|
|
244
|
+
}, [state]);
|
|
245
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionAccess } from '@swirls/shuttle/api';
|
|
2
|
+
import type { WorkspaceTree } from './workspace.js';
|
|
3
|
+
export declare const FIXTURE_MODES: readonly ['live', 'worst', 'empty', 'huge'];
|
|
4
|
+
export type FixtureMode = (typeof FIXTURE_MODES)[number];
|
|
5
|
+
export declare function workspaceFixture(mode: Exclude<FixtureMode, 'live'>, now: number): WorkspaceTree;
|
|
6
|
+
/** Who is in a session, and what they are called, for the session's avatars. */
|
|
7
|
+
export interface SessionPeopleFixture {
|
|
8
|
+
readonly access: SessionAccess;
|
|
9
|
+
/** Names by user id. Someone missing from it has no name on record. */
|
|
10
|
+
readonly people: ReadonlyMap<string, string>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Worst-case people for a session's avatars: long and short names, scripts without spaces, an
|
|
14
|
+
* emoji first, stray spaces, lowercase, someone with no name at all, and more than fit.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sessionPeopleFixture(mode: Exclude<FixtureMode, 'live'>, me: string): SessionPeopleFixture;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export const FIXTURE_MODES = ['live', 'worst', 'empty', 'huge'];
|
|
2
|
+
const MINUTE = 60_000;
|
|
3
|
+
const HOUR = 60 * MINUTE;
|
|
4
|
+
const DAY = 24 * HOUR;
|
|
5
|
+
function repo(owner, name, extra) {
|
|
6
|
+
return {
|
|
7
|
+
installationId: 1,
|
|
8
|
+
owner,
|
|
9
|
+
name,
|
|
10
|
+
fullName: `${owner}/${name}`,
|
|
11
|
+
defaultBranch: 'main',
|
|
12
|
+
private: false,
|
|
13
|
+
...extra,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function folder(folderId, name, repos, extra) {
|
|
17
|
+
return { folderId, name, createdAt: 0, archived: false, repos, ...extra };
|
|
18
|
+
}
|
|
19
|
+
function session(runId, folderId, title, updatedAt, extra) {
|
|
20
|
+
return {
|
|
21
|
+
runId,
|
|
22
|
+
folderId,
|
|
23
|
+
title,
|
|
24
|
+
goal: title,
|
|
25
|
+
status: 'running',
|
|
26
|
+
activity: 'idle',
|
|
27
|
+
createdAt: updatedAt,
|
|
28
|
+
updatedAt,
|
|
29
|
+
archived: false,
|
|
30
|
+
...extra,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function tree(folders, sessions, installations) {
|
|
34
|
+
return {
|
|
35
|
+
folderOrder: folders.map((entry) => entry.folderId),
|
|
36
|
+
folders: Object.fromEntries(folders.map((entry) => [entry.folderId, entry])),
|
|
37
|
+
sessions: Object.fromEntries(sessions.map((entry) => [entry.runId, entry])),
|
|
38
|
+
installations: Object.fromEntries(installations.map((entry) => [String(entry.installationId), entry])),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const NORTHWIND = 'northwind-industries-holdings';
|
|
42
|
+
/** Realistic worst-case values spread across rows, the way production data mixes them. */
|
|
43
|
+
function worstCase(now) {
|
|
44
|
+
const platform = folder('fx-platform', 'Northwind Platform Infrastructure & Developer Experience', [
|
|
45
|
+
repo(NORTHWIND, 'customer-feedback-from-enterprise-onboarding', { private: true }),
|
|
46
|
+
repo(NORTHWIND, 'api', { defaultBranch: 'release/2026-11-hotfix-payments' }),
|
|
47
|
+
repo('jo', 'x'),
|
|
48
|
+
repo(NORTHWIND, 'web'),
|
|
49
|
+
repo(NORTHWIND, 'mobile'),
|
|
50
|
+
repo(NORTHWIND, 'infra-terraform-modules-shared', { private: true }),
|
|
51
|
+
repo(NORTHWIND, 'docs'),
|
|
52
|
+
repo(NORTHWIND, 'design-tokens'),
|
|
53
|
+
repo(NORTHWIND, 'billing'),
|
|
54
|
+
repo(NORTHWIND, 'search-indexer'),
|
|
55
|
+
repo(NORTHWIND, 'auth'),
|
|
56
|
+
repo(NORTHWIND, 'analytics-pipeline'),
|
|
57
|
+
]);
|
|
58
|
+
const folders = [
|
|
59
|
+
platform,
|
|
60
|
+
folder('fx-jo', 'Jo', [repo('jo', 'dotfiles')]),
|
|
61
|
+
folder('fx-german', 'Benachrichtigungseinstellungen', []),
|
|
62
|
+
folder('fx-cjk', '王秀英的项目', [repo('wang', 'xiu-ying')]),
|
|
63
|
+
folder('fx-rtl', 'نور الهدى عبد الرحمن', []),
|
|
64
|
+
folder('fx-emoji', '👩🏽💻 Priya’s experiments', []),
|
|
65
|
+
folder('fx-archived', 'Q3 launch (do not use)', [], { archived: true }),
|
|
66
|
+
];
|
|
67
|
+
const sessions = [
|
|
68
|
+
session('fx-s1', platform.folderId, 'Migrate the billing webhooks from the legacy Stripe v2 handler to the new idempotent queue consumer and backfill failed events', now - 20_000, { activity: 'working' }),
|
|
69
|
+
session('fx-s2', platform.folderId, 'Fix', now - 3 * MINUTE, { activity: 'needs_input' }),
|
|
70
|
+
session('fx-s2b', platform.folderId, 'Extract Stripe signature verification into shared middleware with replay tests', now - 8 * MINUTE, { activity: 'idle', unread: true }),
|
|
71
|
+
session('fx-s3', platform.folderId, 'Bump @northwind/design-tokens to 4.0.0-beta.12 across every package', now - 5 * HOUR, { activity: 'error' }),
|
|
72
|
+
session('fx-s4', platform.folderId, '<script>alert(1)</script> & **bold**', now - 12 * DAY, {
|
|
73
|
+
status: 'completed',
|
|
74
|
+
}),
|
|
75
|
+
session('fx-s5', platform.folderId, 'Line one\nLine two', now - 330 * DAY, {
|
|
76
|
+
status: 'cancelled',
|
|
77
|
+
}),
|
|
78
|
+
session('fx-s6', platform.folderId, 'Untitled', now - 3 * 365 * DAY),
|
|
79
|
+
session('fx-s7', platform.folderId, 'Rename getUserById to findUser', now - 40 * DAY, {
|
|
80
|
+
status: 'requested',
|
|
81
|
+
}),
|
|
82
|
+
session('fx-s8', 'fx-cjk', '修复登录页面在移动端的布局问题', now - 2 * HOUR, {
|
|
83
|
+
unread: true,
|
|
84
|
+
}),
|
|
85
|
+
session('fx-s9', 'fx-rtl', 'إصلاح خطأ في صفحة تسجيل الدخول', now - DAY, {
|
|
86
|
+
status: 'failed',
|
|
87
|
+
}),
|
|
88
|
+
session('fx-s10', 'fx-archived', 'Ship launch checklist', now - 60 * DAY, {
|
|
89
|
+
archived: true,
|
|
90
|
+
status: 'completed',
|
|
91
|
+
}),
|
|
92
|
+
];
|
|
93
|
+
const installations = [
|
|
94
|
+
{
|
|
95
|
+
installationId: 1,
|
|
96
|
+
account: {
|
|
97
|
+
login: NORTHWIND,
|
|
98
|
+
type: 'Organization',
|
|
99
|
+
avatarUrl: 'https://example.com/avatars/404.png',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{ installationId: 2, account: { login: 'jo', type: 'User', avatarUrl: '' } },
|
|
103
|
+
];
|
|
104
|
+
return tree(folders, sessions, installations);
|
|
105
|
+
}
|
|
106
|
+
/** Realistic upper bound: an org that has used Shuttle daily for a year. */
|
|
107
|
+
function huge(now) {
|
|
108
|
+
const folders = Array.from({ length: 48 }, (_, index) => folder(`fx-folder-${index}`, `Team ${index + 1}`, Array.from({ length: index % 4 }, (_repo, n) => repo(NORTHWIND, `service-${index}-${n}`))));
|
|
109
|
+
const sessions = Array.from({ length: 1284 }, (_, index) => session(`fx-session-${index}`, `fx-folder-${index % folders.length}`, `Session ${index + 1}: tighten retries in the ingest worker`, now - index * 37 * MINUTE, {
|
|
110
|
+
activity: index % 29 === 0
|
|
111
|
+
? 'needs_input'
|
|
112
|
+
: index % 17 === 0
|
|
113
|
+
? 'working'
|
|
114
|
+
: index % 41 === 0
|
|
115
|
+
? 'error'
|
|
116
|
+
: 'idle',
|
|
117
|
+
unread: index % 23 === 0 && index % 17 !== 0 && index % 29 !== 0 && index % 41 !== 0,
|
|
118
|
+
}));
|
|
119
|
+
return tree(folders, sessions, [
|
|
120
|
+
{
|
|
121
|
+
installationId: 1,
|
|
122
|
+
account: { login: NORTHWIND, type: 'Organization', avatarUrl: '' },
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
export function workspaceFixture(mode, now) {
|
|
127
|
+
switch (mode) {
|
|
128
|
+
case 'worst':
|
|
129
|
+
return worstCase(now);
|
|
130
|
+
case 'empty':
|
|
131
|
+
return tree([], [], []);
|
|
132
|
+
case 'huge':
|
|
133
|
+
return huge(now);
|
|
134
|
+
default: {
|
|
135
|
+
const exhaustive = mode;
|
|
136
|
+
return exhaustive;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Worst-case people for a session's avatars: long and short names, scripts without spaces, an
|
|
142
|
+
* emoji first, stray spaces, lowercase, someone with no name at all, and more than fit.
|
|
143
|
+
*/
|
|
144
|
+
export function sessionPeopleFixture(mode, me) {
|
|
145
|
+
if (mode === 'empty') {
|
|
146
|
+
return {
|
|
147
|
+
access: { ownerId: me, memberIds: [], visibility: 'private', canShare: true },
|
|
148
|
+
people: new Map(),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const named = [
|
|
152
|
+
[me, 'Jo'],
|
|
153
|
+
['fx-u1', 'Aleksandra Wiśniewska-Kowalczyk'],
|
|
154
|
+
['fx-u2', '🦊 Fox'],
|
|
155
|
+
['fx-u3', '王秀英'],
|
|
156
|
+
['fx-u4', 'نور الهدى عبد الرحمن'],
|
|
157
|
+
['fx-u5', 'dana'],
|
|
158
|
+
['fx-u6', ' Sam Lee '],
|
|
159
|
+
['fx-u7', 'Christopher Alexander Montgomery III'],
|
|
160
|
+
['fx-u8', '👩🏽💻 Priya'],
|
|
161
|
+
['fx-u9', 'bartholomew.fitzgerald@northwind-industries-holdings.example.com'],
|
|
162
|
+
];
|
|
163
|
+
// In the huge case the session is shared with a whole organization, one person at a time.
|
|
164
|
+
const crowd = mode === 'huge' ? Array.from({ length: 1283 }, (_, index) => `fx-m${index}`) : [];
|
|
165
|
+
return {
|
|
166
|
+
access: {
|
|
167
|
+
ownerId: 'fx-u1',
|
|
168
|
+
// fx-nameless is in the session but has no name on record.
|
|
169
|
+
memberIds: [me, ...named.slice(2).map(([userId]) => userId), 'fx-nameless', ...crowd],
|
|
170
|
+
visibility: mode === 'huge' ? 'private' : 'public',
|
|
171
|
+
canShare: false,
|
|
172
|
+
},
|
|
173
|
+
people: new Map(named),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ChangeStatus, SandboxWorkspaceRepo as WorkspaceRepo } from '@swirls/shuttle/api';
|
|
2
|
+
/**
|
|
3
|
+
* The tree the Workspace tab draws: repositories at the top, their folders and files beneath.
|
|
4
|
+
* A node's `path` is `<repository>/<path in it>`, which is also how files are asked for.
|
|
5
|
+
*/
|
|
6
|
+
export type WorkspaceFilter = 'all' | 'changed';
|
|
7
|
+
export interface WorkspaceNode {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly kind: 'repo' | 'dir' | 'file';
|
|
11
|
+
/** For a file: how the session changed it, if it did. */
|
|
12
|
+
readonly status?: ChangeStatus;
|
|
13
|
+
/** How many changed files are at or beneath this node. */
|
|
14
|
+
readonly changed: number;
|
|
15
|
+
readonly children: readonly WorkspaceNode[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One node per repository, holding every file (`all`) or only the files the session added,
|
|
19
|
+
* changed or deleted (`changed`). Deleted files appear only under `changed`: they are no longer
|
|
20
|
+
* files, but they are part of what was done.
|
|
21
|
+
*/
|
|
22
|
+
export declare function workspaceTree(repos: readonly WorkspaceRepo[], filter: WorkspaceFilter): WorkspaceNode[];
|
|
23
|
+
/** Every file in the workspace, as `<repository>/<path>`. */
|
|
24
|
+
export declare function workspaceFiles(repos: readonly WorkspaceRepo[]): string[];
|
|
25
|
+
/** How the session changed the file at `path`, if it did. */
|
|
26
|
+
export declare function changeAt(repos: readonly WorkspaceRepo[], path: string): ChangeStatus | undefined;
|
|
27
|
+
/** How many files the session changed across the workspace. */
|
|
28
|
+
export declare function changeCount(repos: readonly WorkspaceRepo[]): number;
|
|
29
|
+
/** The folders open to start with: each repository, and the folders directly inside it. */
|
|
30
|
+
export declare function initiallyExpanded(nodes: readonly WorkspaceNode[]): Set<string>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function sortNodes(node) {
|
|
2
|
+
node.children.sort((left, right) => left.kind === right.kind ? left.name.localeCompare(right.name) : left.kind === 'file' ? 1 : -1);
|
|
3
|
+
node.children.forEach(sortNodes);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* One node per repository, holding every file (`all`) or only the files the session added,
|
|
7
|
+
* changed or deleted (`changed`). Deleted files appear only under `changed`: they are no longer
|
|
8
|
+
* files, but they are part of what was done.
|
|
9
|
+
*/
|
|
10
|
+
export function workspaceTree(repos, filter) {
|
|
11
|
+
return repos.map((repo) => {
|
|
12
|
+
const statuses = new Map(repo.changes.map((change) => [change.path, change.status]));
|
|
13
|
+
const root = {
|
|
14
|
+
name: repo.name,
|
|
15
|
+
path: repo.name,
|
|
16
|
+
kind: 'repo',
|
|
17
|
+
changed: 0,
|
|
18
|
+
children: [],
|
|
19
|
+
};
|
|
20
|
+
const paths = filter === 'changed' ? repo.changes.map((change) => change.path) : repo.files;
|
|
21
|
+
for (const path of paths) {
|
|
22
|
+
const parts = path.split('/').filter(Boolean);
|
|
23
|
+
const status = statuses.get(path);
|
|
24
|
+
let cursor = root;
|
|
25
|
+
if (status) {
|
|
26
|
+
root.changed += 1;
|
|
27
|
+
}
|
|
28
|
+
parts.forEach((name, index) => {
|
|
29
|
+
const isFile = index === parts.length - 1;
|
|
30
|
+
const at = `${repo.name}/${parts.slice(0, index + 1).join('/')}`;
|
|
31
|
+
let child = cursor.children.find((node) => node.name === name && node.kind !== 'repo');
|
|
32
|
+
if (!child) {
|
|
33
|
+
child = { name, path: at, kind: isFile ? 'file' : 'dir', changed: 0, children: [] };
|
|
34
|
+
cursor.children.push(child);
|
|
35
|
+
}
|
|
36
|
+
if (status) {
|
|
37
|
+
child.changed += 1;
|
|
38
|
+
}
|
|
39
|
+
if (isFile && status) {
|
|
40
|
+
child.status = status;
|
|
41
|
+
}
|
|
42
|
+
cursor = child;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
sortNodes(root);
|
|
46
|
+
return root;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Every file in the workspace, as `<repository>/<path>`. */
|
|
50
|
+
export function workspaceFiles(repos) {
|
|
51
|
+
return repos.flatMap((repo) => repo.files.map((path) => `${repo.name}/${path}`));
|
|
52
|
+
}
|
|
53
|
+
/** How the session changed the file at `path`, if it did. */
|
|
54
|
+
export function changeAt(repos, path) {
|
|
55
|
+
const slash = path.indexOf('/');
|
|
56
|
+
const repo = repos.find((item) => item.name === path.slice(0, slash));
|
|
57
|
+
return repo?.changes.find((change) => change.path === path.slice(slash + 1))?.status;
|
|
58
|
+
}
|
|
59
|
+
/** How many files the session changed across the workspace. */
|
|
60
|
+
export function changeCount(repos) {
|
|
61
|
+
return repos.reduce((total, repo) => total + repo.changes.length, 0);
|
|
62
|
+
}
|
|
63
|
+
/** The folders open to start with: each repository, and the folders directly inside it. */
|
|
64
|
+
export function initiallyExpanded(nodes) {
|
|
65
|
+
return new Set(nodes.flatMap((repo) => [
|
|
66
|
+
repo.path,
|
|
67
|
+
...repo.children.filter((child) => child.kind === 'dir').map((child) => child.path),
|
|
68
|
+
]));
|
|
69
|
+
}
|