confer-cli 0.8.9

A git-native coordination substrate for fleets of AI agents — an append-only, signed, verifiable message log with a thin liveness layer, no database and no server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
<script lang="ts">
  // The conversation MINIMAP (ui/REDESIGN.md piece 4, item 1 — 2026-07-19,
  // redesign-mockups/04-metathread-minimap.html). Replaces piece 3's
  // "wall of text" sidebar — full snippets + a narrated sentence per
  // topic-crossing — with a glanceable MAP: shape, not content. Per node:
  // an author-colored dot on a topic-colored lane, a kind tag, short-id +
  // time. NO snippet. Full text is one hover away (a small preview card);
  // a topic crossing is ONE labeled divider, not a sentence.
  //
  // INTERACTION MODEL CHANGE from piece 3: click now JUMPS straight to the
  // stream. Piece 3's "peeking != navigating" existed because click was
  // the ONLY way to explore a node without committing — clicking had to be
  // safe-by-default, so it only moved a local pointer, and only Enter (or
  // an explicit button) actually navigated. HOVER now serves that "explore
  // without committing" role (the preview card), so click is free to mean
  // what it looks like it means. Keyboard stays exactly as it was: j/k/h/l
  // move a LOCAL pointer (never navigates), Enter jumps — hover has no
  // keyboard equivalent, so the preview falls back to showing whichever
  // node is currently locally-focused.
  //
  // Reading (full markdown body, refs) is explicitly OUT of scope here —
  // that's the stream's and the focus reader's job (mockup rationale:
  // "the map should point, not re-print"). `messages` is still accepted —
  // buildTrail still needs it to recover real `ts`/parent edges — but this
  // component no longer renders message bodies or CodeRefCard from it.
  import { formatClock, formatIso8601 } from '../format';
  import { buildTrail, childrenOf, KIND_TAG, trailRoot, type TrailNode } from '../thread';
  import { copyToClipboard } from '../clipboard';
  import { paneFocus } from '../paneFocus.svelte';
  import { readState } from '../readState.svelte';
  import CopyIdButton from './CopyIdButton.svelte';
  import CopiedToast from './CopiedToast.svelte';
  import type { Agent, Message as MessageT, ThreadNode } from '../types';

  interface Props {
    thread: ThreadNode[];
    agents: Agent[];
    messages?: MessageT[];
    /** The message this peek session was opened on — the map's initial
     * local focus. Resets local navigation whenever it changes (a
     * genuinely NEW peek session, not a within-panel move). */
    focusedMsgId: string;
    /** Click a node, or Enter on the locally-focused one — the two paths
     * that actually move the stream. */
    onJump?: (msgId: string, topic: string | null) => void;
    /** Esc — close the whole peek (mouse equivalent lives in App.svelte's
     * shared `.ctx-head` close button). */
    onClose?: () => void;
  }

  let { thread, agents, messages = [], focusedMsgId, onJump, onClose }: Props = $props();

  // git-log-style "short sha" — msgIds are 26-char ULIDs, far too wide for
  // this narrow rail. Truncate the DISPLAYED text only; CopyIdButton still
  // copies the full id.
  function shortId(msgId: string): string {
    return msgId.length > 10 ? `${msgId.slice(0, 8)}…` : msgId;
  }

  const agentsById = $derived(new Map(agents.map((a) => [a.id, a])));

  // The real parent/child trail (thread.ts) — recomputed whenever the
  // fetched thread or the message cross-reference changes.
  const trail = $derived(buildTrail(thread, messages));

  // Local focus — moves freely via j/k/h/l, never touching anything
  // outside this panel. Resets to the prop whenever a NEW peek session
  // opens (the prop itself changing means App.svelte loaded a different
  // thread).
  let localFocusedId = $state('');
  $effect(() => {
    localFocusedId = focusedMsgId;
  });

  const focusedNode = $derived(trail.find((n) => n.msgId === localFocusedId) ?? trailRoot(trail));

  // keyboard-architecture-pass BUG FIX (piece 4 item 0, found live: focus
  // the Chat stream, press j/k — after the FIRST move it silently jumped
  // into the meta-thread). Root cause: a stream selection change opens/
  // updates this peek as a SIDE EFFECT of content sync, not the operator
  // asking to navigate here — but this effect used to call real `.focus()`
  // unconditionally on every `focusedNode` change, which paneFocus reads
  // as "the operator moved into thread-peek", stealing the active pane.
  // Fix: only move real focus onto a row when thread-peek is ALREADY the
  // active pane (genuine within-peek navigation, Ctrl+hjkl/click already
  // got it there) — an externally-driven change just updates the `here`
  // highlight, which is entirely `class:here={isHere}` state already.
  let rowEls = $state<Record<string, HTMLElement | null>>({});
  $effect(() => {
    const id = focusedNode?.msgId;
    if (id && paneFocus.focusedId === 'thread-peek') rowEls[id]?.focus();
  });

  function focusNode(msgId: string) {
    if (trail.some((n) => n.msgId === msgId)) localFocusedId = msgId;
  }

  function jump() {
    if (focusedNode) onJump?.(focusedNode.msgId, focusedNode.topic);
  }

  /** The mouse path: focus + jump in one action (see the interaction-model
   * note above — click is a direct "go there", not a two-step). Reads the
   * topic straight off the trail node being clicked rather than the
   * (possibly not-yet-updated) `focusedNode` derived. */
  function jumpTo(msgId: string) {
    focusNode(msgId);
    const node = trail.find((n) => n.msgId === msgId);
    if (node) onJump?.(msgId, node.topic);
  }

  function moveFlat(delta: number) {
    const i = trail.findIndex((n) => n.msgId === localFocusedId);
    const next = trail[i + delta];
    if (next) localFocusedId = next.msgId;
  }

  function stepDeeper() {
    if (!focusedNode) return;
    const kids = childrenOf(trail, focusedNode.msgId);
    if (kids.length > 0) localFocusedId = kids[0]!.msgId;
  }

  function stepBack() {
    if (focusedNode?.parentId) localFocusedId = focusedNode.parentId;
  }

  function handlePeekKeydown(e: KeyboardEvent) {
    switch (e.key) {
      case 'j':
      case 'ArrowDown':
        e.preventDefault();
        moveFlat(1);
        break;
      case 'k':
      case 'ArrowUp':
        e.preventDefault();
        moveFlat(-1);
        break;
      case 'l':
        e.preventDefault();
        stepDeeper();
        break;
      case 'h':
        e.preventDefault();
        stepBack();
        break;
      case 'Enter':
        e.preventDefault();
        jump();
        break;
      case 'y':
        e.preventDefault();
        if (focusedNode) void copyFocusedId(focusedNode.msgId);
        break;
      case 'Escape':
        e.preventDefault();
        onClose?.();
        break;
    }
  }

  // `y` (vim yank) copies the focused node's FULL id — the keyboard path;
  // hovering any row reveals that row's own CopyIdButton for the mouse
  // path (below). Same toast feedback FocusReader's `y` uses, since
  // there's no button under the pointer when this fires from the keyboard.
  let toastText = $state<string | null>(null);
  let toastTimer: ReturnType<typeof setTimeout> | undefined;
  async function copyFocusedId(msgId: string) {
    const ok = await copyToClipboard(msgId);
    if (!ok) return;
    toastText = `copied ${shortId(msgId)}`;
    clearTimeout(toastTimer);
    toastTimer = setTimeout(() => {
      toastText = null;
    }, 1500);
  }

  // keyboard-architecture pass — "thread-peek", registered only while this
  // panel is actually mounted (App.svelte renders it conditionally on the
  // peek being open), so register/unregister just rides the component's
  // own mount/destroy — no separate open/close bookkeeping needed here.
  let mtEl: HTMLDivElement;
  $effect(() => {
    if (!mtEl) return;
    return paneFocus.register({
      id: 'thread-peek',
      label: 'Reference graph',
      el: mtEl,
      getRect: () => mtEl.getBoundingClientRect(),
    });
  });

  // Hover (mouse) or native focus (Tab) previews a DIFFERENT node than the
  // local one without moving it — the map's "explore without committing"
  // affordance. Falls back to the locally-focused node so the preview
  // always shows something relevant, including via keyboard-only j/k/h/l
  // nav (which has no hover equivalent).
  let hoveredId = $state<string | null>(null);
  const previewNode = $derived(trail.find((n) => n.msgId === hoveredId) ?? focusedNode);
  const previewAgent = $derived(previewNode ? agentsById.get(previewNode.from) : undefined);

  // "hide" — declutters the map back to just the header, without touching
  // the peek SESSION itself (appState.selectedMessage stays set; Esc/the
  // shared ✕ close that). Local, resets naturally each time this
  // component mounts fresh.
  let collapsed = $state(false);

  const TOPIC_PALETTE = ['var(--accent)', '#8b8bf0', 'var(--ag-jarvis)', 'var(--ag-orbit)', 'var(--ag-compositor)'];

  function topicOf(node: ThreadNode | TrailNode): string {
    return node.topic ?? '—';
  }

  const uniqueTopics = $derived([...new Set(thread.map(topicOf))]);
  function colorFor(topic: string): string {
    const idx = uniqueTopics.indexOf(topic);
    return TOPIC_PALETTE[idx % TOPIC_PALETTE.length] ?? 'var(--muted)';
  }

  interface Row {
    node: TrailNode;
    laneColor: string;
    /** The topic this row crosses INTO, shown as one labeled divider
     * before the row — null on every row that doesn't cross (including
     * the first, which has nothing before it to cross from). */
    crossing: string | null;
  }

  const rows = $derived.by((): Row[] =>
    trail.map((node, i) => {
      const topic = topicOf(node);
      const prevTopic = i > 0 ? topicOf(trail[i - 1]!) : null;
      return {
        node,
        laneColor: colorFor(topic),
        crossing: i > 0 && topic !== prevTopic ? topic : null,
      };
    })
  );

  const agentCount = $derived(new Set(trail.map((n) => n.from)).size);
  const span = $derived.by(() => {
    if (trail.length < 2) return null;
    const first = trail[0]!;
    const last = trail[trail.length - 1]!;
    if (!first.ts || !last.ts) return null;
    const mins = Math.round((new Date(last.ts).getTime() - new Date(first.ts).getTime()) / 60_000);
    return mins < 60 ? `${mins}m` : `${Math.round(mins / 60)}h`;
  });
