@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.
- package/CHANGELOG.md +18 -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 +75 -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,120 @@
|
|
|
1
|
+
import type { AutoReviewMode } from '@swirls/shuttle/api';
|
|
2
|
+
import type { PublishedPull, PullStackPosition } from '../sessions/session-feed.js';
|
|
3
|
+
export type { AutoReviewMode };
|
|
4
|
+
export type ReviewDecision = 'approved' | 'changes_requested' | 'review_required' | 'none';
|
|
5
|
+
export type CheckRollup = 'passing' | 'failing' | 'pending' | 'neutral';
|
|
6
|
+
export interface PullInboxSummary {
|
|
7
|
+
readonly installationId: number;
|
|
8
|
+
readonly fullName: string;
|
|
9
|
+
readonly number: number;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly body: string;
|
|
12
|
+
readonly url: string;
|
|
13
|
+
readonly state: 'open' | 'closed';
|
|
14
|
+
readonly draft: boolean;
|
|
15
|
+
readonly author: {
|
|
16
|
+
readonly login: string;
|
|
17
|
+
readonly avatarUrl: string;
|
|
18
|
+
};
|
|
19
|
+
readonly headRef: string;
|
|
20
|
+
readonly headSha: string;
|
|
21
|
+
readonly baseRef: string;
|
|
22
|
+
readonly baseSha: string;
|
|
23
|
+
readonly additions: number;
|
|
24
|
+
readonly deletions: number;
|
|
25
|
+
readonly reviewDecision: ReviewDecision;
|
|
26
|
+
readonly checkRollup: CheckRollup;
|
|
27
|
+
readonly updatedAt: number;
|
|
28
|
+
readonly isFork: boolean;
|
|
29
|
+
readonly stack: {
|
|
30
|
+
readonly number: number;
|
|
31
|
+
readonly position: number;
|
|
32
|
+
readonly size: number;
|
|
33
|
+
} | null;
|
|
34
|
+
readonly linkedSessions: readonly LinkedSession[];
|
|
35
|
+
readonly reviewingRunId: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface LinkedSession {
|
|
38
|
+
readonly runId: string;
|
|
39
|
+
readonly role: 'author' | 'reviewer';
|
|
40
|
+
/** Agent thread inside the session that opened or reviewed the PR. */
|
|
41
|
+
readonly threadId?: string;
|
|
42
|
+
}
|
|
43
|
+
/** One link per session and role; a later link may fill in the thread that acted. */
|
|
44
|
+
export declare function withLinkedSession(linked: readonly LinkedSession[], next: LinkedSession): readonly LinkedSession[];
|
|
45
|
+
export interface PullInboxState {
|
|
46
|
+
readonly pulls: Readonly<Record<string, PullInboxSummary>>;
|
|
47
|
+
readonly policies: Readonly<Record<string, {
|
|
48
|
+
readonly installationId: number;
|
|
49
|
+
readonly folders: readonly {
|
|
50
|
+
readonly folderId: string;
|
|
51
|
+
readonly autoReview: AutoReviewMode;
|
|
52
|
+
}[];
|
|
53
|
+
}>>;
|
|
54
|
+
}
|
|
55
|
+
export declare const emptyPullInbox: PullInboxState;
|
|
56
|
+
export declare function pullKey(fullName: string, number: number): string;
|
|
57
|
+
export declare const pullInbox: import("@swirls/looms/core").ProjectionDefinition<PullInboxState>;
|
|
58
|
+
export type PullLaneId = 'needs_review' | 'reviewing' | 'changes_requested' | 'ready' | 'drafts' | 'opened_by_shuttle';
|
|
59
|
+
export declare function laneForPull(pull: PullInboxSummary): PullLaneId;
|
|
60
|
+
export declare const PULL_LANES: {
|
|
61
|
+
id: PullLaneId;
|
|
62
|
+
label: string;
|
|
63
|
+
}[];
|
|
64
|
+
export type InboxEntry = {
|
|
65
|
+
readonly kind: 'pull';
|
|
66
|
+
readonly pull: PullInboxSummary;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'changeset';
|
|
69
|
+
readonly sessionRunId: string;
|
|
70
|
+
readonly pulls: readonly PullInboxSummary[];
|
|
71
|
+
/** Open PRs from this session across every lane. */
|
|
72
|
+
readonly total: number;
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: 'stack';
|
|
75
|
+
readonly stack: PullStack;
|
|
76
|
+
/** Layers that belong in this lane (others render as ghost rows). */
|
|
77
|
+
readonly lanePulls: readonly PullInboxSummary[];
|
|
78
|
+
};
|
|
79
|
+
export interface PullStack {
|
|
80
|
+
readonly key: string;
|
|
81
|
+
readonly fullName: string;
|
|
82
|
+
readonly native: boolean;
|
|
83
|
+
readonly number: number | null;
|
|
84
|
+
readonly baseRef: string;
|
|
85
|
+
/** Bottom → top order. */
|
|
86
|
+
readonly layers: readonly PullInboxSummary[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Native GitHub stacks first (by stack.number), then chained baseRef→headRef
|
|
90
|
+
* groups that are not already in a native stack.
|
|
91
|
+
*/
|
|
92
|
+
export declare function stacksOf(pulls: readonly PullInboxSummary[]): readonly PullStack[];
|
|
93
|
+
export declare function authorRunId(pull: PullInboxSummary): string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Prefer stack groups over changeset groups. PRs one Shuttle session opened
|
|
96
|
+
* that are not stacked still travel together as a changeset. Siblings can
|
|
97
|
+
* diverge across lanes, so each lane groups its own share.
|
|
98
|
+
*/
|
|
99
|
+
export declare function groupPullsByLane(pulls: readonly PullInboxSummary[]): Map<PullLaneId, InboxEntry[]>;
|
|
100
|
+
export declare function pullsForFolder(inbox: PullInboxState, fullNames: readonly string[]): PullInboxSummary[];
|
|
101
|
+
/**
|
|
102
|
+
* Stack position from a Shuttle head branch: `shuttle/<run>/<repo>` is stack 1
|
|
103
|
+
* layer 1, `shuttle/<run>-stack<s?>/<repo>/<n>` is stack s (default 1) layer n.
|
|
104
|
+
*/
|
|
105
|
+
export declare function shuttleStackPosition(headRef: string): PullStackPosition | undefined;
|
|
106
|
+
/** The pull request this session is reviewing, if it is a review session. */
|
|
107
|
+
export declare function reviewedPullForSession(inbox: PullInboxState, runId: string): PullInboxSummary | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The pull request a session's review tab is about: the one it is reviewing, or else the one it
|
|
110
|
+
* opened, so the people who wrote a change see what is said about it where they are working.
|
|
111
|
+
* A session that opened several shows the one touched most recently.
|
|
112
|
+
*/
|
|
113
|
+
export declare function pullOfSession(inbox: PullInboxState, runId: string): PullInboxSummary | undefined;
|
|
114
|
+
/** Open pulls this session authored, with the proposing thread when known. */
|
|
115
|
+
export declare function authoredPullsForSession(inbox: PullInboxState, runId: string): PublishedPull[];
|
|
116
|
+
/** Open PR count per authoring session run id. */
|
|
117
|
+
export declare function authoredPullCounts(inbox: PullInboxState): ReadonlyMap<string, number>;
|
|
118
|
+
export declare function attentionPullCount(pulls: readonly PullInboxSummary[]): number;
|
|
119
|
+
/** The pulls run of the organization the browser is signed in to. */
|
|
120
|
+
export declare function usePullsRunId(): string;
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { defineProjection } from '@swirls/looms/core';
|
|
2
|
+
import { useTenant } from '../../shuttle/index.js';
|
|
3
|
+
/** One link per session and role; a later link may fill in the thread that acted. */
|
|
4
|
+
export function withLinkedSession(linked, next) {
|
|
5
|
+
const index = linked.findIndex((session) => session.runId === next.runId && session.role === next.role);
|
|
6
|
+
if (index === -1) {
|
|
7
|
+
return [...linked, next];
|
|
8
|
+
}
|
|
9
|
+
const current = linked[index];
|
|
10
|
+
if (!next.threadId || current.threadId === next.threadId) {
|
|
11
|
+
return linked;
|
|
12
|
+
}
|
|
13
|
+
return linked.map((session, position) => position === index ? { ...session, threadId: next.threadId } : session);
|
|
14
|
+
}
|
|
15
|
+
export const emptyPullInbox = { pulls: {}, policies: {} };
|
|
16
|
+
export function pullKey(fullName, number) {
|
|
17
|
+
return `${fullName}#${number}`;
|
|
18
|
+
}
|
|
19
|
+
export const pullInbox = defineProjection({
|
|
20
|
+
name: 'pullInbox',
|
|
21
|
+
initialState: emptyPullInbox,
|
|
22
|
+
reduce(state, event) {
|
|
23
|
+
switch (event.type) {
|
|
24
|
+
case 'pulls.pull.upserted': {
|
|
25
|
+
const payload = event.payload;
|
|
26
|
+
const key = pullKey(payload.fullName, payload.number);
|
|
27
|
+
const existing = state.pulls[key];
|
|
28
|
+
if (existing && existing.updatedAt > payload.updatedAt) {
|
|
29
|
+
return state;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...state,
|
|
33
|
+
pulls: {
|
|
34
|
+
...state.pulls,
|
|
35
|
+
[key]: {
|
|
36
|
+
...payload,
|
|
37
|
+
stack: payload.stack ?? null,
|
|
38
|
+
linkedSessions: existing?.linkedSessions ?? [],
|
|
39
|
+
reviewingRunId: existing?.reviewingRunId ?? null,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case 'pulls.pull.closed': {
|
|
45
|
+
const payload = event.payload;
|
|
46
|
+
const key = pullKey(payload.fullName, payload.number);
|
|
47
|
+
const existing = state.pulls[key];
|
|
48
|
+
if (!existing) {
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
...state,
|
|
53
|
+
pulls: {
|
|
54
|
+
...state.pulls,
|
|
55
|
+
[key]: {
|
|
56
|
+
...existing,
|
|
57
|
+
state: 'closed',
|
|
58
|
+
updatedAt: Math.max(existing.updatedAt, payload.updatedAt),
|
|
59
|
+
reviewingRunId: null,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
case 'pulls.checks.updated': {
|
|
65
|
+
const payload = event.payload;
|
|
66
|
+
let changed = false;
|
|
67
|
+
const pulls = { ...state.pulls };
|
|
68
|
+
for (const [key, pull] of Object.entries(state.pulls)) {
|
|
69
|
+
if (pull.fullName !== payload.fullName || pull.headSha !== payload.headSha) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
pulls[key] = {
|
|
73
|
+
...pull,
|
|
74
|
+
checkRollup: payload.checkRollup,
|
|
75
|
+
updatedAt: Math.max(pull.updatedAt, payload.updatedAt),
|
|
76
|
+
};
|
|
77
|
+
changed = true;
|
|
78
|
+
}
|
|
79
|
+
return changed ? { ...state, pulls } : state;
|
|
80
|
+
}
|
|
81
|
+
case 'pulls.review.submitted': {
|
|
82
|
+
const payload = event.payload;
|
|
83
|
+
const key = pullKey(payload.fullName, payload.number);
|
|
84
|
+
const existing = state.pulls[key];
|
|
85
|
+
if (!existing) {
|
|
86
|
+
return state;
|
|
87
|
+
}
|
|
88
|
+
let reviewDecision = existing.reviewDecision;
|
|
89
|
+
switch (payload.verdict) {
|
|
90
|
+
case 'approved':
|
|
91
|
+
reviewDecision = 'approved';
|
|
92
|
+
break;
|
|
93
|
+
case 'changes_requested':
|
|
94
|
+
reviewDecision = 'changes_requested';
|
|
95
|
+
break;
|
|
96
|
+
case 'commented':
|
|
97
|
+
break;
|
|
98
|
+
default: {
|
|
99
|
+
const exhaustive = payload.verdict;
|
|
100
|
+
void exhaustive;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
...state,
|
|
106
|
+
pulls: {
|
|
107
|
+
...state.pulls,
|
|
108
|
+
[key]: {
|
|
109
|
+
...existing,
|
|
110
|
+
reviewDecision,
|
|
111
|
+
updatedAt: Math.max(existing.updatedAt, payload.updatedAt),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
case 'pulls.pull.linked': {
|
|
117
|
+
const payload = event.payload;
|
|
118
|
+
const key = pullKey(payload.fullName, payload.number);
|
|
119
|
+
const existing = state.pulls[key];
|
|
120
|
+
if (!existing) {
|
|
121
|
+
return state;
|
|
122
|
+
}
|
|
123
|
+
const linkedSessions = withLinkedSession(existing.linkedSessions, {
|
|
124
|
+
runId: payload.runId,
|
|
125
|
+
role: payload.role,
|
|
126
|
+
...(payload.threadId ? { threadId: payload.threadId } : {}),
|
|
127
|
+
});
|
|
128
|
+
if (linkedSessions === existing.linkedSessions) {
|
|
129
|
+
return state;
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
...state,
|
|
133
|
+
pulls: { ...state.pulls, [key]: { ...existing, linkedSessions } },
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
case 'pulls.repo.policy.set': {
|
|
137
|
+
const payload = event.payload;
|
|
138
|
+
return {
|
|
139
|
+
...state,
|
|
140
|
+
policies: {
|
|
141
|
+
...state.policies,
|
|
142
|
+
[payload.fullName]: {
|
|
143
|
+
installationId: payload.installationId,
|
|
144
|
+
folders: payload.folders,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
case 'pulls.review.requested': {
|
|
150
|
+
const payload = event.payload;
|
|
151
|
+
const key = pullKey(payload.fullName, payload.number);
|
|
152
|
+
const existing = state.pulls[key];
|
|
153
|
+
if (!existing) {
|
|
154
|
+
return state;
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
...state,
|
|
158
|
+
pulls: {
|
|
159
|
+
...state.pulls,
|
|
160
|
+
[key]: { ...existing, reviewingRunId: payload.runId },
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
165
|
+
return state;
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
export function laneForPull(pull) {
|
|
170
|
+
if (pull.reviewingRunId) {
|
|
171
|
+
return 'reviewing';
|
|
172
|
+
}
|
|
173
|
+
if (pull.draft) {
|
|
174
|
+
return 'drafts';
|
|
175
|
+
}
|
|
176
|
+
if (pull.reviewDecision === 'changes_requested') {
|
|
177
|
+
return 'changes_requested';
|
|
178
|
+
}
|
|
179
|
+
if (pull.reviewDecision === 'approved' && pull.checkRollup === 'passing') {
|
|
180
|
+
return 'ready';
|
|
181
|
+
}
|
|
182
|
+
if (pull.linkedSessions.some((session) => session.role === 'author')) {
|
|
183
|
+
return 'opened_by_shuttle';
|
|
184
|
+
}
|
|
185
|
+
return 'needs_review';
|
|
186
|
+
}
|
|
187
|
+
export const PULL_LANES = [
|
|
188
|
+
{ id: 'needs_review', label: 'Needs review' },
|
|
189
|
+
{ id: 'reviewing', label: 'Shuttle is reviewing' },
|
|
190
|
+
{ id: 'changes_requested', label: 'Changes requested' },
|
|
191
|
+
{ id: 'ready', label: 'Ready to ship' },
|
|
192
|
+
{ id: 'drafts', label: 'Drafts' },
|
|
193
|
+
{ id: 'opened_by_shuttle', label: 'Opened by Shuttle' },
|
|
194
|
+
];
|
|
195
|
+
/**
|
|
196
|
+
* Native GitHub stacks first (by stack.number), then chained baseRef→headRef
|
|
197
|
+
* groups that are not already in a native stack.
|
|
198
|
+
*/
|
|
199
|
+
export function stacksOf(pulls) {
|
|
200
|
+
const open = pulls.filter((pull) => pull.state === 'open');
|
|
201
|
+
const stacks = [];
|
|
202
|
+
const claimed = new Set();
|
|
203
|
+
const byNative = new Map();
|
|
204
|
+
for (const pull of open) {
|
|
205
|
+
if (!pull.stack) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const key = `${pull.fullName}:native:${pull.stack.number}`;
|
|
209
|
+
byNative.set(key, [...(byNative.get(key) ?? []), pull]);
|
|
210
|
+
}
|
|
211
|
+
for (const [key, layers] of byNative) {
|
|
212
|
+
const ordered = [...layers].toSorted((a, b) => (a.stack?.position ?? 0) - (b.stack?.position ?? 0));
|
|
213
|
+
if (ordered.length < 2) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
for (const layer of ordered) {
|
|
217
|
+
claimed.add(pullKey(layer.fullName, layer.number));
|
|
218
|
+
}
|
|
219
|
+
const first = ordered[0];
|
|
220
|
+
stacks.push({
|
|
221
|
+
key,
|
|
222
|
+
fullName: first.fullName,
|
|
223
|
+
native: true,
|
|
224
|
+
number: first.stack?.number ?? null,
|
|
225
|
+
baseRef: ordered[0]?.baseRef ?? 'main',
|
|
226
|
+
layers: ordered,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// Fallback: chain detection by baseRef === another open PR's headRef.
|
|
230
|
+
const byRepo = new Map();
|
|
231
|
+
for (const pull of open) {
|
|
232
|
+
if (claimed.has(pullKey(pull.fullName, pull.number))) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
byRepo.set(pull.fullName, [...(byRepo.get(pull.fullName) ?? []), pull]);
|
|
236
|
+
}
|
|
237
|
+
for (const [fullName, repoPulls] of byRepo) {
|
|
238
|
+
const byHead = new Map(repoPulls.map((pull) => [pull.headRef, pull]));
|
|
239
|
+
const children = new Map();
|
|
240
|
+
for (const pull of repoPulls) {
|
|
241
|
+
if (!byHead.has(pull.baseRef)) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
children.set(pull.baseRef, [...(children.get(pull.baseRef) ?? []), pull]);
|
|
245
|
+
}
|
|
246
|
+
// Roots: open PRs that others stack on, whose base is not another open PR.
|
|
247
|
+
const roots = repoPulls.filter((pull) => !claimed.has(pullKey(pull.fullName, pull.number)) &&
|
|
248
|
+
children.has(pull.headRef) &&
|
|
249
|
+
!byHead.has(pull.baseRef));
|
|
250
|
+
for (const root of roots) {
|
|
251
|
+
const chain = [root];
|
|
252
|
+
let tip = root;
|
|
253
|
+
while (true) {
|
|
254
|
+
const next = children.get(tip.headRef)?.[0];
|
|
255
|
+
if (!next || claimed.has(pullKey(next.fullName, next.number))) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
chain.push(next);
|
|
259
|
+
tip = next;
|
|
260
|
+
}
|
|
261
|
+
if (chain.length < 2) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
for (const layer of chain) {
|
|
265
|
+
claimed.add(pullKey(layer.fullName, layer.number));
|
|
266
|
+
}
|
|
267
|
+
stacks.push({
|
|
268
|
+
key: `${fullName}:chain:${chain.map((layer) => layer.number).join('-')}`,
|
|
269
|
+
fullName,
|
|
270
|
+
native: false,
|
|
271
|
+
number: null,
|
|
272
|
+
baseRef: chain[0].baseRef,
|
|
273
|
+
layers: chain,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return stacks;
|
|
278
|
+
}
|
|
279
|
+
export function authorRunId(pull) {
|
|
280
|
+
return pull.linkedSessions.find((session) => session.role === 'author')?.runId;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Prefer stack groups over changeset groups. PRs one Shuttle session opened
|
|
284
|
+
* that are not stacked still travel together as a changeset. Siblings can
|
|
285
|
+
* diverge across lanes, so each lane groups its own share.
|
|
286
|
+
*/
|
|
287
|
+
export function groupPullsByLane(pulls) {
|
|
288
|
+
const lanes = new Map(PULL_LANES.map((lane) => [lane.id, []]));
|
|
289
|
+
const stacks = stacksOf(pulls);
|
|
290
|
+
const inStack = new Set(stacks.flatMap((stack) => stack.layers.map((layer) => pullKey(layer.fullName, layer.number))));
|
|
291
|
+
const placedStacks = new Set();
|
|
292
|
+
for (const stack of stacks) {
|
|
293
|
+
for (const layer of stack.layers) {
|
|
294
|
+
const lane = laneForPull(layer);
|
|
295
|
+
const placeKey = `${lane}:${stack.key}`;
|
|
296
|
+
if (placedStacks.has(placeKey)) {
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
placedStacks.add(placeKey);
|
|
300
|
+
lanes.get(lane)?.push({
|
|
301
|
+
kind: 'stack',
|
|
302
|
+
stack,
|
|
303
|
+
lanePulls: stack.layers.filter((entry) => laneForPull(entry) === lane),
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const remaining = pulls.filter((pull) => !inStack.has(pullKey(pull.fullName, pull.number)));
|
|
308
|
+
const totals = new Map();
|
|
309
|
+
const byLaneSession = new Map();
|
|
310
|
+
for (const pull of remaining) {
|
|
311
|
+
const runId = authorRunId(pull);
|
|
312
|
+
if (runId) {
|
|
313
|
+
totals.set(runId, (totals.get(runId) ?? 0) + 1);
|
|
314
|
+
const key = `${laneForPull(pull)}:${runId}`;
|
|
315
|
+
byLaneSession.set(key, [...(byLaneSession.get(key) ?? []), pull]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const placed = new Set();
|
|
319
|
+
for (const pull of remaining) {
|
|
320
|
+
const lane = laneForPull(pull);
|
|
321
|
+
const runId = authorRunId(pull);
|
|
322
|
+
const key = `${lane}:${runId}`;
|
|
323
|
+
const group = runId ? byLaneSession.get(key) : undefined;
|
|
324
|
+
if (!runId || !group || group.length < 2) {
|
|
325
|
+
lanes.get(lane)?.push({ kind: 'pull', pull });
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
if (!placed.has(key)) {
|
|
329
|
+
placed.add(key);
|
|
330
|
+
lanes.get(lane)?.push({
|
|
331
|
+
kind: 'changeset',
|
|
332
|
+
sessionRunId: runId,
|
|
333
|
+
pulls: group,
|
|
334
|
+
total: totals.get(runId) ?? group.length,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return lanes;
|
|
339
|
+
}
|
|
340
|
+
export function pullsForFolder(inbox, fullNames) {
|
|
341
|
+
const allowed = new Set(fullNames);
|
|
342
|
+
return Object.values(inbox.pulls)
|
|
343
|
+
.filter((pull) => allowed.has(pull.fullName) && pull.state === 'open')
|
|
344
|
+
.toSorted((a, b) => b.updatedAt - a.updatedAt);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Stack position from a Shuttle head branch: `shuttle/<run>/<repo>` is stack 1
|
|
348
|
+
* layer 1, `shuttle/<run>-stack<s?>/<repo>/<n>` is stack s (default 1) layer n.
|
|
349
|
+
*/
|
|
350
|
+
export function shuttleStackPosition(headRef) {
|
|
351
|
+
const layered = /^shuttle\/[^/]+-stack([1-9]\d*)?\/[^/]+\/([1-9]\d*)$/.exec(headRef);
|
|
352
|
+
if (layered) {
|
|
353
|
+
return { id: layered[1] ? Number(layered[1]) : 1, layer: Number(layered[2]) };
|
|
354
|
+
}
|
|
355
|
+
return /^shuttle\/[^/]+\/[^/]+$/.test(headRef) ? { id: 1, layer: 1 } : undefined;
|
|
356
|
+
}
|
|
357
|
+
/** The pull request this session is reviewing, if it is a review session. */
|
|
358
|
+
export function reviewedPullForSession(inbox, runId) {
|
|
359
|
+
return Object.values(inbox.pulls).find((pull) => pull.linkedSessions.some((session) => session.runId === runId && session.role === 'reviewer'));
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* The pull request a session's review tab is about: the one it is reviewing, or else the one it
|
|
363
|
+
* opened, so the people who wrote a change see what is said about it where they are working.
|
|
364
|
+
* A session that opened several shows the one touched most recently.
|
|
365
|
+
*/
|
|
366
|
+
export function pullOfSession(inbox, runId) {
|
|
367
|
+
return (reviewedPullForSession(inbox, runId) ??
|
|
368
|
+
Object.values(inbox.pulls)
|
|
369
|
+
.filter((pull) => pull.state === 'open' &&
|
|
370
|
+
pull.linkedSessions.some((session) => session.runId === runId && session.role === 'author'))
|
|
371
|
+
.toSorted((a, b) => b.updatedAt - a.updatedAt)[0]);
|
|
372
|
+
}
|
|
373
|
+
/** Open pulls this session authored, with the proposing thread when known. */
|
|
374
|
+
export function authoredPullsForSession(inbox, runId) {
|
|
375
|
+
return Object.values(inbox.pulls)
|
|
376
|
+
.filter((pull) => pull.state === 'open' &&
|
|
377
|
+
pull.linkedSessions.some((session) => session.runId === runId && session.role === 'author'))
|
|
378
|
+
.toSorted((a, b) => b.updatedAt - a.updatedAt)
|
|
379
|
+
.map((pull) => {
|
|
380
|
+
const author = pull.linkedSessions.find((session) => session.runId === runId && session.role === 'author');
|
|
381
|
+
const stack = shuttleStackPosition(pull.headRef);
|
|
382
|
+
return {
|
|
383
|
+
fullName: pull.fullName,
|
|
384
|
+
number: pull.number,
|
|
385
|
+
url: pull.url,
|
|
386
|
+
draft: pull.draft,
|
|
387
|
+
...(author?.threadId ? { threadId: author.threadId } : {}),
|
|
388
|
+
...(stack ? { stack } : {}),
|
|
389
|
+
};
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
/** Open PR count per authoring session run id. */
|
|
393
|
+
export function authoredPullCounts(inbox) {
|
|
394
|
+
const counts = new Map();
|
|
395
|
+
for (const pull of Object.values(inbox.pulls)) {
|
|
396
|
+
if (pull.state !== 'open') {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
for (const runId of new Set(pull.linkedSessions.flatMap((session) => (session.role === 'author' ? [session.runId] : [])))) {
|
|
400
|
+
counts.set(runId, (counts.get(runId) ?? 0) + 1);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return counts;
|
|
404
|
+
}
|
|
405
|
+
export function attentionPullCount(pulls) {
|
|
406
|
+
return pulls.filter((pull) => {
|
|
407
|
+
const lane = laneForPull(pull);
|
|
408
|
+
return lane === 'needs_review' || lane === 'changes_requested';
|
|
409
|
+
}).length;
|
|
410
|
+
}
|
|
411
|
+
/** The pulls run of the organization the browser is signed in to. */
|
|
412
|
+
export function usePullsRunId() {
|
|
413
|
+
return useTenant().runs.pulls;
|
|
414
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PublishedPull } from '../sessions/session-feed.js';
|
|
2
|
+
export interface SessionPullStack {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
readonly fullName: string;
|
|
5
|
+
/** Top layer first. */
|
|
6
|
+
readonly layers: readonly PublishedPull[];
|
|
7
|
+
}
|
|
8
|
+
export interface SessionPullGroups {
|
|
9
|
+
readonly stacks: readonly SessionPullStack[];
|
|
10
|
+
/** One-layer stacks and PRs Shuttle can't place, in input order. */
|
|
11
|
+
readonly standalone: readonly PublishedPull[];
|
|
12
|
+
}
|
|
13
|
+
/** Split a session's PRs into real stacks (2+ layers) and standalone PRs. */
|
|
14
|
+
export declare function groupSessionPulls(pulls: readonly PublishedPull[]): SessionPullGroups;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Split a session's PRs into real stacks (2+ layers) and standalone PRs. */
|
|
2
|
+
export function groupSessionPulls(pulls) {
|
|
3
|
+
const byStack = new Map();
|
|
4
|
+
for (const pull of pulls) {
|
|
5
|
+
if (pull.stack) {
|
|
6
|
+
const key = `${pull.fullName}#${pull.stack.id}`;
|
|
7
|
+
byStack.set(key, [...(byStack.get(key) ?? []), pull]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const stacks = [];
|
|
11
|
+
const stacked = new Set();
|
|
12
|
+
for (const [key, layers] of byStack) {
|
|
13
|
+
if (layers.length < 2) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
for (const layer of layers) {
|
|
17
|
+
stacked.add(layer);
|
|
18
|
+
}
|
|
19
|
+
stacks.push({
|
|
20
|
+
key,
|
|
21
|
+
fullName: layers[0].fullName,
|
|
22
|
+
layers: layers.toSorted((a, b) => (b.stack?.layer ?? 0) - (a.stack?.layer ?? 0)),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
stacks: stacks.toSorted((a, b) => a.key.localeCompare(b.key)),
|
|
27
|
+
standalone: pulls.filter((pull) => !stacked.has(pull)),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PullInboxSummary, type PullStack } from './pulls.js';
|
|
2
|
+
export declare function StackLadder({ stack, highlight, ghostOutsideLane, onOpenPull, className, }: {
|
|
3
|
+
stack: PullStack;
|
|
4
|
+
highlight?: PullInboxSummary;
|
|
5
|
+
/** Layers not in this set render as compact ghost rows (lane label). */
|
|
6
|
+
ghostOutsideLane?: ReadonlySet<string>;
|
|
7
|
+
onOpenPull?: (pull: PullInboxSummary) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ExternalLink, Layers } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../lib/cn.js';
|
|
4
|
+
import { CheckGlyph, RepoDot, repoShortName } from './pull-glyphs.js';
|
|
5
|
+
import { laneForPull } from './pulls.js';
|
|
6
|
+
const LANE_LABEL = {
|
|
7
|
+
needs_review: 'Needs review',
|
|
8
|
+
reviewing: 'Reviewing',
|
|
9
|
+
changes_requested: 'Changes requested',
|
|
10
|
+
ready: 'Ready',
|
|
11
|
+
drafts: 'Drafts',
|
|
12
|
+
opened_by_shuttle: 'Opened by Shuttle',
|
|
13
|
+
};
|
|
14
|
+
export function StackLadder({ stack, highlight, ghostOutsideLane, onOpenPull, className, }) {
|
|
15
|
+
// Top of stack first for the visual ladder.
|
|
16
|
+
const topFirst = [...stack.layers].toReversed();
|
|
17
|
+
return (_jsxs("div", { className: cn('flex flex-col gap-2', className), children: [_jsxs("div", { className: "text-muted-foreground flex items-center gap-1.5 text-[11px]", children: [_jsx(Layers, { className: "size-3.5 shrink-0" }), _jsxs("span", { className: "text-foreground/90 font-medium", children: ["Stack \u00B7 ", repoShortName(stack.fullName), stack.number != null ? ` #${stack.number}` : ''] }), _jsx("span", { className: "ml-auto tabular-nums", children: stack.layers.length })] }), !stack.native ? (_jsx("p", { className: "text-status-warning text-[11px] leading-snug", children: "Chained by base branch \u2014 not a GitHub stack" })) : null, _jsxs("ol", { className: "relative flex flex-col gap-1 pl-3", children: [_jsx("span", { "aria-hidden": true, className: "bg-border absolute top-2 bottom-2 left-[5px] w-px" }), topFirst.map((pull) => {
|
|
18
|
+
const key = `${pull.fullName}#${pull.number}`;
|
|
19
|
+
const ghost = ghostOutsideLane != null && !ghostOutsideLane.has(key);
|
|
20
|
+
const active = highlight != null &&
|
|
21
|
+
highlight.fullName === pull.fullName &&
|
|
22
|
+
highlight.number === pull.number;
|
|
23
|
+
if (ghost) {
|
|
24
|
+
return (_jsxs("li", { className: "relative flex items-center gap-2 py-0.5 pl-3", children: [_jsx("span", { className: "bg-border absolute top-1/2 left-[-7px] size-1.5 -translate-y-1/2 rounded-full" }), _jsxs("span", { className: "text-muted-foreground truncate text-[11px]", children: ["#", pull.number, " \u00B7 in ", LANE_LABEL[laneForPull(pull)] ?? laneForPull(pull)] })] }, key));
|
|
25
|
+
}
|
|
26
|
+
const row = (_jsxs(_Fragment, { children: [_jsx("span", { className: "bg-foreground/40 absolute top-1/2 left-[-7px] size-1.5 -translate-y-1/2 rounded-full" }), _jsx(RepoDot, { fullName: pull.fullName, className: "size-2.5 shrink-0" }), _jsxs("span", { className: "text-muted-foreground shrink-0 tabular-nums", children: ["#", pull.number] }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: pull.title }), pull.draft ? (_jsx("span", { className: "text-muted-foreground shrink-0 text-[10px] uppercase", children: "Draft" })) : null, _jsx(CheckGlyph, { rollup: pull.checkRollup, className: "size-3.5 shrink-0" }), _jsx("a", { href: pull.url, target: "_blank", rel: "noreferrer", className: "text-muted-foreground hover:text-foreground shrink-0", onClick: (event) => event.stopPropagation(), children: _jsx(ExternalLink, { className: "size-3" }) })] }));
|
|
27
|
+
if (onOpenPull) {
|
|
28
|
+
return (_jsx("li", { children: _jsx("button", { type: "button", onClick: () => onOpenPull(pull), className: cn('relative flex w-full items-center gap-2 rounded-md py-1 pl-3 text-left text-[12px]', active ? 'bg-muted/60' : 'hover:bg-muted/40'), children: row }) }, key));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx("li", { className: cn('relative flex items-center gap-2 py-1 pl-3 text-[12px]', active && 'bg-muted/60 rounded-md'), children: row }, key));
|
|
31
|
+
})] }), _jsxs("p", { className: "text-muted-foreground pl-3 text-[11px]", children: ["into ", stack.baseRef] })] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ThreadNode } from '@swirls/looms/core';
|
|
2
|
+
import type { AgentIdentity } from './agents.js';
|
|
3
|
+
import { type SessionActivityState } from './session-activity.js';
|
|
4
|
+
export declare function AgentTree({ root, activityState, identities, eventCounts, totalEventCount, selectedThreadId, showCounts, onSelect, stopIn, }: {
|
|
5
|
+
root: ThreadNode | null;
|
|
6
|
+
activityState: SessionActivityState;
|
|
7
|
+
identities: ReadonlyMap<string, AgentIdentity>;
|
|
8
|
+
eventCounts: ReadonlyMap<string, number>;
|
|
9
|
+
totalEventCount: number;
|
|
10
|
+
selectedThreadId: string | undefined;
|
|
11
|
+
/** Shows how many events each thread has. Only useful beside the event history. */
|
|
12
|
+
showCounts?: boolean;
|
|
13
|
+
onSelect: (threadId: string | undefined) => void;
|
|
14
|
+
/** The session whose agents can be stopped from here. Left out, they cannot be. */
|
|
15
|
+
stopIn?: string;
|
|
16
|
+
}): import("react").JSX.Element;
|