@bridgebrew/sessions 0.0.34 → 0.0.38

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/browser/index.tsx CHANGED
@@ -81,9 +81,11 @@ import {
81
81
  SelectContent,
82
82
  SelectItem,
83
83
  SelectTrigger,
84
- SplitHandle,
85
- SplitPane,
86
- SplitView,
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 { SessionDetails } from './changes.tsx';
113
+ import { DetailsPanel, Row, detailsOf, type GitRowsProps } from './details.tsx';
112
114
  import { SessionPrompt } from '@bridgebrew/session-ui/prompt';
113
- import { shownModel, type HarnessModels, type PickerModel } from '@bridgebrew/session-ui/model-picker';
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 { BranchActions, CleanupDialog, cleanupOf, type Cleanup } from './branch-actions.tsx';
132
- import { PullRequestPill, type SessionPullRequest } from './pull-request.tsx';
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';
@@ -224,10 +229,9 @@ const useBranches = (slug: string, node: string, startNew = false) => {
224
229
  setBranches(undefined);
225
230
  choose(undefined);
226
231
  if (node === 'root') return;
227
- fetch(
228
- `/${encodeURIComponent(slug)}/api/project/branches?node=${encodeURIComponent(node)}`,
229
- { cache: 'no-store' },
230
- )
232
+ fetch(`/${encodeURIComponent(slug)}/api/project/branches?node=${encodeURIComponent(node)}`, {
233
+ cache: 'no-store',
234
+ })
231
235
  .then((res) => (res.ok ? readJson(res) : undefined))
232
236
  .then((body: unknown) => {
233
237
  if (gone || !isRecord(body) || !Array.isArray(body.branches)) return;
@@ -345,6 +349,14 @@ export const notesOf = (session: Session): QueuedNote[] =>
345
349
  ? { node, screen: { plugin: name, id: 'sessions' }, item: from }
346
350
  : { item: from, reuse: true },
347
351
  }));
352
+ /** A button of the window's bar, as the shell takes it (`screen`'s `setActions`, plugins/shell/shell.d.ts). */
353
+ type ScreenAction = {
354
+ id: string;
355
+ label: string;
356
+ icon: string;
357
+ pressed?: boolean;
358
+ onSelect: () => void;
359
+ };
348
360
  type Action = 'settle' | 'unsettle' | 'pin' | 'unpin' | 'unread' | 'archive' | 'restore' | 'wake';
349
361
  type Shelf = 'pinned' | 'active' | 'working' | 'snoozed' | 'settled' | 'archived';
350
362
  /** Settled rows shown before "Show more". */
@@ -382,6 +394,22 @@ export interface Listing {
382
394
  snooze?: boolean;
383
395
  }
384
396
 
397
+ /** A watch's new connection, before its first message (plugins#239): the lines past `saved` (the log's, for sure) leave
398
+ * the page, with the results they gave (`resulted`, tool id → seq): a restart may have lost them and numbered others
399
+ * the same, and the server sends what is past `saved` again. Never at the snapshot: older lines come before it when
400
+ * they do not fit. Returns the new `last`. */
401
+ export const dropUnsaved = (
402
+ last: number,
403
+ saved: number,
404
+ resulted: Map<string, number>,
405
+ setEvents: (update: (was: Stored[]) => Stored[]) => void,
406
+ ) => {
407
+ if (last <= saved) return last;
408
+ for (const [id, seq] of resulted) if (seq > saved) resulted.delete(id);
409
+ setEvents((was) => was.filter((line) => line.seq <= saved));
410
+ return saved;
411
+ };
412
+
385
413
  /** `live` after stored line `event`: a turn starts and ends; a settled segment or tool leaves the live part. */
386
414
  export const afterStored = (live: Live | null, event: Stored): Live | null => {
387
415
  if (event.type === 'turn/start')
@@ -609,6 +637,7 @@ interface ViewComponentSlotProps {
609
637
  * session opened on this node, named as the window's item. Its keys act only while its window is `focused`. */
610
638
  type RenderTabs = {
611
639
  (name: 'sessions.tab', owner: TabSlotProps): React.ReactNode;
640
+ (name: 'sessions.details', owner: GitRowsProps): React.ReactNode;
612
641
  (
613
642
  name: 'views.component',
614
643
  owner: ViewComponentSlotProps,
@@ -663,53 +692,45 @@ const RowMenu = ({
663
692
  each: Session;
664
693
  actions: React.RefObject<RowActions | undefined>;
665
694
  }) => actions.current!.menuItems(each);
666
- /** A row's status as its mark (none when idle). */
667
- const statusMark = (status: string) => {
668
- if (status === 'decision')
669
- return (
670
- <span
671
- role="img"
672
- aria-label="Decision waiting"
673
- className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent"
674
- >
675
- <Icon name="bell" size={12} />
676
- Decision
677
- </span>
678
- );
679
- if (status === 'question')
680
- return (
681
- <span
682
- role="img"
683
- aria-label="A question past its deadline"
684
- className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent"
685
- >
686
- <Icon name="bell" size={12} />
687
- Your call
688
- </span>
689
- );
690
- if (status === 'running') return <Spinner />;
691
- if (status === 'failed')
692
- return (
693
- <span role="img" aria-label="Failed" className="inline-flex shrink-0 text-destructive">
694
- <Icon name="triangle-alert" size={14} />
695
- </span>
696
- );
697
- if (status === 'unread')
698
- return (
699
- <span role="img" aria-label="Unread" className="size-2 shrink-0 rounded-full bg-accent" />
700
- );
701
- if (status === 'woke')
702
- return (
703
- <span
704
- role="img"
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;
695
+ /** Working: a ring with a dot inside (the kit's StatusIcon has none: a bare dot is never a full disc). */
696
+ const WorkingMark = () => (
697
+ <span
698
+ aria-hidden
699
+ className="inline-flex size-3 shrink-0 items-center justify-center rounded-full border-[1.5px] border-accent"
700
+ >
701
+ <span className="size-1 rounded-full bg-accent" />
702
+ </span>
703
+ );
704
+ /** A row's state in its slot, mark and word (none when idle, or unread without a turn that ended well). */
705
+ const disc = (status: 'warning' | 'error' | 'resolved') => (
706
+ <StatusIcon status={status} size="sm" aria-hidden />
707
+ );
708
+ /** Each state's mark, word, colour and name (the names the list's marks always had). */
709
+ const STATES: Record<string, [React.ReactNode, string, string, string]> = {
710
+ decision: [disc('warning'), 'Needs you', 'text-warning-text', 'Decision waiting'],
711
+ question: [disc('warning'), 'Your call', 'text-warning-text', 'A question past its deadline'],
712
+ running: [<WorkingMark />, 'Working', 'text-accent', 'Working'],
713
+ failed: [disc('error'), 'Failed', 'text-destructive', 'Failed'],
714
+ done: [disc('resolved'), 'Done', 'text-success', 'Done'],
715
+ woke: [<Icon name="alarm-clock" size={12} />, 'Woke', 'text-accent', 'Woke from a snooze'],
716
+ };
717
+ /** A row's state in its slot, mark and word: none when idle, or unread without a turn that ended well. */
718
+ const stateMark = (status: string, each: Session) => {
719
+ const shown =
720
+ STATES[status === 'unread' && each.lastTurn?.reason === 'completed' ? 'done' : status];
721
+ if (!shown) return null;
722
+ const [mark, word, className, label] = shown;
723
+ return (
724
+ <span
725
+ role="img"
726
+ aria-label={label}
727
+ data-state={word}
728
+ className={cn('inline-flex shrink-0 items-center gap-1 text-xs font-medium', className)}
729
+ >
730
+ {mark}
731
+ {word}
732
+ </span>
733
+ );
713
734
  };
714
735
 
715
736
  /** A row's hover action: settle, wake in Snoozed, un-settle in Settled, restore in Archived. */
@@ -937,21 +958,12 @@ export const SessionRow = React.memo(function SessionRow({
937
958
  faded && 'opacity-60 group-hover:opacity-100',
938
959
  )}
939
960
  >
961
+ {/* Two lines, each slot in its place for every session (plugins#239 §2): its title and its time
962
+ (its actions while hovered); its branch (or stage) and model, then unread and its state. */}
940
963
  <div className="flex h-5 items-center gap-2">
941
964
  <span className="min-w-0 flex-1 truncate text-sm font-semibold text-foreground">
942
965
  {each.title}
943
966
  </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
967
  {each.snoozedUntil ? (
956
968
  <span
957
969
  title={`Wakes ${when(each.snoozedUntil)}`}
@@ -967,87 +979,114 @@ export const SessionRow = React.memo(function SessionRow({
967
979
  )}
968
980
  {hover}
969
981
  </div>
970
- {depth === 0 && (
971
- <p className="mt-0.5 truncate text-xs text-secondary">
972
- {each.preview ?? 'No messages yet'}
973
- </p>
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={
982
+ <div className="mt-0.5 flex h-4 items-center gap-1 text-xs text-muted">
983
+ <span data-slot="where" className="inline-flex min-w-0 flex-1 items-center gap-1">
984
+ {worktreeName !== undefined && (
985
+ <>
986
+ <Icon name="git-branch" size={12} />
979
987
  <span
980
- aria-label={modelLabel}
981
- className="inline-flex size-4 shrink-0 items-center justify-center text-foreground"
982
- />
983
- }
988
+ data-who="branch"
989
+ className="min-w-0 max-w-32 shrink truncate"
990
+ title={`Works on ${worktreeName}`}
991
+ >
992
+ {worktreeName}
993
+ </span>
994
+ <span aria-hidden>·</span>
995
+ </>
996
+ )}
997
+ <span
998
+ aria-hidden
999
+ className="inline-flex size-3.5 shrink-0 items-center justify-center text-foreground"
984
1000
  >
985
1001
  <ProviderMark provider={provider} size={12} />
986
- </TooltipTrigger>
987
- <TooltipContent>{modelLabel}</TooltipContent>
988
- </Tooltip>
989
- {nodeTitle !== undefined && (
990
- <Badge className="min-w-0 justify-start gap-1 truncate">
991
- <Icon name="folder" size={12} />
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()}
1002
+ </span>
1003
+ <span
1004
+ data-who="model"
1005
+ className="min-w-0 truncate"
1006
+ title={modelLabel}
1007
+ aria-label={modelLabel}
1036
1008
  >
1037
- <Icon
1038
- name="chevron-right"
1039
- size={12}
1040
- className={cn('transition-transform', kidsOpen && 'rotate-90')}
1009
+ {modelLabel.split(' · ').at(-1)}
1010
+ </span>
1011
+ </span>
1012
+ <span data-slot="unread" className="inline-flex w-2 shrink-0 justify-center">
1013
+ {(status === 'unread' || status === 'failed') && (
1014
+ <span
1015
+ role="img"
1016
+ aria-label="Unread"
1017
+ className="size-2 rounded-full bg-accent"
1041
1018
  />
1042
- {[
1043
- kids > 0 && `${kids} child${kids === 1 ? '' : 'ren'}`,
1044
- agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
1045
- ]
1046
- .filter(Boolean)
1047
- .join(' · ')}
1048
- </Button>
1049
- )}
1019
+ )}
1020
+ </span>
1021
+ <span data-slot="state" className="inline-flex shrink-0">
1022
+ {stateMark(status, each)}
1023
+ </span>
1050
1024
  </div>
1025
+ {(nodeTitle !== undefined || !!each.tags?.length || kids + agents > 0) && (
1026
+ <div className="mt-1.5 flex flex-wrap items-center gap-1">
1027
+ {nodeTitle !== undefined && (
1028
+ <Badge className="min-w-0 justify-start gap-1 truncate">
1029
+ <Icon name="folder" size={12} />
1030
+ {nodeTitle}
1031
+ </Badge>
1032
+ )}
1033
+ {each.tags?.map((tag) => (
1034
+ <button
1035
+ key={tag}
1036
+ type="button"
1037
+ data-tag={tag}
1038
+ aria-pressed={tagged === tag}
1039
+ title={
1040
+ tagged === tag ? 'Show every session' : `Show the sessions tagged ${tag}`
1041
+ }
1042
+ className={cn(
1043
+ 'cursor-pointer rounded-full border-0 px-1.5 text-[11px] leading-4 text-secondary hover:bg-border/60',
1044
+ tagged === tag ? 'bg-accent/15 text-accent' : 'bg-border/40',
1045
+ )}
1046
+ onClick={(event) => {
1047
+ event.stopPropagation();
1048
+ actions.current!.setTagged((was) => (was === tag ? undefined : tag));
1049
+ }}
1050
+ onPointerDown={(event) => event.stopPropagation()}
1051
+ >
1052
+ #{tag}
1053
+ </button>
1054
+ ))}
1055
+ {/* Its children (bridge#212): shown or hidden under it, the toggle in one place, the line's end. */}
1056
+ {kids + agents > 0 && (
1057
+ <Button
1058
+ size="sm"
1059
+ // Not the row's menu: its children shown keep the row's stamp, its actions hidden (`:not([data-kids])`).
1060
+ data-kids
1061
+ aria-expanded={kidsOpen}
1062
+ aria-label={`${kidsOpen ? 'Hide' : 'Show'} ${[
1063
+ kids > 0 && `${kids} child session${kids === 1 ? '' : 's'}`,
1064
+ agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
1065
+ ]
1066
+ .filter(Boolean)
1067
+ .join(' and ')} of ${each.title}`}
1068
+ className="-my-1 ml-auto h-6 gap-1 px-1.5 text-xs text-muted"
1069
+ onClick={(event) => {
1070
+ event.stopPropagation();
1071
+ actions.current!.toggleChildren?.(each.id);
1072
+ }}
1073
+ onPointerDown={(event) => event.stopPropagation()}
1074
+ >
1075
+ <Icon
1076
+ name="chevron-right"
1077
+ size={12}
1078
+ className={cn('transition-transform', kidsOpen && 'rotate-90')}
1079
+ />
1080
+ {[
1081
+ kids > 0 && `${kids} child${kids === 1 ? '' : 'ren'}`,
1082
+ agents > 0 && `${agents} sub-agent${agents === 1 ? '' : 's'}`,
1083
+ ]
1084
+ .filter(Boolean)
1085
+ .join(' · ')}
1086
+ </Button>
1087
+ )}
1088
+ </div>
1089
+ )}
1051
1090
  </div>
1052
1091
  )}
1053
1092
  </ListItem>
@@ -1110,6 +1149,7 @@ function Sessions({
1110
1149
  item,
1111
1150
  focused,
1112
1151
  renderSlot,
1152
+ setActions,
1113
1153
  }: {
1114
1154
  ctx: Context;
1115
1155
  node: string;
@@ -1117,6 +1157,8 @@ function Sessions({
1117
1157
  item: string | undefined;
1118
1158
  focused: boolean | undefined;
1119
1159
  renderSlot: RenderTabs;
1160
+ /** The shell's buttons in this window's bar (`screen`'s `setActions`); absent from an older shell. */
1161
+ setActions?: ((actions: readonly ScreenAction[]) => void) | undefined;
1120
1162
  }) {
1121
1163
  const { workspace } = ctx;
1122
1164
  const api = `/${workspace.slug}/api/sessions/sessions`;
@@ -1167,8 +1209,10 @@ function Sessions({
1167
1209
  // Another item: the choice made apart is dropped.
1168
1210
  React.useEffect(() => setOverride(undefined), [item]);
1169
1211
  // 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.
1212
+ const chosenItem = override && override.over === item ? override.id : (item ?? fallback);
1213
+ // The phone's Details item (./details.tsx) names its session here.
1170
1214
  const { session: asked, subagent: shownSub } = itemParts(
1171
- override && override.over === item ? override.id : (item ?? fallback),
1215
+ chosenItem === undefined ? undefined : detailsOf(chosenItem).session,
1172
1216
  );
1173
1217
  /** The session asked here now, read by an action that answers after the person may have opened another. */
1174
1218
  const shown = React.useRef(asked);
@@ -1260,10 +1304,11 @@ function Sessions({
1260
1304
  }),
1261
1305
  [],
1262
1306
  );
1263
- /** The file a tool call's change counts opened the details panel on (`at`: each click scrolls to it again). */
1307
+ /** The diff the conversation asked the details panel for: at a tool call's file, or its top (a turn's Review
1308
+ * changes); `at`: each click opens it again. Forgotten once the panel opened it. */
1264
1309
  const [changeAsked, setChangeAsked] = React.useState<{
1265
1310
  session: string;
1266
- path: string;
1311
+ path?: string;
1267
1312
  at: number;
1268
1313
  }>();
1269
1314
  const viewport = React.useRef<HTMLDivElement>(null);
@@ -1319,7 +1364,9 @@ function Sessions({
1319
1364
  return {};
1320
1365
  }
1321
1366
  });
1322
- const isOpen = (shelf: Shelf) => shelves[shelf] ?? (shelf !== 'settled' && shelf !== 'working');
1367
+ // A search opens every shelf: what it found shows wherever it is.
1368
+ const isOpen = (shelf: Shelf) =>
1369
+ query.trim() !== '' || (shelves[shelf] ?? (shelf !== 'settled' && shelf !== 'working'));
1323
1370
  const setOpen = (shelf: Shelf, open: boolean) =>
1324
1371
  setShelves((was) => {
1325
1372
  const next = { ...was, [shelf]: open };
@@ -1338,30 +1385,9 @@ function Sessions({
1338
1385
  const [cleanup, setCleanup] = React.useState<Cleanup>();
1339
1386
  /** The archived sessions, listed while "Show archived" is on (`undefined`: off). */
1340
1387
  const [archived, setArchived] = React.useState<Session[]>();
1341
- /** The header's title being edited (`undefined`: the session's title shows). */
1342
- const [draft, setDraft] = React.useState<string>();
1343
- const titleField = React.useRef<HTMLInputElement>(null);
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. */
1388
+ /** A rename asked from a row's menu: the session and the title being written, in a dialog. */
1389
+ const [renaming, setRenaming] = React.useState<{ id: string; title: string }>();
1390
+ /** The sessions list beside the conversation, hidden from the conversation's header, kept per node. */
1365
1391
  const listKey = `bridge.sessions.list.${JSON.stringify([workspace.slug, node])}`;
1366
1392
  const [listShown, setListShown] = React.useState(() => {
1367
1393
  try {
@@ -1370,17 +1396,7 @@ function Sessions({
1370
1396
  return true;
1371
1397
  }
1372
1398
  });
1373
- /** The list's content while it slides in or out: held at the pane's open width (px), so it is clipped, not reflowed;
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);
1399
+ const toggleList = () =>
1384
1400
  setListShown((was) => {
1385
1401
  try {
1386
1402
  localStorage.setItem(listKey, was ? '0' : '1');
@@ -1389,7 +1405,41 @@ function Sessions({
1389
1405
  }
1390
1406
  return !was;
1391
1407
  });
1408
+ /** The details panel on the right (plugins#239), shown or hidden from the session's header: kept in the user's
1409
+ * profile (shown until hidden). */
1410
+ const panelShown = React.useSyncExternalStore(
1411
+ profile.subscribe,
1412
+ () => profile.get('sessions', 'details-panel', { workspace: currentWorkspace() }) !== false,
1413
+ );
1414
+ /** The screen's box is too narrow for three panes (`multiPaneAsideWidth`): the panel opens as a window over the
1415
+ * conversation instead, from the same button. */
1416
+ const screenBox = React.useRef<HTMLElement>(null);
1417
+ const [narrow, setNarrow] = React.useState(false);
1418
+ React.useLayoutEffect(() => {
1419
+ const element = screenBox.current;
1420
+ if (!element || typeof ResizeObserver === 'undefined') return;
1421
+ const measure = (width: number) => setNarrow(width > 0 && width < multiPaneAsideWidth);
1422
+ measure(element.getBoundingClientRect().width);
1423
+ const observer = new ResizeObserver(([entry]) => entry && measure(entry.contentRect.width));
1424
+ observer.observe(element);
1425
+ return () => observer.disconnect();
1426
+ }, [!!listing]);
1427
+ /** The panel's window, while the screen is narrow. */
1428
+ const [panelWindow, setPanelWindow] = React.useState(false);
1429
+ React.useEffect(() => {
1430
+ if (!narrow) setPanelWindow(false);
1431
+ }, [narrow]);
1432
+ const togglePanel = () => {
1433
+ if (narrow) return setPanelWindow((was) => !was);
1434
+ profile.set('sessions', 'details-panel', !panelShown, { scope: 'global' });
1435
+ };
1436
+ /** The panel shown (its window on a narrow screen), for the conversation asking it for the diff. */
1437
+ const showPanel = () => {
1438
+ if (narrow) setPanelWindow(true);
1439
+ else if (!panelShown) profile.set('sessions', 'details-panel', true, { scope: 'global' });
1392
1440
  };
1441
+ /** What the sessions list shows: the sessions whose title or branch holds it, across shelves. */
1442
+ const [query, setQuery] = React.useState('');
1393
1443
  /** The list shows only the sessions with tag `tagged` when set (the workspace's tags, most used first: `known`). */
1394
1444
  const [tagged, setTagged] = React.useState<string>();
1395
1445
  /** The session whose custom snooze time is being chosen (the SnoozeDialog), and a pinned one being snoozed, asked
@@ -1507,8 +1557,8 @@ function Sessions({
1507
1557
  return `${harnessLabel(each.harness)} · ${shown ? `${shown.name}${each.model ? '' : ' (default)'}` : 'Default model'}`;
1508
1558
  };
1509
1559
 
1510
- // One subscription for the shown session; after an error, a new one from the last `seq` held, 1 s later, doubling to
1511
- // 30 s (back to 1 s at a snapshot). It ends with the view or the workspace.
1560
+ // One subscription for the shown session; after an error, a new one from the last `seq` the log holds (`saved`), 1 s
1561
+ // later, doubling to 30 s (back to 1 s at a snapshot). It ends with the view or the workspace.
1512
1562
  React.useEffect(() => {
1513
1563
  setEvents([]);
1514
1564
  setLive(null);
@@ -1520,21 +1570,23 @@ function Sessions({
1520
1570
  setAway(false);
1521
1571
  if (!current) return;
1522
1572
  let last = 0;
1573
+ /** The newest `seq` the log holds (`saved` messages, the snapshot's): kept across a reconnect (`dropUnsaved`). */
1574
+ let saved = 0;
1523
1575
  let stop: (() => void) | undefined;
1524
1576
  let retry: ReturnType<typeof setTimeout> | undefined;
1525
1577
  let delay = 1000;
1526
1578
  let closed = false;
1527
1579
  /** A snapshot came already: the next one is a reconnect's. */
1528
1580
  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 Set<string>();
1581
+ /** Ids with a stored `tool/result` in the current turn (and its `seq`): a later live event of theirs is stale. */
1582
+ const resulted = new Map<string, number>();
1531
1583
  const add = (lines: Stored[]) => {
1532
1584
  const fresh = lines.filter((line) => line.seq > last);
1533
1585
  if (!fresh.length) return;
1534
1586
  last = fresh.at(-1)!.seq;
1535
1587
  for (const line of fresh) {
1536
1588
  if (line.type === 'turn/start') resulted.clear();
1537
- if (line.type === 'tool/result' && line.id) resulted.add(line.id);
1589
+ if (line.type === 'tool/result' && line.id) resulted.set(line.id, line.seq);
1538
1590
  }
1539
1591
  if (fresh.some((line) => listChanges.has(line.type))) void load();
1540
1592
  setEvents((was) => [...was, ...fresh]);
@@ -1549,7 +1601,9 @@ function Sessions({
1549
1601
  const subscribe = () => {
1550
1602
  /** The snapshot came on this connection: stored lines before it are history, not the running turn. */
1551
1603
  let isSynced = false;
1552
- // On the page carrier, not persistent: on an end or a lost connection this view opens it again from `last`.
1604
+ /** No message came on this connection yet. */
1605
+ let fresh = true;
1606
+ // On the page carrier, not persistent: on an end or a lost connection this view opens it again from `saved`.
1553
1607
  let retried = false;
1554
1608
  const again = () => {
1555
1609
  stop?.();
@@ -1560,7 +1614,7 @@ function Sessions({
1560
1614
  delay = Math.min(delay * 2, 30_000);
1561
1615
  };
1562
1616
  // From the start, the newest page only: earlier ones load as the reader scrolls up (`loadEarlier`).
1563
- const from = last ? `after=${last}` : `after=0&limit=${HISTORY_PAGE}`;
1617
+ const from = saved ? `after=${saved}` : `after=0&limit=${HISTORY_PAGE}`;
1564
1618
  stop = workspace.stream(
1565
1619
  `${api}/watch?id=${encodeURIComponent(current)}&page=${page}&${from}`,
1566
1620
  {
@@ -1569,12 +1623,24 @@ function Sessions({
1569
1623
  onEnd: again,
1570
1624
  onItem: (value) => {
1571
1625
  const data = value as
1572
- | { type: 'snapshot'; events: Stored[]; live: Live | null; more?: boolean }
1626
+ | {
1627
+ type: 'snapshot';
1628
+ events: Stored[];
1629
+ live: Live | null;
1630
+ more?: boolean;
1631
+ saved?: number;
1632
+ }
1573
1633
  | { type: 'stored'; event: Stored }
1634
+ | { type: 'saved'; seq: number }
1574
1635
  | { type: 'live'; event: LiveEvent }
1575
1636
  | { type: 'ping' }
1576
1637
  | { type: 'open-link'; path: string; turn?: string; request?: string };
1577
- if (data.type === 'snapshot') {
1638
+ if (fresh) {
1639
+ fresh = false;
1640
+ last = dropUnsaved(last, saved, resulted, setEvents);
1641
+ }
1642
+ if (data.type === 'saved') saved = Math.max(saved, data.seq);
1643
+ else if (data.type === 'snapshot') {
1578
1644
  isSynced = true;
1579
1645
  activity.connected();
1580
1646
  delay = 1000;
@@ -1584,6 +1650,7 @@ function Sessions({
1584
1650
  if (resumed) void load();
1585
1651
  resumed = true;
1586
1652
  add(data.events);
1653
+ saved = Math.max(saved, data.saved ?? last);
1587
1654
  setLive(data.live);
1588
1655
  } else if (data.type === 'stored') {
1589
1656
  if (data.event.seq <= last) return;
@@ -1671,14 +1738,6 @@ function Sessions({
1671
1738
  React.useEffect(() => {
1672
1739
  if (current) visit(current);
1673
1740
  }, [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
1741
  // In the shell's help, with the plugin's name, while a Sessions screen is shown (the copies share one declaration).
1683
1742
  React.useEffect(() => {
1684
1743
  const removals = keys().map((each) => ctx.shell.shortcuts.declare(each, name));
@@ -1815,7 +1874,7 @@ function Sessions({
1815
1874
  shown={tabs.shown}
1816
1875
  tabs={tabs.value}
1817
1876
  chat={title}
1818
- title={draft ?? session.title}
1877
+ title={session.title}
1819
1878
  />
1820
1879
  ) : (
1821
1880
  title
@@ -1991,6 +2050,37 @@ function Sessions({
1991
2050
  element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
1992
2051
  };
1993
2052
 
2053
+ /** The panel shown (beside, or as its window when narrow). */
2054
+ const panelOpen = narrow ? panelWindow : panelShown;
2055
+ /** The window bar's buttons (the shell's `setActions`, plugins#239): the sessions list's, then the panel's (none in a
2056
+ * sub-agent's view, which has no panel). Their clicks read the page's latest state. */
2057
+ const toggles = React.useRef({ list: toggleList, panel: togglePanel });
2058
+ toggles.current = { list: toggleList, panel: togglePanel };
2059
+ const actions: ScreenAction[] = [
2060
+ {
2061
+ id: 'sessions-list',
2062
+ label: listShown ? 'Hide sessions' : 'Show sessions',
2063
+ icon: 'panel-left',
2064
+ pressed: listShown,
2065
+ onSelect: () => toggles.current.list(),
2066
+ },
2067
+ ...(session && shownSub === undefined
2068
+ ? [
2069
+ {
2070
+ id: 'details-panel',
2071
+ label: panelOpen ? 'Hide panel' : 'Show panel',
2072
+ icon: 'panel-right',
2073
+ pressed: panelOpen,
2074
+ onSelect: () => toggles.current.panel(),
2075
+ },
2076
+ ]
2077
+ : []),
2078
+ ];
2079
+ const actionsKey = JSON.stringify(actions.map(({ onSelect: _, ...each }) => each));
2080
+ React.useEffect(() => {
2081
+ setActions?.(actions);
2082
+ }, [setActions, actionsKey]);
2083
+ React.useEffect(() => () => setActions?.([]), [setActions]);
1994
2084
  if (!listing) return <section aria-label="Screen" className="flex min-h-0 flex-1" />;
1995
2085
  if (!listing.project && !listing.workspace) {
1996
2086
  return (
@@ -2022,9 +2112,18 @@ function Sessions({
2022
2112
  // The shelves: a snoozed session is in Snoozed until it wakes (a pin may wait under it); else a pinned one is in
2023
2113
  // Pinned whatever else it is (settle clears the pin).
2024
2114
  // A child is listed under its parent, never on a shelf of its own; its parent works or waits while it does.
2025
- const shownSessions = tagged
2026
- ? family.top.filter((each) => each.tags?.includes(tagged))
2027
- : family.top;
2115
+ const words = query.trim().toLowerCase();
2116
+ /** Session `each` is shown: its tag is the one chosen, and its title or branch (or worktree) holds the search. */
2117
+ const matches = (each: Session) =>
2118
+ (!tagged || !!each.tags?.includes(tagged)) &&
2119
+ (!words ||
2120
+ [
2121
+ each.title,
2122
+ each.branch?.name,
2123
+ each.worktree && (worktreeNames.get(each.worktree.slug) ?? each.worktree.slug),
2124
+ ].some((text) => text?.toLowerCase().includes(words)));
2125
+ // ponytail: a child is found through its parent's row only; search the children too if asked.
2126
+ const shownSessions = family.top.filter(matches);
2028
2127
  const snoozed = shownSessions
2029
2128
  .filter((each) => each.snoozedUntil)
2030
2129
  .sort((a, b) => a.snoozedUntil!.localeCompare(b.snoozedUntil!));
@@ -2037,7 +2136,7 @@ function Sessions({
2037
2136
  const settled = awake
2038
2137
  .filter((each) => !each.pinnedAt && each.settledAt)
2039
2138
  .sort((a, b) => b.settledAt!.localeCompare(a.settledAt!));
2040
- const archivedShown = tagged ? archived?.filter((each) => each.tags?.includes(tagged)) : archived;
2139
+ const archivedShown = archived?.filter(matches);
2041
2140
  const settledShown = allSettled ? settled : settled.slice(0, SETTLED_SHOWN);
2042
2141
  /** The rows in list order, for previous and next. */
2043
2142
  const ordered = [
@@ -2210,23 +2309,23 @@ function Sessions({
2210
2309
  reorder(ids);
2211
2310
  };
2212
2311
  const rename = () => {
2213
- const title = draft?.trim();
2214
- setDraft(undefined);
2215
- if (!session || !title || title === session.title) return;
2312
+ const asked = renaming;
2313
+ setRenaming(undefined);
2314
+ const title = asked?.title.trim();
2315
+ const was = listing?.sessions.find((each) => each.id === asked?.id);
2316
+ if (!asked || !was || !title || title === was.title) return;
2216
2317
  setListing(
2217
2318
  (was) =>
2218
2319
  was && {
2219
2320
  ...was,
2220
- sessions: was.sessions.map((each) =>
2221
- each.id === session.id ? { ...each, title } : each,
2222
- ),
2321
+ sessions: was.sessions.map((each) => (each.id === asked.id ? { ...each, title } : each)),
2223
2322
  },
2224
2323
  );
2225
2324
  void workspace
2226
2325
  .fetch(`${api}/rename`, {
2227
2326
  method: 'POST',
2228
2327
  headers,
2229
- body: JSON.stringify({ id: session.id, title }),
2328
+ body: JSON.stringify({ id: asked.id, title }),
2230
2329
  })
2231
2330
  .then(readJson)
2232
2331
  .then(load, (cause) => {
@@ -2234,10 +2333,7 @@ function Sessions({
2234
2333
  void load();
2235
2334
  });
2236
2335
  };
2237
- const askRename = (each: Session) => {
2238
- renameAsked.current = each.id;
2239
- choose(each.id);
2240
- };
2336
+ const askRename = (each: Session) => setRenaming({ id: each.id, title: each.title });
2241
2337
  onKey.current = (event) => {
2242
2338
  // Another window is the one the user works in, or a modal dialog is open over the page: the keys are its own.
2243
2339
  if (focused === false || modalOpen()) return;
@@ -2627,7 +2723,7 @@ function Sessions({
2627
2723
  size="sm"
2628
2724
  aria-label="The branch the new session works on"
2629
2725
  title="The branch the new session works on"
2630
- className="w-auto max-w-44 shrink-0 gap-1 rounded-full text-xs"
2726
+ className="w-auto max-w-44 min-w-0 gap-1 rounded-full text-xs"
2631
2727
  data-branch-picker
2632
2728
  >
2633
2729
  <Icon name={branchOf.newBranch ? 'plus' : 'git-branch'} size={12} />
@@ -2660,7 +2756,7 @@ function Sessions({
2660
2756
  <span
2661
2757
  data-branch-fixed
2662
2758
  title="The branch this session works on: fixed after its first message"
2663
- className="inline-flex max-w-44 shrink-0 items-center gap-1 text-xs text-muted"
2759
+ className="inline-flex max-w-44 min-w-0 items-center gap-1 text-xs text-muted"
2664
2760
  >
2665
2761
  <Icon name="git-branch" size={12} />
2666
2762
  <span className="truncate font-mono">
@@ -2727,62 +2823,143 @@ function Sessions({
2727
2823
  </div>
2728
2824
  );
2729
2825
 
2730
- /** The button showing or hiding the sessions list, in the pane's header. */
2731
- const listToggle = (
2732
- <Tooltip>
2733
- <TooltipTrigger
2734
- render={
2826
+ /** The open session's pull request act (watch, unwatch, unlink), for its pill. */
2827
+ const actPullRequest = (id: string) => (action: 'watch' | 'unwatch' | 'unlink') =>
2828
+ void post(`/pull-request/${action}`, { id })
2829
+ .then(() => load())
2830
+ .catch(report);
2831
+ /** Without the shell's window bar (an older shell): the same buttons, at the conversation's top. */
2832
+ const ownToggles =
2833
+ !setActions &&
2834
+ actions.map((each) => (
2835
+ <Tooltip key={each.id}>
2836
+ <TooltipTrigger
2837
+ render={
2838
+ <Button
2839
+ size="icon-sm"
2840
+ aria-label={each.label}
2841
+ aria-pressed={each.pressed}
2842
+ className="shrink-0"
2843
+ onClick={each.onSelect}
2844
+ />
2845
+ }
2846
+ >
2847
+ <Icon name={each.icon} />
2848
+ </TooltipTrigger>
2849
+ <TooltipContent>{each.label}</TooltipContent>
2850
+ </Tooltip>
2851
+ ));
2852
+
2853
+ /** The rows the page adds to the details panel (plugins#239): what the session's header held. */
2854
+ const panelRows = session && {
2855
+ gallery: (
2856
+ <Row
2857
+ name="Gallery"
2858
+ icon="image"
2859
+ value={
2735
2860
  <Button
2736
- size="icon"
2737
- aria-label={listShown ? 'Hide sessions list' : 'Show sessions list'}
2738
- aria-expanded={listShown}
2739
- className="-ml-2 shrink-0"
2740
- onClick={toggleList}
2741
- />
2861
+ size="sm"
2862
+ variant="ghost"
2863
+ aria-label="Gallery"
2864
+ className="-mr-2 gap-1"
2865
+ onClick={() => setGalleryOpen(true)}
2866
+ >
2867
+ {pins.length ? `${pins.length} pinned` : 'Open'}
2868
+ </Button>
2742
2869
  }
2743
- >
2744
- <Icon name={listShown ? 'panel-left-close' : 'panel-left-open'} />
2745
- </TooltipTrigger>
2746
- <TooltipContent>{listShown ? 'Hide sessions list' : 'Show sessions list'}</TooltipContent>
2747
- </Tooltip>
2870
+ />
2871
+ ),
2872
+ marks: (
2873
+ <>
2874
+ {session.pinnedAt && <Row name="Pinned" icon="pin" />}
2875
+ {session.settledAt && !session.pinnedAt && <Row name="Settled" icon="check" />}
2876
+ {session.snoozedUntil && (
2877
+ <Row
2878
+ name="Snoozed"
2879
+ icon="alarm-clock"
2880
+ value={
2881
+ <span title={`Wakes ${when(session.snoozedUntil)}`}>
2882
+ {snoozeWakeLabel(session.snoozedUntil)}
2883
+ </span>
2884
+ }
2885
+ />
2886
+ )}
2887
+ <SessionScheduled
2888
+ ctx={ctx}
2889
+ node={node}
2890
+ session={session}
2891
+ wrap={(menu) => <Row name="Scheduled" icon="calendar-clock" value={menu} />}
2892
+ />
2893
+ {/* A child session's parent (bridge#212): a link to it. */}
2894
+ {session.parent !== undefined && (
2895
+ <Row name="Parent" icon="arrow-up" value={<ParentLink parent={session.parent} />} />
2896
+ )}
2897
+ {/* Where it works (research-083): its stage, by the branches it runs. */}
2898
+ {session.worktree && (
2899
+ <Row
2900
+ name="Stage"
2901
+ icon="git-fork"
2902
+ value={
2903
+ <span
2904
+ className="truncate"
2905
+ title={`Works in the stage ${worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}`}
2906
+ >
2907
+ {worktreeNames.get(session.worktree.slug) ?? session.worktree.slug}
2908
+ </span>
2909
+ }
2910
+ />
2911
+ )}
2912
+ </>
2913
+ ),
2914
+ };
2915
+ /** The details panel (./details.tsx): the open session's branch, changes, pull request, tags, and its rows. */
2916
+ const panel = session && (
2917
+ <LineageContext.Provider value={lineageOf ?? null}>
2918
+ <DetailsPanel
2919
+ session={session}
2920
+ slug={branchesAt}
2921
+ known={known}
2922
+ post={post}
2923
+ onChanged={() => void load()}
2924
+ actPullRequest={actPullRequest(session.id)}
2925
+ // Its git rows and the Commit changes dialog: the `git` plugin's (`sessions.details`).
2926
+ gitRows={(props) => renderSlot('sessions.details', props)}
2927
+ onOpenSession={(id) => {
2928
+ setTagged(undefined);
2929
+ choose(id);
2930
+ }}
2931
+ // A Git action done (Create PR among them): its pull request is found or read again.
2932
+ onGitAnswer={() => void post('/pull-request/refresh', { id: session.id }).catch(report)}
2933
+ onInstallGit={() => installGit(workspace.slug)}
2934
+ diffAsked={changeAsked?.session === session.id ? changeAsked : undefined}
2935
+ onDiffAnswered={() => setChangeAsked(undefined)}
2936
+ {...panelRows}
2937
+ />
2938
+ </LineageContext.Provider>
2748
2939
  );
2749
-
2940
+ /** The panel on the right, while it shows and there is room for it (none in a sub-agent's view). */
2941
+ const aside = !narrow && panelShown && shownSub === undefined ? panel || undefined : undefined;
2750
2942
  const page = (
2751
2943
  <section
2944
+ ref={screenBox}
2752
2945
  aria-label="Screen"
2753
2946
  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
2947
  >
2759
- <SplitView
2760
- orientation="horizontal"
2761
- storageKey="sessions/browser/list@v1"
2762
- // The list's pane (the library sizes it with flex-grow): closed to nothing while hidden, its share kept for
2763
- // when it comes back; the width and the content's opacity slide only on a toggle, never during a drag.
2764
- className={cn(
2765
- !listShown && '[&>[data-slot=resizable-panel-group]>#sessions]:grow-0!',
2766
- listFrozen !== undefined &&
2767
- '[&>[data-slot=resizable-panel-group]>#sessions]:transition-[flex-grow] [&>[data-slot=resizable-panel-group]>#sessions]:duration-200 [&>[data-slot=resizable-panel-group]>#sessions]:ease-out',
2768
- )}
2769
- >
2770
- <SplitPane id="sessions" defaultSize="280px" minSize="220px" maxSize="480px">
2771
- {/* Hidden, the list is out of the tab order and the accessibility tree; anchored right, it slides left. */}
2772
- <div
2773
- ref={listContent}
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
- >
2948
+ <MultiPane
2949
+ // One kept layout for the list and the details panel, shown or hidden (the kit keeps each pane's width when the
2950
+ // panel toggles). Nothing collapses on its own: a narrow screen opens the panel as a window instead (`narrow`),
2951
+ // and keeps the list beside the conversation as it always did.
2952
+ storageKey="sessions/browser/panes@v1"
2953
+ collapse={false}
2954
+ // The details panel is a card beside the conversation (owner, plugins#239), not a full-height column.
2955
+ asideVariant="floating"
2956
+ defaultNavSize="280px"
2957
+ defaultAsideSize="340px"
2958
+ // Hidden, the list is no pane at all: the kit keeps the panel's width and gives the room to the conversation,
2959
+ // and brings the list back at its own width.
2960
+ nav={
2961
+ listShown && (
2962
+ <Pane className="bg-background">
2786
2963
  <PaneHeader className="h-11 shrink-0 border-b border-border py-0 pl-4 pr-2">
2787
2964
  <h1 className="text-sm font-semibold">Sessions</h1>
2788
2965
  <Tooltip>
@@ -2794,6 +2971,22 @@ function Sessions({
2794
2971
  <TooltipContent>New chat</TooltipContent>
2795
2972
  </Tooltip>
2796
2973
  </PaneHeader>
2974
+ <div className="shrink-0 px-3 pb-1 pt-2">
2975
+ <Input
2976
+ type="search"
2977
+ size="sm"
2978
+ aria-label="Search sessions"
2979
+ placeholder="Search sessions"
2980
+ value={query}
2981
+ onChange={(event) => setQuery(event.currentTarget.value)}
2982
+ onKeyDown={(event) => {
2983
+ if (event.key === 'Escape' && query) {
2984
+ event.stopPropagation();
2985
+ setQuery('');
2986
+ }
2987
+ }}
2988
+ />
2989
+ </div>
2797
2990
  <PaneBody viewportClassName={fitWidth}>
2798
2991
  <nav aria-label="Sessions">
2799
2992
  {tagged && (
@@ -2810,8 +3003,12 @@ function Sessions({
2810
3003
  </Button>
2811
3004
  </div>
2812
3005
  )}
2813
- {listing.sessions.length === 0 && !archived && (
3006
+ {listing.sessions.length === 0 && !archived ? (
2814
3007
  <EmptyState>No sessions yet. Start one from the composer.</EmptyState>
3008
+ ) : (
3009
+ words &&
3010
+ shownSessions.length === 0 &&
3011
+ !archivedShown?.length && <EmptyState>No sessions match.</EmptyState>
2815
3012
  )}
2816
3013
  {shelf(
2817
3014
  'pinned',
@@ -2913,10 +3110,9 @@ function Sessions({
2913
3110
  </nav>
2914
3111
  </PaneBody>
2915
3112
  </Pane>
2916
- </div>
2917
- </SplitPane>
2918
- <SplitHandle {...(!listShown && { className: 'hidden' })} />
2919
- <SplitPane id="session" minSize="360px">
3113
+ )
3114
+ }
3115
+ main={
2920
3116
  <LineageContext.Provider value={lineageOf ?? null}>
2921
3117
  {session && shownSub !== undefined ? (
2922
3118
  // A sub-agent's view (bridge#212 S8): read only, from its session's stream.
@@ -2939,231 +3135,71 @@ function Sessions({
2939
3135
  }
2940
3136
  folder={sessionFolder}
2941
3137
  workspace={workspace.slug}
2942
- listToggle={listToggle}
3138
+ listToggle={ownToggles ? ownToggles[0] : undefined}
2943
3139
  {...(session.subagents?.find((each) => each.id === shownSub)?.stoppable && {
2944
3140
  onStop: () => stopSub.current(shownSub),
2945
3141
  })}
2946
3142
  />
2947
3143
  ) : (
2948
3144
  <div className="flex h-full min-w-0 flex-col">
2949
- <header className="flex h-11 shrink-0 items-center gap-2 border-b border-border px-4">
2950
- {listToggle}
2951
- {withTabs(
2952
- session ? (
2953
- // The title, renamed in place: Enter or leaving the field keeps it, Escape restores it.
2954
- <Input
2955
- ref={titleField}
2956
- size="sm"
2957
- aria-label="Session title"
2958
- value={draft ?? session.title}
2959
- className="w-auto min-w-16 max-w-[480px] truncate font-semibold field-sizing-content"
2960
- onChange={(event) => setDraft(event.currentTarget.value)}
2961
- onBlur={rename}
2962
- onKeyDown={(event) => {
2963
- if (event.key === 'Enter' && !isComposing(event))
2964
- event.currentTarget.blur();
2965
- else if (event.key === 'Escape' && !isComposing(event)) {
2966
- setDraft(undefined);
2967
- requestAnimationFrame(() => titleField.current?.blur());
2968
- }
2969
- }}
2970
- />
2971
- ) : (
2972
- <h2 className="min-w-0 truncate text-sm font-semibold">
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
- {
3145
+ {/* No header (plugins#239): the title is the window's breadcrumb, the rest in the details panel. A slim
3146
+ row on top only for its tabs (`sessions.tab`, an agent's browser), or the toggles an older shell
3147
+ cannot take in its window bar. */}
3148
+ {((tabs.open.length > 0 && session) || ownToggles) && (
3149
+ <div className="flex h-10 shrink-0 items-center gap-2 border-b border-border px-2">
3150
+ {ownToggles && ownToggles[0]}
3151
+ {tabs.open.length > 0 &&
3152
+ session &&
3153
+ withTabs(
3154
+ <span className="min-w-0 truncate pr-2 text-sm font-medium">
3155
+ {session.title}
3156
+ </span>,
3157
+ )}
3158
+ <span className="flex-1" />
3159
+ {ownToggles && ownToggles.slice(1)}
3160
+ </div>
3161
+ )}
3162
+ {session && (
3163
+ <GalleryDialog
3164
+ open={galleryOpen}
3165
+ onOpenChange={(next) => {
3166
+ setGalleryOpen(next);
3167
+ if (!next && current && sessionNode)
3168
+ void loadPins({
3116
3169
  key: 'session',
3117
3170
  label: 'Session',
3118
- node: session.node,
3119
- session: session.id,
3120
- },
3121
- ...(session.node !== 'root'
3122
- ? [{ key: 'project' as const, label: 'Project', node: session.node }]
3123
- : []),
3124
- { key: 'workspace', label: 'Workspace', node: 'root' },
3125
- ]}
3126
- load={loadPins}
3127
- unpin={(pin) =>
3128
- unpinImage(pin).catch((cause) => {
3129
- report(cause);
3130
- throw cause;
3131
- })
3132
- }
3133
- onOpenSession={(id) => {
3134
- setTagged(undefined);
3135
- choose(id);
3136
- }}
3137
- titleOf={(id) => listing?.sessions.find((each) => each.id === id)?.title}
3138
- />
3139
- )}
3140
- {session && (
3141
- <DropdownMenu>
3142
- <DropdownMenuTrigger
3143
- render={<Button size="icon" aria-label="Session actions" />}
3144
- >
3145
- <Icon name="ellipsis" />
3146
- </DropdownMenuTrigger>
3147
- <DropdownMenuContent align="end">
3148
- {menuItems(session, true)}
3149
- </DropdownMenuContent>
3150
- </DropdownMenu>
3151
- )}
3152
- </header>
3171
+ node: sessionNode,
3172
+ session: current,
3173
+ }).then(setPins, () => {});
3174
+ }}
3175
+ workspace={workspace.slug}
3176
+ scopes={[
3177
+ {
3178
+ key: 'session',
3179
+ label: 'Session',
3180
+ node: session.node,
3181
+ session: session.id,
3182
+ },
3183
+ ...(session.node !== 'root'
3184
+ ? [{ key: 'project' as const, label: 'Project', node: session.node }]
3185
+ : []),
3186
+ { key: 'workspace', label: 'Workspace', node: 'root' },
3187
+ ]}
3188
+ load={loadPins}
3189
+ unpin={(pin) =>
3190
+ unpinImage(pin).catch((cause) => {
3191
+ report(cause);
3192
+ throw cause;
3193
+ })
3194
+ }
3195
+ onOpenSession={(id) => {
3196
+ setTagged(undefined);
3197
+ choose(id);
3198
+ }}
3199
+ titleOf={(id) => listing?.sessions.find((each) => each.id === id)?.title}
3200
+ />
3201
+ )}
3153
3202
  <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
3203
  {current && (
3168
3204
  <>
3169
3205
  <ScrollArea
@@ -3188,13 +3224,14 @@ function Sessions({
3188
3224
  promptHandle.current?.focus();
3189
3225
  }}
3190
3226
  onReview={() => {
3191
- if (!details) toggleDetails();
3227
+ setChangeAsked({ session: current, at: Date.now() });
3228
+ showPanel();
3192
3229
  }}
3193
3230
  onAnswer={(event, option) => answer(event.id!, option)}
3194
3231
  onDecisionShown={onDecisionShown}
3195
3232
  onOpenChange={(path) => {
3196
3233
  setChangeAsked({ session: current, path, at: Date.now() });
3197
- if (!details) toggleDetails();
3234
+ showPanel();
3198
3235
  }}
3199
3236
  lineage={lineageOf}
3200
3237
  />
@@ -3254,6 +3291,29 @@ function Sessions({
3254
3291
  )}
3255
3292
  {prompt}
3256
3293
  </div>
3294
+ {narrow && panelWindow && panel && (
3295
+ // Too narrow for a third pane: the panel as a window over the conversation's right side.
3296
+ <div
3297
+ role="dialog"
3298
+ aria-label="Details panel"
3299
+ 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"
3300
+ onKeyDown={(event) => {
3301
+ if (event.key === 'Escape' && !event.defaultPrevented)
3302
+ setPanelWindow(false);
3303
+ }}
3304
+ >
3305
+ <div className="flex h-11 shrink-0 items-center justify-end border-b border-border px-2">
3306
+ <Button
3307
+ size="icon"
3308
+ aria-label="Close details panel"
3309
+ onClick={() => setPanelWindow(false)}
3310
+ >
3311
+ <Icon name="x" />
3312
+ </Button>
3313
+ </div>
3314
+ <div className="min-h-0 flex-1 overflow-y-auto">{panel}</div>
3315
+ </div>
3316
+ )}
3257
3317
  {current && (
3258
3318
  <TabsProvider value={tabs.value}>
3259
3319
  <div className="pointer-events-none absolute inset-0">
@@ -3265,8 +3325,9 @@ function Sessions({
3265
3325
  </div>
3266
3326
  )}
3267
3327
  </LineageContext.Provider>
3268
- </SplitPane>
3269
- </SplitView>
3328
+ }
3329
+ aside={aside}
3330
+ />
3270
3331
  <SnoozeDialog
3271
3332
  open={!!customFor}
3272
3333
  onOpenChange={(open) => {
@@ -3276,6 +3337,49 @@ function Sessions({
3276
3337
  onSnooze={(until) => customFor && chooseSnooze(customFor, until)}
3277
3338
  />
3278
3339
  <CleanupDialog offer={cleanup} onClose={() => setCleanup(undefined)} />
3340
+ <Dialog
3341
+ open={!!renaming}
3342
+ onOpenChange={(open) => {
3343
+ if (!open) setRenaming(undefined);
3344
+ }}
3345
+ >
3346
+ <DialogContent>
3347
+ <form
3348
+ onSubmit={(event) => {
3349
+ event.preventDefault();
3350
+ rename();
3351
+ }}
3352
+ >
3353
+ <DialogHeader>
3354
+ <DialogTitle>Rename the session</DialogTitle>
3355
+ </DialogHeader>
3356
+ <DialogBody className="pb-3">
3357
+ <Input
3358
+ aria-label="Session title"
3359
+ autoFocus
3360
+ value={renaming?.title ?? ''}
3361
+ onFocus={(event) => event.currentTarget.select()}
3362
+ // An input method's Enter ends its composition, never submits (#90).
3363
+ onKeyDown={(event) => {
3364
+ if (event.key === 'Enter' && isComposing(event)) event.preventDefault();
3365
+ }}
3366
+ onChange={(event) => {
3367
+ const title = event.currentTarget.value;
3368
+ setRenaming((was) => was && { ...was, title });
3369
+ }}
3370
+ />
3371
+ </DialogBody>
3372
+ <DialogFooter className="justify-end gap-2">
3373
+ <Button type="button" onClick={() => setRenaming(undefined)}>
3374
+ Cancel
3375
+ </Button>
3376
+ <Button type="submit" variant="primary" disabled={!renaming?.title.trim()}>
3377
+ Rename
3378
+ </Button>
3379
+ </DialogFooter>
3380
+ </form>
3381
+ </DialogContent>
3382
+ </Dialog>
3279
3383
  <Dialog
3280
3384
  open={!!pinAsk}
3281
3385
  onOpenChange={(open) => {
@@ -3434,7 +3538,7 @@ export function apply(ctx: Context) {
3434
3538
  off?.();
3435
3539
  };
3436
3540
  });
3437
- // Declares `sessions.tab` (./tabs.tsx), a list other plugins fill, and `views.component` (research-036 P2), which
3541
+ // Declares `sessions.tab` (./tabs.tsx) and `sessions.details` (./details.tsx), lists other plugins fill, and `views.component` (research-036 P2), which
3438
3542
  // other plugins fill too: each entry gets the component a view calls (`{ component, props, node }`), is keyed by its
3439
3543
  // plugin key, and draws all of that plugin's components by `component`. Not in the shell's slot map, so typed here.
3440
3544
  type ScreenProps = {
@@ -3443,6 +3547,7 @@ export function apply(ctx: Context) {
3443
3547
  item?: string;
3444
3548
  focused?: boolean;
3445
3549
  renderSlot: RenderTabs;
3550
+ setActions?: (actions: readonly ScreenAction[]) => void;
3446
3551
  };
3447
3552
  // oxlint-disable-next-line bridge/no-new-unchecked-cast -- typing: slots.register's overloads do not name this screen's children
3448
3553
  const slots = ctx.slots as unknown as {
@@ -3452,6 +3557,7 @@ export function apply(ctx: Context) {
3452
3557
  key: string;
3453
3558
  children: {
3454
3559
  'sessions.tab': { kind: 'list'; scope: 'root' };
3560
+ 'sessions.details': { kind: 'list'; scope: 'root' };
3455
3561
  'views.component': { kind: 'keyed'; scope: 'root' };
3456
3562
  };
3457
3563
  },
@@ -3464,10 +3570,12 @@ export function apply(ctx: Context) {
3464
3570
  key: name,
3465
3571
  children: {
3466
3572
  'sessions.tab': { kind: 'list', scope: 'root' },
3573
+ // The details panel's git rows (the `git` plugin's, bridge-plugins#256).
3574
+ 'sessions.details': { kind: 'list', scope: 'root' },
3467
3575
  'views.component': { kind: 'keyed', scope: 'root' },
3468
3576
  },
3469
3577
  },
3470
- ({ node, screen, item, focused, renderSlot }) => (
3578
+ ({ node, screen, item, focused, renderSlot, setActions }) => (
3471
3579
  <Sessions
3472
3580
  ctx={ctx}
3473
3581
  node={node}
@@ -3475,13 +3583,14 @@ export function apply(ctx: Context) {
3475
3583
  item={item}
3476
3584
  focused={focused}
3477
3585
  renderSlot={renderSlot}
3586
+ setActions={setActions}
3478
3587
  />
3479
3588
  ),
3480
3589
  );
3481
3590
  // The phone's variant (research-020 D5), drawn by the shell in the place of `screen` (./mobile.tsx).
3482
3591
  ctx.slots.register(
3483
3592
  { name: 'mobileScreen', key: name },
3484
- ({ node, item, readOnly, setActions, setChrome }) => (
3593
+ ({ node, item, readOnly, setActions, setChrome, renderFactorySlot }) => (
3485
3594
  <MobileSessions
3486
3595
  ctx={ctx}
3487
3596
  node={node}
@@ -3489,6 +3598,8 @@ export function apply(ctx: Context) {
3489
3598
  readOnly={readOnly}
3490
3599
  setActions={setActions}
3491
3600
  setChrome={setChrome}
3601
+ // The renderer's factory slots, named at run time (`git.session-details`).
3602
+ renderFactorySlot={renderFactorySlot as React.ComponentProps<typeof MobileSessions>['renderFactorySlot']}
3492
3603
  />
3493
3604
  ),
3494
3605
  );