@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,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation } from '@tanstack/react-query';
|
|
3
|
+
import { ExternalLink, GitPullRequest, LoaderCircle } from 'lucide-react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Button } from '../../components/ui/button.js';
|
|
6
|
+
import { Textarea } from '../../components/ui/textarea.js';
|
|
7
|
+
import { cn } from '../../lib/cn.js';
|
|
8
|
+
import { jsonText } from '../../lib/json.js';
|
|
9
|
+
import { clockTime } from '../../lib/time.js';
|
|
10
|
+
import { useNow } from '../../lib/use-now.js';
|
|
11
|
+
import { useShuttleHost } from '../../shuttle/index.js';
|
|
12
|
+
import { agentRole } from './agents.js';
|
|
13
|
+
import { decideStructuredApproval } from './signals.js';
|
|
14
|
+
export function PullPublishCard({ item, context, className, }) {
|
|
15
|
+
const host = useShuttleHost();
|
|
16
|
+
const identity = context.identities.get(item.threadId);
|
|
17
|
+
const [title, setTitle] = useState(jsonText(item.defaults?.title) ?? '');
|
|
18
|
+
const [body, setBody] = useState(jsonText(item.defaults?.body) ?? '');
|
|
19
|
+
const decide = useMutation({
|
|
20
|
+
mutationFn: (actionId) => actionId === 'discard'
|
|
21
|
+
? decideStructuredApproval(host, context.runId, item.approvalId, {
|
|
22
|
+
actionId: 'discard',
|
|
23
|
+
outcome: 'reject',
|
|
24
|
+
})
|
|
25
|
+
: decideStructuredApproval(host, context.runId, item.approvalId, {
|
|
26
|
+
actionId,
|
|
27
|
+
outcome: 'approve',
|
|
28
|
+
payload: {
|
|
29
|
+
title: title.trim() || 'Shuttle changes',
|
|
30
|
+
body,
|
|
31
|
+
draft: actionId === 'draft',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
// Once the session has the decision the card stays locked: the feed replaces it with the outcome.
|
|
36
|
+
const pending = decide.isPending || decide.isSuccess;
|
|
37
|
+
const error = decide.error?.message;
|
|
38
|
+
return (_jsxs("div", { className: cn('flex gap-3', className), "data-approval-id": item.approvalId, children: [_jsx(AgentAvatar, { identity: identity, threadId: item.threadId }), _jsxs("div", { className: cn('min-w-0 flex-1 rounded-xl border p-3', item.decision ? 'bg-card/40' : 'border-brand/30 bg-brand/6'), children: [_jsxs("div", { className: "text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]", children: [_jsx(GitPullRequest, { className: cn('size-3.5 shrink-0', !item.decision && 'text-brand', item.publish?.status === 'published' && 'text-status-completed') }), _jsx("span", { className: "text-foreground/90 font-medium whitespace-nowrap", children: publishHeading(item) }), _jsx("span", { className: "message-time shrink-0 whitespace-nowrap tabular-nums", children: clockTime(item.ts) }), item.decision ? null : (_jsx("span", { className: "text-brand ml-auto shrink-0", children: "Needs approval" }))] }), item.decision ? (_jsx(PublishOutcome, { item: item, agentLabel: identity?.label ?? 'this agent', onInspect: () => context.onInspect(item.threadId, item.seq) })) : (_jsxs("div", { className: "mt-3 flex flex-col gap-2", children: [jsonText(item.defaults?.parentPullLabel) ? (_jsxs("p", { className: "text-muted-foreground text-[11px]", children: ["Stacks on", ' ', _jsx("span", { className: "text-foreground/90 font-mono", children: jsonText(item.defaults?.parentPullLabel) })] })) : null, jsonText(item.defaults?.restackLabel) ? (_jsxs("p", { className: "text-muted-foreground text-[11px]", children: ["Will force-update", ' ', _jsx("span", { className: "text-foreground/90 font-mono", children: jsonText(item.defaults?.restackLabel) })] })) : null, _jsx("input", { value: title, onChange: (event) => setTitle(event.target.value), disabled: pending, className: "border-input bg-background text-foreground h-9 rounded-md border px-3 text-[13px]", placeholder: "Pull request title" }), _jsx(Textarea, { value: body, onChange: (event) => setBody(event.target.value), disabled: pending, placeholder: "Summary, testing, risks\u2026", className: "min-h-24 resize-none text-[13px]" }), _jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [error ? (_jsx("span", { className: "text-status-failed mr-auto min-w-0 text-xs break-words", children: error })) : null, _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: pending, onClick: () => decide.mutate('discard'), children: "Discard" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: pending, onClick: () => decide.mutate('draft'), children: "Publish as draft" }), _jsx(Button, { type: "button", variant: "brand", size: "sm", disabled: pending, onClick: () => decide.mutate('publish'), children: "Publish" })] })] }))] })] }));
|
|
39
|
+
}
|
|
40
|
+
function publishHeading(item) {
|
|
41
|
+
if (!item.decision) {
|
|
42
|
+
return 'Publish pull requests';
|
|
43
|
+
}
|
|
44
|
+
if (item.decision.answer === null) {
|
|
45
|
+
return 'Pull requests discarded';
|
|
46
|
+
}
|
|
47
|
+
if (!item.publish) {
|
|
48
|
+
return 'Publish approved';
|
|
49
|
+
}
|
|
50
|
+
switch (item.publish.status) {
|
|
51
|
+
case 'published': {
|
|
52
|
+
const count = item.publish.pulls.length;
|
|
53
|
+
return `Opened ${count} pull request${count === 1 ? '' : 's'}`;
|
|
54
|
+
}
|
|
55
|
+
case 'failed':
|
|
56
|
+
return 'Couldn’t publish pull requests';
|
|
57
|
+
default: {
|
|
58
|
+
const exhaustive = item.publish;
|
|
59
|
+
return exhaustive;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Publishing commits and opens PRs in a few seconds; minutes of silence means no result is coming. */
|
|
64
|
+
const PUBLISH_STALE_MS = 5 * 60_000;
|
|
65
|
+
function PublishPending({ decidedAt }) {
|
|
66
|
+
const now = useNow(15_000);
|
|
67
|
+
if (now - decidedAt > PUBLISH_STALE_MS) {
|
|
68
|
+
return (_jsx("p", { className: "text-muted-foreground mt-2 text-xs", children: "No publish result was recorded. Ask the conductor to propose the pull request again." }));
|
|
69
|
+
}
|
|
70
|
+
return (_jsxs("p", { className: "text-muted-foreground mt-2 flex items-center gap-1.5 text-xs", children: [_jsx(LoaderCircle, { className: "size-3 animate-spin" }), "Committing changes and opening pull requests\u2026"] }));
|
|
71
|
+
}
|
|
72
|
+
function PublishOutcome({ item, agentLabel, onInspect, }) {
|
|
73
|
+
if (item.decision?.answer === null) {
|
|
74
|
+
return _jsx("p", { className: "text-muted-foreground mt-2 text-xs", children: "Nothing was pushed." });
|
|
75
|
+
}
|
|
76
|
+
if (!item.publish) {
|
|
77
|
+
return _jsx(PublishPending, { decidedAt: item.decision?.ts ?? item.ts });
|
|
78
|
+
}
|
|
79
|
+
if (item.publish.status === 'failed') {
|
|
80
|
+
return _jsx("p", { className: "text-status-failed mt-2 text-xs break-words", children: item.publish.error });
|
|
81
|
+
}
|
|
82
|
+
return (_jsxs("div", { className: "mt-2 flex flex-col gap-1", children: [_jsx("ul", { className: "-mx-1 flex flex-col", children: item.publish.pulls.map((pull) => (_jsx("li", { children: _jsxs("a", { href: pull.url, target: "_blank", rel: "noreferrer", className: "hover:bg-accent/50 group flex h-8 min-w-0 items-center gap-2 rounded-md px-1 text-[13px] transition-colors duration-100", children: [_jsx("span", { className: "text-muted-foreground truncate", children: pull.fullName }), _jsxs("span", { className: "text-foreground shrink-0 font-mono", children: ["#", pull.number] }), pull.draft ? (_jsx("span", { className: "text-muted-foreground shrink-0 rounded border border-dashed px-1 text-[10px] uppercase", children: "Draft" })) : null, _jsx(ExternalLink, { className: "text-muted-foreground ml-auto size-3 shrink-0 opacity-0 transition-opacity duration-100 group-hover:opacity-100" })] }) }, `${pull.fullName}#${pull.number}`))) }), _jsxs("p", { className: "text-muted-foreground text-[11px]", children: ["Opened by", ' ', _jsx("button", { type: "button", onClick: onInspect, className: "hover:text-foreground underline-offset-2 hover:underline", children: agentLabel }), ". The folder\u2019s pull request inbox links back here."] })] }));
|
|
83
|
+
}
|
|
84
|
+
function AgentAvatar({ identity, threadId }) {
|
|
85
|
+
const role = identity?.role ?? agentRole(undefined);
|
|
86
|
+
const Icon = role.icon;
|
|
87
|
+
return (_jsx("span", { className: cn('mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-current/10 ring-1 ring-current/15 ring-inset', role.tone), title: threadId, children: _jsx(Icon, { className: "size-3.5" }) }));
|
|
88
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RecentSession {
|
|
2
|
+
readonly runId: string;
|
|
3
|
+
readonly goal: string;
|
|
4
|
+
readonly openedAt: number;
|
|
5
|
+
}
|
|
6
|
+
/** Sessions this browser opened, so the list works before a D1 replica is bound. */
|
|
7
|
+
export declare function recentSessions(): RecentSession[];
|
|
8
|
+
export declare function rememberSession(session: {
|
|
9
|
+
runId: string;
|
|
10
|
+
goal: string;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isRecord } from '../../lib/json.js';
|
|
2
|
+
const STORAGE_KEY = 'shuttle.recent-sessions';
|
|
3
|
+
const LIMIT = 20;
|
|
4
|
+
function isRecentSession(value) {
|
|
5
|
+
if (!isRecord(value)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const entry = value;
|
|
9
|
+
return (typeof entry.runId === 'string' &&
|
|
10
|
+
typeof entry.goal === 'string' &&
|
|
11
|
+
typeof entry.openedAt === 'number');
|
|
12
|
+
}
|
|
13
|
+
/** Sessions this browser opened, so the list works before a D1 replica is bound. */
|
|
14
|
+
export function recentSessions() {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]');
|
|
17
|
+
return Array.isArray(parsed) ? parsed.filter(isRecentSession) : [];
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function rememberSession(session) {
|
|
24
|
+
const next = [
|
|
25
|
+
{ ...session, openedAt: Date.now() },
|
|
26
|
+
...recentSessions().filter((entry) => entry.runId !== session.runId),
|
|
27
|
+
].slice(0, LIMIT);
|
|
28
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SeenSessionsSnapshot {
|
|
2
|
+
readonly baselineAt: number;
|
|
3
|
+
readonly seen: Readonly<Record<string, number>>;
|
|
4
|
+
}
|
|
5
|
+
export declare function getSeenSessionsSnapshot(): SeenSessionsSnapshot;
|
|
6
|
+
export declare function subscribeSeenSessions(listener: () => void): () => void;
|
|
7
|
+
export declare function markSessionSeen(runId: string, at?: number): void;
|
|
8
|
+
export declare function useSeenSessions(): SeenSessionsSnapshot;
|
|
9
|
+
export declare function isSessionUnread(session: {
|
|
10
|
+
readonly runId: string;
|
|
11
|
+
readonly unread?: boolean;
|
|
12
|
+
readonly lastCompletedAt?: number;
|
|
13
|
+
}, options: {
|
|
14
|
+
readonly activeRunId?: string | null;
|
|
15
|
+
readonly snapshot: SeenSessionsSnapshot;
|
|
16
|
+
}): boolean;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { isRecord } from '../../lib/json.js';
|
|
3
|
+
const STORAGE_KEY = 'shuttle.session-seen';
|
|
4
|
+
const SEEN_LIMIT = 250;
|
|
5
|
+
const listeners = new Set();
|
|
6
|
+
let cachedSnapshot = null;
|
|
7
|
+
function hasLocalStorage() {
|
|
8
|
+
return typeof localStorage !== 'undefined';
|
|
9
|
+
}
|
|
10
|
+
function parseSnapshot(raw) {
|
|
11
|
+
if (!raw) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(raw);
|
|
16
|
+
if (!isRecord(parsed)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const record = parsed;
|
|
20
|
+
if (typeof record.baselineAt !== 'number' || !Number.isFinite(record.baselineAt)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const seen = {};
|
|
24
|
+
if (isRecord(record.seen)) {
|
|
25
|
+
for (const [key, value] of Object.entries(record.seen)) {
|
|
26
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
27
|
+
seen[key] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { baselineAt: record.baselineAt, seen };
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function persistSnapshot(snapshot) {
|
|
38
|
+
if (!hasLocalStorage()) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(snapshot));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Storage quota errors should never break navigation.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function trimSeen(seen) {
|
|
49
|
+
const entries = Object.entries(seen);
|
|
50
|
+
if (entries.length <= SEEN_LIMIT) {
|
|
51
|
+
return seen;
|
|
52
|
+
}
|
|
53
|
+
return Object.fromEntries(entries.toSorted((left, right) => right[1] - left[1]).slice(0, SEEN_LIMIT));
|
|
54
|
+
}
|
|
55
|
+
export function getSeenSessionsSnapshot() {
|
|
56
|
+
if (cachedSnapshot) {
|
|
57
|
+
return cachedSnapshot;
|
|
58
|
+
}
|
|
59
|
+
const fromStorage = hasLocalStorage() ? parseSnapshot(localStorage.getItem(STORAGE_KEY)) : null;
|
|
60
|
+
if (fromStorage) {
|
|
61
|
+
cachedSnapshot = fromStorage;
|
|
62
|
+
return cachedSnapshot;
|
|
63
|
+
}
|
|
64
|
+
cachedSnapshot = {
|
|
65
|
+
baselineAt: Date.now(),
|
|
66
|
+
seen: {},
|
|
67
|
+
};
|
|
68
|
+
persistSnapshot(cachedSnapshot);
|
|
69
|
+
return cachedSnapshot;
|
|
70
|
+
}
|
|
71
|
+
export function subscribeSeenSessions(listener) {
|
|
72
|
+
listeners.add(listener);
|
|
73
|
+
return () => listeners.delete(listener);
|
|
74
|
+
}
|
|
75
|
+
export function markSessionSeen(runId, at = Date.now()) {
|
|
76
|
+
const current = getSeenSessionsSnapshot();
|
|
77
|
+
const prev = current.seen[runId] ?? 0;
|
|
78
|
+
if (prev >= at) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
cachedSnapshot = {
|
|
82
|
+
baselineAt: current.baselineAt,
|
|
83
|
+
seen: trimSeen({
|
|
84
|
+
...current.seen,
|
|
85
|
+
[runId]: at,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
persistSnapshot(cachedSnapshot);
|
|
89
|
+
for (const listener of listeners) {
|
|
90
|
+
listener();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function useSeenSessions() {
|
|
94
|
+
return useSyncExternalStore(subscribeSeenSessions, getSeenSessionsSnapshot, getSeenSessionsSnapshot);
|
|
95
|
+
}
|
|
96
|
+
export function isSessionUnread(session, options) {
|
|
97
|
+
if (session.runId === options.activeRunId) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (typeof session.unread === 'boolean') {
|
|
101
|
+
return session.unread;
|
|
102
|
+
}
|
|
103
|
+
if (session.lastCompletedAt === undefined) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
const threshold = Math.max(options.snapshot.baselineAt, options.snapshot.seen[session.runId] ?? 0);
|
|
107
|
+
return session.lastCompletedAt > threshold;
|
|
108
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ProjectionDefinition, ThreadNode } from '@swirls/looms/core';
|
|
2
|
+
import type { SessionFeed, ToolCallItem } from './session-feed.js';
|
|
3
|
+
export type SessionActivity = 'working' | 'needs_input' | 'idle' | 'error';
|
|
4
|
+
export type SessionIndicatorTone = 'starting' | 'working' | 'needs_input' | 'ready' | 'failed' | 'idle' | 'completed' | 'cancelled';
|
|
5
|
+
export type ThreadActivityTone = 'working' | 'delegating' | 'needs_input' | 'idle' | 'completed' | 'failed' | 'cancelled';
|
|
6
|
+
type OpenToolCallState = 'executing' | 'spawned_child' | 'awaiting_effects';
|
|
7
|
+
interface AgentThreadActivity {
|
|
8
|
+
readonly kind: 'agent';
|
|
9
|
+
readonly definitionName: string;
|
|
10
|
+
readonly lineCount: number;
|
|
11
|
+
readonly midCallLines: number;
|
|
12
|
+
readonly inTurn: boolean;
|
|
13
|
+
readonly needsLlmCall: boolean;
|
|
14
|
+
readonly deferWake: boolean;
|
|
15
|
+
readonly openToolCalls: Readonly<Record<string, OpenToolCallState>>;
|
|
16
|
+
}
|
|
17
|
+
interface EvaluatorThreadActivity {
|
|
18
|
+
readonly kind: 'evaluator';
|
|
19
|
+
readonly definitionName: string;
|
|
20
|
+
}
|
|
21
|
+
interface SessionCoordinatorActivity {
|
|
22
|
+
readonly kind: 'shuttle-session';
|
|
23
|
+
readonly definitionName: string;
|
|
24
|
+
readonly parkedOnMailbox: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface GenericThreadActivity {
|
|
27
|
+
readonly kind: 'other';
|
|
28
|
+
readonly definitionName: string;
|
|
29
|
+
readonly activeWaits: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
type TrackedThreadActivity = AgentThreadActivity | EvaluatorThreadActivity | SessionCoordinatorActivity | GenericThreadActivity;
|
|
32
|
+
export interface SessionActivityState {
|
|
33
|
+
readonly runStatus: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
34
|
+
readonly rootThreadId: string | null;
|
|
35
|
+
readonly conductorThreadId: string | null;
|
|
36
|
+
readonly bindingSandbox: boolean;
|
|
37
|
+
readonly queuedForConductor: boolean;
|
|
38
|
+
readonly sessionError: boolean;
|
|
39
|
+
readonly pendingUserMessages: readonly string[];
|
|
40
|
+
readonly pendingApprovals: Readonly<Record<string, string>>;
|
|
41
|
+
readonly threads: Readonly<Record<string, TrackedThreadActivity>>;
|
|
42
|
+
readonly activity: SessionActivity;
|
|
43
|
+
}
|
|
44
|
+
export declare const initialSessionActivityState: SessionActivityState;
|
|
45
|
+
export declare function deriveSessionActivity(state: Omit<SessionActivityState, 'activity'>): SessionActivity;
|
|
46
|
+
/** Pure session activity fold — keep transitions in sync with apps/worker/src/workspace/activity-state.ts. */
|
|
47
|
+
export declare function reduceSessionActivity(state: SessionActivityState, event: {
|
|
48
|
+
readonly seq: number;
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly payload: unknown;
|
|
51
|
+
readonly threadId?: string | null;
|
|
52
|
+
}): SessionActivityState;
|
|
53
|
+
export declare const sessionActivity: ProjectionDefinition<SessionActivityState>;
|
|
54
|
+
/** Resolve a single thread node's true live status for AgentTree. */
|
|
55
|
+
export declare function resolveThreadActivityTone(state: SessionActivityState, node: Pick<ThreadNode, 'threadId' | 'kind' | 'status'>): ThreadActivityTone;
|
|
56
|
+
export declare function resolveSessionIndicator(input: {
|
|
57
|
+
readonly status: string;
|
|
58
|
+
readonly activity: string;
|
|
59
|
+
readonly unread?: boolean;
|
|
60
|
+
}): SessionIndicatorTone;
|
|
61
|
+
export declare function sessionIndicatorLabel(tone: SessionIndicatorTone): string;
|
|
62
|
+
export interface FolderIndicatorRollup {
|
|
63
|
+
readonly tone: 'needs_input' | 'failed' | 'working' | 'ready';
|
|
64
|
+
readonly count: number;
|
|
65
|
+
readonly label: string;
|
|
66
|
+
}
|
|
67
|
+
export interface RouteWaitFallback {
|
|
68
|
+
readonly threadId: string;
|
|
69
|
+
readonly toolName: string;
|
|
70
|
+
readonly elapsedMs: number;
|
|
71
|
+
}
|
|
72
|
+
/** An agent thread (not a narrator) that is mid-turn or executing a tool, for route wait UX. */
|
|
73
|
+
export declare function findInFlightToolCall(activity: Omit<SessionActivityState, 'activity'>): {
|
|
74
|
+
readonly threadId: string;
|
|
75
|
+
readonly toolName: string;
|
|
76
|
+
} | null;
|
|
77
|
+
/** Prefer feed tool rows when names and timestamps are available. */
|
|
78
|
+
export declare function findRunningToolInFeed(feed: SessionFeed): {
|
|
79
|
+
readonly threadId: string;
|
|
80
|
+
readonly call: ToolCallItem;
|
|
81
|
+
} | null;
|
|
82
|
+
export declare function shouldShowRouteWaitFallback(messageTs: number, hasRoute: boolean, now: number): boolean;
|
|
83
|
+
export declare function deriveRouteWaitFallback(input: {
|
|
84
|
+
readonly messageTs: number;
|
|
85
|
+
readonly hasRoute: boolean;
|
|
86
|
+
readonly now: number;
|
|
87
|
+
readonly activity: SessionActivityState;
|
|
88
|
+
readonly feed: SessionFeed;
|
|
89
|
+
}): RouteWaitFallback | null;
|
|
90
|
+
/**
|
|
91
|
+
* Summarize actionable session states inside a collapsed folder or hidden overflow slice.
|
|
92
|
+
* Returns `null` when every session is quiet (`idle`, `completed`, `cancelled`).
|
|
93
|
+
*/
|
|
94
|
+
export declare function resolveFolderIndicator(tones: readonly SessionIndicatorTone[]): FolderIndicatorRollup | null;
|
|
95
|
+
export {};
|