</script>

<!-- role="toolbar": the same WAI-ARIA fit piece 2's HubRail used for a
     roving-tabindex set of keyboard-navigable controls (j/k/h/l/Enter/Esc
     over the trail's rows) — see HubRail.svelte's own note on why this
     role rather than an unclaimed listbox/group. -->
<div
  class="mt"
  role="toolbar"
  aria-orientation="vertical"
  tabindex="-1"
  bind:this={mtEl}
  onkeydown={handlePeekKeydown}
  data-testid="thread-peek"
>
  <div class="mh2">
    <div class="mtitle">
      <span aria-hidden="true">⋔</span> Thread map
      <button
        type="button"
        class="collapse"
        onclick={() => (collapsed = !collapsed)}
        aria-expanded={!collapsed}
        data-testid="peek-collapse"
      >
        {collapsed ? '⌃ show' : '⌄ hide'}
      </button>
      <!-- The real mouse-close for the peek SESSION (Esc's mouse
           equivalent — flagged as missing during the keyboard-
           architecture pass's mouse-parity audit). App.svelte's shared
           `.ctx-head` ✕ looked like it should cover this but doesn't: it's
           `display:none` above 1024px (mobile-drawer-only, design/43) and
           `.rail-r` is always visible on desktop — so there was no
           DESKTOP mouse-close at all. This one is always visible, self-
           contained to the peek's own header, and calls the same
           `onClose` Esc already does. -->
      <button type="button" class="close" onclick={() => onClose?.()} aria-label="Close peek" title="Close (Esc)" data-testid="peek-close">
        ✕
      </button>
    </div>
    {#if !collapsed}
      <div class="mstat mono">
        <span>{trail.length} msg{trail.length === 1 ? '' : 's'}{#if span} · {span}{/if}{#if agentCount} · {agentCount} agent{agentCount === 1 ? '' : 's'}{/if}</span>
        {#if uniqueTopics.length > 1}
          {#each uniqueTopics as topic (topic)}
            <span class="tp"><span class="swatch" style="background:{colorFor(topic)}"></span>#{topic}</span>
          {/each}
        {/if}
      </div>
    {/if}
  </div>

  <CopiedToast text={toastText} />

  {#if !collapsed}
    <div class="map" data-testid="peek-map">
      {#each rows as row (row.node.msgId)}
        {@const agent = agentsById.get(row.node.from)}
        {@const isHere = row.node.msgId === focusedNode?.msgId}
        {#if row.crossing}
          <div class="cross"><span class="ln"></span><span class="chip mono">↘ #{row.crossing}</span><span class="ln"></span></div>
        {/if}
        <div
          class="node"
          class:req={row.node.type === 'request'}
          class:done={row.node.type === 'done'}
          class:here={isHere}
          role="button"
          tabindex="0"
          bind:this={rowEls[row.node.msgId]}
          onclick={() => jumpTo(row.node.msgId)}
          onkeydown={(e) => {
            if (e.key === 'Enter' || e.key === ' ') jumpTo(row.node.msgId);
          }}
          onmouseenter={() => (hoveredId = row.node.msgId)}
          onmouseleave={() => (hoveredId = null)}
          onfocus={() => (hoveredId = row.node.msgId)}
          onblur={() => (hoveredId = null)}
          data-testid="peek-node"
        >
          <span class="lane" style="background:{row.laneColor}"></span>
          <span class="spine"><span class="knob" style="background:{agent?.color ?? 'var(--muted)'}"></span></span>
          <span class="who">
            <span class="kd">{KIND_TAG[row.node.type]}</span>
            <span class="nm">{agent?.display ?? row.node.from}</span>
            {#if isHere}<span class="here-tag">here</span>{/if}
            {#if readState.isDetailViewed(row.node.msgId)}
              <!-- Completionist-safe (piece 4, item 2) — same neutral-by-
                   absence glyph as the stream's own Message.svelte. -->
              <span class="detail-viewed" title="Opened in the focus reader" aria-label="Opened in the focus reader">✓</span>
            {/if}
          </span>
          <span class="meta mono">
            <CopyIdButton id={row.node.msgId} class="node-copy-id" />
            <span title={row.node.ts ? formatIso8601(row.node.ts) : undefined}>
              {shortId(row.node.msgId)}{#if row.node.ts} · {formatClock(row.node.ts)}{/if}
            </span>
          </span>
        </div>
      {/each}
    </div>

    <div class="preview" data-testid="peek-preview">
      {#if previewNode}
        <div class="pvh mono">
          ▸ {hoveredId ? 'hover' : 'focused'} — {previewAgent?.display ?? previewNode.from}{#if previewNode.ts} · {formatClock(previewNode.ts)}{/if}
        </div>
        {previewNode.summary}
      {/if}
    </div>

    <div class="mfoot">
      <span><span class="kk">click</span> jump</span>
      <span><span class="kk">j</span><span class="kk">k</span> move</span>
      <span><span class="kk">l</span> deeper · <span class="kk">h</span> back</span>
      <span><span class="kk">y</span> copy id</span>
      <span><span class="kk">esc</span> close</span>
    </div>
  {/if}
</div>

<style>
  .mt {
    text-align: left;
  }

  .mh2 {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }
  .mtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 640;
  }
  .mtitle .collapse {
    margin-left: auto;
    font: 600 10px/1 var(--mono);
    color: var(--muted);
    border: 1px solid var(--border-2);
    background: var(--panel-2);
    border-radius: 5px;
    padding: 3px 6px;
  }
  .mtitle .collapse:hover {
    color: var(--text);
    border-color: var(--accent);
  }
  .mtitle .collapse:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .mtitle .close {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border-2);
    background: var(--panel-2);
    border-radius: 5px;
  }
  .mtitle .close:hover {
    color: var(--text);
    border-color: var(--accent);
  }
  .mtitle .close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .mstat {
    margin-top: 6px;
    font-size: 10.5px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .mstat .tp {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .mstat .swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
  }

  /* ── the map — one line per node, NO snippet ── */
  .map {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .node {
    position: relative;
    display: grid;
    grid-template-columns: 3px 14px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
  }
  .node:hover {
    background: var(--panel-2);
  }
  .node:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }
  .node .lane {
    align-self: stretch;
    border-radius: 2px;
  }
  .node .spine {
    position: relative;
    display: flex;
    justify-content: center;
  }
  .node .knob {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
  }
  .node.req .knob {
    border-radius: 2px;
  }
  .node .who {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .node .kd {
    font: 700 8.5px/1 var(--mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--border-2);
    color: var(--muted);
    flex: 0 0 auto;
  }
  .node.req .kd {
    color: var(--open);
    border-color: color-mix(in srgb, var(--open) 40%, transparent);
  }
  .node.done .kd {
    color: var(--done);
    border-color: color-mix(in srgb, var(--done) 40%, transparent);
  }
  .node .nm {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .node .here-tag {
    font: 700 9px/1 var(--mono);
    color: var(--accent);
    flex: 0 0 auto;
  }
  /* Subtle, positive-only — same convention as Message.svelte's own
     detail-viewed glyph (never a colored/urgent badge; absence is
     neutral, not a debt). */
  .node .detail-viewed {
    font: 700 9px/1 var(--mono);
    color: var(--done);
    opacity: 0.75;
    flex: 0 0 auto;
  }
  .node .meta {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--faint);
    white-space: nowrap;
    justify-self: end;
  }
  /* CopyIdButton defaults to opacity:0 (design/41) — reveal it on the
     row's own hover/focus, same convention as Message's own copy-id. */
  .node:hover :global(.node-copy-id),
  .node:focus-within :global(.node-copy-id) {
    opacity: 1;
  }
  .node.here {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
  }
  .node.here .knob {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  }
  .node.here .nm {
    color: var(--text);
  }

  /* topic-crossing — ONE labeled divider, not a sentence per hop */
  .cross {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 4px 4px;
  }
  .cross .ln {
    height: 1px;
    flex: 1;
    background: var(--border);
  }
  .cross .chip {
    font-size: 9.5px;
    letter-spacing: 0.03em;
    color: var(--muted);
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--border);
  }

  /* ── preview — the text is one hover/focus away, on-demand ── */
  .preview {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
  }
  .preview .pvh {
    font-size: 10px;
    color: var(--faint);
    margin-bottom: 3px;
  }

  /* ── keyboard footer ── */
  .mfoot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font: 500 10px/1 var(--mono);
    color: var(--muted);
  }
  .mfoot .kk {
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 2px;
  }
</style>