@saadnvd1/agent-os 0.3.826 → 0.3.833
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/README.md +2 -0
- package/app/layout.tsx +3 -0
- package/components/Chat/ChatPanel.tsx +94 -23
- package/components/Chat/EventRow.tsx +15 -1
- package/components/Chat/ForkResults.tsx +109 -0
- package/components/Chat/Forks.tsx +54 -103
- package/components/Chat/QuoteButton.tsx +59 -21
- package/components/Chat/TimelineRows.tsx +1 -0
- package/components/Chat/composer/ComposerBody.tsx +14 -2
- package/components/Chat/composer/ForkHeader.tsx +55 -0
- package/components/Chat/composer/Toolbar.tsx +43 -7
- package/components/Chat/quote-selection.ts +6 -2
- package/content/whats-new.json +16 -0
- package/data/fork/index.ts +6 -1
- package/lib/chat/commands.ts +0 -15
- package/lib/chat/events.ts +3 -0
- package/lib/fork/brief.ts +4 -2
- package/lib/fork/deliver.ts +6 -1
- package/lib/fork/ledger.ts +5 -0
- package/lib/fork/settle.ts +8 -4
- package/lib/fork/types.ts +5 -1
- package/lib/fork/view.ts +4 -1
- package/lib/updates/generated.ts +29 -0
- package/lib/updates/run.ts +16 -6
- package/package.json +1 -1
- package/scripts/autodeploy +4 -0
- package/scripts/autodeploy.test.ts +6 -1
- package/scripts/generated-files.txt +3 -0
- package/scripts/generated.test.ts +77 -0
- package/scripts/lib/build-swap.sh +4 -0
- package/scripts/lib/generated.sh +18 -0
- package/scripts/redeploy +1 -0
- package/scripts/redeploy.test.ts +1 -0
- package/scripts/update-e2e.test.ts +2 -0
package/README.md
CHANGED
|
@@ -68,6 +68,8 @@ It ends by offering `agent-os setup`. If another device can't reach the machine
|
|
|
68
68
|
|
|
69
69
|
Then open AgentOS, add a project from ⌘K, and press ⌥N. The [install guide](docs/guides/install.md) covers Windows (WSL2), the supported agents, first run and the `agent-os` commands. To use it from your phone, see the [phone guide](docs/guides/phone.md).
|
|
70
70
|
|
|
71
|
+
AgentOS keeps itself up to date: once a release is two hours old and nothing has been working for 10 minutes, it installs it, and puts the previous version back if the new one doesn't come up healthy. Turn it off or change the idle time in **Settings → Updates**, or pin it with `AGENTOS_AUTO_UPDATE=off` and `AGENTOS_AUTO_UPDATE_IDLE_MIN`. Details are in [Automatic updates](docs/guides/install.md#automatic-updates).
|
|
72
|
+
|
|
71
73
|
## Connect
|
|
72
74
|
|
|
73
75
|
AgentOS Connect is live. It gives your machine a private address at runagentos.com, so your phone reaches it from any network with nothing to open on your router and no VPN.
|
package/app/layout.tsx
CHANGED
|
@@ -97,6 +97,9 @@ export default function RootLayout({
|
|
|
97
97
|
</SerwistProvider>
|
|
98
98
|
<Toaster
|
|
99
99
|
position="top-center"
|
|
100
|
+
// Below the header, not over its title.
|
|
101
|
+
offset={{ top: 56 }}
|
|
102
|
+
mobileOffset={{ top: 64 }}
|
|
100
103
|
closeButton
|
|
101
104
|
toastOptions={{
|
|
102
105
|
className: "!bg-card !border-border !text-foreground !shadow-lg",
|
|
@@ -14,14 +14,11 @@ import { useChat } from "@/data/chat/useChat";
|
|
|
14
14
|
import { PausedBanner } from "./PausedBanner";
|
|
15
15
|
import { groupTimeline } from "@/lib/chat/group";
|
|
16
16
|
import type { ChatItem } from "@/lib/chat/events";
|
|
17
|
-
import {
|
|
18
|
-
isForkCommand,
|
|
19
|
-
isFreshCommand,
|
|
20
|
-
withFork,
|
|
21
|
-
withFresh,
|
|
22
|
-
} from "@/lib/chat/commands";
|
|
17
|
+
import { isFreshCommand, withFresh } from "@/lib/chat/commands";
|
|
23
18
|
import { useExperiment } from "@/data/experiments";
|
|
24
|
-
import {
|
|
19
|
+
import { useStartForks } from "@/data/fork";
|
|
20
|
+
import { toast } from "sonner";
|
|
21
|
+
import { ForksStrip, forkLabel } from "./Forks";
|
|
25
22
|
import { ReplyingTo } from "./ReplyingTo";
|
|
26
23
|
import { compactsFirst } from "@/lib/chat/pending";
|
|
27
24
|
import { useFreshStart } from "@/data/sessions";
|
|
@@ -107,8 +104,14 @@ export function ChatPanel({
|
|
|
107
104
|
append?: boolean;
|
|
108
105
|
}>();
|
|
109
106
|
const forksOn = useExperiment("forks");
|
|
110
|
-
const
|
|
111
|
-
|
|
107
|
+
const startFork = useStartForks(sessionId);
|
|
108
|
+
// Set while a selection is being forked; per session, like asIs below.
|
|
109
|
+
const [forkDraft, setForkDraft] = useState<{
|
|
110
|
+
sessionId: string;
|
|
111
|
+
quote: string;
|
|
112
|
+
own: boolean;
|
|
113
|
+
} | null>(null);
|
|
114
|
+
const fork = forksOn && forkDraft?.sessionId === sessionId ? forkDraft : null;
|
|
112
115
|
const {
|
|
113
116
|
items,
|
|
114
117
|
hasMore,
|
|
@@ -187,12 +190,33 @@ export function ChatPanel({
|
|
|
187
190
|
append?: boolean;
|
|
188
191
|
}>();
|
|
189
192
|
|
|
193
|
+
// Leaving Fork mode keeps the selection as a normal quote in the draft.
|
|
194
|
+
const leaveFork = () => {
|
|
195
|
+
if (fork?.quote)
|
|
196
|
+
setInsert({
|
|
197
|
+
text: quoteMarkdown(fork.quote),
|
|
198
|
+
at: Date.now(),
|
|
199
|
+
append: true,
|
|
200
|
+
});
|
|
201
|
+
setForkDraft(null);
|
|
202
|
+
};
|
|
203
|
+
|
|
190
204
|
// Esc sets the composer's ghost text aside, or else stops the turn
|
|
191
205
|
// (lib/chat/escape), from anywhere in this panel.
|
|
192
206
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
193
|
-
const escape = useRef({
|
|
207
|
+
const escape = useRef({
|
|
208
|
+
running,
|
|
209
|
+
interrupt,
|
|
210
|
+
suggestion,
|
|
211
|
+
leaveFork: null as (() => void) | null,
|
|
212
|
+
});
|
|
194
213
|
useEffect(() => {
|
|
195
|
-
escape.current = {
|
|
214
|
+
escape.current = {
|
|
215
|
+
running,
|
|
216
|
+
interrupt,
|
|
217
|
+
suggestion,
|
|
218
|
+
leaveFork: fork ? leaveFork : null,
|
|
219
|
+
};
|
|
196
220
|
});
|
|
197
221
|
useEffect(() => {
|
|
198
222
|
const onKey = (e: KeyboardEvent) => {
|
|
@@ -203,6 +227,17 @@ export function ChatPanel({
|
|
|
203
227
|
const overlay = !!document.querySelector(OVERLAY_SELECTOR);
|
|
204
228
|
const ghost = !!root.querySelector(GHOST_SELECTOR);
|
|
205
229
|
const composer = (e.target as Element).closest?.(".chat-composer");
|
|
230
|
+
// Fork mode ends first; the typed text stays as a normal draft.
|
|
231
|
+
if (
|
|
232
|
+
e.key === "Escape" &&
|
|
233
|
+
escape.current.leaveFork &&
|
|
234
|
+
composer &&
|
|
235
|
+
!overlay
|
|
236
|
+
) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
escape.current.leaveFork();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
206
241
|
const action = escapeAction(
|
|
207
242
|
e,
|
|
208
243
|
escape.current.running,
|
|
@@ -233,6 +268,10 @@ export function ChatPanel({
|
|
|
233
268
|
setInsert({ text: quoteMarkdown(t), at: Date.now(), append: true }),
|
|
234
269
|
focusComposer
|
|
235
270
|
);
|
|
271
|
+
const forkQuote = (text: string) => {
|
|
272
|
+
setForkDraft({ sessionId, quote: text, own: false });
|
|
273
|
+
focusComposer();
|
|
274
|
+
};
|
|
236
275
|
const togglePlan = plan === null ? undefined : () => setPlan(!plan);
|
|
237
276
|
const sendText = (text: string) => {
|
|
238
277
|
toEnd();
|
|
@@ -643,7 +682,11 @@ export function ChatPanel({
|
|
|
643
682
|
onStop={stopTask}
|
|
644
683
|
onLoadOutput={loadTaskOutput}
|
|
645
684
|
/>
|
|
646
|
-
<QuoteButton
|
|
685
|
+
<QuoteButton
|
|
686
|
+
rootRef={scrollRef}
|
|
687
|
+
onQuote={quote}
|
|
688
|
+
onFork={forksOn ? forkQuote : undefined}
|
|
689
|
+
/>
|
|
647
690
|
<PausedBanner sessionId={sessionId} />
|
|
648
691
|
<ForksStrip sessionId={sessionId} />
|
|
649
692
|
<Queue
|
|
@@ -682,14 +725,49 @@ export function ChatPanel({
|
|
|
682
725
|
insert={insert}
|
|
683
726
|
running={running}
|
|
684
727
|
disabled={!connected}
|
|
685
|
-
placeholder={
|
|
728
|
+
placeholder={
|
|
729
|
+
!connected
|
|
730
|
+
? "Reconnecting…"
|
|
731
|
+
: fork
|
|
732
|
+
? "What should the fork do?"
|
|
733
|
+
: `Message ${sessionName}`
|
|
734
|
+
}
|
|
735
|
+
fork={
|
|
736
|
+
fork
|
|
737
|
+
? {
|
|
738
|
+
quote: fork.quote,
|
|
739
|
+
own: fork.own,
|
|
740
|
+
onOwn: () => setForkDraft({ ...fork, own: !fork.own }),
|
|
741
|
+
onLeave: leaveFork,
|
|
742
|
+
onDropQuote: () => setForkDraft({ ...fork, quote: "" }),
|
|
743
|
+
}
|
|
744
|
+
: undefined
|
|
745
|
+
}
|
|
686
746
|
onSend={(text, images, files) => {
|
|
687
747
|
if (freshStart && isFreshCommand(text)) {
|
|
688
748
|
startFresh.mutate(sessionId);
|
|
689
749
|
return;
|
|
690
750
|
}
|
|
691
|
-
if (
|
|
692
|
-
|
|
751
|
+
if (fork) {
|
|
752
|
+
startFork.mutate(
|
|
753
|
+
{
|
|
754
|
+
instructions: [(quoteMarkdown(fork.quote) + text).trim()],
|
|
755
|
+
worktree: fork.own,
|
|
756
|
+
// The result comes back by itself, as a card, without a message from the reader.
|
|
757
|
+
delivery: "wake",
|
|
758
|
+
labels: [forkLabel(text, fork.quote)],
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
onSuccess: () => {
|
|
762
|
+
toast.success("Started fork");
|
|
763
|
+
setForkDraft(null);
|
|
764
|
+
},
|
|
765
|
+
onError: (e) => {
|
|
766
|
+
toast.error(e.message);
|
|
767
|
+
setInsert({ text, at: Date.now() });
|
|
768
|
+
},
|
|
769
|
+
}
|
|
770
|
+
);
|
|
693
771
|
return;
|
|
694
772
|
}
|
|
695
773
|
toEnd();
|
|
@@ -711,7 +789,7 @@ export function ChatPanel({
|
|
|
711
789
|
}
|
|
712
790
|
}}
|
|
713
791
|
onStop={interrupt}
|
|
714
|
-
commands={
|
|
792
|
+
commands={freshStart ? withFresh(commands) : commands}
|
|
715
793
|
onRefreshCommands={refreshCommands}
|
|
716
794
|
refreshingCommands={refreshingCommands}
|
|
717
795
|
models={models}
|
|
@@ -731,13 +809,6 @@ export function ChatPanel({
|
|
|
731
809
|
focusKey={active ? sessionId : null}
|
|
732
810
|
/>
|
|
733
811
|
</div>
|
|
734
|
-
{forksOn && (
|
|
735
|
-
<ForkDialog
|
|
736
|
-
sessionId={sessionId}
|
|
737
|
-
open={forkOpen}
|
|
738
|
-
onOpenChange={setForkOpen}
|
|
739
|
-
/>
|
|
740
|
-
)}
|
|
741
812
|
{undoPreview && (
|
|
742
813
|
<UndoDialog
|
|
743
814
|
preview={undoPreview.preview}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "lucide-react";
|
|
14
14
|
import type { ChatItem, ChatOrigin, ChatOriginKind } from "@/lib/chat/events";
|
|
15
15
|
import { eventParts, originOf } from "@/lib/chat/origin";
|
|
16
|
+
import { ForkResults } from "./ForkResults";
|
|
16
17
|
import { SessionAnchor } from "./SessionAnchor";
|
|
17
18
|
import { cn } from "@/lib/utils";
|
|
18
19
|
import { UserMessage } from "./Messages";
|
|
@@ -155,13 +156,24 @@ function Row({
|
|
|
155
156
|
export function EventRow({
|
|
156
157
|
item,
|
|
157
158
|
origin,
|
|
159
|
+
onQuote,
|
|
158
160
|
}: {
|
|
159
161
|
item: UserItem;
|
|
160
162
|
origin: ChatOrigin;
|
|
163
|
+
onQuote?: (text: string) => void;
|
|
161
164
|
}) {
|
|
162
165
|
const { body, decided } = eventParts(item, origin);
|
|
163
166
|
const decidedLabel = `${ownerInUi(useOwnerName(), true)} decided`;
|
|
164
167
|
const decision = origin.kind === "decision";
|
|
168
|
+
if (origin.forks)
|
|
169
|
+
return (
|
|
170
|
+
<ForkResults
|
|
171
|
+
parent={origin.forks.parent}
|
|
172
|
+
ids={origin.forks.ids}
|
|
173
|
+
fallback={body}
|
|
174
|
+
onQuote={onQuote}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
165
177
|
return (
|
|
166
178
|
<div className="flex flex-col gap-1">
|
|
167
179
|
{decided.map((d, i) => (
|
|
@@ -207,11 +219,13 @@ export function EventRow({
|
|
|
207
219
|
export function UserTurn({
|
|
208
220
|
item,
|
|
209
221
|
onUndo,
|
|
222
|
+
onQuote,
|
|
210
223
|
}: {
|
|
211
224
|
item: UserItem;
|
|
212
225
|
onUndo?: () => void;
|
|
226
|
+
onQuote?: (text: string) => void;
|
|
213
227
|
}) {
|
|
214
228
|
const origin = originOf(item);
|
|
215
|
-
if (origin) return <EventRow item={item} origin={origin} />;
|
|
229
|
+
if (origin) return <EventRow item={item} origin={origin} onQuote={onQuote} />;
|
|
216
230
|
return <UserMessage item={item} onUndo={onUndo} />;
|
|
217
231
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { GitFork, Quote, RotateCcw } from "lucide-react";
|
|
4
|
+
import { useForkChildren, type ChildView } from "@/data/fork";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import { StatusPill } from "@/components/ui/status-pill";
|
|
7
|
+
import { SessionAnchor } from "./SessionAnchor";
|
|
8
|
+
import { emptyNote, stateLabel, useRunAgain } from "./Forks";
|
|
9
|
+
|
|
10
|
+
const took = (c: ChildView) => {
|
|
11
|
+
if (!c.startedAt || !c.settledAt) return null;
|
|
12
|
+
const s = Math.max(1, Math.round((c.settledAt - c.startedAt) / 1000));
|
|
13
|
+
return s < 60
|
|
14
|
+
? `${s}s`
|
|
15
|
+
: `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, "0")}s`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function Card({
|
|
19
|
+
c,
|
|
20
|
+
onQuote,
|
|
21
|
+
again,
|
|
22
|
+
}: {
|
|
23
|
+
c: ChildView;
|
|
24
|
+
onQuote?: (text: string) => void;
|
|
25
|
+
again: ReturnType<typeof useRunAgain>;
|
|
26
|
+
}) {
|
|
27
|
+
const { text, tone } = stateLabel(c);
|
|
28
|
+
const empty = c.outcome === "empty";
|
|
29
|
+
const body = empty ? emptyNote(c) : (c.excerpt ?? c.summary ?? "");
|
|
30
|
+
return (
|
|
31
|
+
<section
|
|
32
|
+
aria-label={`Fork ${c.n} result`}
|
|
33
|
+
className="bg-card popover-surface space-y-2 rounded-2xl p-3"
|
|
34
|
+
>
|
|
35
|
+
<div className="flex items-center gap-2">
|
|
36
|
+
<GitFork aria-hidden className="text-muted-foreground size-4" />
|
|
37
|
+
<span className="text-muted-foreground font-mono text-[11px] tracking-wider uppercase">
|
|
38
|
+
Fork {c.n}
|
|
39
|
+
</span>
|
|
40
|
+
<StatusPill tone={tone}>{text}</StatusPill>
|
|
41
|
+
<span className="text-muted-foreground ml-auto text-xs">{took(c)}</span>
|
|
42
|
+
</div>
|
|
43
|
+
<p className="text-sm font-medium">{c.label.replace(/^\d+\.\s*/, "")}</p>
|
|
44
|
+
<p
|
|
45
|
+
className={
|
|
46
|
+
empty
|
|
47
|
+
? "text-sm text-amber-600 dark:text-amber-400"
|
|
48
|
+
: "text-muted-foreground line-clamp-6 text-sm whitespace-pre-wrap"
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
{body}
|
|
52
|
+
</p>
|
|
53
|
+
<div className="flex flex-wrap gap-2">
|
|
54
|
+
<Button asChild size="sm" className="min-h-11">
|
|
55
|
+
<SessionAnchor sessionId={c.id}>Open fork</SessionAnchor>
|
|
56
|
+
</Button>
|
|
57
|
+
{empty ? (
|
|
58
|
+
<Button
|
|
59
|
+
size="sm"
|
|
60
|
+
variant="secondary"
|
|
61
|
+
className="min-h-11"
|
|
62
|
+
disabled={again.pending}
|
|
63
|
+
onClick={() => again.run(c)}
|
|
64
|
+
>
|
|
65
|
+
<RotateCcw aria-hidden className="size-4" /> Run again
|
|
66
|
+
</Button>
|
|
67
|
+
) : (
|
|
68
|
+
onQuote &&
|
|
69
|
+
body && (
|
|
70
|
+
<Button
|
|
71
|
+
size="sm"
|
|
72
|
+
variant="secondary"
|
|
73
|
+
className="min-h-11"
|
|
74
|
+
onClick={() => onQuote(c.excerpt ?? c.summary ?? "")}
|
|
75
|
+
>
|
|
76
|
+
<Quote aria-hidden className="size-4" /> Quote
|
|
77
|
+
</Button>
|
|
78
|
+
)
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
</section>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A delivery of fork results, as one card per fork in the parent's chat.
|
|
86
|
+
export function ForkResults({
|
|
87
|
+
parent,
|
|
88
|
+
ids,
|
|
89
|
+
onQuote,
|
|
90
|
+
fallback,
|
|
91
|
+
}: {
|
|
92
|
+
parent: string;
|
|
93
|
+
ids: string[];
|
|
94
|
+
fallback: string;
|
|
95
|
+
onQuote?: (text: string) => void;
|
|
96
|
+
}) {
|
|
97
|
+
const { data } = useForkChildren(parent, true);
|
|
98
|
+
const again = useRunAgain(parent);
|
|
99
|
+
const cards = (data?.children ?? []).filter((c) => ids.includes(c.id));
|
|
100
|
+
if (!cards.length)
|
|
101
|
+
return <p className="text-muted-foreground text-xs">{fallback}</p>;
|
|
102
|
+
return (
|
|
103
|
+
<div className="flex flex-col gap-2">
|
|
104
|
+
{cards.map((c) => (
|
|
105
|
+
<Card key={c.id} c={c} onQuote={onQuote} again={again} />
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { GitFork,
|
|
4
|
+
import { GitFork, Square } from "lucide-react";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { useExperiment } from "@/data/experiments";
|
|
7
|
-
import { useClientConfig } from "@/data/client-config/queries";
|
|
8
7
|
import {
|
|
9
8
|
useCancelForks,
|
|
10
9
|
useForkChildren,
|
|
@@ -12,17 +11,7 @@ import {
|
|
|
12
11
|
type ChildView,
|
|
13
12
|
} from "@/data/fork";
|
|
14
13
|
import { Button } from "@/components/ui/button";
|
|
15
|
-
import {
|
|
16
|
-
Dialog,
|
|
17
|
-
DialogContent,
|
|
18
|
-
DialogDescription,
|
|
19
|
-
DialogFooter,
|
|
20
|
-
DialogHeader,
|
|
21
|
-
DialogTitle,
|
|
22
|
-
} from "@/components/ui/dialog";
|
|
23
14
|
import { StatusPill } from "@/components/ui/status-pill";
|
|
24
|
-
import { Switch } from "@/components/ui/switch";
|
|
25
|
-
import { Textarea } from "@/components/ui/textarea";
|
|
26
15
|
import { SessionAnchor } from "./SessionAnchor";
|
|
27
16
|
|
|
28
17
|
type Tone = "amber" | "muted" | "green" | "primary" | "red";
|
|
@@ -34,22 +23,55 @@ export function stateLabel(c: ChildView): { text: string; tone: Tone } {
|
|
|
34
23
|
if (c.state === "needs_input") return { text: "Needs you", tone: "amber" };
|
|
35
24
|
if (c.outcome === "failed") return { text: "Failed", tone: "red" };
|
|
36
25
|
if (c.outcome === "cancelled") return { text: "Stopped", tone: "muted" };
|
|
26
|
+
if (c.outcome === "empty") return { text: "No result", tone: "amber" };
|
|
37
27
|
return { text: "Done", tone: "green" };
|
|
38
28
|
}
|
|
39
29
|
|
|
30
|
+
// The strip's name for a fork: what was asked, else what was quoted, so a
|
|
31
|
+
// quote-first instruction isn't labelled with its "> ".
|
|
32
|
+
export const forkLabel = (typed: string, quote: string): string => {
|
|
33
|
+
const line = (typed.trim() || quote.trim()).split("\n")[0].trim();
|
|
34
|
+
return line.length > 60 ? `${line.slice(0, 59)}…` : line;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// What a fork that ended with nothing to read says in place of a result.
|
|
38
|
+
export const emptyNote = (c: ChildView) =>
|
|
39
|
+
c.summary && c.summary !== "ended without a result"
|
|
40
|
+
? `Ended with “${c.summary}”, not an answer`
|
|
41
|
+
: "Ended without a result";
|
|
42
|
+
|
|
43
|
+
// Starts the same instruction again, for a fork that came back with nothing.
|
|
44
|
+
export function useRunAgain(sessionId: string) {
|
|
45
|
+
const start = useStartForks(sessionId);
|
|
46
|
+
return {
|
|
47
|
+
pending: start.isPending,
|
|
48
|
+
run: (c: ChildView) =>
|
|
49
|
+
start.mutate(
|
|
50
|
+
{ instructions: [c.instruction], worktree: c.worktree },
|
|
51
|
+
{
|
|
52
|
+
onSuccess: () => toast.success("Started fork"),
|
|
53
|
+
onError: (e) => toast.error(e.message),
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
function Row({
|
|
41
60
|
c,
|
|
42
61
|
onStop,
|
|
43
62
|
stopping,
|
|
63
|
+
again,
|
|
44
64
|
}: {
|
|
45
65
|
c: ChildView;
|
|
66
|
+
again: ReturnType<typeof useRunAgain>;
|
|
46
67
|
onStop: () => void;
|
|
47
68
|
stopping: boolean;
|
|
48
69
|
}) {
|
|
49
70
|
const { text, tone } = stateLabel(c);
|
|
50
71
|
const open = c.state !== "settled";
|
|
72
|
+
const empty = c.outcome === "empty";
|
|
51
73
|
const note =
|
|
52
|
-
c.summary ??
|
|
74
|
+
(empty ? emptyNote(c) : c.summary) ??
|
|
53
75
|
(c.asks
|
|
54
76
|
? `Asks: ${c.asks}`
|
|
55
77
|
: c.state === "queued"
|
|
@@ -65,7 +87,13 @@ function Row({
|
|
|
65
87
|
{c.n}. {c.label.replace(/^\d+\.\s*/, "")}
|
|
66
88
|
</p>
|
|
67
89
|
{note && (
|
|
68
|
-
<p
|
|
90
|
+
<p
|
|
91
|
+
className={
|
|
92
|
+
empty
|
|
93
|
+
? "truncate text-xs text-amber-600 dark:text-amber-400"
|
|
94
|
+
: "text-muted-foreground truncate text-xs"
|
|
95
|
+
}
|
|
96
|
+
>
|
|
69
97
|
{note}
|
|
70
98
|
{c.resultKind === "implicit" && c.outcome === "ok"
|
|
71
99
|
? " · ended without reporting"
|
|
@@ -73,6 +101,16 @@ function Row({
|
|
|
73
101
|
</p>
|
|
74
102
|
)}
|
|
75
103
|
</div>
|
|
104
|
+
{empty && (
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
disabled={again.pending}
|
|
108
|
+
onClick={() => again.run(c)}
|
|
109
|
+
className="text-primary flex min-h-11 shrink-0 items-center px-2 text-sm"
|
|
110
|
+
>
|
|
111
|
+
Run again
|
|
112
|
+
</button>
|
|
113
|
+
)}
|
|
76
114
|
<SessionAnchor
|
|
77
115
|
sessionId={c.id}
|
|
78
116
|
className="text-primary flex min-h-11 shrink-0 items-center px-2 text-sm"
|
|
@@ -100,6 +138,7 @@ export function ForksStrip({ sessionId }: { sessionId: string }) {
|
|
|
100
138
|
const on = useExperiment("forks");
|
|
101
139
|
const { data } = useForkChildren(sessionId, on);
|
|
102
140
|
const cancel = useCancelForks(sessionId);
|
|
141
|
+
const again = useRunAgain(sessionId);
|
|
103
142
|
const [collapsed, setCollapsed] = useState(false);
|
|
104
143
|
if (!on || !data) return null;
|
|
105
144
|
if (data.asChild) return <ForkOfBanner info={data.asChild} />;
|
|
@@ -150,6 +189,7 @@ export function ForksStrip({ sessionId }: { sessionId: string }) {
|
|
|
150
189
|
key={c.id}
|
|
151
190
|
c={c}
|
|
152
191
|
stopping={cancel.isPending}
|
|
192
|
+
again={again}
|
|
153
193
|
onStop={() => stop(String(c.n))}
|
|
154
194
|
/>
|
|
155
195
|
))}
|
|
@@ -187,92 +227,3 @@ function ForkOfBanner({
|
|
|
187
227
|
</section>
|
|
188
228
|
);
|
|
189
229
|
}
|
|
190
|
-
|
|
191
|
-
// "/fork": instructions for N copies of this session.
|
|
192
|
-
export function ForkDialog({
|
|
193
|
-
sessionId,
|
|
194
|
-
open,
|
|
195
|
-
onOpenChange,
|
|
196
|
-
}: {
|
|
197
|
-
sessionId: string;
|
|
198
|
-
open: boolean;
|
|
199
|
-
onOpenChange: (open: boolean) => void;
|
|
200
|
-
}) {
|
|
201
|
-
const start = useStartForks(sessionId);
|
|
202
|
-
const max = useClientConfig().data?.forks?.maxPerFork ?? 8;
|
|
203
|
-
const [texts, setTexts] = useState<string[]>([""]);
|
|
204
|
-
const [worktree, setWorktree] = useState(false);
|
|
205
|
-
const filled = texts.map((t) => t.trim()).filter(Boolean);
|
|
206
|
-
const submit = () =>
|
|
207
|
-
start.mutate(
|
|
208
|
-
{ instructions: filled, worktree },
|
|
209
|
-
{
|
|
210
|
-
onSuccess: (r) => {
|
|
211
|
-
toast.success(
|
|
212
|
-
`Started ${r.children.length} ${r.children.length === 1 ? "fork" : "forks"}`
|
|
213
|
-
);
|
|
214
|
-
setTexts([""]);
|
|
215
|
-
setWorktree(false);
|
|
216
|
-
onOpenChange(false);
|
|
217
|
-
},
|
|
218
|
-
onError: (e) => toast.error(e.message),
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
return (
|
|
222
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
223
|
-
<DialogContent className="max-h-[90dvh] overflow-y-auto sm:max-w-lg">
|
|
224
|
-
<DialogHeader>
|
|
225
|
-
<DialogTitle>Fork this session</DialogTitle>
|
|
226
|
-
<DialogDescription>
|
|
227
|
-
Each copy knows what this session knows and works in the background.
|
|
228
|
-
You keep going; results are added to your next message.
|
|
229
|
-
</DialogDescription>
|
|
230
|
-
</DialogHeader>
|
|
231
|
-
<div className="space-y-2">
|
|
232
|
-
{texts.map((t, i) => (
|
|
233
|
-
<Textarea
|
|
234
|
-
key={i}
|
|
235
|
-
value={t}
|
|
236
|
-
rows={2}
|
|
237
|
-
aria-label={`Fork ${i + 1}`}
|
|
238
|
-
placeholder={`What should fork ${i + 1} do?`}
|
|
239
|
-
onChange={(e) =>
|
|
240
|
-
setTexts(texts.map((x, j) => (j === i ? e.target.value : x)))
|
|
241
|
-
}
|
|
242
|
-
/>
|
|
243
|
-
))}
|
|
244
|
-
{texts.length < max && (
|
|
245
|
-
<Button
|
|
246
|
-
type="button"
|
|
247
|
-
variant="ghost"
|
|
248
|
-
size="sm"
|
|
249
|
-
className="min-h-11"
|
|
250
|
-
onClick={() => setTexts([...texts, ""])}
|
|
251
|
-
>
|
|
252
|
-
<Plus aria-hidden className="size-4" /> Another
|
|
253
|
-
</Button>
|
|
254
|
-
)}
|
|
255
|
-
<label className="flex min-h-11 items-center justify-between gap-3 text-sm">
|
|
256
|
-
<span>
|
|
257
|
-
Own checkout
|
|
258
|
-
<span className="text-muted-foreground block text-xs">
|
|
259
|
-
For forks that edit code. Off: they read this checkout and leave
|
|
260
|
-
it alone.
|
|
261
|
-
</span>
|
|
262
|
-
</span>
|
|
263
|
-
<Switch checked={worktree} onCheckedChange={setWorktree} />
|
|
264
|
-
</label>
|
|
265
|
-
</div>
|
|
266
|
-
<DialogFooter>
|
|
267
|
-
<Button
|
|
268
|
-
className="min-h-11"
|
|
269
|
-
disabled={!filled.length || start.isPending}
|
|
270
|
-
onClick={submit}
|
|
271
|
-
>
|
|
272
|
-
{filled.length > 1 ? `Start ${filled.length} forks` : "Start fork"}
|
|
273
|
-
</Button>
|
|
274
|
-
</DialogFooter>
|
|
275
|
-
</DialogContent>
|
|
276
|
-
</Dialog>
|
|
277
|
-
);
|
|
278
|
-
}
|