@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,549 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation } from '@tanstack/react-query';
|
|
3
|
+
import { ArrowRight, Check, CircleStop, ChevronRight, CornerDownRight, FileDiff, GitPullRequest, Globe, LoaderCircle, MessageCircleQuestion, MessageSquareDashed, Shuffle, Sparkles, TriangleAlert, X, } from 'lucide-react';
|
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { FollowList } from '../../components/follow-list.js';
|
|
6
|
+
import { Markdown } from '../../components/markdown.js';
|
|
7
|
+
import { statusClass, statusLabel } from '../../components/status.js';
|
|
8
|
+
import { StatusDot } from '../../components/status-dot.js';
|
|
9
|
+
import { Button } from '../../components/ui/button.js';
|
|
10
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger, } from '../../components/ui/dropdown-menu.js';
|
|
11
|
+
import { EmptyState } from '../../components/ui/panel.js';
|
|
12
|
+
import { Textarea } from '../../components/ui/textarea.js';
|
|
13
|
+
import { cn, compactJson } from '../../lib/cn.js';
|
|
14
|
+
import { jsonFields, jsonText } from '../../lib/json.js';
|
|
15
|
+
import { clockTime } from '../../lib/time.js';
|
|
16
|
+
import { useNow } from '../../lib/use-now.js';
|
|
17
|
+
import { Link, useApi, useShuttleHost, useTenant } from '../../shuttle/index.js';
|
|
18
|
+
import { changedPaths, previewPorts } from '../artifacts/artifact-links.js';
|
|
19
|
+
import { agentRole } from './agents.js';
|
|
20
|
+
import { classifyHeuristic } from './intake-heuristic.js';
|
|
21
|
+
import { provisionalRouteSummary, routeStyles } from './interjection-routes.js';
|
|
22
|
+
import { MediaStrip } from './media-strip.js';
|
|
23
|
+
import { PullPublishCard } from './pull-publish-card.js';
|
|
24
|
+
import { deriveRouteWaitFallback, resolveThreadActivityTone, } from './session-activity.js';
|
|
25
|
+
import { interjectionKinds, } from './session-feed.js';
|
|
26
|
+
import { answerQuestion, decideStructuredApproval, reroute } from './signals.js';
|
|
27
|
+
import { projectTimeline, repeatedMessages, threadParents, threadSpeaks, } from './timeline.js';
|
|
28
|
+
function thoughtKey(threadId, turn) {
|
|
29
|
+
return `${threadId}:${turn}`;
|
|
30
|
+
}
|
|
31
|
+
function formatSeconds(durationMs) {
|
|
32
|
+
if (durationMs >= 60_000) {
|
|
33
|
+
const minutes = Math.floor(durationMs / 60_000);
|
|
34
|
+
const seconds = Math.round((durationMs % 60_000) / 1000);
|
|
35
|
+
return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;
|
|
36
|
+
}
|
|
37
|
+
if (durationMs >= 10_000) {
|
|
38
|
+
return `${Math.round(durationMs / 1000)}s`;
|
|
39
|
+
}
|
|
40
|
+
const fixed = Math.max(0.1, durationMs / 1000).toFixed(1);
|
|
41
|
+
return fixed.endsWith('.0') ? `${fixed.slice(0, -2)}s` : `${fixed}s`;
|
|
42
|
+
}
|
|
43
|
+
function formatThoughtLabel(durationMs) {
|
|
44
|
+
return durationMs !== undefined ? `Thought for ${formatSeconds(durationMs)}` : 'Thought';
|
|
45
|
+
}
|
|
46
|
+
function cleanSnippet(line) {
|
|
47
|
+
return line
|
|
48
|
+
.replace(/^[\s>#*-]+/, '')
|
|
49
|
+
.replace(/[`*_~]/g, '')
|
|
50
|
+
.replace(/\s+/g, ' ')
|
|
51
|
+
.trim();
|
|
52
|
+
}
|
|
53
|
+
function latestThoughtLine(text) {
|
|
54
|
+
const lines = text.split('\n');
|
|
55
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
56
|
+
const cleaned = cleanSnippet(lines[index] ?? '');
|
|
57
|
+
if (cleaned) {
|
|
58
|
+
return cleaned;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
function rowSpeakerThreadId(row) {
|
|
64
|
+
if (!row) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
switch (row.kind) {
|
|
68
|
+
case 'agent':
|
|
69
|
+
case 'thought':
|
|
70
|
+
case 'tools':
|
|
71
|
+
case 'question':
|
|
72
|
+
case 'media':
|
|
73
|
+
case 'stream':
|
|
74
|
+
return row.threadId;
|
|
75
|
+
case 'user':
|
|
76
|
+
case 'notice':
|
|
77
|
+
case 'delegation':
|
|
78
|
+
return undefined;
|
|
79
|
+
default: {
|
|
80
|
+
const exhaustive = row;
|
|
81
|
+
return exhaustive;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function Conversation({ runId, feed, activity, streaming, identities, onInspect, onOpenArtifact, root, openThreadId, onOpenThread, }) {
|
|
86
|
+
const { parents, threadNodes } = useMemo(() => {
|
|
87
|
+
const nodes = new Map();
|
|
88
|
+
function visit(node) {
|
|
89
|
+
nodes.set(node.threadId, node);
|
|
90
|
+
node.children.forEach(visit);
|
|
91
|
+
}
|
|
92
|
+
if (root) {
|
|
93
|
+
visit(root);
|
|
94
|
+
}
|
|
95
|
+
return { parents: threadParents(root), threadNodes: nodes };
|
|
96
|
+
}, [root]);
|
|
97
|
+
const { rows, liveByToolCardId, inlineNarratorByMessageId } = useMemo(() => {
|
|
98
|
+
let lastUserIndex = -1;
|
|
99
|
+
for (let index = feed.items.length - 1; index >= 0; index -= 1) {
|
|
100
|
+
if (feed.items[index]?.kind === 'user') {
|
|
101
|
+
lastUserIndex = index;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const latestThreadItem = new Map();
|
|
106
|
+
for (let index = lastUserIndex + 1; index < feed.items.length; index += 1) {
|
|
107
|
+
const item = feed.items[index];
|
|
108
|
+
if (item &&
|
|
109
|
+
(item.kind === 'agent' ||
|
|
110
|
+
item.kind === 'tools' ||
|
|
111
|
+
item.kind === 'question' ||
|
|
112
|
+
item.kind === 'thought')) {
|
|
113
|
+
latestThreadItem.set(item.threadId, item);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const attached = new Map();
|
|
117
|
+
const liveRows = [];
|
|
118
|
+
for (const [threadId, turn] of Object.entries(streaming)) {
|
|
119
|
+
// A thread that is folded away or outside this view has no bubble of its own.
|
|
120
|
+
if (feed.narrators[threadId] || !threadSpeaks(threadId, parents, openThreadId)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const hasThinking = turn.thinking.trim().length > 0;
|
|
124
|
+
const hasText = turn.text.trim().length > 0;
|
|
125
|
+
if (!hasThinking && !hasText) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const latest = latestThreadItem.get(threadId);
|
|
129
|
+
// Keep between-tool thinking inside the agent's active tool card instead of popping a temporary bubble.
|
|
130
|
+
if (!hasText && latest?.kind === 'tools') {
|
|
131
|
+
attached.set(latest.id, turn);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
liveRows.push({
|
|
135
|
+
kind: 'stream',
|
|
136
|
+
id: `stream_${threadId}`,
|
|
137
|
+
threadId,
|
|
138
|
+
turn: turn.turn,
|
|
139
|
+
text: turn.text,
|
|
140
|
+
thinking: turn.thinking,
|
|
141
|
+
thinkingStartedAt: turn.thinkingStartedAt,
|
|
142
|
+
thinkingEndedAt: turn.thinkingEndedAt,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const narratorRepliesByMessageId = new Map();
|
|
146
|
+
for (const item of feed.items) {
|
|
147
|
+
if (item.kind === 'agent' && item.replyTo) {
|
|
148
|
+
const list = narratorRepliesByMessageId.get(item.replyTo) ?? [];
|
|
149
|
+
list.push(item);
|
|
150
|
+
narratorRepliesByMessageId.set(item.replyTo, list);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// At the top level a narrator's reply sits under the message it answers. Inside the
|
|
154
|
+
// narrator's own thread there is no such message, so it shows in the timeline.
|
|
155
|
+
const visibleItems = openThreadId === undefined
|
|
156
|
+
? feed.items.filter((item) => !(item.kind === 'agent' && item.replyTo !== undefined))
|
|
157
|
+
: feed.items;
|
|
158
|
+
// A message waiting for an agent to finish its turn sits below that turn's live work.
|
|
159
|
+
const waiting = (item) => item.kind === 'user' && item.messageId in feed.queued;
|
|
160
|
+
return {
|
|
161
|
+
rows: [
|
|
162
|
+
...projectTimeline(visibleItems.filter((item) => !waiting(item)), parents, openThreadId),
|
|
163
|
+
...liveRows,
|
|
164
|
+
...(openThreadId === undefined ? visibleItems.filter(waiting) : []),
|
|
165
|
+
],
|
|
166
|
+
liveByToolCardId: attached,
|
|
167
|
+
inlineNarratorByMessageId: narratorRepliesByMessageId,
|
|
168
|
+
};
|
|
169
|
+
}, [feed.items, feed.narrators, feed.queued, streaming, parents, openThreadId]);
|
|
170
|
+
const repeats = useMemo(() => repeatedMessages(feed.items), [feed.items]);
|
|
171
|
+
// History replayed on load renders still; live arrivals settle in once, even if virtualization remounts them.
|
|
172
|
+
const [mountedAt] = useState(() => Date.now());
|
|
173
|
+
const animated = useRef(new Set());
|
|
174
|
+
const [thoughtOpen, setThoughtOpenState] = useState(() => new Map());
|
|
175
|
+
const setThoughtOpen = useCallback((key, open) => {
|
|
176
|
+
setThoughtOpenState((prev) => {
|
|
177
|
+
if (prev.get(key) === open) {
|
|
178
|
+
return prev;
|
|
179
|
+
}
|
|
180
|
+
const next = new Map(prev);
|
|
181
|
+
next.set(key, open);
|
|
182
|
+
return next;
|
|
183
|
+
});
|
|
184
|
+
}, []);
|
|
185
|
+
const onSettled = useCallback((id) => {
|
|
186
|
+
animated.current.add(id);
|
|
187
|
+
}, []);
|
|
188
|
+
const context = useMemo(() => ({
|
|
189
|
+
runId,
|
|
190
|
+
feed,
|
|
191
|
+
activity,
|
|
192
|
+
identities,
|
|
193
|
+
onInspect,
|
|
194
|
+
onOpenArtifact,
|
|
195
|
+
onOpenThread,
|
|
196
|
+
threadNodes,
|
|
197
|
+
repeats,
|
|
198
|
+
thoughtOpen,
|
|
199
|
+
setThoughtOpen,
|
|
200
|
+
liveByToolCardId,
|
|
201
|
+
inlineNarratorByMessageId,
|
|
202
|
+
streaming,
|
|
203
|
+
}), [
|
|
204
|
+
runId,
|
|
205
|
+
feed,
|
|
206
|
+
activity,
|
|
207
|
+
identities,
|
|
208
|
+
onInspect,
|
|
209
|
+
onOpenArtifact,
|
|
210
|
+
onOpenThread,
|
|
211
|
+
threadNodes,
|
|
212
|
+
repeats,
|
|
213
|
+
thoughtOpen,
|
|
214
|
+
setThoughtOpen,
|
|
215
|
+
liveByToolCardId,
|
|
216
|
+
inlineNarratorByMessageId,
|
|
217
|
+
streaming,
|
|
218
|
+
]);
|
|
219
|
+
return (_jsx(FollowList
|
|
220
|
+
// A different thread is a different timeline: start it at its latest, not mid-scroll.
|
|
221
|
+
, { items: rows, getKey: (row) => row.id, estimateSize: 72, overscan: 6, paddingStart: 16, paddingEnd: 28, viewportClassName: "conversation-fade", itemClassName: "px-4 sm:px-6", empty: openThreadId === undefined ? (_jsx(EmptyState, { icon: _jsx(MessageSquareDashed, {}), title: "Connecting to the session", children: "Events stream in from the Durable Object as soon as the run starts." })) : (_jsx(EmptyState, { icon: _jsx(MessageSquareDashed, {}), title: "Nothing here yet", children: "This agent has not said or done anything so far." })), renderItem: (row, index) => {
|
|
222
|
+
const previousThreadId = rowSpeakerThreadId(index > 0 ? rows[index - 1] : undefined);
|
|
223
|
+
return (_jsx("div", { className: "message-row mx-auto w-full max-w-3xl py-1.5", children: _jsx(RowView, { row: row, previousThreadId: previousThreadId, context: context, animate: ('ts' in row ? row.ts >= mountedAt : true) && !animated.current.has(row.id), onSettled: onSettled }) }));
|
|
224
|
+
} }, openThreadId ?? 'session'));
|
|
225
|
+
}
|
|
226
|
+
const RowView = memo(function RowView({ row, previousThreadId, context, animate, onSettled, }) {
|
|
227
|
+
// Keep the first decision for this mount so a re-render never cuts the entrance short.
|
|
228
|
+
const [entering] = useState(animate);
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
onSettled(row.id);
|
|
231
|
+
}, [onSettled, row.id]);
|
|
232
|
+
const className = entering ? 'rise-in' : undefined;
|
|
233
|
+
switch (row.kind) {
|
|
234
|
+
case 'user':
|
|
235
|
+
return (_jsx(UserMessage, { className: className, item: row, context: context, route: context.feed.routes[row.messageId], deliveries: context.feed.deliveries[row.messageId] ?? [], classifying: Boolean(context.feed.classifying[row.messageId]) }));
|
|
236
|
+
case 'agent':
|
|
237
|
+
return _jsx(AgentMessage, { className: className, item: row, context: context });
|
|
238
|
+
case 'thought':
|
|
239
|
+
return (_jsx(ThoughtWhisper, { className: className, item: row, showIdentity: previousThreadId !== row.threadId, context: context }));
|
|
240
|
+
case 'tools':
|
|
241
|
+
return (_jsx(ToolActivity, { className: className, item: row, showIdentity: previousThreadId !== row.threadId, context: context }));
|
|
242
|
+
case 'question':
|
|
243
|
+
return _jsx(QuestionCard, { className: className, item: row, context: context });
|
|
244
|
+
case 'notice':
|
|
245
|
+
return _jsx(Notice, { className: className, item: row, context: context });
|
|
246
|
+
case 'media':
|
|
247
|
+
return (_jsx(SharedMedia, { className: className, item: row, showIdentity: previousThreadId !== row.threadId, context: context }));
|
|
248
|
+
case 'delegation':
|
|
249
|
+
return _jsx(DelegationCard, { className: className, row: row, context: context });
|
|
250
|
+
case 'stream':
|
|
251
|
+
return (_jsx(AgentBubble, { className: className, identity: context.identities.get(row.threadId), threadId: row.threadId, turn: row.turn, text: row.text, thinking: row.thinking, thinkingStartedAt: row.thinkingStartedAt, thinkingEndedAt: row.thinkingEndedAt, streaming: true, context: context, onInspect: context.onInspect }));
|
|
252
|
+
default: {
|
|
253
|
+
const exhaustive = row;
|
|
254
|
+
return exhaustive;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
function humanize(text, identities) {
|
|
259
|
+
let result = text;
|
|
260
|
+
for (const identity of identities.values()) {
|
|
261
|
+
result = result.replaceAll(identity.threadId, identity.label);
|
|
262
|
+
}
|
|
263
|
+
return result;
|
|
264
|
+
}
|
|
265
|
+
function UserMessage({ item, route, deliveries, classifying, context, className, }) {
|
|
266
|
+
const me = useTenant().user.id;
|
|
267
|
+
return (_jsxs("div", { className: cn('group/user flex w-full flex-col gap-1.5', className), children: [_jsxs("div", { className: "flex flex-col items-end gap-1.5", children: [_jsxs("div", { className: "text-muted-foreground flex items-center gap-2 pr-1 text-[11px]", children: [_jsx("span", { className: "text-foreground/80 font-medium", children: item.goal ? 'Goal' : item.author && item.author.id !== me ? item.author.name : 'You' }), _jsx("span", { className: "message-time tabular-nums", children: clockTime(item.ts) })] }), item.text ? (_jsx("div", { className: cn('max-w-[85%] rounded-2xl rounded-tr-md px-3.5 py-2.5 text-[13.5px] leading-relaxed whitespace-pre-wrap', item.goal
|
|
268
|
+
? 'bg-brand/12 text-foreground ring-brand/25 ring-1 ring-inset'
|
|
269
|
+
: 'bg-secondary text-secondary-foreground'), children: item.text })) : null, item.attachments ? (_jsx(MediaStrip, { runId: context.runId, assets: item.attachments, align: "end", className: "max-w-[85%]" })) : null, item.goal ? null : (_jsx(RouteChip, { runId: context.runId, messageId: item.messageId, messageTs: item.ts, text: item.text, route: route, deliveries: deliveries, classifying: classifying, forcedKind: item.forced, identities: context.identities, context: context, onInspect: context.onInspect }))] }), !item.goal ? _jsx(InlineNarratorReplies, { messageId: item.messageId, context: context }) : null] }));
|
|
270
|
+
}
|
|
271
|
+
function InlineNarratorReplies({ messageId, context, }) {
|
|
272
|
+
const narratorThreadId = context.feed.narratorFor[messageId];
|
|
273
|
+
const settled = context.inlineNarratorByMessageId.get(messageId) ?? [];
|
|
274
|
+
const streamTurn = narratorThreadId ? context.streaming[narratorThreadId] : undefined;
|
|
275
|
+
const hasStream = streamTurn !== undefined &&
|
|
276
|
+
(streamTurn.thinking.trim().length > 0 || streamTurn.text.trim().length > 0);
|
|
277
|
+
if (settled.length === 0 && !hasStream) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
return (_jsxs("div", { className: "mt-1 w-full space-y-2", children: [settled.map((item) => (_jsx(AgentBubble, { identity: context.identities.get(item.threadId), threadId: item.threadId, turn: item.thought?.turn, text: item.text, thought: item.thought, ts: item.ts, seq: item.seq, repeat: context.repeats.has(item.id), context: context, onInspect: context.onInspect }, item.id))), hasStream && narratorThreadId && streamTurn ? (_jsx(AgentBubble, { identity: context.identities.get(narratorThreadId), threadId: narratorThreadId, turn: streamTurn.turn, text: streamTurn.text, thinking: streamTurn.thinking, thinkingStartedAt: streamTurn.thinkingStartedAt, thinkingEndedAt: streamTurn.thinkingEndedAt, streaming: true, context: context, onInspect: context.onInspect })) : null] }));
|
|
281
|
+
}
|
|
282
|
+
function RouteWaitFallbackRow({ runId, wait, identities, onInspect, }) {
|
|
283
|
+
const api = useApi();
|
|
284
|
+
const stop = useMutation(api.sessions.stop.mutationOptions());
|
|
285
|
+
const pending = stop.isPending;
|
|
286
|
+
const label = identities.get(wait.threadId)?.label ?? 'worker';
|
|
287
|
+
return (_jsxs("span", { className: "text-muted-foreground inline-flex max-w-full flex-wrap items-center justify-end gap-2 pr-1 text-[11px]", children: [_jsxs("button", { type: "button", onClick: () => onInspect(wait.threadId), className: "hover:text-foreground text-left", children: ["Waiting for ", label, " to finish", ' ', _jsx("span", { className: "text-foreground/90 font-mono", children: wait.toolName }), _jsxs("span", { className: "tabular-nums", children: [" \u00B7 ", formatSeconds(wait.elapsedMs)] })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: pending, className: "h-6 gap-1 px-2 text-[11px]", onClick: () => stop.mutate({ id: runId, threadId: wait.threadId }), children: [pending ? (_jsx(LoaderCircle, { className: "size-3 animate-spin" })) : (_jsx(CircleStop, { className: "size-3" })), "Stop"] })] }));
|
|
288
|
+
}
|
|
289
|
+
/** Owns the 1s clock so only unrouted messages re-render while waiting. */
|
|
290
|
+
function PendingRouteChip({ runId, messageTs, text, classifying, forcedKind, identities, context, onInspect, }) {
|
|
291
|
+
const now = useNow(1_000);
|
|
292
|
+
const waitFallback = deriveRouteWaitFallback({
|
|
293
|
+
messageTs,
|
|
294
|
+
hasRoute: false,
|
|
295
|
+
now,
|
|
296
|
+
activity: context.activity,
|
|
297
|
+
feed: context.feed,
|
|
298
|
+
});
|
|
299
|
+
const provisionalKind = forcedKind ?? classifyHeuristic(text);
|
|
300
|
+
const style = routeStyles[provisionalKind];
|
|
301
|
+
const Icon = style.icon;
|
|
302
|
+
return (_jsxs("div", { className: "flex max-w-[85%] flex-col items-end gap-1.5", children: [_jsxs("span", { className: cn('inline-flex h-6 items-center gap-1.5 rounded-full bg-current/10 px-2 text-[11px] font-medium ring-1 ring-current/15 ring-inset', style.tone), title: style.description, children: [classifying ? (_jsx(LoaderCircle, { className: "size-3 animate-spin" })) : (_jsx(Icon, { className: "size-3" })), _jsxs("span", { children: [style.label, _jsxs("span", { className: "opacity-70", children: [" \u00B7 ", provisionalRouteSummary(provisionalKind)] })] })] }), waitFallback ? (_jsx(RouteWaitFallbackRow, { runId: runId, wait: waitFallback, identities: identities, onInspect: onInspect })) : null] }));
|
|
303
|
+
}
|
|
304
|
+
function RunningElapsed({ startedAt }) {
|
|
305
|
+
const now = useNow(1_000);
|
|
306
|
+
return (_jsx("span", { className: "text-status-running ml-auto shrink-0 tabular-nums", children: formatSeconds(Math.max(0, now - startedAt)) }));
|
|
307
|
+
}
|
|
308
|
+
function RouteChip({ runId, messageId, messageTs, text, route, deliveries, classifying, forcedKind, identities, context, onInspect, }) {
|
|
309
|
+
const host = useShuttleHost();
|
|
310
|
+
// What becomes of a reroute shows on the feed, as the message's new route.
|
|
311
|
+
const sendReroute = useMutation({
|
|
312
|
+
mutationFn: (kind) => reroute(host, runId, messageId, kind),
|
|
313
|
+
});
|
|
314
|
+
if (!route) {
|
|
315
|
+
return (_jsx(PendingRouteChip, { runId: runId, messageTs: messageTs, text: text, classifying: classifying, forcedKind: forcedKind, identities: identities, context: context, onInspect: onInspect }));
|
|
316
|
+
}
|
|
317
|
+
const style = routeStyles[route.kind];
|
|
318
|
+
const Icon = style.icon;
|
|
319
|
+
const targets = [...new Map(deliveries.map((entry) => [entry.threadId, entry])).values()];
|
|
320
|
+
const forced = forcedKind !== undefined;
|
|
321
|
+
return (_jsxs("div", { className: "flex max-w-[85%] flex-wrap items-center justify-end gap-1.5 text-[11px]", children: [_jsxs("span", { className: cn('inline-flex h-6 items-center gap-1.5 rounded-full bg-current/10 px-2 font-medium ring-1 ring-current/15 ring-inset', style.tone), title: style.description, children: [_jsx(Icon, { className: "size-3" }), style.label, forced ? _jsx("span", { className: "opacity-60", children: "\u00B7 forced" }) : null] }), targets.length > 0 ? (targets.map((delivery) => {
|
|
322
|
+
const identity = identities.get(delivery.threadId);
|
|
323
|
+
const label = identity?.label ?? 'agent';
|
|
324
|
+
const waiting = context.feed.queued[messageId] === delivery.threadId;
|
|
325
|
+
return (_jsxs("button", { type: "button", onClick: () => onInspect(delivery.threadId), className: "text-muted-foreground hover:text-foreground hover:bg-accent inline-flex h-6 items-center gap-1 rounded-full border px-2 transition-colors duration-100", title: delivery.interrupt
|
|
326
|
+
? 'Interrupted the current turn'
|
|
327
|
+
: waiting
|
|
328
|
+
? `${label} reads this when it finishes its current turn`
|
|
329
|
+
: 'Queued for the next step', children: [_jsx(ArrowRight, { className: "size-3" }), label, delivery.interrupt ? (_jsx("span", { className: "text-route-correction font-medium", children: "interrupt" })) : waiting ? (_jsx("span", { className: "opacity-70", children: "\u00B7 after this turn" })) : null] }, delivery.threadId));
|
|
330
|
+
})) : (_jsx("span", { className: "text-muted-foreground px-1", children: humanize(route.summary, identities) })), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "Reroute message", className: "text-muted-foreground hover:text-foreground hover:bg-accent data-[state=open]:bg-accent flex size-6 items-center justify-center rounded-full opacity-0 transition-opacity duration-150 group-hover/user:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100", children: _jsx(Shuffle, { className: "size-3" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsx(DropdownMenuLabel, { children: "Reroute as\u2026" }), interjectionKinds
|
|
331
|
+
.filter((kind) => kind !== route.kind)
|
|
332
|
+
.map((kind) => (_jsxs(DropdownMenuItem, { onSelect: () => sendReroute.mutate(kind), children: [_jsx("span", { className: cn('size-1.5 rounded-full', routeStyles[kind].dot) }), routeStyles[kind].label, _jsx("span", { className: "text-muted-foreground ml-auto pl-3 text-[11px]", children: routeStyles[kind].description })] }, kind)))] })] })] }));
|
|
333
|
+
}
|
|
334
|
+
function AgentAvatar({ identity, threadId }) {
|
|
335
|
+
const role = identity?.role ?? agentRole(undefined);
|
|
336
|
+
const Icon = role.icon;
|
|
337
|
+
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" }) }));
|
|
338
|
+
}
|
|
339
|
+
function ThinkingTrace({ text, durationMs, activelyThinking, open, onToggle, }) {
|
|
340
|
+
const label = activelyThinking ? 'Thinking…' : formatThoughtLabel(durationMs);
|
|
341
|
+
const liveSnippet = activelyThinking && !open ? latestThoughtLine(text) : '';
|
|
342
|
+
return (_jsxs("div", { className: "mt-1 min-w-0", children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: onToggle, className: "text-muted-foreground/80 hover:text-foreground inline-flex max-w-full min-w-0 items-center gap-1 text-left text-[11.5px] transition-colors duration-100", children: [_jsx(ChevronRight, { className: cn('ease-snappy size-3 shrink-0 transition-transform duration-150', open && 'rotate-90') }), _jsx("span", { className: cn('shrink-0 whitespace-nowrap tabular-nums', activelyThinking && 'text-status-running breathe'), children: label }), liveSnippet ? (_jsx("span", { className: "text-muted-foreground/65 min-w-0 truncate pl-1", children: liveSnippet })) : null] }), open ? (_jsx("div", { className: "thinking-trace-body border-border/80 mt-1.5 mb-1 max-h-52 overflow-y-auto border-l py-0.5 pl-3", children: _jsx(Markdown, { text: text, className: "text-muted-foreground text-[12.5px] leading-relaxed" }) })) : null] }));
|
|
343
|
+
}
|
|
344
|
+
function AgentBubble({ identity, threadId, turn, text, thinking, thought, thinkingStartedAt, thinkingEndedAt, ts, seq, replyTo, streaming = false, repeat = false, context, onInspect, className, }) {
|
|
345
|
+
const thinkingText = (thinking ?? thought?.text ?? '').trim();
|
|
346
|
+
const replyText = text.trim();
|
|
347
|
+
const activelyThinking = streaming && thinkingText.length > 0 && replyText.length === 0;
|
|
348
|
+
const status = streaming && replyText.length > 0 ? 'typing' : null;
|
|
349
|
+
const durationMs = thought?.durationMs ??
|
|
350
|
+
(thinkingStartedAt !== undefined && thinkingEndedAt !== undefined
|
|
351
|
+
? Math.max(0, thinkingEndedAt - thinkingStartedAt)
|
|
352
|
+
: undefined);
|
|
353
|
+
const key = turn !== undefined
|
|
354
|
+
? thoughtKey(threadId, turn)
|
|
355
|
+
: thought
|
|
356
|
+
? thoughtKey(threadId, thought.turn)
|
|
357
|
+
: null;
|
|
358
|
+
const open = key && context ? Boolean(context.thoughtOpen.get(key)) : false;
|
|
359
|
+
// A finished thought of a second or so is routine, and is left out.
|
|
360
|
+
const [repeatShown, setRepeatShown] = useState(false);
|
|
361
|
+
const folded = repeat && !repeatShown;
|
|
362
|
+
const briefThought = !activelyThinking && durationMs !== undefined && durationMs < 2000;
|
|
363
|
+
return (_jsxs("div", { className: cn('flex gap-3', className), children: [_jsx(AgentAvatar, { identity: identity, threadId: threadId }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-[11px]", children: [_jsx("button", { type: "button", onClick: () => onInspect(threadId, seq), className: "text-foreground/90 hover:text-foreground shrink-0 font-medium whitespace-nowrap hover:underline", children: identity?.label ?? 'Agent' }), ts !== undefined ? (_jsx("span", { className: "message-time shrink-0 whitespace-nowrap tabular-nums", children: clockTime(ts) })) : null, status ? (_jsx("span", { className: "text-status-running shrink-0 whitespace-nowrap", children: status })) : null] }), folded ? (_jsxs("button", { type: "button", onClick: () => setRepeatShown(true), "aria-expanded": false, className: "text-muted-foreground/80 hover:text-foreground mt-1 inline-flex max-w-full items-center gap-1 text-left text-[12.5px] transition-colors duration-100", children: [_jsx(ChevronRight, { className: "size-3 shrink-0" }), _jsx("span", { className: "truncate", children: "Same reply as before" })] })) : null, replyTo && !folded ? (_jsxs("p", { className: "text-muted-foreground mt-1 flex items-center gap-1 truncate text-[11px]", children: [_jsx(CornerDownRight, { className: "size-3 shrink-0" }), _jsx("span", { className: "truncate italic", children: replyTo })] })) : null, thinkingText && key && context && !folded && !briefThought ? (_jsx(ThinkingTrace, { text: thinkingText, durationMs: activelyThinking ? undefined : durationMs, activelyThinking: activelyThinking, open: open, onToggle: () => context.setThoughtOpen(key, !open) })) : null, replyText && !folded ? (_jsx(Markdown, { text: text, className: cn('text-foreground/95 mt-1 text-[13.5px] leading-relaxed', streaming && 'caret') })) : null, replyText && !streaming && !folded && context?.onOpenArtifact ? (_jsx(PreviewLinks, { text: text ?? '', onOpen: context.onOpenArtifact })) : null] })] }));
|
|
364
|
+
}
|
|
365
|
+
/** A quiet button under a message that opens what the message is about in the artifacts pane. */
|
|
366
|
+
function ArtifactLink({ icon, onOpen, children, }) {
|
|
367
|
+
return (_jsxs("button", { type: "button", onClick: onOpen, className: "text-muted-foreground hover:text-foreground hover:bg-accent/60 bg-card/60 ease-snappy inline-flex h-7 max-w-full items-center gap-1.5 rounded-lg border px-2.5 text-[12px] transition-[background-color,color,transform] duration-150 active:scale-[0.97] [&_svg]:size-3.5 [&_svg]:shrink-0", children: [icon, _jsx("span", { className: "min-w-0 truncate", children: children }), _jsx(ArrowRight, { className: "opacity-60" })] }));
|
|
368
|
+
}
|
|
369
|
+
/** Links to the previews a message says are running. */
|
|
370
|
+
function PreviewLinks({ text, onOpen }) {
|
|
371
|
+
const ports = useMemo(() => previewPorts(text), [text]);
|
|
372
|
+
if (ports.length === 0) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
return (_jsx("div", { className: "mt-2 flex flex-wrap gap-1.5", children: ports.map((port) => (_jsxs(ArtifactLink, { icon: _jsx(Globe, {}), onOpen: () => onOpen('browser', port), children: ["Open preview on port ", _jsx("span", { className: "tabular-nums", children: port })] }, port))) }));
|
|
376
|
+
}
|
|
377
|
+
function AgentMessage({ item, context, className, }) {
|
|
378
|
+
const replyTo = item.replyTo ? context.feed.messageText[item.replyTo] : undefined;
|
|
379
|
+
return (_jsx(AgentBubble, { className: className, identity: context.identities.get(item.threadId), threadId: item.threadId, turn: item.thought?.turn, text: item.text, thought: item.thought, ts: item.ts, seq: item.seq, replyTo: replyTo, repeat: context.repeats.has(item.id), context: context, onInspect: context.onInspect }));
|
|
380
|
+
}
|
|
381
|
+
/** Files an agent shared, shown in the conversation under the agent's name. */
|
|
382
|
+
function SharedMedia({ item, showIdentity, context, className, }) {
|
|
383
|
+
const identity = context.identities.get(item.threadId);
|
|
384
|
+
const count = item.assets.length;
|
|
385
|
+
return (_jsxs("div", { className: cn('flex flex-col gap-1.5 pl-10', className), children: [_jsxs("div", { className: "text-muted-foreground flex min-w-0 items-center gap-1.5 text-[11.5px]", children: [showIdentity ? (_jsx("button", { type: "button", onClick: () => context.onInspect(item.threadId, item.seq), className: cn('shrink-0 font-medium whitespace-nowrap hover:underline', identity?.role.tone), children: identity?.label ?? 'Agent' })) : null, _jsxs("span", { children: ["shared ", count === 1 ? 'a file' : `${count} files`] }), _jsx("span", { className: "message-time tabular-nums", children: clockTime(item.ts) }), context.onOpenArtifact ? (_jsx("button", { type: "button", onClick: () => context.onOpenArtifact?.('media'), className: "hover:text-foreground ml-auto shrink-0 hover:underline", children: "All media" })) : null] }), _jsx(MediaStrip, { runId: context.runId, assets: item.assets })] }));
|
|
386
|
+
}
|
|
387
|
+
/** Borderless fallback for the rare case where a turn settles with only a thought. */
|
|
388
|
+
function ThoughtWhisper({ item, showIdentity, context, className, }) {
|
|
389
|
+
const identity = context.identities.get(item.threadId);
|
|
390
|
+
const key = thoughtKey(item.threadId, item.turn);
|
|
391
|
+
const open = Boolean(context.thoughtOpen.get(key));
|
|
392
|
+
const label = formatThoughtLabel(item.durationMs);
|
|
393
|
+
return (_jsxs("div", { className: cn('pl-10', className), children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1.5 py-0.5 text-[11.5px]", children: [showIdentity ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => context.onInspect(item.threadId, item.seq), className: cn('shrink-0 font-medium whitespace-nowrap hover:underline', identity?.role.tone), children: identity?.label ?? 'Agent' }), _jsx("span", { className: "text-muted-foreground/40 shrink-0 select-none", children: "\u00B7" })] })) : null, _jsxs("button", { type: "button", "aria-expanded": open, onClick: () => context.setThoughtOpen(key, !open), className: "text-muted-foreground/80 hover:text-foreground inline-flex min-w-0 items-center gap-1 text-left transition-colors duration-100", children: [_jsx(ChevronRight, { className: cn('ease-snappy size-3 shrink-0 transition-transform duration-150', open && 'rotate-90') }), _jsx("span", { className: "shrink-0 whitespace-nowrap tabular-nums", children: label })] })] }), open ? (_jsx("div", { className: "thinking-trace-body border-border/80 mt-1 ml-1 max-h-52 overflow-y-auto border-l py-0.5 pl-3", children: _jsx(Markdown, { text: item.text, className: "text-muted-foreground text-[12.5px] leading-relaxed" }) })) : null] }));
|
|
394
|
+
}
|
|
395
|
+
function toolArgsPreview(call) {
|
|
396
|
+
const fields = jsonFields(call.args);
|
|
397
|
+
const primary = fields.path ?? fields.command ?? fields.pattern ?? fields.text ?? fields.goal;
|
|
398
|
+
return jsonText(primary) ?? compactJson(call.args, 80);
|
|
399
|
+
}
|
|
400
|
+
function ToolStatusIcon({ status }) {
|
|
401
|
+
switch (status) {
|
|
402
|
+
case 'running':
|
|
403
|
+
return _jsx(LoaderCircle, { className: "text-status-running size-3 shrink-0 animate-spin" });
|
|
404
|
+
case 'ok':
|
|
405
|
+
return _jsx(Check, { className: "text-status-completed size-3 shrink-0" });
|
|
406
|
+
case 'error':
|
|
407
|
+
return _jsx(X, { className: "text-status-failed size-3 shrink-0" });
|
|
408
|
+
default: {
|
|
409
|
+
const exhaustive = status;
|
|
410
|
+
return exhaustive;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function sumThoughtDuration(thoughts) {
|
|
415
|
+
let total = 0;
|
|
416
|
+
let any = false;
|
|
417
|
+
for (const thought of thoughts) {
|
|
418
|
+
if (thought.durationMs !== undefined) {
|
|
419
|
+
total += thought.durationMs;
|
|
420
|
+
any = true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return any ? total : undefined;
|
|
424
|
+
}
|
|
425
|
+
function ToolActivity({ item, showIdentity, context, className, }) {
|
|
426
|
+
const identity = context.identities.get(item.threadId);
|
|
427
|
+
const liveTurn = context.liveByToolCardId.get(item.id);
|
|
428
|
+
const liveThinking = liveTurn?.thinking.trim() ?? '';
|
|
429
|
+
const hasThoughts = item.thoughts.length > 0;
|
|
430
|
+
const showThoughtHeader = hasThoughts || liveThinking.length > 0;
|
|
431
|
+
const showIdentityInCard = showIdentity && !showThoughtHeader;
|
|
432
|
+
const thoughtToggleKey = `tools_thought:${item.id}`;
|
|
433
|
+
const thoughtExpanded = Boolean(context.thoughtOpen.get(thoughtToggleKey));
|
|
434
|
+
const totalThoughtDurationMs = sumThoughtDuration(item.thoughts);
|
|
435
|
+
const changed = useMemo(() => changedPaths(item.calls), [item.calls]);
|
|
436
|
+
const runningCalls = item.calls.filter((call) => call.status === 'running');
|
|
437
|
+
const running = runningCalls.length;
|
|
438
|
+
const lastRunningCall = runningCalls.at(-1);
|
|
439
|
+
const failed = item.calls.filter((call) => call.status === 'error').length;
|
|
440
|
+
// A burst shows as its one-line summary until the reader opens it.
|
|
441
|
+
const [open, setOpen] = useState(false);
|
|
442
|
+
const summary = running > 0
|
|
443
|
+
? `running ${lastRunningCall?.name ?? 'tool'}…`
|
|
444
|
+
: `used ${item.calls.length} tool${item.calls.length === 1 ? '' : 's'}`;
|
|
445
|
+
const collapsedDetail = !open && lastRunningCall ? toolArgsPreview(lastRunningCall) : '';
|
|
446
|
+
return (_jsxs("div", { className: cn('pl-10', className), children: [showThoughtHeader ? (_jsxs("div", { className: "mb-1.5 flex min-w-0 items-center gap-1.5 text-[11.5px]", children: [showIdentity ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => context.onInspect(item.threadId, item.seq), className: cn('shrink-0 font-medium whitespace-nowrap hover:underline', identity?.role.tone), children: identity?.label ?? 'Agent' }), _jsx("span", { className: "text-muted-foreground/40 shrink-0 select-none", children: "\u00B7" })] })) : null, _jsxs("button", { type: "button", "aria-expanded": thoughtExpanded, onClick: () => context.setThoughtOpen(thoughtToggleKey, !thoughtExpanded), className: "text-muted-foreground/80 hover:text-foreground inline-flex min-w-0 items-center gap-1 text-left transition-colors duration-100", children: [_jsx(ChevronRight, { className: cn('ease-snappy size-3 shrink-0 transition-transform duration-150', thoughtExpanded && 'rotate-90') }), _jsx("span", { className: cn('shrink-0 whitespace-nowrap tabular-nums', liveThinking && 'text-status-running breathe'), children: liveThinking ? 'Thinking…' : formatThoughtLabel(totalThoughtDurationMs) }), liveThinking && !thoughtExpanded ? (_jsx("span", { className: "text-muted-foreground/60 min-w-0 truncate pl-1", children: latestThoughtLine(liveThinking) })) : null] })] })) : null, thoughtExpanded && showThoughtHeader ? (_jsxs("div", { className: "thinking-trace-body border-border/80 mb-2 ml-1 max-h-56 space-y-2.5 overflow-y-auto border-l py-0.5 pl-3", children: [item.thoughts.map((thought) => (_jsx(Markdown, { text: thought.text, className: "text-muted-foreground text-[12.5px] leading-relaxed" }, thought.id))), liveThinking ? (_jsx(Markdown, { text: liveThinking, className: "text-muted-foreground text-[12.5px] leading-relaxed" })) : null] })) : null, _jsxs("div", { className: "bg-card/60 rounded-lg border text-xs", children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), className: cn('hover:bg-accent/40 flex h-8 w-full min-w-0 items-center gap-2 px-2.5 text-left transition-colors duration-100', open ? 'rounded-t-lg' : 'rounded-lg'), children: [_jsx(ChevronRight, { className: cn('text-muted-foreground ease-snappy size-3 shrink-0 transition-transform duration-150', open && 'rotate-90') }), showIdentityInCard ? (_jsx("span", { className: cn('shrink-0 font-medium whitespace-nowrap', identity?.role.tone), children: identity?.label ?? 'Agent' })) : null, _jsx("span", { className: "text-muted-foreground min-w-0 truncate", children: summary }), collapsedDetail ? (_jsx("span", { className: "text-muted-foreground/60 min-w-0 truncate font-mono text-[11px]", children: collapsedDetail })) : null, failed > 0 ? (_jsxs("span", { className: "text-status-failed ml-auto inline-flex shrink-0 items-center gap-1 whitespace-nowrap", children: [_jsx(TriangleAlert, { className: "size-3 shrink-0" }), failed, " failed"] })) : null] }), open ? (_jsx("ul", { className: "border-t px-1 py-1", children: item.calls.map((call) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => context.onInspect(item.threadId, call.seq), className: "hover:bg-accent/50 flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-2 text-left transition-colors duration-100", title: call.error ?? compactJson(call.args, 400), children: [_jsx(ToolStatusIcon, { status: call.status }), _jsx("span", { className: "text-foreground shrink-0 font-mono text-[11px] whitespace-nowrap", children: call.name }), _jsx("span", { className: "text-muted-foreground min-w-0 truncate font-mono text-[11px]", children: call.error ?? toolArgsPreview(call) }), call.status === 'running' && call.startedAt !== undefined ? (_jsx(RunningElapsed, { startedAt: call.startedAt })) : null] }) }, call.toolCallId))) })) : null] }), changed.length > 0 && context.onOpenArtifact ? (_jsx("div", { className: "mt-1.5", children: _jsx(ArtifactLink, { icon: _jsx(FileDiff, {}), onOpen: () => context.onOpenArtifact?.('files'), children: changed.length === 1
|
|
447
|
+
? `Changed ${changed[0]?.split('/').pop() ?? '1 file'}`
|
|
448
|
+
: `Changed ${changed.length.toLocaleString()} files` }) })) : null] }));
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* An agent's delegated work as one row: who did it, what it came to, and whether it is still
|
|
452
|
+
* going. Opening it shows that agent's own timeline.
|
|
453
|
+
*/
|
|
454
|
+
function DelegationCard({ row, context, className, }) {
|
|
455
|
+
const identity = context.identities.get(row.threadId);
|
|
456
|
+
const node = context.threadNodes.get(row.threadId);
|
|
457
|
+
const tone = node ? resolveThreadActivityTone(context.activity, node) : 'idle';
|
|
458
|
+
const label = identity?.label ?? 'Agent';
|
|
459
|
+
const facts = [
|
|
460
|
+
row.agents > 1 ? `${row.agents.toLocaleString()} agents` : null,
|
|
461
|
+
row.toolCalls > 0
|
|
462
|
+
? `${row.toolCalls.toLocaleString()} ${row.toolCalls === 1 ? 'step' : 'steps'}`
|
|
463
|
+
: null,
|
|
464
|
+
row.changedFiles > 0
|
|
465
|
+
? `${row.changedFiles.toLocaleString()} ${row.changedFiles === 1 ? 'file' : 'files'} changed`
|
|
466
|
+
: null,
|
|
467
|
+
].filter((fact) => fact !== null);
|
|
468
|
+
return (_jsx("div", { className: cn('pl-10', className), children: _jsxs("button", { type: "button", onClick: () => context.onOpenThread(row.threadId), "aria-label": `Open ${label}'s work`, className: "group/delegation bg-card/60 hover:bg-accent/50 ease-snappy flex w-full min-w-0 items-center gap-2.5 rounded-xl border px-3 py-2 text-left transition-[background-color,transform] duration-150 active:scale-[0.995]", children: [_jsx(AgentAvatar, { identity: identity, threadId: row.threadId }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2 text-[12px]", children: [_jsx("span", { className: "text-foreground/90 shrink-0 font-medium", children: label }), _jsx(StatusDot, { status: tone }), tone === 'idle' || tone === 'completed' ? null : (_jsx("span", { className: cn('shrink-0 text-[11px]', statusClass(tone)), children: statusLabel(tone) })), _jsx("span", { className: "text-muted-foreground min-w-0 truncate text-[11.5px] tabular-nums", children: facts.join(' · ') }), row.failed > 0 ? (_jsxs("span", { className: "text-status-failed inline-flex shrink-0 items-center gap-1 text-[11.5px] tabular-nums", children: [_jsx(TriangleAlert, { className: "size-3" }), row.failed.toLocaleString(), " failed"] })) : null] }), row.lastText ? (_jsx("span", { className: "text-muted-foreground truncate text-[12px]", dir: "auto", children: cleanSnippet(row.lastText.split('\n').find((line) => line.trim()) ?? '') })) : null] }), _jsx(ChevronRight, { className: "text-muted-foreground group-hover/delegation:text-foreground size-3.5 shrink-0 transition-colors duration-100" })] }) }));
|
|
469
|
+
}
|
|
470
|
+
function QuestionCard({ item, context, className, }) {
|
|
471
|
+
if (item.approvalId.startsWith('pr_publish_')) {
|
|
472
|
+
return _jsx(PullPublishCard, { item: item, context: context, className: className });
|
|
473
|
+
}
|
|
474
|
+
if (item.approvalId.startsWith('pr_review_')) {
|
|
475
|
+
return _jsx(PullReviewCard, { item: item, context: context, className: className });
|
|
476
|
+
}
|
|
477
|
+
return _jsx(AskUserCard, { item: item, context: context, className: className });
|
|
478
|
+
}
|
|
479
|
+
function AskUserCard({ item, context, className, }) {
|
|
480
|
+
const host = useShuttleHost();
|
|
481
|
+
const identity = context.identities.get(item.threadId);
|
|
482
|
+
const [draft, setDraft] = useState('');
|
|
483
|
+
// `null` leaves the question to the agent's judgment.
|
|
484
|
+
const answer = useMutation({
|
|
485
|
+
mutationFn: (text) => answerQuestion(host, context.runId, item.approvalId, text),
|
|
486
|
+
});
|
|
487
|
+
// Once the session has the answer the card stays locked: the feed replaces it with the outcome.
|
|
488
|
+
const pending = answer.isPending || answer.isSuccess ? (answer.variables === null ? 'defer' : 'answer') : null;
|
|
489
|
+
const error = answer.error?.message;
|
|
490
|
+
const key = item.thought ? thoughtKey(item.threadId, item.thought.turn) : null;
|
|
491
|
+
const thoughtExpanded = key ? Boolean(context.thoughtOpen.get(key)) : false;
|
|
492
|
+
return (_jsxs("div", { className: cn('flex gap-3', className), 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' : 'bg-brand/6 border-brand/30'), children: [_jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-[11px]", children: [_jsx(MessageCircleQuestion, { className: cn('size-3.5 shrink-0', item.decision ? undefined : 'text-brand') }), _jsxs("button", { type: "button", onClick: () => context.onInspect(item.threadId, item.seq), className: "text-foreground/90 hover:text-foreground shrink-0 font-medium whitespace-nowrap hover:underline", children: [identity?.label ?? 'Agent', " asks"] }), _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 whitespace-nowrap", children: "Waiting on you" }))] }), item.thought && key ? (_jsx(ThinkingTrace, { text: item.thought.text, durationMs: item.thought.durationMs, activelyThinking: false, open: thoughtExpanded, onToggle: () => context.setThoughtOpen(key, !thoughtExpanded) })) : null, _jsx("p", { className: "text-foreground/95 mt-1.5 text-[13.5px] leading-relaxed whitespace-pre-wrap", children: humanize(item.title, context.identities) }), item.decision ? (_jsxs("p", { className: "text-muted-foreground mt-2.5 flex items-start gap-1.5 border-t pt-2.5 text-xs", children: [_jsx(CornerDownRight, { className: "mt-0.5 size-3 shrink-0" }), item.decision.answer === null ? (_jsx("span", { className: "italic", children: "Left to the agent's judgment" })) : (_jsx("span", { className: "text-foreground/90 whitespace-pre-wrap", children: item.decision.answer }))] })) : (_jsxs("form", { className: "mt-3 flex flex-col gap-2", onSubmit: (event) => {
|
|
493
|
+
event.preventDefault();
|
|
494
|
+
if (draft.trim()) {
|
|
495
|
+
answer.mutate(draft.trim());
|
|
496
|
+
}
|
|
497
|
+
}, children: [_jsx(Textarea, { value: draft, onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
|
|
498
|
+
if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing) {
|
|
499
|
+
event.preventDefault();
|
|
500
|
+
event.currentTarget.form?.requestSubmit();
|
|
501
|
+
}
|
|
502
|
+
}, placeholder: "Type your answer\u2026", disabled: pending !== null, className: "max-h-40 min-h-10 resize-none" }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [error ? _jsx("span", { className: "text-status-failed mr-auto text-xs", children: error }) : null, _jsxs(Button, { type: "button", variant: "ghost", size: "sm", disabled: pending !== null, onClick: () => answer.mutate(null), children: [pending === 'defer' ? _jsx(LoaderCircle, { className: "animate-spin" }) : null, "Use your judgment"] }), _jsxs(Button, { type: "submit", variant: "brand", size: "sm", disabled: pending !== null || !draft.trim(), children: [pending === 'answer' ? _jsx(LoaderCircle, { className: "animate-spin" }) : null, "Answer"] })] })] }))] })] }));
|
|
503
|
+
}
|
|
504
|
+
function PullReviewCard({ item, context, className, }) {
|
|
505
|
+
const host = useShuttleHost();
|
|
506
|
+
const identity = context.identities.get(item.threadId);
|
|
507
|
+
const drafts = context.feed.draftReviewComments;
|
|
508
|
+
const [summary, setSummary] = useState(item.title.replace(/^Submit pull request review\?\s*/i, '') || item.title);
|
|
509
|
+
const [verdict, setVerdict] = useState('comment');
|
|
510
|
+
const [enabled, setEnabled] = useState(() => Object.fromEntries(drafts.map((comment) => [comment.commentId, true])));
|
|
511
|
+
const decide = useMutation({
|
|
512
|
+
mutationFn: (actionId) => actionId === 'discard'
|
|
513
|
+
? decideStructuredApproval(host, context.runId, item.approvalId, {
|
|
514
|
+
actionId: 'discard',
|
|
515
|
+
outcome: 'reject',
|
|
516
|
+
})
|
|
517
|
+
: decideStructuredApproval(host, context.runId, item.approvalId, {
|
|
518
|
+
actionId: 'submit',
|
|
519
|
+
outcome: 'approve',
|
|
520
|
+
payload: {
|
|
521
|
+
summary,
|
|
522
|
+
verdict,
|
|
523
|
+
comments: drafts
|
|
524
|
+
.filter((comment) => enabled[comment.commentId] !== false)
|
|
525
|
+
.map((comment) => ({
|
|
526
|
+
path: comment.path,
|
|
527
|
+
line: comment.line,
|
|
528
|
+
side: comment.side,
|
|
529
|
+
body: comment.body,
|
|
530
|
+
})),
|
|
531
|
+
},
|
|
532
|
+
}),
|
|
533
|
+
});
|
|
534
|
+
// Once the session has the decision the card stays locked: the feed replaces it with the outcome.
|
|
535
|
+
const pending = decide.isPending || decide.isSuccess;
|
|
536
|
+
const error = decide.error?.message;
|
|
537
|
+
return (_jsxs("div", { className: cn('flex gap-3', className), 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 items-center gap-2 text-[11px]", children: [_jsx(GitPullRequest, { className: cn('size-3.5 shrink-0', item.decision ? undefined : 'text-brand') }), _jsx("span", { className: "text-foreground/90 font-medium", children: "Submit review" }), _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("p", { className: "text-muted-foreground mt-2 text-xs", children: item.decision.answer === null ? 'Discarded' : item.decision.answer })) : (_jsxs("div", { className: "mt-3 flex flex-col gap-2", children: [_jsx(Textarea, { value: summary, onChange: (event) => setSummary(event.target.value), disabled: pending, className: "min-h-20 resize-none text-[13px]" }), drafts.length > 0 ? (_jsx("ul", { className: "flex flex-col gap-1.5", children: drafts.map((comment) => (_jsxs("li", { className: "bg-background/60 flex items-start gap-2 rounded-md border px-2 py-1.5 text-[11px]", children: [_jsx("input", { type: "checkbox", checked: enabled[comment.commentId] !== false, disabled: pending, onChange: (event) => setEnabled((prev) => ({
|
|
538
|
+
...prev,
|
|
539
|
+
[comment.commentId]: event.target.checked,
|
|
540
|
+
})), className: "mt-0.5 size-3" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("p", { className: "text-muted-foreground font-mono", children: [comment.path, ":", comment.line, " \u00B7 ", comment.severity] }), _jsx("p", { className: "text-foreground/90 mt-0.5 whitespace-pre-wrap", children: comment.body })] })] }, comment.commentId))) })) : null, _jsx("div", { className: "flex flex-wrap gap-2", children: ['comment', 'approve', 'request_changes'].map((option) => (_jsx(Button, { type: "button", size: "sm", variant: verdict === option ? 'brand' : 'outline', disabled: pending, onClick: () => setVerdict(option), children: option === 'request_changes'
|
|
541
|
+
? 'Request changes'
|
|
542
|
+
: option === 'approve'
|
|
543
|
+
? 'Approve'
|
|
544
|
+
: 'Comment' }, option))) }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [error ? _jsx("span", { className: "text-status-failed mr-auto text-xs", children: error }) : null, _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: pending, onClick: () => decide.mutate('discard'), children: "Discard" }), _jsx(Button, { type: "button", variant: "brand", size: "sm", disabled: pending, onClick: () => decide.mutate('submit'), children: "Submit review" })] })] }))] })] }));
|
|
545
|
+
}
|
|
546
|
+
function Notice({ item, context, className, }) {
|
|
547
|
+
const identity = item.threadId ? context.identities.get(item.threadId) : undefined;
|
|
548
|
+
return (_jsxs("div", { className: cn('flex items-center gap-3 py-1 text-[11px]', className), children: [_jsx("span", { className: "bg-border h-px flex-1" }), _jsxs("span", { className: cn('inline-flex max-w-[80%] items-center gap-1.5 text-center', item.tone === 'error' ? 'text-status-failed' : 'text-muted-foreground'), children: [item.runId ? _jsx(Sparkles, { className: "text-route-constraint size-3 shrink-0" }) : null, item.tone === 'error' ? _jsx(TriangleAlert, { className: "size-3 shrink-0" }) : null, _jsxs("span", { className: "truncate", children: [identity ? `${identity.label}: ` : '', humanize(item.text, context.identities)] }), item.runId ? (_jsx(Link, { to: { page: 'playbook' }, className: "text-foreground shrink-0 font-medium hover:underline", children: "Open playbook" })) : null] }), _jsx("span", { className: "bg-border h-px flex-1" })] }));
|
|
549
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HarnessId, type Team } from '@swirls/shuttle/api';
|
|
2
|
+
import { type SignInPlace } from '../connections/places.js';
|
|
3
|
+
/** Picks which agent runs the session: Shuttle's own loop, or a connected subscription. */
|
|
4
|
+
export declare function HarnessSwitcher({ value, onChange, team, onTeamChange, disabled, side, place, }: {
|
|
5
|
+
value: HarnessId;
|
|
6
|
+
onChange: (harness: HarnessId) => void;
|
|
7
|
+
/** Who Shuttle's conductor may delegate to. Only applies to a Shuttle session. */
|
|
8
|
+
team?: Team;
|
|
9
|
+
onTeamChange?: (team: Team) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Which way the menu opens: up from a composer at the bottom, down from a form. */
|
|
12
|
+
side?: 'top' | 'bottom';
|
|
13
|
+
/** Where the session runs, so the picker says whether each agent is signed in there. */
|
|
14
|
+
place?: SignInPlace | null;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* The agent and team new sessions start with, for forms that create a session. `save` must
|
|
18
|
+
* finish before the session is launched: a session takes the defaults on its first turn.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useDefaultHarness(): {
|
|
21
|
+
harness: HarnessId;
|
|
22
|
+
setHarness: (harness: HarnessId) => void;
|
|
23
|
+
team: Team;
|
|
24
|
+
setTeam: (team: Team) => void;
|
|
25
|
+
save: () => Promise<unknown>;
|
|
26
|
+
};
|