@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,109 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { skipToken, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { Check, Cloud, Laptop, LoaderCircle } from 'lucide-react';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover.js';
|
|
6
|
+
import { cn } from '../../lib/cn.js';
|
|
7
|
+
import { isolationLabel, useApi, useDevice, useShuttleHost, } from '../../shuttle/index.js';
|
|
8
|
+
import { sessionQueries } from './session-queries.js';
|
|
9
|
+
const PROVIDERS = {
|
|
10
|
+
daytona: 'Daytona',
|
|
11
|
+
cloudflare: 'Cloudflare',
|
|
12
|
+
memory: 'In memory',
|
|
13
|
+
};
|
|
14
|
+
const rowClass = 'hover:bg-accent focus-visible:ring-ring/50 flex w-full items-start gap-2.5 rounded-md px-2 py-2 text-left outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50';
|
|
15
|
+
function Row({ icon, title, detail, current, busy, disabled, onSelect, }) {
|
|
16
|
+
return (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": current, disabled: disabled || busy, onClick: current ? undefined : onSelect, className: rowClass, children: [_jsx("span", { className: "text-muted-foreground mt-0.5 shrink-0 [&>svg]:size-3.5", children: icon }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block text-[12.5px] leading-tight font-medium", children: title }), _jsx("span", { className: "text-muted-foreground mt-0.5 block text-[11.5px] leading-snug text-pretty", children: detail })] }), _jsx("span", { className: "mt-0.5 flex size-3.5 shrink-0 items-center justify-center", children: busy ? (_jsx(LoaderCircle, { className: "text-muted-foreground size-3.5 animate-spin" })) : current ? (_jsx(Check, { className: "size-3.5" })) : null })] }));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Where a session runs, in the session's title bar: on this machine or in the cloud, with a way
|
|
20
|
+
* to move it. It appears in the desktop app, and anywhere for a session that is on a machine.
|
|
21
|
+
* Give it the session as its `key` so it starts fresh when the page moves to another session.
|
|
22
|
+
*/
|
|
23
|
+
export function SessionPlace({ runId, working }) {
|
|
24
|
+
const host = useShuttleHost();
|
|
25
|
+
const api = useApi();
|
|
26
|
+
const app = useDevice();
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const [runner, setRunner] = useState(null);
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
// The session page's loader starts this read without waiting on it. A move that is waiting
|
|
31
|
+
// happens shortly after the turn ends, without the page being told, so it is asked after.
|
|
32
|
+
const placeQuery = sessionQueries(host, runId).place;
|
|
33
|
+
const placeKey = placeQuery.queryKey;
|
|
34
|
+
const { data: place } = useQuery({
|
|
35
|
+
...placeQuery,
|
|
36
|
+
refetchInterval: (query) => (query.state.data?.pending != null ? 2000 : false),
|
|
37
|
+
});
|
|
38
|
+
// This machine's sandbox, which only the desktop app has.
|
|
39
|
+
const machineQuery = api.runners.get.queryOptions({
|
|
40
|
+
input: app ? { deviceId: app.deviceId } : skipToken,
|
|
41
|
+
});
|
|
42
|
+
const machineKey = machineQuery.queryKey;
|
|
43
|
+
const { data: machine } = useQuery(machineQuery);
|
|
44
|
+
const refresh = useCallback(() => {
|
|
45
|
+
void queryClient.invalidateQueries({ queryKey: placeKey });
|
|
46
|
+
void queryClient.invalidateQueries({ queryKey: machineKey });
|
|
47
|
+
}, [queryClient, placeKey, machineKey]);
|
|
48
|
+
// Where the session is can change under the page: a turn for someone else takes it to the
|
|
49
|
+
// cloud. The session's event stream says when a turn ends, and that is when to ask again.
|
|
50
|
+
const wasWorking = useRef(working);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (wasWorking.current && !working) {
|
|
53
|
+
refresh();
|
|
54
|
+
}
|
|
55
|
+
wasWorking.current = working;
|
|
56
|
+
}, [refresh, working]);
|
|
57
|
+
// The desktop app's runner is outside the page: it is asked once, then tells of each change.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!app) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
void app.runnerStatus().then(setRunner);
|
|
63
|
+
return app.onRunnerStatus((status) => {
|
|
64
|
+
setRunner(status);
|
|
65
|
+
refresh();
|
|
66
|
+
});
|
|
67
|
+
}, [app, refresh]);
|
|
68
|
+
// While the session is working this only asks: the move happens when the turn ends.
|
|
69
|
+
const move = useMutation(api.sandbox.place.move.mutationOptions({
|
|
70
|
+
onSuccess: (next) => queryClient.setQueryData(placeKey, next),
|
|
71
|
+
}));
|
|
72
|
+
const moving = move.isPending ? move.variables.to : null;
|
|
73
|
+
const error = move.error?.message;
|
|
74
|
+
if (!place || (!app && place.sandbox.location !== 'local' && !place.local)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const local = place.sandbox.location === 'local';
|
|
78
|
+
const onThisMachine = local && app !== null && place.sandbox.deviceId === app.deviceId;
|
|
79
|
+
const elsewhere = local && !onThisMachine;
|
|
80
|
+
const deviceName = place.sandbox.device?.name ?? 'another machine';
|
|
81
|
+
const cloudName = PROVIDERS[place.cloud.provider] ?? place.cloud.provider;
|
|
82
|
+
const backend = machine?.backend ?? runner?.backend;
|
|
83
|
+
const localDetail = !machine?.online
|
|
84
|
+
? runner?.status === 'preparing'
|
|
85
|
+
? (runner.message ?? 'Getting the sandbox ready…')
|
|
86
|
+
: (runner?.message ?? 'The local sandbox is not running.')
|
|
87
|
+
: `${backend?.label ?? 'Local sandbox'}, ${isolationLabel(backend?.isolation)}. Files and sign-ins stay on this machine.`;
|
|
88
|
+
return (_jsxs(Popover, { open: open, onOpenChange: (next) => {
|
|
89
|
+
setOpen(next);
|
|
90
|
+
if (next) {
|
|
91
|
+
refresh();
|
|
92
|
+
}
|
|
93
|
+
}, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", "aria-label": `Runs ${local ? `on ${onThisMachine ? 'this machine' : deviceName}` : 'in the cloud'}. Change where this session runs`, className: cn('text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 inline-flex h-6 shrink-0 items-center gap-1.5 rounded-full border px-2 text-[11px] transition-colors duration-100 outline-none focus-visible:ring-2', local && place.sandbox.online === false && 'border-amber-500/40 text-amber-600'), children: [moving ? (_jsx(LoaderCircle, { className: "size-3 animate-spin" })) : local ? (_jsx(Laptop, { className: "size-3" })) : (_jsx(Cloud, { className: "size-3" })), _jsx("span", { className: "max-w-32 truncate", children: moving ? 'Moving…' : local ? (onThisMachine ? 'This machine' : deviceName) : 'Cloud' })] }) }), _jsxs(PopoverContent, { align: "end", className: "w-80 p-1.5", children: [_jsx("p", { className: "text-muted-foreground px-2 pt-1.5 pb-1 text-[11px]", children: "Where this session runs" }), _jsxs("div", { role: "menu", children: [app ? (_jsx(Row, { icon: _jsx(Laptop, {}), title: "This machine", detail: localDetail, current: onThisMachine, busy: moving === 'local', disabled: moving !== null || !machine?.online || !place.cloud.movable, onSelect: () => {
|
|
94
|
+
if (app) {
|
|
95
|
+
move.mutate({ id: runId, to: 'local', deviceId: app.deviceId });
|
|
96
|
+
}
|
|
97
|
+
} })) : null, elsewhere ? (_jsx(Row, { icon: _jsx(Laptop, {}), title: deviceName, detail: place.sandbox.online
|
|
98
|
+
? 'Connected. Its files and sign-ins stay on that machine.'
|
|
99
|
+
: 'Not connected. The session can still move to the cloud from its last save.', current: true, busy: false, disabled: false, onSelect: () => { } })) : null, _jsx(Row, { icon: _jsx(Cloud, {}), title: "Cloud", detail: `${cloudName}. Keeps working when this machine is closed, and teammates can join.`, current: !local, busy: moving === 'cloud', disabled: moving !== null || !place.cloud.movable || (place.local !== null && !place.local.mine), onSelect: () => move.mutate({ id: runId, to: 'cloud' }) })] }), _jsx("p", { role: error ? 'alert' : undefined, className: cn('px-2 pt-1 pb-1.5 text-[11px] leading-snug text-pretty', error ? 'text-destructive' : 'text-muted-foreground'), children: error ??
|
|
100
|
+
(place.pending
|
|
101
|
+
? `Moves to ${place.pending === 'local' ? 'this machine' : 'the cloud'} when this turn ends.`
|
|
102
|
+
: place.leftBehind
|
|
103
|
+
? 'This session left a machine that was not connected, from its last save. Anything changed there since is still on that machine.'
|
|
104
|
+
: working
|
|
105
|
+
? 'The session is working. A move you choose now happens when this turn ends.'
|
|
106
|
+
: place.cloud.movable
|
|
107
|
+
? 'Moving carries the branches and uncommitted files. Installed dependencies are rebuilt where it lands.'
|
|
108
|
+
: 'Moving needs Code Storage and a cloud sandbox that runs Linux.') })] })] }));
|
|
109
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PublishedPull } from './session-feed.js';
|
|
2
|
+
/** One header pill for every PR this session opened; the menu groups stacks and standalone PRs. */
|
|
3
|
+
export declare function SessionPrPills({ pulls, labelFor, onInspect, }: {
|
|
4
|
+
pulls: readonly PublishedPull[];
|
|
5
|
+
labelFor: (threadId: string | null) => string | undefined;
|
|
6
|
+
onInspect: (threadId: string) => void;
|
|
7
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Bot, ExternalLink, GitPullRequest, Layers } from 'lucide-react';
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '../../components/ui/dropdown-menu.js';
|
|
5
|
+
import { cn } from '../../lib/cn.js';
|
|
6
|
+
import { RepoDot, repoShortName } from '../pulls/pull-glyphs.js';
|
|
7
|
+
import { groupSessionPulls } from '../pulls/session-pull-groups.js';
|
|
8
|
+
const STACKED_DOTS = 4;
|
|
9
|
+
function PullRow({ pull, layer }) {
|
|
10
|
+
return (_jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { href: pull.url, target: "_blank", rel: "noreferrer", title: pull.fullName, children: [layer !== undefined ? (_jsx("span", { className: "text-muted-foreground w-4 shrink-0 text-center text-[10px] tabular-nums", children: layer })) : (_jsx(RepoDot, { fullName: pull.fullName })), _jsx("span", { className: "min-w-0 truncate", children: repoShortName(pull.fullName) }), _jsxs("span", { className: "text-muted-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-[9px] uppercase", children: "Draft" })) : null, _jsx(ExternalLink, { className: "text-muted-foreground ml-auto" })] }) }));
|
|
11
|
+
}
|
|
12
|
+
/** One header pill for every PR this session opened; the menu groups stacks and standalone PRs. */
|
|
13
|
+
export function SessionPrPills({ pulls, labelFor, onInspect, }) {
|
|
14
|
+
const first = pulls[0];
|
|
15
|
+
if (!first) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const single = pulls.length === 1;
|
|
19
|
+
const { stacks, standalone } = groupSessionPulls(pulls);
|
|
20
|
+
const onlyStack = stacks.length === 1 && standalone.length === 0 ? stacks[0] : undefined;
|
|
21
|
+
const allDraft = pulls.every((pull) => pull.draft);
|
|
22
|
+
const repos = [...new Set(pulls.map((pull) => pull.fullName))];
|
|
23
|
+
const multiRepo = repos.length > 1;
|
|
24
|
+
const openers = [...new Set(pulls.flatMap((pull) => (pull.threadId ? [pull.threadId] : [])))];
|
|
25
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { title: single
|
|
26
|
+
? `${first.fullName}#${first.number}`
|
|
27
|
+
: pulls.map((pull) => `${pull.fullName}#${pull.number}`).join('\n'), className: cn('text-muted-foreground hover:text-foreground data-[state=open]:text-foreground data-[state=open]:bg-accent inline-flex max-w-44 shrink-0 items-center gap-1.5 rounded-full border px-2 py-0.5 text-[11px] transition-colors duration-100 outline-none', allDraft && 'border-dashed'), children: [stacks.length > 0 ? (_jsx(Layers, { className: "size-3 shrink-0" })) : (_jsx(GitPullRequest, { className: "size-3 shrink-0" })), single ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "min-w-0 truncate font-mono", children: [repoShortName(first.fullName), "#", first.number] }), first.draft ? _jsx("span", { className: "text-[9px] uppercase opacity-70", children: "draft" }) : null] })) : onlyStack ? (_jsxs("span", { className: "tabular-nums", children: ["Stack \u00B7 ", pulls.length] })) : (_jsxs(_Fragment, { children: [multiRepo ? (_jsx("span", { "aria-hidden": true, className: "flex items-center", children: repos.slice(0, STACKED_DOTS).map((fullName) => (_jsx(RepoDot, { fullName: fullName, className: "ring-background -ml-0.5 size-2 ring-2 first:ml-0" }, fullName))) })) : null, _jsxs("span", { className: "tabular-nums", children: [pulls.length, " PRs"] })] }))] }), _jsxs(DropdownMenuContent, { align: "end", className: "w-72", children: [single ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuLabel, { children: "Pull request" }), _jsx(PullRow, { pull: first })] })) : (_jsxs(_Fragment, { children: [stacks.map((stack, index) => (_jsxs(Fragment, { children: [index > 0 ? _jsx(DropdownMenuSeparator, {}) : null, _jsxs(_Fragment, { children: [_jsxs(DropdownMenuLabel, { children: ["Stack \u00B7 ", stack.layers.length, multiRepo ? ` · ${repoShortName(stack.fullName)}` : ''] }), stack.layers.map((pull) => (_jsx(PullRow, { pull: pull, layer: pull.stack?.layer }, pull.number)))] })] }, stack.key))), standalone.length > 0 ? (_jsxs(_Fragment, { children: [stacks.length > 0 ? _jsx(DropdownMenuSeparator, {}) : null, _jsxs(_Fragment, { children: [_jsx(DropdownMenuLabel, { children: stacks.length > 0 ? 'Standalone' : `${pulls.length} pull requests` }), standalone.map((pull) => (_jsx(PullRow, { pull: pull }, `${pull.fullName}#${pull.number}`)))] })] })) : null] })), openers.length > 0 ? _jsx(DropdownMenuSeparator, {}) : null, openers.map((threadId) => (_jsxs(DropdownMenuItem, { onSelect: () => onInspect(threadId), children: [_jsx(Bot, {}), _jsxs("span", { className: "truncate", children: ["Opened by ", labelFor(threadId) ?? 'Agent'] })] }, threadId)))] })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type ShuttleHost } from '../../shuttle/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the Worker keeps about one session, as queries. The session page's loader reads the ones
|
|
4
|
+
* it cannot render without; the rest are read by whatever shows them.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sessionQueries({ api }: ShuttleHost, id: string): {
|
|
7
|
+
/** Which agent runs the session. */
|
|
8
|
+
harness: NoInfer<{
|
|
9
|
+
input: {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
13
|
+
harness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
14
|
+
}, Error>, "input">>;
|
|
15
|
+
/** Who Shuttle's conductor may hand work to. */
|
|
16
|
+
team: NoInfer<{
|
|
17
|
+
input: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
21
|
+
team: {
|
|
22
|
+
workers: boolean;
|
|
23
|
+
codex: boolean;
|
|
24
|
+
claudeCode: boolean;
|
|
25
|
+
cursor: boolean;
|
|
26
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
27
|
+
};
|
|
28
|
+
}, Error>, "input">>;
|
|
29
|
+
/** The model and effort each vendor agent runs on. */
|
|
30
|
+
vendorModels: NoInfer<{
|
|
31
|
+
input: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
35
|
+
choices: Partial<Record<string, {
|
|
36
|
+
model?: string | undefined;
|
|
37
|
+
effort?: string | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
}, Error>, "input">>;
|
|
40
|
+
/** Who can open the session. */
|
|
41
|
+
access: NoInfer<{
|
|
42
|
+
input: {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
45
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
46
|
+
ownerId: string | null;
|
|
47
|
+
memberIds: readonly string[];
|
|
48
|
+
visibility: "private" | "public";
|
|
49
|
+
canShare: boolean;
|
|
50
|
+
}, Error>, "input">>;
|
|
51
|
+
/** Whose sandbox holds the session's files. */
|
|
52
|
+
place: NoInfer<{
|
|
53
|
+
input: {
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
57
|
+
pending: "cloud" | "local" | null;
|
|
58
|
+
leftBehind: {
|
|
59
|
+
deviceId: string | null;
|
|
60
|
+
at: number;
|
|
61
|
+
} | null;
|
|
62
|
+
personal: boolean;
|
|
63
|
+
holderId: string | null;
|
|
64
|
+
here: boolean;
|
|
65
|
+
sandbox: {
|
|
66
|
+
online?: boolean | undefined;
|
|
67
|
+
device?: {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
platform: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
backend?: {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
isolation: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
provider: string;
|
|
78
|
+
location: "cloud" | "local";
|
|
79
|
+
deviceId?: string | null | undefined;
|
|
80
|
+
};
|
|
81
|
+
local: {
|
|
82
|
+
deviceId: string;
|
|
83
|
+
mine: boolean;
|
|
84
|
+
} | null;
|
|
85
|
+
cloud: {
|
|
86
|
+
provider: string;
|
|
87
|
+
movable: boolean;
|
|
88
|
+
};
|
|
89
|
+
}, Error>, "input">>;
|
|
90
|
+
};
|
|
91
|
+
/** Changes which agent runs the session. Applies from the session's next turn. */
|
|
92
|
+
export declare function useSetSessionHarness(runId: string, onRefused?: (cause: Error) => void): import("@tanstack/react-query").UseMutationResult<{
|
|
93
|
+
harness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
94
|
+
}, Error, {
|
|
95
|
+
id: string;
|
|
96
|
+
harness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
97
|
+
}, {
|
|
98
|
+
previous: {
|
|
99
|
+
harness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
100
|
+
} | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
/** Changes the session's team. Applies from the conductor's next turn. */
|
|
103
|
+
export declare function useSetSessionTeam(runId: string, onRefused?: (cause: Error) => void): import("@tanstack/react-query").UseMutationResult<{
|
|
104
|
+
team: {
|
|
105
|
+
workers: boolean;
|
|
106
|
+
codex: boolean;
|
|
107
|
+
claudeCode: boolean;
|
|
108
|
+
cursor: boolean;
|
|
109
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
110
|
+
};
|
|
111
|
+
}, Error, {
|
|
112
|
+
id: string;
|
|
113
|
+
team: {
|
|
114
|
+
workers: boolean;
|
|
115
|
+
codex: boolean;
|
|
116
|
+
claudeCode: boolean;
|
|
117
|
+
cursor: boolean;
|
|
118
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
119
|
+
};
|
|
120
|
+
}, {
|
|
121
|
+
previous: {
|
|
122
|
+
team: {
|
|
123
|
+
workers: boolean;
|
|
124
|
+
codex: boolean;
|
|
125
|
+
claudeCode: boolean;
|
|
126
|
+
cursor: boolean;
|
|
127
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
128
|
+
};
|
|
129
|
+
} | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
/** Changes the model or effort one vendor agent runs on. Applies from that agent's next turn. */
|
|
132
|
+
export declare function useSetSessionVendorModel(runId: string, onRefused?: (cause: Error) => void): import("@tanstack/react-query").UseMutationResult<{
|
|
133
|
+
choices: Partial<Record<string, {
|
|
134
|
+
model?: string | undefined;
|
|
135
|
+
effort?: string | undefined;
|
|
136
|
+
}>>;
|
|
137
|
+
}, Error, {
|
|
138
|
+
id: string;
|
|
139
|
+
model?: string | undefined;
|
|
140
|
+
effort?: string | undefined;
|
|
141
|
+
harness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
142
|
+
}, {
|
|
143
|
+
previous: {
|
|
144
|
+
choices: Partial<Record<string, {
|
|
145
|
+
model?: string | undefined;
|
|
146
|
+
effort?: string | undefined;
|
|
147
|
+
}>>;
|
|
148
|
+
} | undefined;
|
|
149
|
+
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Sets what new sessions start with: the agent, the team, or both. The connections listing
|
|
152
|
+
* carries those defaults, so it is read again afterwards.
|
|
153
|
+
*/
|
|
154
|
+
export declare function useSetSessionDefaults(onRefused?: (cause: Error) => void): import("@tanstack/react-query").UseMutationResult<{
|
|
155
|
+
defaultHarness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
156
|
+
defaultTeam: {
|
|
157
|
+
workers: boolean;
|
|
158
|
+
codex: boolean;
|
|
159
|
+
claudeCode: boolean;
|
|
160
|
+
cursor: boolean;
|
|
161
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
162
|
+
};
|
|
163
|
+
}, Error, {
|
|
164
|
+
harness?: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}` | undefined;
|
|
165
|
+
team?: {
|
|
166
|
+
workers: boolean;
|
|
167
|
+
codex: boolean;
|
|
168
|
+
claudeCode: boolean;
|
|
169
|
+
cursor: boolean;
|
|
170
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
171
|
+
} | undefined;
|
|
172
|
+
}, unknown>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useApi, useShuttleHost } from '../../shuttle/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the Worker keeps about one session, as queries. The session page's loader reads the ones
|
|
5
|
+
* it cannot render without; the rest are read by whatever shows them.
|
|
6
|
+
*/
|
|
7
|
+
export function sessionQueries({ api }, id) {
|
|
8
|
+
const input = { id };
|
|
9
|
+
return {
|
|
10
|
+
/** Which agent runs the session. */
|
|
11
|
+
harness: api.sessions.harness.get.queryOptions({ input }),
|
|
12
|
+
/** Who Shuttle's conductor may hand work to. */
|
|
13
|
+
team: api.sessions.team.get.queryOptions({ input }),
|
|
14
|
+
/** The model and effort each vendor agent runs on. */
|
|
15
|
+
vendorModels: api.sessions.vendorModels.get.queryOptions({ input }),
|
|
16
|
+
/** Who can open the session. */
|
|
17
|
+
access: api.sessions.access.get.queryOptions({ input }),
|
|
18
|
+
/** Whose sandbox holds the session's files. */
|
|
19
|
+
place: api.sandbox.place.get.queryOptions({ input }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Shows a change at once and keeps the page honest about it afterwards. `shown` is written to
|
|
24
|
+
* the query before the Worker answers. What the Worker saved replaces it, unless a later change
|
|
25
|
+
* of the same thing in the same session is still on its way, whose answer is the one that
|
|
26
|
+
* counts. A change the Worker refuses is taken back, and the query is read again in case more
|
|
27
|
+
* than one was. `onRefused` hears of every refusal, not only the last change's.
|
|
28
|
+
*/
|
|
29
|
+
function optimistic(queryClient, queryKey, mutationKey, shown, onRefused) {
|
|
30
|
+
const read = () => queryClient.getQueryData(queryKey);
|
|
31
|
+
const write = (data) => queryClient.setQueryData(queryKey, data);
|
|
32
|
+
return {
|
|
33
|
+
mutationKey,
|
|
34
|
+
onMutate: async (input) => {
|
|
35
|
+
// A read still on its way would bring back what the session had before this change.
|
|
36
|
+
await queryClient.cancelQueries({ queryKey });
|
|
37
|
+
const previous = read();
|
|
38
|
+
write(shown(input, previous));
|
|
39
|
+
return { previous };
|
|
40
|
+
},
|
|
41
|
+
onSuccess: (saved) => {
|
|
42
|
+
if (queryClient.isMutating({ mutationKey }) === 1) {
|
|
43
|
+
write(saved);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
onError: (cause, _input, context) => {
|
|
47
|
+
write(context?.previous);
|
|
48
|
+
void queryClient.invalidateQueries({ queryKey });
|
|
49
|
+
onRefused?.(cause);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Changes which agent runs the session. Applies from the session's next turn. */
|
|
54
|
+
export function useSetSessionHarness(runId, onRefused) {
|
|
55
|
+
const api = useApi();
|
|
56
|
+
const queryClient = useQueryClient();
|
|
57
|
+
const { queryKey } = sessionQueries(useShuttleHost(), runId).harness;
|
|
58
|
+
return useMutation(api.sessions.harness.set.mutationOptions(optimistic(queryClient, queryKey, [...api.sessions.harness.set.mutationKey(), runId], ({ harness }) => ({ harness }), onRefused)));
|
|
59
|
+
}
|
|
60
|
+
/** Changes the session's team. Applies from the conductor's next turn. */
|
|
61
|
+
export function useSetSessionTeam(runId, onRefused) {
|
|
62
|
+
const api = useApi();
|
|
63
|
+
const queryClient = useQueryClient();
|
|
64
|
+
const { queryKey } = sessionQueries(useShuttleHost(), runId).team;
|
|
65
|
+
return useMutation(api.sessions.team.set.mutationOptions(optimistic(queryClient, queryKey, [...api.sessions.team.set.mutationKey(), runId], ({ team }) => ({ team }), onRefused)));
|
|
66
|
+
}
|
|
67
|
+
/** Changes the model or effort one vendor agent runs on. Applies from that agent's next turn. */
|
|
68
|
+
export function useSetSessionVendorModel(runId, onRefused) {
|
|
69
|
+
const api = useApi();
|
|
70
|
+
const queryClient = useQueryClient();
|
|
71
|
+
const { queryKey } = sessionQueries(useShuttleHost(), runId).vendorModels;
|
|
72
|
+
return useMutation(api.sessions.vendorModels.set.mutationOptions(optimistic(queryClient, queryKey, [...api.sessions.vendorModels.set.mutationKey(), runId], ({ harness, model, effort }, current) => ({
|
|
73
|
+
choices: {
|
|
74
|
+
...current?.choices,
|
|
75
|
+
[harness]: { ...(model ? { model } : {}), ...(effort ? { effort } : {}) },
|
|
76
|
+
},
|
|
77
|
+
}), onRefused)));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sets what new sessions start with: the agent, the team, or both. The connections listing
|
|
81
|
+
* carries those defaults, so it is read again afterwards.
|
|
82
|
+
*/
|
|
83
|
+
export function useSetSessionDefaults(onRefused) {
|
|
84
|
+
const api = useApi();
|
|
85
|
+
const queryClient = useQueryClient();
|
|
86
|
+
return useMutation(api.connections.setDefault.mutationOptions({
|
|
87
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: api.connections.list.key() }),
|
|
88
|
+
onError: onRefused,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LinkedRepo } from '../workspace/workspace.js';
|
|
2
|
+
/** One trigger for every linked repo, so its width doesn't grow with the folder. */
|
|
3
|
+
export declare function SessionRepos({ folderId, folderName, repos, align, }: {
|
|
4
|
+
folderId: string;
|
|
5
|
+
folderName: string;
|
|
6
|
+
repos: readonly LinkedRepo[];
|
|
7
|
+
align?: 'start' | 'end';
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowRight, ChevronDown, ExternalLink, GitBranch, Lock } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../components/ui/button.js';
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover.js';
|
|
5
|
+
import { Link } from '../../shuttle/index.js';
|
|
6
|
+
import { RepoName } from '../workspace/repo-chip.js';
|
|
7
|
+
import { repoCountLabel } from '../workspace/workspace.js';
|
|
8
|
+
/** One trigger for every linked repo, so its width doesn't grow with the folder. */
|
|
9
|
+
export function SessionRepos({ folderId, folderName, repos, align = 'end', }) {
|
|
10
|
+
const [first] = repos;
|
|
11
|
+
if (!first) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "sm", className: "data-[state=open]:bg-accent data-[state=open]:text-foreground max-w-44", "aria-label": `${repoCountLabel(repos.length)} in ${folderName}`, children: [_jsx(GitBranch, {}), _jsx("span", { className: "hidden min-w-0 truncate md:inline", children: repos.length === 1 ? first.name : `${repos.length.toLocaleString()} repos` }), _jsx("span", { className: "tabular-nums md:hidden", children: repos.length.toLocaleString() }), _jsx(ChevronDown, { className: "opacity-60" })] }) }), _jsxs(PopoverContent, { align: align, collisionPadding: 12, className: "w-80", children: [_jsxs("div", { className: "flex items-baseline gap-2 border-b px-3 py-2.5", children: [_jsx("span", { className: "text-[12px] font-medium", children: "Repositories" }), _jsx("span", { className: "text-muted-foreground font-mono text-[11px] tabular-nums", children: repos.length.toLocaleString() }), _jsx("span", { className: "text-muted-foreground ml-auto min-w-0 truncate text-[11px]", dir: "auto", title: folderName, children: folderName })] }), _jsx("ul", { className: "max-h-72 overflow-y-auto overscroll-contain p-1", children: repos.map((repo) => (_jsx("li", { children: _jsxs("a", { href: `https://github.com/${repo.fullName}`, target: "_blank", rel: "noreferrer", className: "hover:bg-accent focus-visible:bg-accent group/repo flex h-8 items-center gap-2 rounded-md px-2 text-[12px] transition-colors duration-100 outline-none", children: [_jsx(RepoName, { repo: repo, className: "flex-1" }), repo.private ? (_jsx(Lock, { className: "text-muted-foreground size-3 shrink-0", "aria-label": "Private" })) : null, _jsx("span", { className: "text-muted-foreground max-w-20 shrink-0 truncate font-mono text-[10px]", title: repo.defaultBranch, children: repo.defaultBranch }), _jsx(ExternalLink, { className: "text-muted-foreground size-3 shrink-0 opacity-0 transition-opacity duration-100 group-hover/repo:opacity-100 group-focus-visible/repo:opacity-100" })] }) }, repo.fullName))) }), _jsx("div", { className: "border-t p-1", children: _jsxs(Link, { to: { page: 'folder', folderId: folderId }, className: "text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent flex h-8 items-center gap-2 rounded-md px-2 text-[12px] transition-colors duration-100 outline-none", children: ["Manage repos", _jsx(ArrowRight, { className: "ml-auto size-3.5" })] }) })] })] }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The people in this session, as avatars in the session's title bar. Opening them shows who
|
|
3
|
+
* can open the session and a way to change it. Give it the session as its `key` so it starts
|
|
4
|
+
* fresh when the page moves to another session.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SessionShare({ runId }: {
|
|
7
|
+
runId: string;
|
|
8
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { Building2, Check, Lock, UserRound } from 'lucide-react';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover.js';
|
|
6
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../../components/ui/tooltip.js';
|
|
7
|
+
import { cn } from '../../lib/cn.js';
|
|
8
|
+
import { initials } from '../../lib/initials.js';
|
|
9
|
+
import { peopleQuery, useApi, useOrgPeople, useShuttle, useShuttleHost, } from '../../shuttle/index.js';
|
|
10
|
+
import { useFixtureMode } from '../workspace/workspace-context.js';
|
|
11
|
+
import { sessionPeopleFixture } from '../workspace/workspace-fixtures.js';
|
|
12
|
+
import { sessionQueries } from './session-queries.js';
|
|
13
|
+
const rowClass = 'flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left';
|
|
14
|
+
const interactiveRowClass = 'hover:bg-accent focus-visible:ring-ring/50 outline-none focus-visible:ring-2';
|
|
15
|
+
const MAX_AVATARS = 3;
|
|
16
|
+
/** Counts past this read as "99+", which is as much as an avatar-sized circle holds. */
|
|
17
|
+
const MAX_COUNT = 99;
|
|
18
|
+
function countLabel(count) {
|
|
19
|
+
return count > MAX_COUNT ? `${MAX_COUNT}+` : `+${count}`;
|
|
20
|
+
}
|
|
21
|
+
function Avatar({ className, children }) {
|
|
22
|
+
return (_jsx("span", { className: cn('bg-secondary text-foreground border-background flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-full border-2 text-[9.5px] leading-none font-medium', className), children: children }));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The people in this session, as avatars in the session's title bar. Opening them shows who
|
|
26
|
+
* can open the session and a way to change it. Give it the session as its `key` so it starts
|
|
27
|
+
* fresh when the page moves to another session.
|
|
28
|
+
*/
|
|
29
|
+
export function SessionShare({ runId }) {
|
|
30
|
+
const host = useShuttleHost();
|
|
31
|
+
const api = useApi();
|
|
32
|
+
const { identity } = useShuttle();
|
|
33
|
+
const tenant = identity.tenant;
|
|
34
|
+
const orgPeople = useOrgPeople();
|
|
35
|
+
const [open, setOpen] = useState(false);
|
|
36
|
+
const queryClient = useQueryClient();
|
|
37
|
+
// Where the host offers fixtures: the fixture toggle swaps in worst-case people where the session's are loaded.
|
|
38
|
+
const [fixtureMode] = useFixtureMode();
|
|
39
|
+
const fixture = useMemo(() => host.fixtures && fixtureMode !== 'live'
|
|
40
|
+
? sessionPeopleFixture(fixtureMode, tenant.user.id)
|
|
41
|
+
: null, [host.fixtures, fixtureMode, tenant.user.id]);
|
|
42
|
+
// The session page's loader starts this read without waiting on it: the title bar shows
|
|
43
|
+
// without the avatars, and they come in when it lands.
|
|
44
|
+
const accessQuery = sessionQueries(host, runId).access;
|
|
45
|
+
const accessKey = accessQuery.queryKey;
|
|
46
|
+
const { data: access } = useQuery({ ...accessQuery, enabled: !fixture });
|
|
47
|
+
// Only the open popover lists the organization.
|
|
48
|
+
const members = useQuery({ ...peopleQuery(tenant.org.id, identity.listPeople), enabled: open });
|
|
49
|
+
/** Shows the change at once and puts the old state back if the Worker refuses it. */
|
|
50
|
+
const update = useMutation(api.sessions.access.update.mutationOptions({
|
|
51
|
+
onMutate: async ({ memberIds, visibility }) => {
|
|
52
|
+
await queryClient.cancelQueries({ queryKey: accessKey });
|
|
53
|
+
const previous = queryClient.getQueryData(accessKey);
|
|
54
|
+
if (previous) {
|
|
55
|
+
queryClient.setQueryData(accessKey, {
|
|
56
|
+
...previous,
|
|
57
|
+
...(memberIds ? { memberIds } : {}),
|
|
58
|
+
...(visibility ? { visibility } : {}),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return { previous };
|
|
62
|
+
},
|
|
63
|
+
onSuccess: (saved) => queryClient.setQueryData(accessKey, saved),
|
|
64
|
+
onError: (_cause, _change, context) => {
|
|
65
|
+
queryClient.setQueryData(accessKey, context?.previous);
|
|
66
|
+
},
|
|
67
|
+
}));
|
|
68
|
+
const loaded = fixture?.access ?? access;
|
|
69
|
+
if (!loaded) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
// A const of its own, so the functions below keep the narrowed type.
|
|
73
|
+
const current = loaded;
|
|
74
|
+
const shared = new Set(current.memberIds);
|
|
75
|
+
const people = fixture?.people ?? orgPeople;
|
|
76
|
+
const error = update.error?.message ?? members.error?.message;
|
|
77
|
+
function change(next) {
|
|
78
|
+
update.mutate({ id: runId, ...next });
|
|
79
|
+
}
|
|
80
|
+
function toggle(userId) {
|
|
81
|
+
change({
|
|
82
|
+
memberIds: shared.has(userId)
|
|
83
|
+
? current.memberIds.filter((id) => id !== userId)
|
|
84
|
+
: [...current.memberIds, userId],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const isPublic = current.visibility === 'public';
|
|
88
|
+
const others = (members.data ?? []).filter((member) => member.userId !== current.ownerId);
|
|
89
|
+
const owner = (members.data ?? []).find((member) => member.userId === current.ownerId);
|
|
90
|
+
const label = isPublic
|
|
91
|
+
? 'Everyone in the organization'
|
|
92
|
+
: current.memberIds.length > 0
|
|
93
|
+
? `Shared with ${current.memberIds.length.toLocaleString()} ${current.memberIds.length === 1 ? 'person' : 'people'}`
|
|
94
|
+
: 'Private';
|
|
95
|
+
// You first, then the owner, then everyone the session is shared with.
|
|
96
|
+
const me = tenant.user.id;
|
|
97
|
+
const here = [
|
|
98
|
+
...new Set([me, ...(current.ownerId ? [current.ownerId] : []), ...current.memberIds]),
|
|
99
|
+
];
|
|
100
|
+
const shown = here.slice(0, MAX_AVATARS);
|
|
101
|
+
const extra = here.length - shown.length;
|
|
102
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsxs(Tooltip, { open: open ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(PopoverTrigger, { "aria-label": `Sharing: ${label}`, className: "focus-visible:ring-ring/50 ease-snappy mx-1 flex h-6 shrink-0 items-center rounded-full transition-transform duration-150 outline-none focus-visible:ring-[3px] active:scale-[0.97]", children: [shown.map((userId, index) => (_jsx(Avatar, { className: index > 0 ? '-ml-1.5 hidden @sm:flex' : undefined, children: initials(people.get(userId)) || _jsx(UserRound, { className: "size-3" }) }, userId))), extra > 0 ? (_jsx(Avatar, { className: "text-muted-foreground -ml-1.5 hidden text-[9px] tabular-nums @sm:flex", children: countLabel(extra) })) : null, here.length > 1 ? (_jsx(Avatar, { className: "text-muted-foreground -ml-1.5 text-[9px] tabular-nums @sm:hidden", children: countLabel(here.length - 1) })) : null, isPublic ? (_jsx(Avatar, { className: "text-muted-foreground -ml-1.5 hidden @sm:flex", children: _jsx(Building2, { className: "size-3" }) })) : null] }) }), _jsx(TooltipContent, { side: "bottom", align: "end", children: label })] }), _jsxs(PopoverContent, { align: "end", className: "w-80 p-2", children: [_jsx("h2", { className: "px-2 pt-1 pb-2 text-[13px] font-medium", children: "Who can open this session" }), current.ownerId === null ? (_jsx("p", { className: "text-muted-foreground px-2 pb-2 text-[12px] leading-relaxed text-pretty", children: "Shuttle started this session, so everyone in the organization can open it." })) : (_jsxs(_Fragment, { children: [_jsxs("div", { role: "radiogroup", "aria-label": "Visibility", className: "flex flex-col gap-px", children: [_jsx(VisibilityOption, { icon: _jsx(Lock, {}), title: "Private", detail: "Only you and the people you add. Nobody else knows it exists.", selected: !isPublic, onSelect: current.canShare && isPublic ? () => change({ visibility: 'private' }) : undefined }), _jsx(VisibilityOption, { icon: _jsx(Building2, {}), title: "Everyone in the organization", detail: "Every member can find it, read it and send messages.", selected: isPublic, onSelect: current.canShare && !isPublic ? () => change({ visibility: 'public' }) : undefined })] }), isPublic ? null : (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-muted-foreground px-2 pt-3 pb-1 text-[11px] font-medium", children: current.canShare ? 'Add people' : 'People' }), _jsxs("ul", { className: "flex max-h-56 flex-col gap-px overflow-y-auto", children: [owner ? (_jsx(MemberRow, { member: owner, you: owner.userId === tenant.user.id, note: "Owner" })) : null, others
|
|
103
|
+
.filter((member) => current.canShare || shared.has(member.userId))
|
|
104
|
+
.map((member) => (_jsx(MemberRow, { member: member, you: member.userId === tenant.user.id, checked: shared.has(member.userId), onToggle: current.canShare ? () => toggle(member.userId) : undefined }, member.userId))), current.canShare && members.data && others.length === 0 ? (_jsx("li", { className: "text-muted-foreground px-2 py-1.5 text-[12px] leading-relaxed", children: "Nobody else is in this organization yet. Invite people from the account menu." })) : null] })] })), current.canShare ? null : (_jsx("p", { className: "text-muted-foreground px-2 pt-2 text-[11.5px]", children: "Only the session's owner can change this." }))] })), error ? (_jsx("p", { role: "alert", className: "text-destructive px-2 pt-2 text-[12px]", children: error })) : null] })] }));
|
|
105
|
+
}
|
|
106
|
+
function VisibilityOption({ icon, title, detail, selected, onSelect, }) {
|
|
107
|
+
return (_jsxs("button", { type: "button", role: "radio", "aria-checked": selected, disabled: !onSelect && !selected, className: cn(rowClass, 'items-start disabled:opacity-50', onSelect ? interactiveRowClass : 'cursor-default outline-none', selected && 'bg-accent/60'), onClick: onSelect, children: [_jsx("span", { className: "text-muted-foreground mt-0.5 [&_svg]:size-3.5", children: icon }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "text-[12.5px] font-medium", children: title }), _jsx("span", { className: "text-muted-foreground text-[11.5px] leading-snug text-pretty", children: detail })] }), selected ? _jsx(Check, { className: "text-brand mt-0.5 size-3.5 shrink-0" }) : null] }));
|
|
108
|
+
}
|
|
109
|
+
function MemberRow({ member, you, note, checked, onToggle, }) {
|
|
110
|
+
const body = (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("span", { className: "truncate text-[12.5px]", children: [member.name || member.email, you ? _jsx("span", { className: "text-muted-foreground", children: " (you)" }) : null] }), _jsx("span", { className: "text-muted-foreground truncate text-[11px]", children: member.email })] }), note ? _jsx("span", { className: "text-muted-foreground text-[11px]", children: note }) : null, checked ? _jsx(Check, { className: "text-brand size-3.5 shrink-0" }) : null] }));
|
|
111
|
+
return (_jsx("li", { children: onToggle ? (_jsx("button", { type: "button", role: "checkbox", "aria-checked": checked ?? false, className: cn(rowClass, interactiveRowClass), onClick: onToggle, children: body })) : (_jsx("div", { className: rowClass, children: body })) }));
|
|
112
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ArtifactTab, ArtifactTabKind, SessionTabSet } from '../workspace/workspace.js';
|
|
2
|
+
export declare const emptyTabSet: SessionTabSet;
|
|
3
|
+
export declare function hasTabEvents(set: SessionTabSet | undefined): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The tabs a session shows. Event history is no longer a tab — it opens as a drawer under the
|
|
6
|
+
* session — so Events tabs saved by older sessions are left out. A session with nothing open
|
|
7
|
+
* has no tabs.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveTabSet(projected: SessionTabSet | undefined): SessionTabSet;
|
|
10
|
+
export type PendingTabOp = {
|
|
11
|
+
readonly kind: 'open';
|
|
12
|
+
readonly tab: ArtifactTab;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'close';
|
|
15
|
+
readonly tabId: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'reorder';
|
|
18
|
+
readonly tabIds: readonly string[];
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'retarget';
|
|
21
|
+
readonly tabId: string;
|
|
22
|
+
readonly title: string;
|
|
23
|
+
readonly target: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function applyPendingOps(base: SessionTabSet, pending: readonly PendingTabOp[]): SessionTabSet;
|
|
26
|
+
/**
|
|
27
|
+
* Drop the whole pending queue once the projection matches what those ops would
|
|
28
|
+
* produce. Partial absorption keeps the queue so optimistic UI stays coherent.
|
|
29
|
+
*/
|
|
30
|
+
export declare function prunePendingOps(projected: SessionTabSet | undefined, pending: readonly PendingTabOp[]): PendingTabOp[];
|
|
31
|
+
export declare function activeTabStorageKey(runId: string): string;
|
|
32
|
+
export declare function readActiveTabId(runId: string): string | null;
|
|
33
|
+
export declare function writeActiveTabId(runId: string, tabId: string | null): void;
|
|
34
|
+
/** Prefer the remembered tab when still open; otherwise the neighbour of a closed tab, else first. */
|
|
35
|
+
export declare function resolveActiveTabId(set: SessionTabSet, preferred: string | null | undefined, closedTabId?: string): string | null;
|
|
36
|
+
export declare function neighborAfterClose(previousOrder: readonly string[], closedTabId: string): string | null;
|
|
37
|
+
export declare function tabTitleForKind(kind: ArtifactTabKind, target?: string): string;
|
|
38
|
+
export declare function singletonTabId(kind: ArtifactTabKind): string | null;
|