@bridgebrew/sessions 0.0.34 → 0.0.43
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/branch-name.ts +45 -0
- package/browser/branch-actions.tsx +26 -47
- package/browser/conversation.tsx +123 -3
- package/browser/details.tsx +408 -0
- package/browser/index.tsx +685 -497
- package/browser/mobile.tsx +118 -8
- package/browser/pull-request.tsx +9 -6
- package/browser/session-scheduled.tsx +6 -3
- package/browser/subagent-view.tsx +2 -2
- package/contract.ts +6 -0
- package/delegations.ts +6 -7
- package/package.json +51 -10
- package/server.ts +642 -236
- package/text.ts +9 -0
- package/browser/changes.tsx +0 -464
- package/git.ts +0 -318
package/browser/index.tsx
CHANGED
|
@@ -81,9 +81,11 @@ import {
|
|
|
81
81
|
SelectContent,
|
|
82
82
|
SelectItem,
|
|
83
83
|
SelectTrigger,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
MultiPane,
|
|
85
|
+
multiPaneAsideWidth,
|
|
86
|
+
currentWorkspace,
|
|
87
|
+
profile,
|
|
88
|
+
StatusIcon,
|
|
87
89
|
SidebarGroup,
|
|
88
90
|
SidebarGroupContent,
|
|
89
91
|
SidebarGroupTrigger,
|
|
@@ -108,16 +110,19 @@ import {
|
|
|
108
110
|
import type { Context } from 'cordis';
|
|
109
111
|
import type {} from '@bridge/ui-renderer/client';
|
|
110
112
|
import type { ViewComponentRenderer } from './views/view.tsx';
|
|
111
|
-
import {
|
|
113
|
+
import { DetailsPanel, Row, detailsOf, type GitRowsProps } from './details.tsx';
|
|
112
114
|
import { SessionPrompt } from '@bridgebrew/session-ui/prompt';
|
|
113
|
-
import {
|
|
115
|
+
import {
|
|
116
|
+
shownModel,
|
|
117
|
+
type HarnessModels,
|
|
118
|
+
type PickerModel,
|
|
119
|
+
} from '@bridgebrew/session-ui/model-picker';
|
|
114
120
|
import { ProviderMark, providerOf } from '@bridgebrew/session-ui/providers';
|
|
115
121
|
import {
|
|
116
122
|
Conversation,
|
|
117
123
|
DecisionDock,
|
|
118
124
|
Queued,
|
|
119
125
|
type QueuedNote,
|
|
120
|
-
Spinner,
|
|
121
126
|
Tasks,
|
|
122
127
|
decisionsOf,
|
|
123
128
|
NO_DECISIONS,
|
|
@@ -128,8 +133,8 @@ import {
|
|
|
128
133
|
import { Questions, type Question } from './questions.tsx';
|
|
129
134
|
import { GalleryPins, type Attached, type Pinned, type Viewed } from '@bridgebrew/session-ui/media';
|
|
130
135
|
import { GalleryDialog, type Scope } from './gallery.tsx';
|
|
131
|
-
import {
|
|
132
|
-
import {
|
|
136
|
+
import { CleanupDialog, cleanupOf, installGit, type Cleanup } from './branch-actions.tsx';
|
|
137
|
+
import type { SessionPullRequest } from './pull-request.tsx';
|
|
133
138
|
import { viewTools as viewToolsOf, Missing } from './views.tsx';
|
|
134
139
|
import { Tab, TabStrip, TabsProvider, useSessionTabs, type TabSlotProps } from './tabs.tsx';
|
|
135
140
|
import { MobileSessions } from './mobile.tsx';
|
|
@@ -177,6 +182,8 @@ export const shownWorktree = (workspace: { slug: string }) => {
|
|
|
177
182
|
return shown !== '' && shown !== workspace.slug ? shown : undefined;
|
|
178
183
|
};
|
|
179
184
|
/** `url` asking for worktree `worktree`'s sessions only, when there is one. */
|
|
185
|
+
/** Open in editor from another computer (the host's `local`, bridge-plugins#253): its links say so instead of opening. */
|
|
186
|
+
const notLocal = 'Open in editor is not available yet from another computer';
|
|
180
187
|
const forWorktree = (url: string, worktree: string | undefined) =>
|
|
181
188
|
worktree === undefined
|
|
182
189
|
? url
|
|
@@ -224,10 +231,9 @@ const useBranches = (slug: string, node: string, startNew = false) => {
|
|
|
224
231
|
setBranches(undefined);
|
|
225
232
|
choose(undefined);
|
|
226
233
|
if (node === 'root') return;
|
|
227
|
-
fetch(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
)
|
|
234
|
+
fetch(`/${encodeURIComponent(slug)}/api/project/branches?node=${encodeURIComponent(node)}`, {
|
|
235
|
+
cache: 'no-store',
|
|
236
|
+
})
|
|
231
237
|
.then((res) => (res.ok ? readJson(res) : undefined))
|
|
232
238
|
.then((body: unknown) => {
|
|
233
239
|
if (gone || !isRecord(body) || !Array.isArray(body.branches)) return;
|
|
@@ -345,6 +351,14 @@ export const notesOf = (session: Session): QueuedNote[] =>
|
|
|
345
351
|
? { node, screen: { plugin: name, id: 'sessions' }, item: from }
|
|
346
352
|
: { item: from, reuse: true },
|
|
347
353
|
}));
|
|
354
|
+
/** A button of the window's bar, as the shell takes it (`screen`'s `setActions`, plugins/shell/shell.d.ts). */
|
|
355
|
+
type ScreenAction = {
|
|
356
|
+
id: string;
|
|
357
|
+
label: string;
|
|
358
|
+
icon: string;
|
|
359
|
+
pressed?: boolean;
|
|
360
|
+
onSelect: () => void;
|
|
361
|
+
};
|
|
348
362
|
type Action = 'settle' | 'unsettle' | 'pin' | 'unpin' | 'unread' | 'archive' | 'restore' | 'wake';
|
|
349
363
|
type Shelf = 'pinned' | 'active' | 'working' | 'snoozed' | 'settled' | 'archived';
|
|
350
364
|
/** Settled rows shown before "Show more". */
|
|
@@ -382,6 +396,22 @@ export interface Listing {
|
|
|
382
396
|
snooze?: boolean;
|
|
383
397
|
}
|
|
384
398
|
|
|
399
|
+
/** A watch's new connection, before its first message (plugins#239): the lines past `saved` (the log's, for sure) leave
|
|
400
|
+
* the page, with the results they gave (`resulted`, tool id → seq): a restart may have lost them and numbered others
|
|
401
|
+
* the same, and the server sends what is past `saved` again. Never at the snapshot: older lines come before it when
|
|
402
|
+
* they do not fit. Returns the new `last`. */
|
|
403
|
+
export const dropUnsaved = (
|
|
404
|
+
last: number,
|
|
405
|
+
saved: number,
|
|
406
|
+
resulted: Map<string, number>,
|
|
407
|
+
setEvents: (update: (was: Stored[]) => Stored[]) => void,
|
|
408
|
+
) => {
|
|
409
|
+
if (last <= saved) return last;
|
|
410
|
+
for (const [id, seq] of resulted) if (seq > saved) resulted.delete(id);
|
|
411
|
+
setEvents((was) => was.filter((line) => line.seq <= saved));
|
|
412
|
+
return saved;
|
|
413
|
+
};
|
|
414
|
+
|
|
385
415
|
/** `live` after stored line `event`: a turn starts and ends; a settled segment or tool leaves the live part. */
|
|
386
416
|
export const afterStored = (live: Live | null, event: Stored): Live | null => {
|
|
387
417
|
if (event.type === 'turn/start')
|
|
@@ -440,7 +470,16 @@ export const afterLive = (live: Live | null, event: LiveEvent): Live | null => {
|
|
|
440
470
|
if (event.type === 'text') return { ...live, text: live.text + (event.text ?? '') };
|
|
441
471
|
if (event.type === 'thought') return { ...live, thought: live.thought + (event.text ?? '') };
|
|
442
472
|
if (event.type === 'plan') return { ...live, plan: event.entries ?? [] };
|
|
443
|
-
|
|
473
|
+
// Given in parts (Claude: `used` per message, `size` alone on its result): a part keeps the other.
|
|
474
|
+
if (event.type === 'usage')
|
|
475
|
+
return {
|
|
476
|
+
...live,
|
|
477
|
+
usage: {
|
|
478
|
+
...live.usage,
|
|
479
|
+
...(event.used !== undefined && { used: event.used }),
|
|
480
|
+
...(event.size !== undefined && { size: event.size }),
|
|
481
|
+
},
|
|
482
|
+
};
|
|
444
483
|
if (event.type === 'decision') return { ...live, decisions: [...live.decisions, event] };
|
|
445
484
|
if (event.type === 'view/draft')
|
|
446
485
|
return {
|
|
@@ -609,6 +648,7 @@ interface ViewComponentSlotProps {
|
|
|
609
648
|
* session opened on this node, named as the window's item. Its keys act only while its window is `focused`. */
|
|
610
649
|
type RenderTabs = {
|
|
611
650
|
(name: 'sessions.tab', owner: TabSlotProps): React.ReactNode;
|
|
651
|
+
(name: 'sessions.details', owner: GitRowsProps): React.ReactNode;
|
|
612
652
|
(
|
|
613
653
|
name: 'views.component',
|
|
614
654
|
owner: ViewComponentSlotProps,
|
|
@@ -663,53 +703,45 @@ const RowMenu = ({
|
|
|
663
703
|
each: Session;
|
|
664
704
|
actions: React.RefObject<RowActions | undefined>;
|
|
665
705
|
}) => actions.current!.menuItems(each);
|
|
666
|
-
/**
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
aria-label="Woke from a snooze"
|
|
706
|
-
className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent"
|
|
707
|
-
>
|
|
708
|
-
<Icon name="alarm-clock" size={12} />
|
|
709
|
-
Woke
|
|
710
|
-
</span>
|
|
711
|
-
);
|
|
712
|
-
return null;
|
|
706
|
+
/** Working: a ring with a dot inside (the kit's StatusIcon has none: a bare dot is never a full disc). */
|
|
707
|
+
const WorkingMark = () => (
|
|
708
|
+
<span
|
|
709
|
+
aria-hidden
|
|
710
|
+
className="inline-flex size-3 shrink-0 items-center justify-center rounded-full border-[1.5px] border-accent"
|
|
711
|
+
>
|
|
712
|
+
<span className="size-1 rounded-full bg-accent" />
|
|
713
|
+
</span>
|
|
714
|
+
);
|
|
715
|
+
/** A row's state in its slot, mark and word (none when idle, or unread without a turn that ended well). */
|
|
716
|
+
const disc = (status: 'warning' | 'error' | 'resolved') => (
|
|
717
|
+
<StatusIcon status={status} size="sm" aria-hidden />
|
|
718
|
+
);
|
|
719
|
+
/** Each state's mark, word, colour and name (the names the list's marks always had). */
|
|
720
|
+
const STATES: Record<string, [React.ReactNode, string, string, string]> = {
|
|
721
|
+
decision: [disc('warning'), 'Needs you', 'text-warning-text', 'Decision waiting'],
|
|
722
|
+
question: [disc('warning'), 'Your call', 'text-warning-text', 'A question past its deadline'],
|
|
723
|
+
running: [<WorkingMark />, 'Working', 'text-accent', 'Working'],
|
|
724
|
+
failed: [disc('error'), 'Failed', 'text-destructive', 'Failed'],
|
|
725
|
+
done: [disc('resolved'), 'Done', 'text-success', 'Done'],
|
|
726
|
+
woke: [<Icon name="alarm-clock" size={12} />, 'Woke', 'text-accent', 'Woke from a snooze'],
|
|
727
|
+
};
|
|
728
|
+
/** A row's state in its slot, mark and word: none when idle, or unread without a turn that ended well. */
|
|
729
|
+
const stateMark = (status: string, each: Session) => {
|
|
730
|
+
const shown =
|
|
731
|
+
STATES[status === 'unread' && each.lastTurn?.reason === 'completed' ? 'done' : status];
|
|
732
|
+
if (!shown) return null;
|
|
733
|
+
const [mark, word, className, label] = shown;
|
|
734
|
+
return (
|
|
735
|
+
<span
|
|
736
|
+
role="img"
|
|
737
|
+
aria-label={label}
|
|
738
|
+
data-state={word}
|
|
739
|
+
className={cn('inline-flex shrink-0 items-center gap-1 text-xs font-medium', className)}
|
|
740
|
+
>
|
|
741
|
+
{mark}
|
|
742
|
+
{word}
|
|
743
|
+
</span>
|
|
744
|
+
);
|
|
713
745
|
};
|
|
714
746
|
|
|
715
747
|
/** A row's hover action: settle, wake in Snoozed, un-settle in Settled, restore in Archived. */
|
|
@@ -937,21 +969,12 @@ export const SessionRow = React.memo(function SessionRow({
|
|
|
937
969
|
faded && 'opacity-60 group-hover:opacity-100',
|
|
938
970
|
)}
|
|
939
971
|
>
|
|
972
|
+
{/* Two lines, each slot in its place for every session (plugins#239 §2): its title and its time
|
|
973
|
+
(its actions while hovered); its branch (or stage) and model, then unread and its state. */}
|
|
940
974
|
<div className="flex h-5 items-center gap-2">
|
|
941
975
|
<span className="min-w-0 flex-1 truncate text-sm font-semibold text-foreground">
|
|
942
976
|
{each.title}
|
|
943
977
|
</span>
|
|
944
|
-
{/* Where it works, in the workspace's own list (research-083): a stage, by the branches it runs. */}
|
|
945
|
-
{worktreeName !== undefined && (
|
|
946
|
-
<span
|
|
947
|
-
title={`Works in the stage ${worktreeName}`}
|
|
948
|
-
className="inline-flex max-w-32 shrink-0 items-center gap-1 text-xs text-muted"
|
|
949
|
-
>
|
|
950
|
-
<Icon name="git-branch" size={12} />
|
|
951
|
-
<span className="truncate">{worktreeName}</span>
|
|
952
|
-
</span>
|
|
953
|
-
)}
|
|
954
|
-
{statusMark(status)}
|
|
955
978
|
{each.snoozedUntil ? (
|
|
956
979
|
<span
|
|
957
980
|
title={`Wakes ${when(each.snoozedUntil)}`}
|
|
@@ -967,87 +990,114 @@ export const SessionRow = React.memo(function SessionRow({
|
|
|
967
990
|
)}
|
|
968
991
|
{hover}
|
|
969
992
|
</div>
|
|
970
|
-
|
|
971
|
-
<
|
|
972
|
-
{
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
<div className={cn('flex flex-wrap items-center gap-1', depth ? 'mt-0.5' : 'mt-1.5')}>
|
|
976
|
-
<Tooltip>
|
|
977
|
-
<TooltipTrigger
|
|
978
|
-
render={
|
|
993
|
+
<div className="mt-0.5 flex h-4 items-center gap-1 text-xs text-muted">
|
|
994
|
+
<span data-slot="where" className="inline-flex min-w-0 flex-1 items-center gap-1">
|
|
995
|
+
{worktreeName !== undefined && (
|
|
996
|
+
<>
|
|
997
|
+
<Icon name="git-branch" size={12} />
|
|
979
998
|
<span
|
|
980
|
-
|
|
981
|
-
className="
|
|
982
|
-
|
|
983
|
-
|
|
999
|
+
data-who="branch"
|
|
1000
|
+
className="min-w-0 max-w-32 shrink truncate"
|
|
1001
|
+
title={`Works on ${worktreeName}`}
|
|
1002
|
+
>
|
|
1003
|
+
{worktreeName}
|
|
1004
|
+
</span>
|
|
1005
|
+
<span aria-hidden>·</span>
|
|
1006
|
+
</>
|
|
1007
|
+
)}
|
|
1008
|
+
<span
|
|
1009
|
+
aria-hidden
|
|
1010
|
+
className="inline-flex size-3.5 shrink-0 items-center justify-center text-foreground"
|
|
984
1011
|
>
|
|
985
1012
|
<ProviderMark provider={provider} size={12} />
|
|
986
|
-
</
|
|
987
|
-
<
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
{nodeTitle}
|
|
993
|
-
</Badge>
|
|
994
|
-
)}
|
|
995
|
-
{each.tags?.map((tag) => (
|
|
996
|
-
<button
|
|
997
|
-
key={tag}
|
|
998
|
-
type="button"
|
|
999
|
-
data-tag={tag}
|
|
1000
|
-
aria-pressed={tagged === tag}
|
|
1001
|
-
title={
|
|
1002
|
-
tagged === tag ? 'Show every session' : `Show the sessions tagged ${tag}`
|
|
1003
|
-
}
|
|
1004
|
-
className={cn(
|
|
1005
|
-
'cursor-pointer rounded-full border-0 px-1.5 text-[11px] leading-4 text-secondary hover:bg-border/60',
|
|
1006
|
-
tagged === tag ? 'bg-accent/15 text-accent' : 'bg-border/40',
|
|
1007
|
-
)}
|
|
1008
|
-
onClick={(event) => {
|
|
1009
|
-
event.stopPropagation();
|
|
1010
|
-
actions.current!.setTagged((was) => (was === tag ? undefined : tag));
|
|
1011
|
-
}}
|
|
1012
|
-
onPointerDown={(event) => event.stopPropagation()}
|
|
1013
|
-
>
|
|
1014
|
-
#{tag}
|
|
1015
|
-
</button>
|
|
1016
|
-
))}
|
|
1017
|
-
{/* Its children (bridge#212): shown or hidden under it, the toggle in one place, the line's end. */}
|
|
1018
|
-
{kids + agents > 0 && (
|
|
1019
|
-
<Button
|
|
1020
|
-
size="sm"
|
|
1021
|
-
// Not the row's menu: its children shown keep the row's stamp, its actions hidden (`:not([data-kids])`).
|
|
1022
|
-
data-kids
|
|
1023
|
-
aria-expanded={kidsOpen}
|
|
1024
|
-
aria-label={`${kidsOpen ? 'Hide' : 'Show'} ${[
|
|
1025
|
-
kids > 0 && `${kids} child session${kids === 1 ? '' : 's'}`,
|
|
1026
|
-
agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
|
|
1027
|
-
]
|
|
1028
|
-
.filter(Boolean)
|
|
1029
|
-
.join(' and ')} of ${each.title}`}
|
|
1030
|
-
className="-my-1 ml-auto h-6 gap-1 px-1.5 text-xs text-muted"
|
|
1031
|
-
onClick={(event) => {
|
|
1032
|
-
event.stopPropagation();
|
|
1033
|
-
actions.current!.toggleChildren?.(each.id);
|
|
1034
|
-
}}
|
|
1035
|
-
onPointerDown={(event) => event.stopPropagation()}
|
|
1013
|
+
</span>
|
|
1014
|
+
<span
|
|
1015
|
+
data-who="model"
|
|
1016
|
+
className="min-w-0 truncate"
|
|
1017
|
+
title={modelLabel}
|
|
1018
|
+
aria-label={modelLabel}
|
|
1036
1019
|
>
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1020
|
+
{modelLabel.split(' · ').at(-1)}
|
|
1021
|
+
</span>
|
|
1022
|
+
</span>
|
|
1023
|
+
<span data-slot="unread" className="inline-flex w-2 shrink-0 justify-center">
|
|
1024
|
+
{(status === 'unread' || status === 'failed') && (
|
|
1025
|
+
<span
|
|
1026
|
+
role="img"
|
|
1027
|
+
aria-label="Unread"
|
|
1028
|
+
className="size-2 rounded-full bg-accent"
|
|
1041
1029
|
/>
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
.join(' · ')}
|
|
1048
|
-
</Button>
|
|
1049
|
-
)}
|
|
1030
|
+
)}
|
|
1031
|
+
</span>
|
|
1032
|
+
<span data-slot="state" className="inline-flex shrink-0">
|
|
1033
|
+
{stateMark(status, each)}
|
|
1034
|
+
</span>
|
|
1050
1035
|
</div>
|
|
1036
|
+
{(nodeTitle !== undefined || !!each.tags?.length || kids + agents > 0) && (
|
|
1037
|
+
<div className="mt-1.5 flex flex-wrap items-center gap-1">
|
|
1038
|
+
{nodeTitle !== undefined && (
|
|
1039
|
+
<Badge className="min-w-0 justify-start gap-1 truncate">
|
|
1040
|
+
<Icon name="folder" size={12} />
|
|
1041
|
+
{nodeTitle}
|
|
1042
|
+
</Badge>
|
|
1043
|
+
)}
|
|
1044
|
+
{each.tags?.map((tag) => (
|
|
1045
|
+
<button
|
|
1046
|
+
key={tag}
|
|
1047
|
+
type="button"
|
|
1048
|
+
data-tag={tag}
|
|
1049
|
+
aria-pressed={tagged === tag}
|
|
1050
|
+
title={
|
|
1051
|
+
tagged === tag ? 'Show every session' : `Show the sessions tagged ${tag}`
|
|
1052
|
+
}
|
|
1053
|
+
className={cn(
|
|
1054
|
+
'cursor-pointer rounded-full border-0 px-1.5 text-[11px] leading-4 text-secondary hover:bg-border/60',
|
|
1055
|
+
tagged === tag ? 'bg-accent/15 text-accent' : 'bg-border/40',
|
|
1056
|
+
)}
|
|
1057
|
+
onClick={(event) => {
|
|
1058
|
+
event.stopPropagation();
|
|
1059
|
+
actions.current!.setTagged((was) => (was === tag ? undefined : tag));
|
|
1060
|
+
}}
|
|
1061
|
+
onPointerDown={(event) => event.stopPropagation()}
|
|
1062
|
+
>
|
|
1063
|
+
#{tag}
|
|
1064
|
+
</button>
|
|
1065
|
+
))}
|
|
1066
|
+
{/* Its children (bridge#212): shown or hidden under it, the toggle in one place, the line's end. */}
|
|
1067
|
+
{kids + agents > 0 && (
|
|
1068
|
+
<Button
|
|
1069
|
+
size="sm"
|
|
1070
|
+
// Not the row's menu: its children shown keep the row's stamp, its actions hidden (`:not([data-kids])`).
|
|
1071
|
+
data-kids
|
|
1072
|
+
aria-expanded={kidsOpen}
|
|
1073
|
+
aria-label={`${kidsOpen ? 'Hide' : 'Show'} ${[
|
|
1074
|
+
kids > 0 && `${kids} child session${kids === 1 ? '' : 's'}`,
|
|
1075
|
+
agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
|
|
1076
|
+
]
|
|
1077
|
+
.filter(Boolean)
|
|
1078
|
+
.join(' and ')} of ${each.title}`}
|
|
1079
|
+
className="-my-1 ml-auto h-6 gap-1 px-1.5 text-xs text-muted"
|
|
1080
|
+
onClick={(event) => {
|
|
1081
|
+
event.stopPropagation();
|
|
1082
|
+
actions.current!.toggleChildren?.(each.id);
|
|
1083
|
+
}}
|
|
1084
|
+
onPointerDown={(event) => event.stopPropagation()}
|
|
1085
|
+
>
|
|
1086
|
+
<Icon
|
|
1087
|
+
name="chevron-right"
|
|
1088
|
+
size={12}
|
|
1089
|
+
className={cn('transition-transform', kidsOpen && 'rotate-90')}
|
|
1090
|
+
/>
|
|
1091
|
+
{[
|
|
1092
|
+
kids > 0 && `${kids} child${kids === 1 ? '' : 'ren'}`,
|
|
1093
|
+
agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
|
|
1094
|
+
]
|
|
1095
|
+
.filter(Boolean)
|
|
1096
|
+
.join(' · ')}
|
|
1097
|
+
</Button>
|
|
1098
|
+
)}
|
|
1099
|
+
</div>
|
|
1100
|
+
)}
|
|
1051
1101
|
</div>
|
|
1052
1102
|
)}
|
|
1053
1103
|
</ListItem>
|
|
@@ -1110,6 +1160,7 @@ function Sessions({
|
|
|
1110
1160
|
item,
|
|
1111
1161
|
focused,
|
|
1112
1162
|
renderSlot,
|
|
1163
|
+
setActions,
|
|
1113
1164
|
}: {
|
|
1114
1165
|
ctx: Context;
|
|
1115
1166
|
node: string;
|
|
@@ -1117,6 +1168,8 @@ function Sessions({
|
|
|
1117
1168
|
item: string | undefined;
|
|
1118
1169
|
focused: boolean | undefined;
|
|
1119
1170
|
renderSlot: RenderTabs;
|
|
1171
|
+
/** The shell's buttons in this window's bar (`screen`'s `setActions`); absent from an older shell. */
|
|
1172
|
+
setActions?: ((actions: readonly ScreenAction[]) => void) | undefined;
|
|
1120
1173
|
}) {
|
|
1121
1174
|
const { workspace } = ctx;
|
|
1122
1175
|
const api = `/${workspace.slug}/api/sessions/sessions`;
|
|
@@ -1167,8 +1220,10 @@ function Sessions({
|
|
|
1167
1220
|
// Another item: the choice made apart is dropped.
|
|
1168
1221
|
React.useEffect(() => setOverride(undefined), [item]);
|
|
1169
1222
|
// A sub-agent's item names its session and it (bridge#212 S8): the session is the one shown, its view the sub-agent's.
|
|
1223
|
+
const chosenItem = override && override.over === item ? override.id : (item ?? fallback);
|
|
1224
|
+
// The phone's Details item (./details.tsx) names its session here.
|
|
1170
1225
|
const { session: asked, subagent: shownSub } = itemParts(
|
|
1171
|
-
|
|
1226
|
+
chosenItem === undefined ? undefined : detailsOf(chosenItem).session,
|
|
1172
1227
|
);
|
|
1173
1228
|
/** The session asked here now, read by an action that answers after the person may have opened another. */
|
|
1174
1229
|
const shown = React.useRef(asked);
|
|
@@ -1260,10 +1315,11 @@ function Sessions({
|
|
|
1260
1315
|
}),
|
|
1261
1316
|
[],
|
|
1262
1317
|
);
|
|
1263
|
-
/** The
|
|
1318
|
+
/** The diff the conversation asked the details panel for: at a tool call's file, or its top (a turn's Review
|
|
1319
|
+
* changes); `at`: each click opens it again. Forgotten once the panel opened it. */
|
|
1264
1320
|
const [changeAsked, setChangeAsked] = React.useState<{
|
|
1265
1321
|
session: string;
|
|
1266
|
-
path
|
|
1322
|
+
path?: string;
|
|
1267
1323
|
at: number;
|
|
1268
1324
|
}>();
|
|
1269
1325
|
const viewport = React.useRef<HTMLDivElement>(null);
|
|
@@ -1319,7 +1375,9 @@ function Sessions({
|
|
|
1319
1375
|
return {};
|
|
1320
1376
|
}
|
|
1321
1377
|
});
|
|
1322
|
-
|
|
1378
|
+
// A search opens every shelf: what it found shows wherever it is.
|
|
1379
|
+
const isOpen = (shelf: Shelf) =>
|
|
1380
|
+
query.trim() !== '' || (shelves[shelf] ?? (shelf !== 'settled' && shelf !== 'working'));
|
|
1323
1381
|
const setOpen = (shelf: Shelf, open: boolean) =>
|
|
1324
1382
|
setShelves((was) => {
|
|
1325
1383
|
const next = { ...was, [shelf]: open };
|
|
@@ -1338,30 +1396,9 @@ function Sessions({
|
|
|
1338
1396
|
const [cleanup, setCleanup] = React.useState<Cleanup>();
|
|
1339
1397
|
/** The archived sessions, listed while "Show archived" is on (`undefined`: off). */
|
|
1340
1398
|
const [archived, setArchived] = React.useState<Session[]>();
|
|
1341
|
-
/**
|
|
1342
|
-
const [
|
|
1343
|
-
|
|
1344
|
-
/** A rename asked from a row's menu: the header's field takes focus once that session shows. */
|
|
1345
|
-
const renameAsked = React.useRef<string | undefined>(undefined);
|
|
1346
|
-
/** The details panel (tags, changes, commit) shows under the header, kept per node. */
|
|
1347
|
-
const detailsKey = `bridge.sessions.details.${JSON.stringify([workspace.slug, node])}`;
|
|
1348
|
-
const [details, setDetails] = React.useState(() => {
|
|
1349
|
-
try {
|
|
1350
|
-
return localStorage.getItem(detailsKey) === '1';
|
|
1351
|
-
} catch {
|
|
1352
|
-
return false;
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
1355
|
-
const toggleDetails = () =>
|
|
1356
|
-
setDetails((was) => {
|
|
1357
|
-
try {
|
|
1358
|
-
localStorage.setItem(detailsKey, was ? '0' : '1');
|
|
1359
|
-
} catch {
|
|
1360
|
-
/* kept for this view only */
|
|
1361
|
-
}
|
|
1362
|
-
return !was;
|
|
1363
|
-
});
|
|
1364
|
-
/** The sessions list beside the conversation, hidden from the conversation's header, kept like the details. */
|
|
1399
|
+
/** A rename asked from a row's menu: the session and the title being written, in a dialog. */
|
|
1400
|
+
const [renaming, setRenaming] = React.useState<{ id: string; title: string }>();
|
|
1401
|
+
/** The sessions list beside the conversation, hidden from the conversation's header, kept per node. */
|
|
1365
1402
|
const listKey = `bridge.sessions.list.${JSON.stringify([workspace.slug, node])}`;
|
|
1366
1403
|
const [listShown, setListShown] = React.useState(() => {
|
|
1367
1404
|
try {
|
|
@@ -1370,17 +1407,7 @@ function Sessions({
|
|
|
1370
1407
|
return true;
|
|
1371
1408
|
}
|
|
1372
1409
|
});
|
|
1373
|
-
|
|
1374
|
-
* undefined at rest, and always with reduced motion (no slide). */
|
|
1375
|
-
const listContent = React.useRef<HTMLDivElement>(null);
|
|
1376
|
-
const [listFrozen, setListFrozen] = React.useState<number>();
|
|
1377
|
-
const toggleList = () => {
|
|
1378
|
-
// The pane's open width: its share of the group (the library's flex-grow, in %), shown or not.
|
|
1379
|
-
const pane = listContent.current?.closest<HTMLElement>('[data-panel]');
|
|
1380
|
-
const share = parseFloat(pane?.style.flexGrow ?? '');
|
|
1381
|
-
const group = pane?.parentElement?.clientWidth ?? 0;
|
|
1382
|
-
const still = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
1383
|
-
setListFrozen(!still && share > 0 && group > 0 ? (group * share) / 100 : undefined);
|
|
1410
|
+
const toggleList = () =>
|
|
1384
1411
|
setListShown((was) => {
|
|
1385
1412
|
try {
|
|
1386
1413
|
localStorage.setItem(listKey, was ? '0' : '1');
|
|
@@ -1389,7 +1416,41 @@ function Sessions({
|
|
|
1389
1416
|
}
|
|
1390
1417
|
return !was;
|
|
1391
1418
|
});
|
|
1419
|
+
/** The details panel on the right (plugins#239), shown or hidden from the session's header: kept in the user's
|
|
1420
|
+
* profile (shown until hidden). */
|
|
1421
|
+
const panelShown = React.useSyncExternalStore(
|
|
1422
|
+
profile.subscribe,
|
|
1423
|
+
() => profile.get('sessions', 'details-panel', { workspace: currentWorkspace() }) !== false,
|
|
1424
|
+
);
|
|
1425
|
+
/** The screen's box is too narrow for three panes (`multiPaneAsideWidth`): the panel opens as a window over the
|
|
1426
|
+
* conversation instead, from the same button. */
|
|
1427
|
+
const screenBox = React.useRef<HTMLElement>(null);
|
|
1428
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
1429
|
+
React.useLayoutEffect(() => {
|
|
1430
|
+
const element = screenBox.current;
|
|
1431
|
+
if (!element || typeof ResizeObserver === 'undefined') return;
|
|
1432
|
+
const measure = (width: number) => setNarrow(width > 0 && width < multiPaneAsideWidth);
|
|
1433
|
+
measure(element.getBoundingClientRect().width);
|
|
1434
|
+
const observer = new ResizeObserver(([entry]) => entry && measure(entry.contentRect.width));
|
|
1435
|
+
observer.observe(element);
|
|
1436
|
+
return () => observer.disconnect();
|
|
1437
|
+
}, [!!listing]);
|
|
1438
|
+
/** The panel's window, while the screen is narrow. */
|
|
1439
|
+
const [panelWindow, setPanelWindow] = React.useState(false);
|
|
1440
|
+
React.useEffect(() => {
|
|
1441
|
+
if (!narrow) setPanelWindow(false);
|
|
1442
|
+
}, [narrow]);
|
|
1443
|
+
const togglePanel = () => {
|
|
1444
|
+
if (narrow) return setPanelWindow((was) => !was);
|
|
1445
|
+
profile.set('sessions', 'details-panel', !panelShown, { scope: 'global' });
|
|
1392
1446
|
};
|
|
1447
|
+
/** The panel shown (its window on a narrow screen), for the conversation asking it for the diff. */
|
|
1448
|
+
const showPanel = () => {
|
|
1449
|
+
if (narrow) setPanelWindow(true);
|
|
1450
|
+
else if (!panelShown) profile.set('sessions', 'details-panel', true, { scope: 'global' });
|
|
1451
|
+
};
|
|
1452
|
+
/** What the sessions list shows: the sessions whose title or branch holds it, across shelves. */
|
|
1453
|
+
const [query, setQuery] = React.useState('');
|
|
1393
1454
|
/** The list shows only the sessions with tag `tagged` when set (the workspace's tags, most used first: `known`). */
|
|
1394
1455
|
const [tagged, setTagged] = React.useState<string>();
|
|
1395
1456
|
/** The session whose custom snooze time is being chosen (the SnoozeDialog), and a pinned one being snoozed, asked
|
|
@@ -1421,6 +1482,41 @@ function Sessions({
|
|
|
1421
1482
|
.then(readJson),
|
|
1422
1483
|
[workspace, api, node],
|
|
1423
1484
|
);
|
|
1485
|
+
/** Open in editor (bridge-plugins#253): the git plugin's editor and this Bridge's computer; the conversation's links to
|
|
1486
|
+
* the session's files open in it. Read at first, when the page comes back to the front, and when a link is pointed
|
|
1487
|
+
* at: a setting changed meanwhile never shows the editor it no longer picks. */
|
|
1488
|
+
const [editor, setEditor] = React.useState<{ label: string; machine: string; local: boolean }>();
|
|
1489
|
+
const readEditor = React.useRef<() => void>(() => {});
|
|
1490
|
+
React.useEffect(() => {
|
|
1491
|
+
let live = true;
|
|
1492
|
+
readEditor.current = () =>
|
|
1493
|
+
void workspace
|
|
1494
|
+
.fetch(`/${encodeURIComponent(workspace.slug)}/api/git/editors`)
|
|
1495
|
+
.then(readJson)
|
|
1496
|
+
.then((body) => {
|
|
1497
|
+
if (!live) return;
|
|
1498
|
+
const chosen = isRecord(body) && isRecord(body.chosen) ? body.chosen : undefined;
|
|
1499
|
+
const machine = isRecord(body) ? body.machine : undefined;
|
|
1500
|
+
const local = isRecord(body) && body.local === true;
|
|
1501
|
+
if (typeof chosen?.label === 'string' && typeof machine === 'string') {
|
|
1502
|
+
const label = chosen.label;
|
|
1503
|
+
setEditor((was) =>
|
|
1504
|
+
was?.label === label && was.machine === machine && was.local === local
|
|
1505
|
+
? was
|
|
1506
|
+
: { label, machine, local },
|
|
1507
|
+
);
|
|
1508
|
+
} else setEditor(undefined);
|
|
1509
|
+
})
|
|
1510
|
+
.catch(() => {});
|
|
1511
|
+
readEditor.current();
|
|
1512
|
+
const again = () => readEditor.current();
|
|
1513
|
+
window.addEventListener('focus', again);
|
|
1514
|
+
return () => {
|
|
1515
|
+
live = false;
|
|
1516
|
+
readEditor.current = () => {};
|
|
1517
|
+
window.removeEventListener('focus', again);
|
|
1518
|
+
};
|
|
1519
|
+
}, [workspace]);
|
|
1424
1520
|
/** The listing again, for every copy (the store's, which also polls while a session no copy shows runs, and wakes
|
|
1425
1521
|
* the snoozed); a workspace restarting (`starting`) is tried again, not reported. */
|
|
1426
1522
|
const load = (): Promise<boolean> => {
|
|
@@ -1507,8 +1603,8 @@ function Sessions({
|
|
|
1507
1603
|
return `${harnessLabel(each.harness)} · ${shown ? `${shown.name}${each.model ? '' : ' (default)'}` : 'Default model'}`;
|
|
1508
1604
|
};
|
|
1509
1605
|
|
|
1510
|
-
// One subscription for the shown session; after an error, a new one from the last `seq`
|
|
1511
|
-
// 30 s (back to 1 s at a snapshot). It ends with the view or the workspace.
|
|
1606
|
+
// One subscription for the shown session; after an error, a new one from the last `seq` the log holds (`saved`), 1 s
|
|
1607
|
+
// later, doubling to 30 s (back to 1 s at a snapshot). It ends with the view or the workspace.
|
|
1512
1608
|
React.useEffect(() => {
|
|
1513
1609
|
setEvents([]);
|
|
1514
1610
|
setLive(null);
|
|
@@ -1520,21 +1616,23 @@ function Sessions({
|
|
|
1520
1616
|
setAway(false);
|
|
1521
1617
|
if (!current) return;
|
|
1522
1618
|
let last = 0;
|
|
1619
|
+
/** The newest `seq` the log holds (`saved` messages, the snapshot's): kept across a reconnect (`dropUnsaved`). */
|
|
1620
|
+
let saved = 0;
|
|
1523
1621
|
let stop: (() => void) | undefined;
|
|
1524
1622
|
let retry: ReturnType<typeof setTimeout> | undefined;
|
|
1525
1623
|
let delay = 1000;
|
|
1526
1624
|
let closed = false;
|
|
1527
1625
|
/** A snapshot came already: the next one is a reconnect's. */
|
|
1528
1626
|
let resumed = false;
|
|
1529
|
-
/** Ids with a stored `tool/result` in the current turn: a later live event of theirs is stale. */
|
|
1530
|
-
const resulted = new
|
|
1627
|
+
/** Ids with a stored `tool/result` in the current turn (and its `seq`): a later live event of theirs is stale. */
|
|
1628
|
+
const resulted = new Map<string, number>();
|
|
1531
1629
|
const add = (lines: Stored[]) => {
|
|
1532
1630
|
const fresh = lines.filter((line) => line.seq > last);
|
|
1533
1631
|
if (!fresh.length) return;
|
|
1534
1632
|
last = fresh.at(-1)!.seq;
|
|
1535
1633
|
for (const line of fresh) {
|
|
1536
1634
|
if (line.type === 'turn/start') resulted.clear();
|
|
1537
|
-
if (line.type === 'tool/result' && line.id) resulted.
|
|
1635
|
+
if (line.type === 'tool/result' && line.id) resulted.set(line.id, line.seq);
|
|
1538
1636
|
}
|
|
1539
1637
|
if (fresh.some((line) => listChanges.has(line.type))) void load();
|
|
1540
1638
|
setEvents((was) => [...was, ...fresh]);
|
|
@@ -1549,7 +1647,9 @@ function Sessions({
|
|
|
1549
1647
|
const subscribe = () => {
|
|
1550
1648
|
/** The snapshot came on this connection: stored lines before it are history, not the running turn. */
|
|
1551
1649
|
let isSynced = false;
|
|
1552
|
-
|
|
1650
|
+
/** No message came on this connection yet. */
|
|
1651
|
+
let fresh = true;
|
|
1652
|
+
// On the page carrier, not persistent: on an end or a lost connection this view opens it again from `saved`.
|
|
1553
1653
|
let retried = false;
|
|
1554
1654
|
const again = () => {
|
|
1555
1655
|
stop?.();
|
|
@@ -1560,7 +1660,7 @@ function Sessions({
|
|
|
1560
1660
|
delay = Math.min(delay * 2, 30_000);
|
|
1561
1661
|
};
|
|
1562
1662
|
// From the start, the newest page only: earlier ones load as the reader scrolls up (`loadEarlier`).
|
|
1563
|
-
const from =
|
|
1663
|
+
const from = saved ? `after=${saved}` : `after=0&limit=${HISTORY_PAGE}`;
|
|
1564
1664
|
stop = workspace.stream(
|
|
1565
1665
|
`${api}/watch?id=${encodeURIComponent(current)}&page=${page}&${from}`,
|
|
1566
1666
|
{
|
|
@@ -1569,12 +1669,24 @@ function Sessions({
|
|
|
1569
1669
|
onEnd: again,
|
|
1570
1670
|
onItem: (value) => {
|
|
1571
1671
|
const data = value as
|
|
1572
|
-
| {
|
|
1672
|
+
| {
|
|
1673
|
+
type: 'snapshot';
|
|
1674
|
+
events: Stored[];
|
|
1675
|
+
live: Live | null;
|
|
1676
|
+
more?: boolean;
|
|
1677
|
+
saved?: number;
|
|
1678
|
+
}
|
|
1573
1679
|
| { type: 'stored'; event: Stored }
|
|
1680
|
+
| { type: 'saved'; seq: number }
|
|
1574
1681
|
| { type: 'live'; event: LiveEvent }
|
|
1575
1682
|
| { type: 'ping' }
|
|
1576
1683
|
| { type: 'open-link'; path: string; turn?: string; request?: string };
|
|
1577
|
-
if (
|
|
1684
|
+
if (fresh) {
|
|
1685
|
+
fresh = false;
|
|
1686
|
+
last = dropUnsaved(last, saved, resulted, setEvents);
|
|
1687
|
+
}
|
|
1688
|
+
if (data.type === 'saved') saved = Math.max(saved, data.seq);
|
|
1689
|
+
else if (data.type === 'snapshot') {
|
|
1578
1690
|
isSynced = true;
|
|
1579
1691
|
activity.connected();
|
|
1580
1692
|
delay = 1000;
|
|
@@ -1584,6 +1696,7 @@ function Sessions({
|
|
|
1584
1696
|
if (resumed) void load();
|
|
1585
1697
|
resumed = true;
|
|
1586
1698
|
add(data.events);
|
|
1699
|
+
saved = Math.max(saved, data.saved ?? last);
|
|
1587
1700
|
setLive(data.live);
|
|
1588
1701
|
} else if (data.type === 'stored') {
|
|
1589
1702
|
if (data.event.seq <= last) return;
|
|
@@ -1671,14 +1784,6 @@ function Sessions({
|
|
|
1671
1784
|
React.useEffect(() => {
|
|
1672
1785
|
if (current) visit(current);
|
|
1673
1786
|
}, [current]);
|
|
1674
|
-
// A rename asked from a row's menu, once its session shows in the header.
|
|
1675
|
-
React.useEffect(() => {
|
|
1676
|
-
if (!renameAsked.current || renameAsked.current !== current || !titleField.current) return;
|
|
1677
|
-
renameAsked.current = undefined;
|
|
1678
|
-
titleField.current.focus();
|
|
1679
|
-
titleField.current.select();
|
|
1680
|
-
});
|
|
1681
|
-
React.useEffect(() => setDraft(undefined), [current]);
|
|
1682
1787
|
// In the shell's help, with the plugin's name, while a Sessions screen is shown (the copies share one declaration).
|
|
1683
1788
|
React.useEffect(() => {
|
|
1684
1789
|
const removals = keys().map((each) => ctx.shell.shortcuts.declare(each, name));
|
|
@@ -1815,7 +1920,7 @@ function Sessions({
|
|
|
1815
1920
|
shown={tabs.shown}
|
|
1816
1921
|
tabs={tabs.value}
|
|
1817
1922
|
chat={title}
|
|
1818
|
-
title={
|
|
1923
|
+
title={session.title}
|
|
1819
1924
|
/>
|
|
1820
1925
|
) : (
|
|
1821
1926
|
title
|
|
@@ -1991,6 +2096,37 @@ function Sessions({
|
|
|
1991
2096
|
element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
|
|
1992
2097
|
};
|
|
1993
2098
|
|
|
2099
|
+
/** The panel shown (beside, or as its window when narrow). */
|
|
2100
|
+
const panelOpen = narrow ? panelWindow : panelShown;
|
|
2101
|
+
/** The window bar's buttons (the shell's `setActions`, plugins#239): the sessions list's, then the panel's (none in a
|
|
2102
|
+
* sub-agent's view, which has no panel). Their clicks read the page's latest state. */
|
|
2103
|
+
const toggles = React.useRef({ list: toggleList, panel: togglePanel });
|
|
2104
|
+
toggles.current = { list: toggleList, panel: togglePanel };
|
|
2105
|
+
const actions: ScreenAction[] = [
|
|
2106
|
+
{
|
|
2107
|
+
id: 'sessions-list',
|
|
2108
|
+
label: listShown ? 'Hide sessions' : 'Show sessions',
|
|
2109
|
+
icon: 'panel-left',
|
|
2110
|
+
pressed: listShown,
|
|
2111
|
+
onSelect: () => toggles.current.list(),
|
|
2112
|
+
},
|
|
2113
|
+
...(session && shownSub === undefined
|
|
2114
|
+
? [
|
|
2115
|
+
{
|
|
2116
|
+
id: 'details-panel',
|
|
2117
|
+
label: panelOpen ? 'Hide panel' : 'Show panel',
|
|
2118
|
+
icon: 'panel-right',
|
|
2119
|
+
pressed: panelOpen,
|
|
2120
|
+
onSelect: () => toggles.current.panel(),
|
|
2121
|
+
},
|
|
2122
|
+
]
|
|
2123
|
+
: []),
|
|
2124
|
+
];
|
|
2125
|
+
const actionsKey = JSON.stringify(actions.map(({ onSelect: _, ...each }) => each));
|
|
2126
|
+
React.useEffect(() => {
|
|
2127
|
+
setActions?.(actions);
|
|
2128
|
+
}, [setActions, actionsKey]);
|
|
2129
|
+
React.useEffect(() => () => setActions?.([]), [setActions]);
|
|
1994
2130
|
if (!listing) return <section aria-label="Screen" className="flex min-h-0 flex-1" />;
|
|
1995
2131
|
if (!listing.project && !listing.workspace) {
|
|
1996
2132
|
return (
|
|
@@ -2022,9 +2158,18 @@ function Sessions({
|
|
|
2022
2158
|
// The shelves: a snoozed session is in Snoozed until it wakes (a pin may wait under it); else a pinned one is in
|
|
2023
2159
|
// Pinned whatever else it is (settle clears the pin).
|
|
2024
2160
|
// A child is listed under its parent, never on a shelf of its own; its parent works or waits while it does.
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2027
|
-
|
|
2161
|
+
const words = query.trim().toLowerCase();
|
|
2162
|
+
/** Session `each` is shown: its tag is the one chosen, and its title or branch (or worktree) holds the search. */
|
|
2163
|
+
const matches = (each: Session) =>
|
|
2164
|
+
(!tagged || !!each.tags?.includes(tagged)) &&
|
|
2165
|
+
(!words ||
|
|
2166
|
+
[
|
|
2167
|
+
each.title,
|
|
2168
|
+
each.branch?.name,
|
|
2169
|
+
each.worktree && (worktreeNames.get(each.worktree.slug) ?? each.worktree.slug),
|
|
2170
|
+
].some((text) => text?.toLowerCase().includes(words)));
|
|
2171
|
+
// ponytail: a child is found through its parent's row only; search the children too if asked.
|
|
2172
|
+
const shownSessions = family.top.filter(matches);
|
|
2028
2173
|
const snoozed = shownSessions
|
|
2029
2174
|
.filter((each) => each.snoozedUntil)
|
|
2030
2175
|
.sort((a, b) => a.snoozedUntil!.localeCompare(b.snoozedUntil!));
|
|
@@ -2037,7 +2182,7 @@ function Sessions({
|
|
|
2037
2182
|
const settled = awake
|
|
2038
2183
|
.filter((each) => !each.pinnedAt && each.settledAt)
|
|
2039
2184
|
.sort((a, b) => b.settledAt!.localeCompare(a.settledAt!));
|
|
2040
|
-
const archivedShown =
|
|
2185
|
+
const archivedShown = archived?.filter(matches);
|
|
2041
2186
|
const settledShown = allSettled ? settled : settled.slice(0, SETTLED_SHOWN);
|
|
2042
2187
|
/** The rows in list order, for previous and next. */
|
|
2043
2188
|
const ordered = [
|
|
@@ -2210,23 +2355,23 @@ function Sessions({
|
|
|
2210
2355
|
reorder(ids);
|
|
2211
2356
|
};
|
|
2212
2357
|
const rename = () => {
|
|
2213
|
-
const
|
|
2214
|
-
|
|
2215
|
-
|
|
2358
|
+
const asked = renaming;
|
|
2359
|
+
setRenaming(undefined);
|
|
2360
|
+
const title = asked?.title.trim();
|
|
2361
|
+
const was = listing?.sessions.find((each) => each.id === asked?.id);
|
|
2362
|
+
if (!asked || !was || !title || title === was.title) return;
|
|
2216
2363
|
setListing(
|
|
2217
2364
|
(was) =>
|
|
2218
2365
|
was && {
|
|
2219
2366
|
...was,
|
|
2220
|
-
sessions: was.sessions.map((each) =>
|
|
2221
|
-
each.id === session.id ? { ...each, title } : each,
|
|
2222
|
-
),
|
|
2367
|
+
sessions: was.sessions.map((each) => (each.id === asked.id ? { ...each, title } : each)),
|
|
2223
2368
|
},
|
|
2224
2369
|
);
|
|
2225
2370
|
void workspace
|
|
2226
2371
|
.fetch(`${api}/rename`, {
|
|
2227
2372
|
method: 'POST',
|
|
2228
2373
|
headers,
|
|
2229
|
-
body: JSON.stringify({ id:
|
|
2374
|
+
body: JSON.stringify({ id: asked.id, title }),
|
|
2230
2375
|
})
|
|
2231
2376
|
.then(readJson)
|
|
2232
2377
|
.then(load, (cause) => {
|
|
@@ -2234,10 +2379,7 @@ function Sessions({
|
|
|
2234
2379
|
void load();
|
|
2235
2380
|
});
|
|
2236
2381
|
};
|
|
2237
|
-
const askRename = (each: Session) => {
|
|
2238
|
-
renameAsked.current = each.id;
|
|
2239
|
-
choose(each.id);
|
|
2240
|
-
};
|
|
2382
|
+
const askRename = (each: Session) => setRenaming({ id: each.id, title: each.title });
|
|
2241
2383
|
onKey.current = (event) => {
|
|
2242
2384
|
// Another window is the one the user works in, or a modal dialog is open over the page: the keys are its own.
|
|
2243
2385
|
if (focused === false || modalOpen()) return;
|
|
@@ -2527,7 +2669,7 @@ function Sessions({
|
|
|
2527
2669
|
const sessionFolder =
|
|
2528
2670
|
session && session.node !== node
|
|
2529
2671
|
? undefined
|
|
2530
|
-
: (session?.branch?.folder ?? listing.project?.path ?? listing.workspace?.folder);
|
|
2672
|
+
: (session?.branch?.folder ?? session?.worktree?.folder ?? listing.project?.path ?? listing.workspace?.folder);
|
|
2531
2673
|
const relative = (value: string) =>
|
|
2532
2674
|
sessionFolder ? value.split(`${sessionFolder.replace(/[\\/]$/, '')}/`).join('') : value;
|
|
2533
2675
|
// A decision whose row is in view is answered there; the dock takes the first other one.
|
|
@@ -2627,7 +2769,7 @@ function Sessions({
|
|
|
2627
2769
|
size="sm"
|
|
2628
2770
|
aria-label="The branch the new session works on"
|
|
2629
2771
|
title="The branch the new session works on"
|
|
2630
|
-
className="w-auto max-w-44
|
|
2772
|
+
className="w-auto max-w-44 min-w-0 gap-1 rounded-full text-xs"
|
|
2631
2773
|
data-branch-picker
|
|
2632
2774
|
>
|
|
2633
2775
|
<Icon name={branchOf.newBranch ? 'plus' : 'git-branch'} size={12} />
|
|
@@ -2660,7 +2802,7 @@ function Sessions({
|
|
|
2660
2802
|
<span
|
|
2661
2803
|
data-branch-fixed
|
|
2662
2804
|
title="The branch this session works on: fixed after its first message"
|
|
2663
|
-
className="inline-flex max-w-44
|
|
2805
|
+
className="inline-flex max-w-44 min-w-0 items-center gap-1 text-xs text-muted"
|
|
2664
2806
|
>
|
|
2665
2807
|
<Icon name="git-branch" size={12} />
|
|
2666
2808
|
<span className="truncate font-mono">
|
|
@@ -2727,62 +2869,143 @@ function Sessions({
|
|
|
2727
2869
|
</div>
|
|
2728
2870
|
);
|
|
2729
2871
|
|
|
2730
|
-
/** The
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2872
|
+
/** The open session's pull request act (watch, unwatch, unlink), for its pill. */
|
|
2873
|
+
const actPullRequest = (id: string) => (action: 'watch' | 'unwatch' | 'unlink') =>
|
|
2874
|
+
void post(`/pull-request/${action}`, { id })
|
|
2875
|
+
.then(() => load())
|
|
2876
|
+
.catch(report);
|
|
2877
|
+
/** Without the shell's window bar (an older shell): the same buttons, at the conversation's top. */
|
|
2878
|
+
const ownToggles =
|
|
2879
|
+
!setActions &&
|
|
2880
|
+
actions.map((each) => (
|
|
2881
|
+
<Tooltip key={each.id}>
|
|
2882
|
+
<TooltipTrigger
|
|
2883
|
+
render={
|
|
2884
|
+
<Button
|
|
2885
|
+
size="icon-sm"
|
|
2886
|
+
aria-label={each.label}
|
|
2887
|
+
aria-pressed={each.pressed}
|
|
2888
|
+
className="shrink-0"
|
|
2889
|
+
onClick={each.onSelect}
|
|
2890
|
+
/>
|
|
2891
|
+
}
|
|
2892
|
+
>
|
|
2893
|
+
<Icon name={each.icon} />
|
|
2894
|
+
</TooltipTrigger>
|
|
2895
|
+
<TooltipContent>{each.label}</TooltipContent>
|
|
2896
|
+
</Tooltip>
|
|
2897
|
+
));
|
|
2898
|
+
|
|
2899
|
+
/** The rows the page adds to the details panel (plugins#239): what the session's header held. */
|
|
2900
|
+
const panelRows = session && {
|
|
2901
|
+
gallery: (
|
|
2902
|
+
<Row
|
|
2903
|
+
name="Gallery"
|
|
2904
|
+
icon="image"
|
|
2905
|
+
value={
|
|
2735
2906
|
<Button
|
|
2736
|
-
size="
|
|
2737
|
-
|
|
2738
|
-
aria-
|
|
2739
|
-
className="-
|
|
2740
|
-
onClick={
|
|
2741
|
-
|
|
2907
|
+
size="sm"
|
|
2908
|
+
variant="ghost"
|
|
2909
|
+
aria-label="Gallery"
|
|
2910
|
+
className="-mr-2 gap-1"
|
|
2911
|
+
onClick={() => setGalleryOpen(true)}
|
|
2912
|
+
>
|
|
2913
|
+
{pins.length ? `${pins.length} pinned` : 'Open'}
|
|
2914
|
+
</Button>
|
|
2742
2915
|
}
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2916
|
+
/>
|
|
2917
|
+
),
|
|
2918
|
+
marks: (
|
|
2919
|
+
<>
|
|
2920
|
+
{session.pinnedAt && <Row name="Pinned" icon="pin" />}
|
|
2921
|
+
{session.settledAt && !session.pinnedAt && <Row name="Settled" icon="check" />}
|
|
2922
|
+
{session.snoozedUntil && (
|
|
2923
|
+
<Row
|
|
2924
|
+
name="Snoozed"
|
|
2925
|
+
icon="alarm-clock"
|
|
2926
|
+
value={
|
|
2927
|
+
<span title={`Wakes ${when(session.snoozedUntil)}`}>
|
|
2928
|
+
{snoozeWakeLabel(session.snoozedUntil)}
|
|
2929
|
+
</span>
|
|
2930
|
+
}
|
|
2931
|
+
/>
|
|
2932
|
+
)}
|
|
2933
|
+
<SessionScheduled
|
|
2934
|
+
ctx={ctx}
|
|
2935
|
+
node={node}
|
|
2936
|
+
session={session}
|
|
2937
|
+
wrap={(menu) => <Row name="Scheduled" icon="calendar-clock" value={menu} />}
|
|
2938
|
+
/>
|
|
2939
|
+
{/* A child session's parent (bridge#212): a link to it. */}
|
|
2940
|
+
{session.parent !== undefined && (
|
|
2941
|
+
<Row name="Parent" icon="arrow-up" value={<ParentLink parent={session.parent} />} />
|
|
2942
|
+
)}
|
|
2943
|
+
{/* Where it works (research-083): its stage, by the branches it runs. */}
|
|
2944
|
+
{session.worktree && (
|
|
2945
|
+
<Row
|
|
2946
|
+
name="Stage"
|
|
2947
|
+
icon="git-fork"
|
|
2948
|
+
value={
|
|
2949
|
+
<span
|
|
2950
|
+
className="truncate"
|
|
2951
|
+
title={`Works in the stage ${worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}`}
|
|
2952
|
+
>
|
|
2953
|
+
{worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}
|
|
2954
|
+
</span>
|
|
2955
|
+
}
|
|
2956
|
+
/>
|
|
2957
|
+
)}
|
|
2958
|
+
</>
|
|
2959
|
+
),
|
|
2960
|
+
};
|
|
2961
|
+
/** The details panel (./details.tsx): the open session's branch, changes, pull request, tags, and its rows. */
|
|
2962
|
+
const panel = session && (
|
|
2963
|
+
<LineageContext.Provider value={lineageOf ?? null}>
|
|
2964
|
+
<DetailsPanel
|
|
2965
|
+
session={session}
|
|
2966
|
+
slug={branchesAt}
|
|
2967
|
+
known={known}
|
|
2968
|
+
post={post}
|
|
2969
|
+
onChanged={() => void load()}
|
|
2970
|
+
actPullRequest={actPullRequest(session.id)}
|
|
2971
|
+
// Its git rows and the Commit changes dialog: the `git` plugin's (`sessions.details`).
|
|
2972
|
+
gitRows={(props) => renderSlot('sessions.details', props)}
|
|
2973
|
+
onOpenSession={(id) => {
|
|
2974
|
+
setTagged(undefined);
|
|
2975
|
+
choose(id);
|
|
2976
|
+
}}
|
|
2977
|
+
// A Git action done (Create PR among them): its pull request is found or read again.
|
|
2978
|
+
onGitAnswer={() => void post('/pull-request/refresh', { id: session.id }).catch(report)}
|
|
2979
|
+
onInstallGit={() => installGit(workspace.slug)}
|
|
2980
|
+
diffAsked={changeAsked?.session === session.id ? changeAsked : undefined}
|
|
2981
|
+
onDiffAnswered={() => setChangeAsked(undefined)}
|
|
2982
|
+
{...panelRows}
|
|
2983
|
+
/>
|
|
2984
|
+
</LineageContext.Provider>
|
|
2748
2985
|
);
|
|
2749
|
-
|
|
2986
|
+
/** The panel on the right, while it shows and there is room for it (none in a sub-agent's view). */
|
|
2987
|
+
const aside = !narrow && panelShown && shownSub === undefined ? panel || undefined : undefined;
|
|
2750
2988
|
const page = (
|
|
2751
2989
|
<section
|
|
2990
|
+
ref={screenBox}
|
|
2752
2991
|
aria-label="Screen"
|
|
2753
2992
|
className={cn('flex min-h-0 flex-1 overflow-hidden', reset)}
|
|
2754
|
-
onTransitionEnd={(event) => {
|
|
2755
|
-
// The slide ended: shown, the list follows its pane's width again (a drag, a window resized).
|
|
2756
|
-
if (event.propertyName === 'flex-grow' && listShown) setListFrozen(undefined);
|
|
2757
|
-
}}
|
|
2758
2993
|
>
|
|
2759
|
-
<
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
//
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
inert={!listShown}
|
|
2775
|
-
aria-hidden={listShown ? undefined : true}
|
|
2776
|
-
className={cn(
|
|
2777
|
-
'flex h-full justify-end',
|
|
2778
|
-
!listShown && 'opacity-0',
|
|
2779
|
-
listFrozen !== undefined && 'transition-opacity duration-200 ease-out',
|
|
2780
|
-
)}
|
|
2781
|
-
>
|
|
2782
|
-
<Pane
|
|
2783
|
-
className="w-full shrink-0 bg-background"
|
|
2784
|
-
style={listFrozen === undefined ? undefined : { width: listFrozen }}
|
|
2785
|
-
>
|
|
2994
|
+
<MultiPane
|
|
2995
|
+
// One kept layout for the list and the details panel, shown or hidden (the kit keeps each pane's width when the
|
|
2996
|
+
// panel toggles). Nothing collapses on its own: a narrow screen opens the panel as a window instead (`narrow`),
|
|
2997
|
+
// and keeps the list beside the conversation as it always did.
|
|
2998
|
+
storageKey="sessions/browser/panes@v1"
|
|
2999
|
+
collapse={false}
|
|
3000
|
+
// The details panel is a card beside the conversation (owner, plugins#239), not a full-height column.
|
|
3001
|
+
asideVariant="floating"
|
|
3002
|
+
defaultNavSize="280px"
|
|
3003
|
+
defaultAsideSize="340px"
|
|
3004
|
+
// Hidden, the list is no pane at all: the kit keeps the panel's width and gives the room to the conversation,
|
|
3005
|
+
// and brings the list back at its own width.
|
|
3006
|
+
nav={
|
|
3007
|
+
listShown && (
|
|
3008
|
+
<Pane className="bg-background">
|
|
2786
3009
|
<PaneHeader className="h-11 shrink-0 border-b border-border py-0 pl-4 pr-2">
|
|
2787
3010
|
<h1 className="text-sm font-semibold">Sessions</h1>
|
|
2788
3011
|
<Tooltip>
|
|
@@ -2794,6 +3017,22 @@ function Sessions({
|
|
|
2794
3017
|
<TooltipContent>New chat</TooltipContent>
|
|
2795
3018
|
</Tooltip>
|
|
2796
3019
|
</PaneHeader>
|
|
3020
|
+
<div className="shrink-0 px-3 pb-1 pt-2">
|
|
3021
|
+
<Input
|
|
3022
|
+
type="search"
|
|
3023
|
+
size="sm"
|
|
3024
|
+
aria-label="Search sessions"
|
|
3025
|
+
placeholder="Search sessions"
|
|
3026
|
+
value={query}
|
|
3027
|
+
onChange={(event) => setQuery(event.currentTarget.value)}
|
|
3028
|
+
onKeyDown={(event) => {
|
|
3029
|
+
if (event.key === 'Escape' && query) {
|
|
3030
|
+
event.stopPropagation();
|
|
3031
|
+
setQuery('');
|
|
3032
|
+
}
|
|
3033
|
+
}}
|
|
3034
|
+
/>
|
|
3035
|
+
</div>
|
|
2797
3036
|
<PaneBody viewportClassName={fitWidth}>
|
|
2798
3037
|
<nav aria-label="Sessions">
|
|
2799
3038
|
{tagged && (
|
|
@@ -2810,8 +3049,12 @@ function Sessions({
|
|
|
2810
3049
|
</Button>
|
|
2811
3050
|
</div>
|
|
2812
3051
|
)}
|
|
2813
|
-
{listing.sessions.length === 0 && !archived
|
|
3052
|
+
{listing.sessions.length === 0 && !archived ? (
|
|
2814
3053
|
<EmptyState>No sessions yet. Start one from the composer.</EmptyState>
|
|
3054
|
+
) : (
|
|
3055
|
+
words &&
|
|
3056
|
+
shownSessions.length === 0 &&
|
|
3057
|
+
!archivedShown?.length && <EmptyState>No sessions match.</EmptyState>
|
|
2815
3058
|
)}
|
|
2816
3059
|
{shelf(
|
|
2817
3060
|
'pinned',
|
|
@@ -2913,10 +3156,9 @@ function Sessions({
|
|
|
2913
3156
|
</nav>
|
|
2914
3157
|
</PaneBody>
|
|
2915
3158
|
</Pane>
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
<SplitPane id="session" minSize="360px">
|
|
3159
|
+
)
|
|
3160
|
+
}
|
|
3161
|
+
main={
|
|
2920
3162
|
<LineageContext.Provider value={lineageOf ?? null}>
|
|
2921
3163
|
{session && shownSub !== undefined ? (
|
|
2922
3164
|
// A sub-agent's view (bridge#212 S8): read only, from its session's stream.
|
|
@@ -2939,231 +3181,71 @@ function Sessions({
|
|
|
2939
3181
|
}
|
|
2940
3182
|
folder={sessionFolder}
|
|
2941
3183
|
workspace={workspace.slug}
|
|
2942
|
-
listToggle={
|
|
3184
|
+
listToggle={ownToggles ? ownToggles[0] : undefined}
|
|
2943
3185
|
{...(session.subagents?.find((each) => each.id === shownSub)?.stoppable && {
|
|
2944
3186
|
onStop: () => stopSub.current(shownSub),
|
|
2945
3187
|
})}
|
|
2946
3188
|
/>
|
|
2947
3189
|
) : (
|
|
2948
3190
|
<div className="flex h-full min-w-0 flex-col">
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
{current ? '' : 'New chat'}
|
|
2974
|
-
</h2>
|
|
2975
|
-
),
|
|
2976
|
-
)}
|
|
2977
|
-
{/* A child session's parent (bridge#212): a link to it. */}
|
|
2978
|
-
{session?.parent !== undefined && <ParentLink parent={session.parent} />}
|
|
2979
|
-
{/* Where it works (research-083): its stage, by the branches it runs. */}
|
|
2980
|
-
{session?.worktree && (
|
|
2981
|
-
<span
|
|
2982
|
-
title={`Works in the stage ${worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}`}
|
|
2983
|
-
className="inline-flex max-w-48 shrink-0 items-center gap-1 text-xs text-muted"
|
|
2984
|
-
>
|
|
2985
|
-
<Icon name="git-branch" size={13} />
|
|
2986
|
-
<span className="truncate">
|
|
2987
|
-
{worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}
|
|
2988
|
-
</span>
|
|
2989
|
-
</span>
|
|
2990
|
-
)}
|
|
2991
|
-
{session?.pinnedAt && (
|
|
2992
|
-
<span
|
|
2993
|
-
role="img"
|
|
2994
|
-
aria-label="Pinned"
|
|
2995
|
-
className="inline-flex shrink-0 text-muted"
|
|
2996
|
-
>
|
|
2997
|
-
<Icon name="pin" size={13} />
|
|
2998
|
-
</span>
|
|
2999
|
-
)}
|
|
3000
|
-
{session?.settledAt && !session.pinnedAt && (
|
|
3001
|
-
<Badge className="shrink-0">Settled</Badge>
|
|
3002
|
-
)}
|
|
3003
|
-
{session?.snoozedUntil && (
|
|
3004
|
-
<Badge className="shrink-0 gap-1" title={`Wakes ${when(session.snoozedUntil)}`}>
|
|
3005
|
-
<Icon name="alarm-clock" size={12} />
|
|
3006
|
-
Snoozed · {snoozeWakeLabel(session.snoozedUntil)}
|
|
3007
|
-
</Badge>
|
|
3008
|
-
)}
|
|
3009
|
-
{session && <SessionScheduled ctx={ctx} node={node} session={session} />}
|
|
3010
|
-
<span className="flex-1" />
|
|
3011
|
-
{/* Its branch's git actions, on its folder (research-083). */}
|
|
3012
|
-
{/* Its pull request (research-086), beside the Git button. */}
|
|
3013
|
-
{session?.pullRequest && (
|
|
3014
|
-
<PullRequestPill
|
|
3015
|
-
pullRequest={session.pullRequest}
|
|
3016
|
-
act={(action) =>
|
|
3017
|
-
void post(`/pull-request/${action}`, { id: session.id })
|
|
3018
|
-
.then(() => load())
|
|
3019
|
-
.catch(report)
|
|
3020
|
-
}
|
|
3021
|
-
/>
|
|
3022
|
-
)}
|
|
3023
|
-
{session?.branch && !session.branch.temporary && (
|
|
3024
|
-
<BranchActions
|
|
3025
|
-
slug={branchesAt}
|
|
3026
|
-
node={session.node}
|
|
3027
|
-
branch={session.branch.name}
|
|
3028
|
-
session={session.id}
|
|
3029
|
-
refresh={running}
|
|
3030
|
-
// Its own pull request only when it is this branch's: an agent may link another.
|
|
3031
|
-
pullRequestOpen={
|
|
3032
|
-
session.pullRequest?.headBranch === session.branch.name &&
|
|
3033
|
-
(session.pullRequest.state === 'open' ||
|
|
3034
|
-
session.pullRequest.state === 'draft')
|
|
3035
|
-
}
|
|
3036
|
-
// A Git action done (Create PR among them): its pull request is found or read again.
|
|
3037
|
-
onGitAnswer={() =>
|
|
3038
|
-
void post('/pull-request/refresh', { id: session.id }).catch(report)
|
|
3039
|
-
}
|
|
3040
|
-
/>
|
|
3041
|
-
)}
|
|
3042
|
-
{current &&
|
|
3043
|
-
(running ? (
|
|
3044
|
-
<>
|
|
3045
|
-
{openDecisions.length > 0 ? (
|
|
3046
|
-
<span className="flex items-center gap-1.5 text-xs font-medium text-warning-text">
|
|
3047
|
-
<span className="size-1.5 rounded-full bg-warning" />
|
|
3048
|
-
Waiting for you
|
|
3049
|
-
</span>
|
|
3050
|
-
) : (
|
|
3051
|
-
<span className="flex items-center gap-1.5 text-xs text-secondary">
|
|
3052
|
-
<Spinner />
|
|
3053
|
-
Running…
|
|
3054
|
-
</span>
|
|
3055
|
-
)}
|
|
3056
|
-
<Button variant="outline" size="sm" onClick={stop}>
|
|
3057
|
-
Stop
|
|
3058
|
-
</Button>
|
|
3059
|
-
</>
|
|
3060
|
-
) : (
|
|
3061
|
-
<span className="text-xs text-muted">Idle</span>
|
|
3062
|
-
))}
|
|
3063
|
-
{session && (
|
|
3064
|
-
<Tooltip>
|
|
3065
|
-
<TooltipTrigger
|
|
3066
|
-
render={
|
|
3067
|
-
<Button
|
|
3068
|
-
size="sm"
|
|
3069
|
-
aria-label="Tags and changes"
|
|
3070
|
-
aria-pressed={details}
|
|
3071
|
-
className={cn('gap-1', details && 'bg-border/60')}
|
|
3072
|
-
onClick={toggleDetails}
|
|
3073
|
-
/>
|
|
3074
|
-
}
|
|
3075
|
-
>
|
|
3076
|
-
<Icon name="git-branch" size={14} />
|
|
3077
|
-
{session.files?.length ? session.files.length : null}
|
|
3078
|
-
</TooltipTrigger>
|
|
3079
|
-
<TooltipContent>Tags and changes</TooltipContent>
|
|
3080
|
-
</Tooltip>
|
|
3081
|
-
)}
|
|
3082
|
-
{session && (
|
|
3083
|
-
<Tooltip>
|
|
3084
|
-
<TooltipTrigger
|
|
3085
|
-
render={
|
|
3086
|
-
<Button
|
|
3087
|
-
size="sm"
|
|
3088
|
-
aria-label="Gallery"
|
|
3089
|
-
className="gap-1"
|
|
3090
|
-
onClick={() => setGalleryOpen(true)}
|
|
3091
|
-
/>
|
|
3092
|
-
}
|
|
3093
|
-
>
|
|
3094
|
-
<Icon name="image" size={14} />
|
|
3095
|
-
{pins.length ? pins.length : null}
|
|
3096
|
-
</TooltipTrigger>
|
|
3097
|
-
<TooltipContent>Gallery: the pinned images</TooltipContent>
|
|
3098
|
-
</Tooltip>
|
|
3099
|
-
)}
|
|
3100
|
-
{session && (
|
|
3101
|
-
<GalleryDialog
|
|
3102
|
-
open={galleryOpen}
|
|
3103
|
-
onOpenChange={(next) => {
|
|
3104
|
-
setGalleryOpen(next);
|
|
3105
|
-
if (!next && current && sessionNode)
|
|
3106
|
-
void loadPins({
|
|
3107
|
-
key: 'session',
|
|
3108
|
-
label: 'Session',
|
|
3109
|
-
node: sessionNode,
|
|
3110
|
-
session: current,
|
|
3111
|
-
}).then(setPins, () => {});
|
|
3112
|
-
}}
|
|
3113
|
-
workspace={workspace.slug}
|
|
3114
|
-
scopes={[
|
|
3115
|
-
{
|
|
3191
|
+
{/* No header (plugins#239): the title is the window's breadcrumb, the rest in the details panel. A slim
|
|
3192
|
+
row on top only for its tabs (`sessions.tab`, an agent's browser), or the toggles an older shell
|
|
3193
|
+
cannot take in its window bar. */}
|
|
3194
|
+
{((tabs.open.length > 0 && session) || ownToggles) && (
|
|
3195
|
+
<div className="flex h-10 shrink-0 items-center gap-2 border-b border-border px-2">
|
|
3196
|
+
{ownToggles && ownToggles[0]}
|
|
3197
|
+
{tabs.open.length > 0 &&
|
|
3198
|
+
session &&
|
|
3199
|
+
withTabs(
|
|
3200
|
+
<span className="min-w-0 truncate pr-2 text-sm font-medium">
|
|
3201
|
+
{session.title}
|
|
3202
|
+
</span>,
|
|
3203
|
+
)}
|
|
3204
|
+
<span className="flex-1" />
|
|
3205
|
+
{ownToggles && ownToggles.slice(1)}
|
|
3206
|
+
</div>
|
|
3207
|
+
)}
|
|
3208
|
+
{session && (
|
|
3209
|
+
<GalleryDialog
|
|
3210
|
+
open={galleryOpen}
|
|
3211
|
+
onOpenChange={(next) => {
|
|
3212
|
+
setGalleryOpen(next);
|
|
3213
|
+
if (!next && current && sessionNode)
|
|
3214
|
+
void loadPins({
|
|
3116
3215
|
key: 'session',
|
|
3117
3216
|
label: 'Session',
|
|
3118
|
-
node:
|
|
3119
|
-
session:
|
|
3120
|
-
},
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
</DropdownMenuContent>
|
|
3150
|
-
</DropdownMenu>
|
|
3151
|
-
)}
|
|
3152
|
-
</header>
|
|
3217
|
+
node: sessionNode,
|
|
3218
|
+
session: current,
|
|
3219
|
+
}).then(setPins, () => {});
|
|
3220
|
+
}}
|
|
3221
|
+
workspace={workspace.slug}
|
|
3222
|
+
scopes={[
|
|
3223
|
+
{
|
|
3224
|
+
key: 'session',
|
|
3225
|
+
label: 'Session',
|
|
3226
|
+
node: session.node,
|
|
3227
|
+
session: session.id,
|
|
3228
|
+
},
|
|
3229
|
+
...(session.node !== 'root'
|
|
3230
|
+
? [{ key: 'project' as const, label: 'Project', node: session.node }]
|
|
3231
|
+
: []),
|
|
3232
|
+
{ key: 'workspace', label: 'Workspace', node: 'root' },
|
|
3233
|
+
]}
|
|
3234
|
+
load={loadPins}
|
|
3235
|
+
unpin={(pin) =>
|
|
3236
|
+
unpinImage(pin).catch((cause) => {
|
|
3237
|
+
report(cause);
|
|
3238
|
+
throw cause;
|
|
3239
|
+
})
|
|
3240
|
+
}
|
|
3241
|
+
onOpenSession={(id) => {
|
|
3242
|
+
setTagged(undefined);
|
|
3243
|
+
choose(id);
|
|
3244
|
+
}}
|
|
3245
|
+
titleOf={(id) => listing?.sessions.find((each) => each.id === id)?.title}
|
|
3246
|
+
/>
|
|
3247
|
+
)}
|
|
3153
3248
|
<div className="relative flex min-h-0 flex-1 flex-col">
|
|
3154
|
-
{session && details && (
|
|
3155
|
-
<SessionDetails
|
|
3156
|
-
session={session}
|
|
3157
|
-
known={known}
|
|
3158
|
-
focus={changeAsked?.session === session.id ? changeAsked : undefined}
|
|
3159
|
-
post={post}
|
|
3160
|
-
onChanged={() => void load()}
|
|
3161
|
-
onOpen={(id) => {
|
|
3162
|
-
setTagged(undefined);
|
|
3163
|
-
choose(id);
|
|
3164
|
-
}}
|
|
3165
|
-
/>
|
|
3166
|
-
)}
|
|
3167
3249
|
{current && (
|
|
3168
3250
|
<>
|
|
3169
3251
|
<ScrollArea
|
|
@@ -3188,15 +3270,47 @@ function Sessions({
|
|
|
3188
3270
|
promptHandle.current?.focus();
|
|
3189
3271
|
}}
|
|
3190
3272
|
onReview={() => {
|
|
3191
|
-
|
|
3273
|
+
setChangeAsked({ session: current, at: Date.now() });
|
|
3274
|
+
showPanel();
|
|
3192
3275
|
}}
|
|
3193
3276
|
onAnswer={(event, option) => answer(event.id!, option)}
|
|
3194
3277
|
onDecisionShown={onDecisionShown}
|
|
3195
3278
|
onOpenChange={(path) => {
|
|
3196
3279
|
setChangeAsked({ session: current, path, at: Date.now() });
|
|
3197
|
-
|
|
3280
|
+
showPanel();
|
|
3198
3281
|
}}
|
|
3199
3282
|
lineage={lineageOf}
|
|
3283
|
+
openFile={
|
|
3284
|
+
editor && sessionFolder && current
|
|
3285
|
+
? {
|
|
3286
|
+
folder: sessionFolder,
|
|
3287
|
+
// From another computer (the host's `local`), a link says it is not
|
|
3288
|
+
// available yet instead of opening.
|
|
3289
|
+
label: editor.local
|
|
3290
|
+
? `Open in ${editor.label} on ${editor.machine}`
|
|
3291
|
+
: notLocal,
|
|
3292
|
+
refresh: () => readEditor.current(),
|
|
3293
|
+
unavailable: !editor.local,
|
|
3294
|
+
open: ({ path, line, column }) =>
|
|
3295
|
+
void (
|
|
3296
|
+
editor.local
|
|
3297
|
+
? post('/open-in-editor', {
|
|
3298
|
+
id: current,
|
|
3299
|
+
path,
|
|
3300
|
+
...(line && { line }),
|
|
3301
|
+
...(column && { column }),
|
|
3302
|
+
})
|
|
3303
|
+
: Promise.reject(new Error(notLocal))
|
|
3304
|
+
).catch((cause: unknown) =>
|
|
3305
|
+
toast({
|
|
3306
|
+
variant: 'error',
|
|
3307
|
+
title: `${path} not opened`,
|
|
3308
|
+
description: cause instanceof Error ? cause.message : String(cause),
|
|
3309
|
+
}),
|
|
3310
|
+
),
|
|
3311
|
+
}
|
|
3312
|
+
: undefined
|
|
3313
|
+
}
|
|
3200
3314
|
/>
|
|
3201
3315
|
</div>
|
|
3202
3316
|
</GalleryPins.Provider>
|
|
@@ -3254,6 +3368,29 @@ function Sessions({
|
|
|
3254
3368
|
)}
|
|
3255
3369
|
{prompt}
|
|
3256
3370
|
</div>
|
|
3371
|
+
{narrow && panelWindow && panel && (
|
|
3372
|
+
// Too narrow for a third pane: the panel as a window over the conversation's right side.
|
|
3373
|
+
<div
|
|
3374
|
+
role="dialog"
|
|
3375
|
+
aria-label="Details panel"
|
|
3376
|
+
className="absolute inset-y-0 right-0 z-20 flex w-80 max-w-full flex-col border-l border-border bg-background shadow-lg"
|
|
3377
|
+
onKeyDown={(event) => {
|
|
3378
|
+
if (event.key === 'Escape' && !event.defaultPrevented)
|
|
3379
|
+
setPanelWindow(false);
|
|
3380
|
+
}}
|
|
3381
|
+
>
|
|
3382
|
+
<div className="flex h-11 shrink-0 items-center justify-end border-b border-border px-2">
|
|
3383
|
+
<Button
|
|
3384
|
+
size="icon"
|
|
3385
|
+
aria-label="Close details panel"
|
|
3386
|
+
onClick={() => setPanelWindow(false)}
|
|
3387
|
+
>
|
|
3388
|
+
<Icon name="x" />
|
|
3389
|
+
</Button>
|
|
3390
|
+
</div>
|
|
3391
|
+
<div className="min-h-0 flex-1 overflow-y-auto">{panel}</div>
|
|
3392
|
+
</div>
|
|
3393
|
+
)}
|
|
3257
3394
|
{current && (
|
|
3258
3395
|
<TabsProvider value={tabs.value}>
|
|
3259
3396
|
<div className="pointer-events-none absolute inset-0">
|
|
@@ -3265,8 +3402,9 @@ function Sessions({
|
|
|
3265
3402
|
</div>
|
|
3266
3403
|
)}
|
|
3267
3404
|
</LineageContext.Provider>
|
|
3268
|
-
|
|
3269
|
-
|
|
3405
|
+
}
|
|
3406
|
+
aside={aside}
|
|
3407
|
+
/>
|
|
3270
3408
|
<SnoozeDialog
|
|
3271
3409
|
open={!!customFor}
|
|
3272
3410
|
onOpenChange={(open) => {
|
|
@@ -3276,6 +3414,49 @@ function Sessions({
|
|
|
3276
3414
|
onSnooze={(until) => customFor && chooseSnooze(customFor, until)}
|
|
3277
3415
|
/>
|
|
3278
3416
|
<CleanupDialog offer={cleanup} onClose={() => setCleanup(undefined)} />
|
|
3417
|
+
<Dialog
|
|
3418
|
+
open={!!renaming}
|
|
3419
|
+
onOpenChange={(open) => {
|
|
3420
|
+
if (!open) setRenaming(undefined);
|
|
3421
|
+
}}
|
|
3422
|
+
>
|
|
3423
|
+
<DialogContent>
|
|
3424
|
+
<form
|
|
3425
|
+
onSubmit={(event) => {
|
|
3426
|
+
event.preventDefault();
|
|
3427
|
+
rename();
|
|
3428
|
+
}}
|
|
3429
|
+
>
|
|
3430
|
+
<DialogHeader>
|
|
3431
|
+
<DialogTitle>Rename the session</DialogTitle>
|
|
3432
|
+
</DialogHeader>
|
|
3433
|
+
<DialogBody className="pb-3">
|
|
3434
|
+
<Input
|
|
3435
|
+
aria-label="Session title"
|
|
3436
|
+
autoFocus
|
|
3437
|
+
value={renaming?.title ?? ''}
|
|
3438
|
+
onFocus={(event) => event.currentTarget.select()}
|
|
3439
|
+
// An input method's Enter ends its composition, never submits (#90).
|
|
3440
|
+
onKeyDown={(event) => {
|
|
3441
|
+
if (event.key === 'Enter' && isComposing(event)) event.preventDefault();
|
|
3442
|
+
}}
|
|
3443
|
+
onChange={(event) => {
|
|
3444
|
+
const title = event.currentTarget.value;
|
|
3445
|
+
setRenaming((was) => was && { ...was, title });
|
|
3446
|
+
}}
|
|
3447
|
+
/>
|
|
3448
|
+
</DialogBody>
|
|
3449
|
+
<DialogFooter className="justify-end gap-2">
|
|
3450
|
+
<Button type="button" onClick={() => setRenaming(undefined)}>
|
|
3451
|
+
Cancel
|
|
3452
|
+
</Button>
|
|
3453
|
+
<Button type="submit" variant="primary" disabled={!renaming?.title.trim()}>
|
|
3454
|
+
Rename
|
|
3455
|
+
</Button>
|
|
3456
|
+
</DialogFooter>
|
|
3457
|
+
</form>
|
|
3458
|
+
</DialogContent>
|
|
3459
|
+
</Dialog>
|
|
3279
3460
|
<Dialog
|
|
3280
3461
|
open={!!pinAsk}
|
|
3281
3462
|
onOpenChange={(open) => {
|
|
@@ -3434,7 +3615,7 @@ export function apply(ctx: Context) {
|
|
|
3434
3615
|
off?.();
|
|
3435
3616
|
};
|
|
3436
3617
|
});
|
|
3437
|
-
// Declares `sessions.tab` (./tabs.tsx),
|
|
3618
|
+
// Declares `sessions.tab` (./tabs.tsx) and `sessions.details` (./details.tsx), lists other plugins fill, and `views.component` (research-036 P2), which
|
|
3438
3619
|
// other plugins fill too: each entry gets the component a view calls (`{ component, props, node }`), is keyed by its
|
|
3439
3620
|
// plugin key, and draws all of that plugin's components by `component`. Not in the shell's slot map, so typed here.
|
|
3440
3621
|
type ScreenProps = {
|
|
@@ -3443,6 +3624,7 @@ export function apply(ctx: Context) {
|
|
|
3443
3624
|
item?: string;
|
|
3444
3625
|
focused?: boolean;
|
|
3445
3626
|
renderSlot: RenderTabs;
|
|
3627
|
+
setActions?: (actions: readonly ScreenAction[]) => void;
|
|
3446
3628
|
};
|
|
3447
3629
|
// oxlint-disable-next-line bridge/no-new-unchecked-cast -- typing: slots.register's overloads do not name this screen's children
|
|
3448
3630
|
const slots = ctx.slots as unknown as {
|
|
@@ -3452,6 +3634,7 @@ export function apply(ctx: Context) {
|
|
|
3452
3634
|
key: string;
|
|
3453
3635
|
children: {
|
|
3454
3636
|
'sessions.tab': { kind: 'list'; scope: 'root' };
|
|
3637
|
+
'sessions.details': { kind: 'list'; scope: 'root' };
|
|
3455
3638
|
'views.component': { kind: 'keyed'; scope: 'root' };
|
|
3456
3639
|
};
|
|
3457
3640
|
},
|
|
@@ -3464,10 +3647,12 @@ export function apply(ctx: Context) {
|
|
|
3464
3647
|
key: name,
|
|
3465
3648
|
children: {
|
|
3466
3649
|
'sessions.tab': { kind: 'list', scope: 'root' },
|
|
3650
|
+
// The details panel's git rows (the `git` plugin's, bridge-plugins#256).
|
|
3651
|
+
'sessions.details': { kind: 'list', scope: 'root' },
|
|
3467
3652
|
'views.component': { kind: 'keyed', scope: 'root' },
|
|
3468
3653
|
},
|
|
3469
3654
|
},
|
|
3470
|
-
({ node, screen, item, focused, renderSlot }) => (
|
|
3655
|
+
({ node, screen, item, focused, renderSlot, setActions }) => (
|
|
3471
3656
|
<Sessions
|
|
3472
3657
|
ctx={ctx}
|
|
3473
3658
|
node={node}
|
|
@@ -3475,13 +3660,14 @@ export function apply(ctx: Context) {
|
|
|
3475
3660
|
item={item}
|
|
3476
3661
|
focused={focused}
|
|
3477
3662
|
renderSlot={renderSlot}
|
|
3663
|
+
setActions={setActions}
|
|
3478
3664
|
/>
|
|
3479
3665
|
),
|
|
3480
3666
|
);
|
|
3481
3667
|
// The phone's variant (research-020 D5), drawn by the shell in the place of `screen` (./mobile.tsx).
|
|
3482
3668
|
ctx.slots.register(
|
|
3483
3669
|
{ name: 'mobileScreen', key: name },
|
|
3484
|
-
({ node, item, readOnly, setActions, setChrome }) => (
|
|
3670
|
+
({ node, item, readOnly, setActions, setChrome, renderFactorySlot }) => (
|
|
3485
3671
|
<MobileSessions
|
|
3486
3672
|
ctx={ctx}
|
|
3487
3673
|
node={node}
|
|
@@ -3489,6 +3675,8 @@ export function apply(ctx: Context) {
|
|
|
3489
3675
|
readOnly={readOnly}
|
|
3490
3676
|
setActions={setActions}
|
|
3491
3677
|
setChrome={setChrome}
|
|
3678
|
+
// The renderer's factory slots, named at run time (`git.session-details`).
|
|
3679
|
+
renderFactorySlot={renderFactorySlot as React.ComponentProps<typeof MobileSessions>['renderFactorySlot']}
|
|
3492
3680
|
/>
|
|
3493
3681
|
),
|
|
3494
3682
|
);
|