@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,230 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowUpRight, Bot, ChevronRight, GitPullRequest, Layers, Search, TriangleAlert, } from 'lucide-react';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { cn } from '../../lib/cn.js';
|
|
5
|
+
import { compactRelativeTime, fullDateTime } from '../../lib/time.js';
|
|
6
|
+
import { useNow } from '../../lib/use-now.js';
|
|
7
|
+
import { useWorkspaceSessions } from '../workspace/workspace-context.js';
|
|
8
|
+
import { LinkedSessionLink, useSessionTitle } from './linked-session.js';
|
|
9
|
+
import { PullDetailSheet } from './pull-detail-sheet.js';
|
|
10
|
+
import { CheckGlyph, DiffStat, laneTone, RepoDot, repoShortName } from './pull-glyphs.js';
|
|
11
|
+
import { authorRunId, groupPullsByLane, PULL_LANES, pullKey, stacksOf, } from './pulls.js';
|
|
12
|
+
import { StackLadder } from './stack-ladder.js';
|
|
13
|
+
const FILTER_THRESHOLD = 8;
|
|
14
|
+
/** Long lanes show their freshest rows first; the rest wait behind "Show more". */
|
|
15
|
+
const LANE_PREVIEW = 20;
|
|
16
|
+
/** What the last sync could not see, or null when GitHub gave us everything. */
|
|
17
|
+
export function summarizeAccess(report) {
|
|
18
|
+
if (!report) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const blocked = report.repos.filter((repo) => repo.status === 'forbidden');
|
|
22
|
+
const failed = report.repos.filter((repo) => repo.status === 'failed');
|
|
23
|
+
// Only surface access UI when sync actually failed. Missing App scopes alone
|
|
24
|
+
// are fine when a user token (or other path) still filled the inbox.
|
|
25
|
+
if (blocked.length === 0 && failed.length === 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const missing = [...new Set(report.installations.flatMap((entry) => entry.missingPermissions))];
|
|
29
|
+
const install = report.installations.find((entry) => entry.missingPermissions.length > 0);
|
|
30
|
+
return {
|
|
31
|
+
blocked: blocked.map((repo) => repo.fullName),
|
|
32
|
+
failed,
|
|
33
|
+
missing,
|
|
34
|
+
settingsUrl: install?.settingsUrl || null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function matchesFilter(pull, query) {
|
|
38
|
+
return (pull.title.toLowerCase().includes(query) ||
|
|
39
|
+
pull.fullName.toLowerCase().includes(query) ||
|
|
40
|
+
pull.author.login.toLowerCase().includes(query) ||
|
|
41
|
+
String(pull.number).includes(query));
|
|
42
|
+
}
|
|
43
|
+
function entryCount(entries) {
|
|
44
|
+
return entries.reduce((sum, entry) => {
|
|
45
|
+
switch (entry.kind) {
|
|
46
|
+
case 'pull':
|
|
47
|
+
return sum + 1;
|
|
48
|
+
case 'changeset':
|
|
49
|
+
return sum + entry.pulls.length;
|
|
50
|
+
case 'stack':
|
|
51
|
+
return sum + entry.lanePulls.length;
|
|
52
|
+
default: {
|
|
53
|
+
const exhaustive = entry;
|
|
54
|
+
void exhaustive;
|
|
55
|
+
return sum;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, 0);
|
|
59
|
+
}
|
|
60
|
+
function toggled(set, value) {
|
|
61
|
+
const next = new Set(set);
|
|
62
|
+
if (!next.delete(value)) {
|
|
63
|
+
next.add(value);
|
|
64
|
+
}
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
/** `j`/`k` walk rows, Enter opens one, `o` opens it on GitHub, `/` filters. */
|
|
68
|
+
function onListKeyDown(event) {
|
|
69
|
+
const target = event.target;
|
|
70
|
+
if (target.tagName === 'INPUT') {
|
|
71
|
+
if (event.key === 'Escape' || event.key === 'ArrowDown') {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
event.currentTarget.querySelector('[data-pull-row]')?.focus();
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const rows = [...event.currentTarget.querySelectorAll('[data-pull-row]')];
|
|
78
|
+
const index = rows.indexOf(target);
|
|
79
|
+
switch (event.key) {
|
|
80
|
+
case 'j':
|
|
81
|
+
case 'ArrowDown':
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
rows[Math.min(rows.length - 1, index + 1)]?.focus();
|
|
84
|
+
break;
|
|
85
|
+
case 'k':
|
|
86
|
+
case 'ArrowUp':
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
rows[Math.max(0, index - 1)]?.focus();
|
|
89
|
+
break;
|
|
90
|
+
case 'o': {
|
|
91
|
+
const url = target.dataset.url;
|
|
92
|
+
if (url) {
|
|
93
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case '/':
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
event.currentTarget.querySelector('input[type="search"]')?.focus();
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function PullInboxList({ data }) {
|
|
106
|
+
const now = useNow();
|
|
107
|
+
const [filter, setFilter] = useState('');
|
|
108
|
+
const [scope, setScope] = useState(null);
|
|
109
|
+
const [collapsedLanes, setCollapsedLanes] = useState(new Set());
|
|
110
|
+
const [expandedLanes, setExpandedLanes] = useState(new Set());
|
|
111
|
+
const [openKey, setOpenKey] = useState(null);
|
|
112
|
+
const activeRepo = scope && data.repos.includes(scope) ? scope : null;
|
|
113
|
+
const query = filter.trim().toLowerCase();
|
|
114
|
+
const access = summarizeAccess(data.report);
|
|
115
|
+
const reports = useMemo(() => new Map((data.report?.repos ?? []).map((report) => [report.fullName, report])), [data.report]);
|
|
116
|
+
const counts = useMemo(() => {
|
|
117
|
+
const map = new Map();
|
|
118
|
+
for (const pull of data.pulls) {
|
|
119
|
+
map.set(pull.fullName, (map.get(pull.fullName) ?? 0) + 1);
|
|
120
|
+
}
|
|
121
|
+
return map;
|
|
122
|
+
}, [data.pulls]);
|
|
123
|
+
const scoped = useMemo(() => (activeRepo ? data.pulls.filter((pull) => pull.fullName === activeRepo) : data.pulls), [data.pulls, activeRepo]);
|
|
124
|
+
const visible = useMemo(() => (query ? scoped.filter((pull) => matchesFilter(pull, query)) : scoped), [scoped, query]);
|
|
125
|
+
const lanes = useMemo(() => groupPullsByLane(visible), [visible]);
|
|
126
|
+
const openPull = data.pulls.find((pull) => pullKey(pull.fullName, pull.number) === openKey) ?? null;
|
|
127
|
+
const openRunId = openPull ? authorRunId(openPull) : undefined;
|
|
128
|
+
const openStack = useMemo(() => {
|
|
129
|
+
if (!openPull) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return (stacksOf(data.pulls).find((stack) => stack.layers.some((layer) => layer.fullName === openPull.fullName && layer.number === openPull.number)) ?? null);
|
|
133
|
+
}, [data.pulls, openPull]);
|
|
134
|
+
const siblings = useMemo(() => {
|
|
135
|
+
if (openStack) {
|
|
136
|
+
return openStack.layers.filter((pull) => pull !== openPull);
|
|
137
|
+
}
|
|
138
|
+
return openRunId
|
|
139
|
+
? data.pulls.filter((pull) => pull !== openPull && authorRunId(pull) === openRunId)
|
|
140
|
+
: [];
|
|
141
|
+
}, [data.pulls, openPull, openRunId, openStack]);
|
|
142
|
+
const showFilter = scoped.length > FILTER_THRESHOLD || filter !== '';
|
|
143
|
+
const activeReport = activeRepo ? reports.get(activeRepo) : undefined;
|
|
144
|
+
return (_jsxs("div", { className: "flex min-h-0 flex-1 flex-col", onKeyDown: onListKeyDown, children: [data.repos.length > 1 ? (_jsx(RepoScope, { repos: data.repos, counts: counts, total: data.pulls.length, reports: reports, active: activeRepo, onSelect: setScope })) : null, showFilter ? (_jsxs("label", { className: "text-muted-foreground focus-within:text-foreground flex h-9 shrink-0 items-center gap-2 border-b px-3.5 transition-colors duration-100", children: [_jsx(Search, { className: "size-3.5 shrink-0" }), _jsx("input", { type: "search", value: filter, onChange: (event) => setFilter(event.target.value), placeholder: activeRepo
|
|
145
|
+
? `Filter ${repoShortName(activeRepo)}`
|
|
146
|
+
: `Filter ${data.pulls.length.toLocaleString()} pull requests`, "aria-label": "Filter pull requests", className: "placeholder:text-muted-foreground/70 text-foreground min-w-0 flex-1 bg-transparent text-[12.5px] outline-none [&::-webkit-search-cancel-button]:hidden" }), filter ? null : _jsx("kbd", { className: "text-muted-foreground/70 font-mono text-[10px]", children: "/" })] })) : null, _jsxs("div", { className: "scroll-fade min-h-0 flex-1 overflow-y-auto px-1.5 pb-4", children: [access ? _jsx(AccessNotice, { access: access }) : null, activeReport && activeReport.status !== 'ok' ? (_jsx(InboxEmpty, { icon: _jsx(TriangleAlert, {}), title: `No access to ${repoShortName(activeReport.fullName)}`, children: activeReport.status === 'forbidden'
|
|
147
|
+
? 'Shuttle needs Pull requests read access on this repository.'
|
|
148
|
+
: (activeReport.message ?? 'The last sync failed.') })) : scoped.length === 0 ? (_jsx(InboxEmpty, { title: "No open pull requests", children: activeRepo
|
|
149
|
+
? `${repoShortName(activeRepo)} has nothing open right now.`
|
|
150
|
+
: 'PRs on linked repos land here as soon as GitHub reports them.' })) : visible.length === 0 ? (_jsxs(InboxEmpty, { title: "No matches", children: ["Nothing matches \u201C", filter.trim(), "\u201D."] })) : (PULL_LANES.map((lane) => {
|
|
151
|
+
const entries = lanes.get(lane.id) ?? [];
|
|
152
|
+
if (entries.length === 0) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const open = !collapsedLanes.has(lane.id);
|
|
156
|
+
const shown = expandedLanes.has(lane.id) ? entries : entries.slice(0, LANE_PREVIEW);
|
|
157
|
+
const hidden = entryCount(entries) - entryCount(shown);
|
|
158
|
+
return (_jsxs("section", { className: "pt-1", children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: () => setCollapsedLanes((prev) => toggled(prev, lane.id)), className: "bg-sidebar text-muted-foreground hover:text-foreground group focus-visible:bg-accent/40 sticky top-0 z-10 flex h-8 w-full items-center gap-2 rounded-md px-2 text-[11px] font-medium transition-colors duration-100 outline-none", children: [_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', laneTone(lane.id)) }), lane.label, _jsx("span", { className: "text-muted-foreground/70 font-mono text-[10px] tabular-nums", children: entryCount(entries).toLocaleString() }), _jsx(ChevronRight, { className: cn('ease-snappy ml-auto size-3 opacity-0 transition-[transform,opacity] duration-150 group-hover:opacity-100 group-focus-visible:opacity-100', open && 'rotate-90') })] }), open ? (_jsxs("ul", { className: "flex flex-col", children: [shown.map((entry) => {
|
|
159
|
+
switch (entry.kind) {
|
|
160
|
+
case 'pull':
|
|
161
|
+
return (_jsx("li", { children: _jsx(PullRow, { pull: entry.pull, now: now, showRepo: !activeRepo, onOpen: setOpenKey }) }, pullKey(entry.pull.fullName, entry.pull.number)));
|
|
162
|
+
case 'changeset':
|
|
163
|
+
return (_jsx("li", { children: _jsx(ChangesetGroup, { sessionRunId: entry.sessionRunId, pulls: entry.pulls, total: entry.total, now: now, showRepo: !activeRepo, onOpen: setOpenKey }) }, entry.sessionRunId));
|
|
164
|
+
case 'stack':
|
|
165
|
+
return (_jsx("li", { children: _jsx(StackGroup, { stack: entry.stack, lanePulls: entry.lanePulls, onOpen: setOpenKey }) }, entry.stack.key));
|
|
166
|
+
default: {
|
|
167
|
+
const exhaustive = entry;
|
|
168
|
+
void exhaustive;
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}), hidden > 0 ? (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => setExpandedLanes((prev) => toggled(prev, lane.id)), className: "text-muted-foreground hover:text-foreground hover:bg-accent/40 flex h-7 w-full items-center rounded-md px-2 text-[11px] transition-colors duration-100", children: ["Show ", hidden.toLocaleString(), " more"] }) })) : null] })) : null] }, lane.id));
|
|
173
|
+
}))] }), _jsx(PullDetailSheet, { folderId: data.folderId, pull: openPull, siblings: siblings, stack: openStack, onOpenPull: setOpenKey, onOpenChange: (open) => (open ? undefined : setOpenKey(null)) })] }));
|
|
174
|
+
}
|
|
175
|
+
function StackGroup({ stack, lanePulls, onOpen, }) {
|
|
176
|
+
const laneKeys = new Set(lanePulls.map((pull) => pullKey(pull.fullName, pull.number)));
|
|
177
|
+
return (_jsx("div", { className: "px-2 py-1.5", children: _jsx(StackLadder, { stack: stack, ghostOutsideLane: laneKeys, onOpenPull: (pull) => onOpen(pullKey(pull.fullName, pull.number)) }) }));
|
|
178
|
+
}
|
|
179
|
+
/** Repo tabs share the row dots' colors, so a glance ties every PR to its repo. */
|
|
180
|
+
function RepoScope({ repos, counts, total, reports, active, onSelect, }) {
|
|
181
|
+
return (_jsxs("div", { role: "tablist", "aria-label": "Filter by repository", className: "flex h-10 shrink-0 [scrollbar-width:none] items-center gap-1 overflow-x-auto border-b px-2.5 [&::-webkit-scrollbar]:hidden", children: [_jsx(ScopeTab, { active: active === null, onSelect: () => onSelect(null), count: total, children: "All" }), repos.map((fullName) => {
|
|
182
|
+
const report = reports.get(fullName);
|
|
183
|
+
const blocked = report !== undefined && report.status !== 'ok';
|
|
184
|
+
const capped = report && report.synced < report.open;
|
|
185
|
+
return (_jsx(ScopeTab, { active: active === fullName, onSelect: () => onSelect(active === fullName ? null : fullName), count: blocked ? null : (counts.get(fullName) ?? 0), title: blocked
|
|
186
|
+
? `${fullName}: ${report.message ?? 'sync failed'}`
|
|
187
|
+
: capped
|
|
188
|
+
? `${fullName}: showing the ${report.synced.toLocaleString()} most recently updated of ${report.open.toLocaleString()} open`
|
|
189
|
+
: fullName, leading: blocked ? (_jsx(TriangleAlert, { className: "text-status-waiting size-3 shrink-0" })) : (_jsx(RepoDot, { fullName: fullName })), children: repoShortName(fullName) }, fullName));
|
|
190
|
+
})] }));
|
|
191
|
+
}
|
|
192
|
+
function ScopeTab({ active, onSelect, count, title, leading, children, }) {
|
|
193
|
+
return (_jsxs("button", { type: "button", role: "tab", "aria-selected": active, title: title, onClick: onSelect, className: cn('focus-visible:ring-ring/50 inline-flex h-6 max-w-44 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-[11.5px] transition-colors duration-100 outline-none focus-visible:ring-2', active
|
|
194
|
+
? 'bg-accent text-foreground'
|
|
195
|
+
: 'text-muted-foreground hover:text-foreground hover:bg-accent/50'), children: [leading, _jsx("span", { className: "truncate", children: children }), count === null ? null : (_jsx("span", { className: "text-muted-foreground font-mono text-[10px] tabular-nums", children: count > 999 ? '999+' : count }))] }));
|
|
196
|
+
}
|
|
197
|
+
function listPhrase(items) {
|
|
198
|
+
if (items.length <= 1) {
|
|
199
|
+
return items[0] ?? '';
|
|
200
|
+
}
|
|
201
|
+
return `${items.slice(0, -1).join(', ')} and ${items.at(-1)}`;
|
|
202
|
+
}
|
|
203
|
+
function AccessNotice({ access }) {
|
|
204
|
+
const title = access.blocked.length > 0
|
|
205
|
+
? `Can't read pull requests in ${listPhrase(access.blocked.map(repoShortName))}`
|
|
206
|
+
: access.failed.length > 0
|
|
207
|
+
? `Couldn't sync ${listPhrase(access.failed.map((repo) => repoShortName(repo.fullName)))}`
|
|
208
|
+
: 'Check status is hidden';
|
|
209
|
+
const body = access.missing.length > 0
|
|
210
|
+
? `Give the GitHub App read access to ${listPhrase(access.missing)}, then approve the update on the installation.`
|
|
211
|
+
: (access.failed[0]?.message ?? 'Try syncing again.');
|
|
212
|
+
return (_jsxs("div", { role: "status", className: "border-status-waiting/25 bg-status-waiting/[0.06] mx-1 mt-2 mb-1 flex gap-2.5 rounded-lg border px-3 py-2.5", children: [_jsx(TriangleAlert, { className: "text-status-waiting mt-px size-3.5 shrink-0" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "text-[12px] leading-snug font-medium wrap-anywhere", children: title }), _jsx("p", { className: "text-muted-foreground mt-1 text-[11.5px] leading-relaxed", children: body }), access.settingsUrl ? (_jsxs("a", { href: access.settingsUrl, target: "_blank", rel: "noreferrer", className: "text-foreground mt-1.5 inline-flex items-center gap-0.5 text-[11.5px] font-medium underline-offset-2 hover:underline", children: ["Installation settings", _jsx(ArrowUpRight, { className: "size-3" })] })) : null] })] }));
|
|
213
|
+
}
|
|
214
|
+
function PullRow({ pull, now, showRepo, inChangeset = false, onOpen, }) {
|
|
215
|
+
const sessions = useWorkspaceSessions();
|
|
216
|
+
const author = pull.linkedSessions.find((session) => session.role === 'author' && sessions[session.runId]) ??
|
|
217
|
+
pull.linkedSessions.find((session) => session.role === 'author');
|
|
218
|
+
const authorSessionTitle = useSessionTitle(author?.runId);
|
|
219
|
+
return (_jsxs("button", { type: "button", "data-pull-row": true, "data-url": pull.url, onClick: () => onOpen(pullKey(pull.fullName, pull.number)), className: "hover:bg-accent/50 focus-visible:bg-accent/60 flex w-full flex-col gap-1 rounded-md px-2 py-2 text-left transition-colors duration-100 outline-none", children: [_jsxs("span", { className: "flex w-full items-start gap-2", children: [_jsx("span", { dir: "auto", title: pull.title, className: cn('min-w-0 flex-1 truncate text-[12.5px] leading-tight', pull.draft ? 'text-muted-foreground' : 'text-foreground'), children: pull.title }), _jsx(CheckGlyph, { rollup: pull.checkRollup, className: "mt-px" })] }), _jsxs("span", { className: "text-muted-foreground flex w-full items-center gap-1.5 text-[11px]", children: [showRepo ? (_jsxs(_Fragment, { children: [_jsx(RepoDot, { fullName: pull.fullName }), _jsx("span", { className: "max-w-28 shrink-0 truncate", title: pull.fullName, children: repoShortName(pull.fullName) })] })) : null, _jsxs("span", { className: "text-muted-foreground/70 font-mono text-[10px]", children: ["#", pull.number] }), inChangeset ? null : author ? (_jsxs("span", { className: "flex min-w-0 items-center gap-1", title: authorSessionTitle ? `Opened in ${authorSessionTitle}` : 'Opened by Shuttle', children: [_jsx(Bot, { "aria-label": "Opened by Shuttle", className: "text-brand size-3 shrink-0" }), authorSessionTitle ? (_jsx("span", { className: "min-w-0 truncate", dir: "auto", children: authorSessionTitle })) : null] })) : (_jsx("span", { className: "min-w-0 truncate", title: pull.author.login, children: pull.author.login })), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-2", children: [_jsx(DiffStat, { additions: pull.additions, deletions: pull.deletions }), _jsx("time", { title: fullDateTime(pull.updatedAt), className: "w-6 text-right font-mono text-[10px] tabular-nums", children: compactRelativeTime(pull.updatedAt, now) })] })] })] }));
|
|
220
|
+
}
|
|
221
|
+
function ChangesetGroup({ sessionRunId, pulls, total, now, showRepo, onOpen, }) {
|
|
222
|
+
const title = useSessionTitle(sessionRunId);
|
|
223
|
+
const author = pulls
|
|
224
|
+
.flatMap((pull) => pull.linkedSessions)
|
|
225
|
+
.find((session) => session.role === 'author' && session.runId === sessionRunId);
|
|
226
|
+
return (_jsxs("div", { className: "py-0.5", children: [_jsxs("div", { className: "text-muted-foreground flex h-6 items-center gap-1.5 px-2 text-[11px]", children: [_jsx(Layers, { className: "size-3 shrink-0" }), _jsx(LinkedSessionLink, { session: author ?? { runId: sessionRunId, role: 'author' }, className: "hover:text-foreground min-w-0", children: _jsx("span", { className: "truncate", dir: "auto", title: title, children: title ?? 'Shuttle session' }) }), _jsxs("span", { className: "ml-auto shrink-0 font-mono text-[10px] tabular-nums", title: total > pulls.length ? `${total - pulls.length} more in other lanes` : undefined, children: [total > pulls.length ? `${pulls.length} of ${total}` : pulls.length, " PRs"] })] }), _jsx("ul", { className: "border-border/80 ml-3 flex flex-col border-l pl-1", children: pulls.map((pull) => (_jsx("li", { children: _jsx(PullRow, { pull: pull, now: now, showRepo: showRepo, inChangeset: true, onOpen: onOpen }) }, pullKey(pull.fullName, pull.number)))) })] }));
|
|
227
|
+
}
|
|
228
|
+
function InboxEmpty({ icon, title, children, }) {
|
|
229
|
+
return (_jsxs("div", { className: "flex flex-col items-center gap-1.5 px-6 pt-16 text-center", children: [_jsx("span", { className: "text-muted-foreground/50 mb-1 [&_svg]:size-4", children: icon ?? _jsx(GitPullRequest, {}) }), _jsx("p", { className: "text-[12.5px] font-medium wrap-anywhere", children: title }), _jsx("p", { className: "text-muted-foreground max-w-56 text-[11.5px] leading-relaxed", children: children })] }));
|
|
230
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
const STORAGE_KEY = 'shuttle.pullInbox.collapsed';
|
|
3
|
+
const listeners = new Set();
|
|
4
|
+
function read() {
|
|
5
|
+
return typeof localStorage !== 'undefined' && localStorage.getItem(STORAGE_KEY) === '1';
|
|
6
|
+
}
|
|
7
|
+
function subscribe(notify) {
|
|
8
|
+
listeners.add(notify);
|
|
9
|
+
return () => listeners.delete(notify);
|
|
10
|
+
}
|
|
11
|
+
export function setPullInboxCollapsed(collapsed) {
|
|
12
|
+
localStorage.setItem(STORAGE_KEY, collapsed ? '1' : '0');
|
|
13
|
+
for (const notify of listeners) {
|
|
14
|
+
notify();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function usePullInboxCollapsed() {
|
|
18
|
+
return useSyncExternalStore(subscribe, read, () => false);
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FolderSyncReport } from '@swirls/shuttle/api';
|
|
2
|
+
import { type PullInboxSummary } from './pulls.js';
|
|
3
|
+
export interface PullInboxData {
|
|
4
|
+
readonly folderId: string;
|
|
5
|
+
/** Repos the inbox covers, in folder order. */
|
|
6
|
+
readonly repos: readonly string[];
|
|
7
|
+
readonly pulls: readonly PullInboxSummary[];
|
|
8
|
+
readonly attention: number;
|
|
9
|
+
/** What GitHub let the last sync see; null until the first sync answers. */
|
|
10
|
+
readonly report: FolderSyncReport | null;
|
|
11
|
+
readonly syncing: boolean;
|
|
12
|
+
readonly canSync: boolean;
|
|
13
|
+
readonly sync: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Folder PRs from the live pulls run (or a fixture), synced with GitHub when the folder opens.
|
|
17
|
+
*
|
|
18
|
+
* The pull requests themselves arrive on the pulls run's event stream. What the sync answers
|
|
19
|
+
* with is the report of what GitHub let it see, and that is what is kept here: asking for it is
|
|
20
|
+
* what makes the Worker fetch.
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePullInbox(folderId: string, repoNames: readonly string[]): PullInboxData;
|
|
23
|
+
/** Docked to the right of the folder page; collapses to a rail that keeps the count visible. */
|
|
24
|
+
export declare function PullInboxPanel({ data }: {
|
|
25
|
+
data: PullInboxData;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
27
|
+
/** Below the wide breakpoint there is no room to dock, so the same inbox opens as a sheet. */
|
|
28
|
+
export declare function PullInboxSheetButton({ data }: {
|
|
29
|
+
data: PullInboxData;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
3
|
+
import { GitPullRequest, PanelRightClose, PanelRightOpen, RefreshCw } from 'lucide-react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { useProjection, useRunStore } from '@swirls/looms/react';
|
|
6
|
+
import { Button } from '../../components/ui/button.js';
|
|
7
|
+
import { PanelHeader, PanelTitle } from '../../components/ui/panel.js';
|
|
8
|
+
import { Sheet, SheetContent, SheetTitle } from '../../components/ui/sheet.js';
|
|
9
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../../components/ui/tooltip.js';
|
|
10
|
+
import { cn } from '../../lib/cn.js';
|
|
11
|
+
import { useApi, useShuttleHost } from '../../shuttle/index.js';
|
|
12
|
+
import { useFixtureMode } from '../workspace/workspace-context.js';
|
|
13
|
+
import { hugePullInbox, worstCasePullInbox, worstCaseSyncReport } from './pull-fixtures.js';
|
|
14
|
+
import { PullInboxList, summarizeAccess } from './pull-inbox-list.js';
|
|
15
|
+
import { setPullInboxCollapsed, usePullInboxCollapsed } from './pull-inbox-pref.js';
|
|
16
|
+
import { attentionPullCount, emptyPullInbox, pullInbox, pullsForFolder, usePullsRunId, } from './pulls.js';
|
|
17
|
+
/**
|
|
18
|
+
* Folder PRs from the live pulls run (or a fixture), synced with GitHub when the folder opens.
|
|
19
|
+
*
|
|
20
|
+
* The pull requests themselves arrive on the pulls run's event stream. What the sync answers
|
|
21
|
+
* with is the report of what GitHub let it see, and that is what is kept here: asking for it is
|
|
22
|
+
* what makes the Worker fetch.
|
|
23
|
+
*/
|
|
24
|
+
export function usePullInbox(folderId, repoNames) {
|
|
25
|
+
const api = useApi();
|
|
26
|
+
const { client } = useShuttleHost();
|
|
27
|
+
const [fixtureMode] = useFixtureMode();
|
|
28
|
+
const store = useRunStore(usePullsRunId());
|
|
29
|
+
const liveInbox = useProjection(store, pullInbox);
|
|
30
|
+
const live = fixtureMode === 'live';
|
|
31
|
+
// Keyed by the repositories as well as the folder, so linking or unlinking one syncs again.
|
|
32
|
+
// GitHub is asked once per opening: a sync that fails is not tried again behind the person's
|
|
33
|
+
// back, and coming back to the window does not start one. The button does.
|
|
34
|
+
const sync = useQuery({
|
|
35
|
+
queryKey: [...api.workspace.pulls.sync.queryKey({ input: { folderId } }), repoNames],
|
|
36
|
+
queryFn: () => client.workspace.pulls.sync({ folderId }),
|
|
37
|
+
enabled: live && repoNames.length > 0,
|
|
38
|
+
// The last report stays up while the repositories change under it.
|
|
39
|
+
placeholderData: keepPreviousData,
|
|
40
|
+
retry: false,
|
|
41
|
+
refetchOnWindowFocus: false,
|
|
42
|
+
refetchOnReconnect: false,
|
|
43
|
+
});
|
|
44
|
+
const liveReport = sync.data?.folderId === folderId ? sync.data : null;
|
|
45
|
+
const inbox = useMemo(() => {
|
|
46
|
+
switch (fixtureMode) {
|
|
47
|
+
case 'worst':
|
|
48
|
+
return worstCasePullInbox();
|
|
49
|
+
case 'huge':
|
|
50
|
+
return hugePullInbox();
|
|
51
|
+
case 'empty':
|
|
52
|
+
return emptyPullInbox;
|
|
53
|
+
case 'live':
|
|
54
|
+
return liveInbox;
|
|
55
|
+
default: {
|
|
56
|
+
const exhaustive = fixtureMode;
|
|
57
|
+
return exhaustive;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [fixtureMode, liveInbox]);
|
|
61
|
+
const repos = useMemo(() => (live ? repoNames : inboxRepos(inbox)), [inbox, live, repoNames]);
|
|
62
|
+
const pulls = useMemo(() => pullsForFolder(inbox, repos), [inbox, repos]);
|
|
63
|
+
const report = useMemo(() => (fixtureMode === 'worst' ? worstCaseSyncReport(folderId) : live ? liveReport : null), [fixtureMode, folderId, live, liveReport]);
|
|
64
|
+
return {
|
|
65
|
+
folderId,
|
|
66
|
+
repos,
|
|
67
|
+
pulls,
|
|
68
|
+
attention: attentionPullCount(pulls),
|
|
69
|
+
report,
|
|
70
|
+
syncing: sync.isFetching,
|
|
71
|
+
canSync: live,
|
|
72
|
+
sync() {
|
|
73
|
+
if (live && !sync.isFetching) {
|
|
74
|
+
void sync.refetch();
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Fixture PRs live on fixture repos, so fixture mode shows all of them. */
|
|
80
|
+
function inboxRepos(inbox) {
|
|
81
|
+
return [...new Set(Object.values(inbox.pulls).map((pull) => pull.fullName))].toSorted();
|
|
82
|
+
}
|
|
83
|
+
/** Docked to the right of the folder page; collapses to a rail that keeps the count visible. */
|
|
84
|
+
export function PullInboxPanel({ data }) {
|
|
85
|
+
const collapsed = usePullInboxCollapsed();
|
|
86
|
+
return (_jsx("aside", { "aria-label": "Pull requests", className: cn('pull-inbox bg-sidebar h-full shrink-0 overflow-hidden border-l', collapsed ? 'w-11' : 'w-[22rem]'), children: collapsed ? (_jsx(CollapsedRail, { data: data })) : (_jsxs("div", { className: "pull-inbox-layer flex h-full w-[22rem] flex-col", children: [_jsx(InboxHeader, { data: data, children: _jsx(IconAction, { label: "Collapse", onClick: () => setPullInboxCollapsed(true), children: _jsx(PanelRightClose, {}) }) }), _jsx(PullInboxList, { data: data })] })) }));
|
|
87
|
+
}
|
|
88
|
+
function CollapsedRail({ data }) {
|
|
89
|
+
const { attention } = data;
|
|
90
|
+
const blocked = summarizeAccess(data.report) !== null;
|
|
91
|
+
const label = [
|
|
92
|
+
'Show pull requests',
|
|
93
|
+
attention > 0 ? `${attention} need attention` : `${data.pulls.length} open`,
|
|
94
|
+
blocked ? 'some repositories could not be read' : null,
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(', ');
|
|
98
|
+
return (_jsxs("button", { type: "button", "aria-label": label, title: label, onClick: () => setPullInboxCollapsed(false), className: "pull-inbox-layer text-muted-foreground hover:text-foreground hover:bg-accent/30 focus-visible:bg-accent/40 flex h-full w-11 flex-col items-center transition-colors duration-100 outline-none", children: [_jsx("span", { className: "flex h-12 w-full shrink-0 items-center justify-center border-b", children: _jsx(PanelRightOpen, { className: "size-3.5" }) }), _jsxs("span", { className: "relative mt-3.5", children: [_jsx(GitPullRequest, { className: "size-3.5" }), attention > 0 ? (_jsx("span", { className: "bg-brand text-brand-foreground absolute -top-2 -right-2.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full px-1 font-mono text-[9px] font-semibold tabular-nums", children: attention > 99 ? '99+' : attention })) : null] }), _jsx("span", { className: "mt-3 text-[11px] font-medium tracking-wide [writing-mode:vertical-rl]", children: "Pull requests" }), blocked ? _jsx("span", { className: "bg-status-waiting mt-2.5 size-1.5 rounded-full" }) : null] }));
|
|
99
|
+
}
|
|
100
|
+
/** Below the wide breakpoint there is no room to dock, so the same inbox opens as a sheet. */
|
|
101
|
+
export function PullInboxSheetButton({ data }) {
|
|
102
|
+
const [open, setOpen] = useState(false);
|
|
103
|
+
return (_jsxs(Sheet, { open: open, onOpenChange: setOpen, children: [_jsxs(Button, { variant: "ghost", size: "xs", onClick: () => setOpen(true), children: [_jsx(GitPullRequest, {}), "Pull requests", data.attention > 0 ? (_jsx("span", { className: "bg-brand/15 text-brand rounded-full px-1.5 font-mono text-[10px] tabular-nums", children: data.attention })) : null] }), _jsxs(SheetContent, { className: "bg-sidebar", children: [_jsx(SheetTitle, { className: "sr-only", children: "Pull requests" }), _jsx(InboxHeader, { data: data, className: "pr-12" }), _jsx(PullInboxList, { data: data })] })] }));
|
|
104
|
+
}
|
|
105
|
+
function InboxHeader({ data, className, children, }) {
|
|
106
|
+
return (_jsxs(PanelHeader, { className: cn('pr-2 pl-3.5', className), children: [_jsx(PanelTitle, { meta: data.pulls.length > 0 ? data.pulls.length.toLocaleString() : undefined, children: "Pull requests" }), _jsxs("div", { className: "ml-auto flex items-center gap-0.5", children: [data.canSync ? (_jsx(IconAction, { label: data.syncing ? 'Syncing…' : 'Sync with GitHub', onClick: data.sync, children: _jsx(RefreshCw, { className: cn(data.syncing && 'animate-spin') }) })) : null, children] })] }));
|
|
107
|
+
}
|
|
108
|
+
function IconAction({ label, onClick, children, }) {
|
|
109
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": label, onClick: onClick, children: children }) }), _jsx(TooltipContent, { side: "bottom", children: label })] }));
|
|
110
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PullComment, PullThread, PullThreadsState } from '@swirls/shuttle/core/pulls';
|
|
2
|
+
import { type ShuttleHost } from '../../shuttle/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* The review threads on each pull request, mirrored from GitHub. The worker owns the events and
|
|
5
|
+
* keeps the same projection (`pulls/threads.ts`); this is its copy for the browser.
|
|
6
|
+
*/
|
|
7
|
+
export type { PullComment, PullThread, PullThreadsState };
|
|
8
|
+
export declare const pullThreads: import("@swirls/looms/core").ProjectionDefinition<PullThreadsState>;
|
|
9
|
+
/** Asks the worker to fetch a pull request's threads from GitHub into the mirror. */
|
|
10
|
+
export declare function syncPullThreads(host: ShuttleHost, folderId: string, fullName: string, number: number): Promise<{
|
|
11
|
+
threads: number;
|
|
12
|
+
changed: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
/** The person has no GitHub account connected, so nothing can be posted as them yet. */
|
|
15
|
+
export declare class GithubNotConnectedError extends Error {
|
|
16
|
+
constructor(message?: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Turns the Worker's "GitHub is not connected" refusal into the error the comment box knows how
|
|
20
|
+
* to offer a way out of. The Worker answers 409 with the reason as the error's message and the
|
|
21
|
+
* sentence for people in its data. An answer that carries the reason in its data instead, as
|
|
22
|
+
* `error` or `code`, is read the same way. Anything else is handed back as it came.
|
|
23
|
+
*/
|
|
24
|
+
export declare function asGithubNotConnected(cause: unknown): unknown;
|
|
25
|
+
/** Where a comment goes: under a thread, or on a line of the diff to start one. */
|
|
26
|
+
export type CommentTarget = {
|
|
27
|
+
readonly rootId: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly path: string;
|
|
30
|
+
readonly line: number;
|
|
31
|
+
readonly side: 'LEFT' | 'RIGHT';
|
|
32
|
+
/** For a comment about several lines: where they start. `line` is where they end. */
|
|
33
|
+
readonly startLine?: number;
|
|
34
|
+
readonly startSide?: 'LEFT' | 'RIGHT';
|
|
35
|
+
};
|
|
36
|
+
/** Posts a comment on the pull request as the signed-in person. */
|
|
37
|
+
export declare function postPullComment(host: ShuttleHost, folderId: string, fullName: string, number: number, target: CommentTarget, body: string): Promise<void>;
|
|
38
|
+
/** Resolves or reopens a thread on the pull request as the signed-in person. */
|
|
39
|
+
export declare function setPullThreadResolved(host: ShuttleHost, folderId: string, fullName: string, number: number, rootId: number, resolved: boolean): Promise<void>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { ORPCError } from '@orpc/client';
|
|
2
|
+
import { defineProjection } from '@swirls/looms/core';
|
|
3
|
+
import {} from '../../shuttle/index.js';
|
|
4
|
+
import { pullKey } from './pulls.js';
|
|
5
|
+
const byAge = (a, b) => a.createdAt - b.createdAt || a.commentId - b.commentId;
|
|
6
|
+
function withComment(threads, comment) {
|
|
7
|
+
const thread = threads.find((item) => item.rootId === comment.rootId);
|
|
8
|
+
if (!thread) {
|
|
9
|
+
return [...threads, { rootId: comment.rootId, resolved: false, comments: [comment] }];
|
|
10
|
+
}
|
|
11
|
+
const known = thread.comments.find((item) => item.commentId === comment.commentId);
|
|
12
|
+
if (known && known.updatedAt > comment.updatedAt) {
|
|
13
|
+
return threads;
|
|
14
|
+
}
|
|
15
|
+
const comments = [
|
|
16
|
+
...thread.comments.filter((item) => item.commentId !== comment.commentId),
|
|
17
|
+
comment,
|
|
18
|
+
].toSorted(byAge);
|
|
19
|
+
return threads.map((item) => (item === thread ? { ...thread, comments } : item));
|
|
20
|
+
}
|
|
21
|
+
function withoutComment(threads, commentId) {
|
|
22
|
+
return threads.flatMap((thread) => {
|
|
23
|
+
if (!thread.comments.some((comment) => comment.commentId === commentId)) {
|
|
24
|
+
return [thread];
|
|
25
|
+
}
|
|
26
|
+
if (thread.rootId === commentId) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return [
|
|
30
|
+
{ ...thread, comments: thread.comments.filter((comment) => comment.commentId !== commentId) },
|
|
31
|
+
];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export const pullThreads = defineProjection({
|
|
35
|
+
name: 'pullThreads',
|
|
36
|
+
initialState: { pulls: {} },
|
|
37
|
+
reduce(state, event) {
|
|
38
|
+
switch (event.type) {
|
|
39
|
+
case 'pulls.comment.upserted': {
|
|
40
|
+
const key = pullKey(event.payload.fullName, event.payload.number);
|
|
41
|
+
const threads = state.pulls[key] ?? [];
|
|
42
|
+
const next = withComment(threads, event.payload.comment);
|
|
43
|
+
return next === threads ? state : { pulls: { ...state.pulls, [key]: next } };
|
|
44
|
+
}
|
|
45
|
+
case 'pulls.comment.removed': {
|
|
46
|
+
const key = pullKey(event.payload.fullName, event.payload.number);
|
|
47
|
+
const threads = state.pulls[key];
|
|
48
|
+
return threads
|
|
49
|
+
? { pulls: { ...state.pulls, [key]: withoutComment(threads, event.payload.commentId) } }
|
|
50
|
+
: state;
|
|
51
|
+
}
|
|
52
|
+
case 'pulls.thread.resolution': {
|
|
53
|
+
const key = pullKey(event.payload.fullName, event.payload.number);
|
|
54
|
+
const threads = state.pulls[key];
|
|
55
|
+
if (!threads) {
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
pulls: {
|
|
60
|
+
...state.pulls,
|
|
61
|
+
[key]: threads.map((thread) => thread.rootId === event.payload.rootId
|
|
62
|
+
? { ...thread, resolved: event.payload.resolved }
|
|
63
|
+
: thread),
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
case 'pulls.threads.synced': {
|
|
68
|
+
const key = pullKey(event.payload.fullName, event.payload.number);
|
|
69
|
+
return {
|
|
70
|
+
pulls: {
|
|
71
|
+
...state.pulls,
|
|
72
|
+
[key]: event.payload.threads.map((thread) => ({
|
|
73
|
+
rootId: thread.rootId,
|
|
74
|
+
resolved: thread.resolved,
|
|
75
|
+
comments: thread.comments.toSorted(byAge),
|
|
76
|
+
})),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
default:
|
|
81
|
+
return state;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
/** Asks the worker to fetch a pull request's threads from GitHub into the mirror. */
|
|
86
|
+
export function syncPullThreads(host, folderId, fullName, number) {
|
|
87
|
+
return host.client.workspace.pulls.syncThreads({ folderId, fullName, number });
|
|
88
|
+
}
|
|
89
|
+
/** The person has no GitHub account connected, so nothing can be posted as them yet. */
|
|
90
|
+
export class GithubNotConnectedError extends Error {
|
|
91
|
+
constructor(message = 'Connect your GitHub account so this can be posted as you.') {
|
|
92
|
+
super(message);
|
|
93
|
+
this.name = 'GithubNotConnectedError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** The reason the Worker gives when it refuses to act as a person who has not connected GitHub. */
|
|
97
|
+
const GITHUB_NOT_CONNECTED = 'github_not_connected';
|
|
98
|
+
function textAt(value, key) {
|
|
99
|
+
if (typeof value !== 'object' || value === null || !(key in value)) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const found = Reflect.get(value, key);
|
|
103
|
+
return typeof found === 'string' ? found : undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Turns the Worker's "GitHub is not connected" refusal into the error the comment box knows how
|
|
107
|
+
* to offer a way out of. The Worker answers 409 with the reason as the error's message and the
|
|
108
|
+
* sentence for people in its data. An answer that carries the reason in its data instead, as
|
|
109
|
+
* `error` or `code`, is read the same way. Anything else is handed back as it came.
|
|
110
|
+
*/
|
|
111
|
+
export function asGithubNotConnected(cause) {
|
|
112
|
+
if (!(cause instanceof ORPCError) || cause.status !== 409) {
|
|
113
|
+
return cause;
|
|
114
|
+
}
|
|
115
|
+
const reasons = [cause.message, textAt(cause.data, 'error'), textAt(cause.data, 'code')];
|
|
116
|
+
if (!reasons.includes(GITHUB_NOT_CONNECTED)) {
|
|
117
|
+
return cause;
|
|
118
|
+
}
|
|
119
|
+
const sentence = textAt(cause.data, 'message');
|
|
120
|
+
return new GithubNotConnectedError(sentence && sentence !== GITHUB_NOT_CONNECTED ? sentence : undefined);
|
|
121
|
+
}
|
|
122
|
+
/** Posts a comment on the pull request as the signed-in person. */
|
|
123
|
+
export async function postPullComment(host, folderId, fullName, number, target, body) {
|
|
124
|
+
try {
|
|
125
|
+
await host.client.workspace.pulls.comment({ folderId, fullName, number, ...target, body });
|
|
126
|
+
}
|
|
127
|
+
catch (cause) {
|
|
128
|
+
throw asGithubNotConnected(cause);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Resolves or reopens a thread on the pull request as the signed-in person. */
|
|
132
|
+
export async function setPullThreadResolved(host, folderId, fullName, number, rootId, resolved) {
|
|
133
|
+
try {
|
|
134
|
+
await host.client.workspace.pulls.resolveThread({
|
|
135
|
+
folderId,
|
|
136
|
+
fullName,
|
|
137
|
+
number,
|
|
138
|
+
rootId,
|
|
139
|
+
resolved,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (cause) {
|
|
143
|
+
throw asGithubNotConnected(cause);
|
|
144
|
+
}
|
|
145
|
+
}
|