heyquilt 0.3.170 → 0.3.171

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.
Files changed (61) hide show
  1. package/RELEASES.md +22 -0
  2. package/bin/quilt.js +16 -9
  3. package/package.json +2 -2
  4. package/src/agent-task-workflow.js +2 -9
  5. package/src/base-pick.js +91 -0
  6. package/src/boxes.js +6 -7
  7. package/src/catchup.js +1 -1
  8. package/src/chat-links.js +1 -3
  9. package/src/connection.js +24 -5
  10. package/src/control.js +27 -20
  11. package/src/duties.js +32 -56
  12. package/src/github-commit.js +1 -1
  13. package/src/held.js +323 -0
  14. package/src/hooks.js +27 -66
  15. package/src/identity.js +1 -1
  16. package/src/inbox.js +5 -4
  17. package/src/key-cli.js +1 -1
  18. package/src/live-merge.js +592 -0
  19. package/src/mcp.js +57 -102
  20. package/src/merge3.js +65 -1
  21. package/src/now-summary.js +4 -6
  22. package/src/pathrules.js +1 -1
  23. package/src/persona.js +1 -1
  24. package/src/presence.js +2 -0
  25. package/src/protocol.js +2 -2
  26. package/src/read-bases.js +123 -0
  27. package/src/relay-ask.js +2 -2
  28. package/src/relay-live-write.js +173 -0
  29. package/src/relay-mcp.js +173 -212
  30. package/src/relay-prune.js +2 -2
  31. package/src/relay-turn-sync.js +146 -142
  32. package/src/runner.js +0 -2
  33. package/src/server.js +253 -375
  34. package/src/session-follow.js +3 -1
  35. package/src/session-quilt.js +2 -21
  36. package/src/session-seam.js +35 -7
  37. package/src/session.js +650 -554
  38. package/src/setup.js +15 -25
  39. package/src/source-live/bring-in.js +5 -5
  40. package/src/source-live/land.js +20 -3
  41. package/src/source-live/live-block.js +391 -51
  42. package/src/status.js +8 -12
  43. package/src/textdiff.js +54 -0
  44. package/src/turn-sync-plan.js +6 -18
  45. package/src/turn-sync.js +28 -21
  46. package/src/ui/agent-guide.js +13 -13
  47. package/src/ui/app.css +19 -40
  48. package/src/ui/boxes.js +8 -16
  49. package/src/ui/common.js +1 -1
  50. package/src/ui/fileview.js +11 -15
  51. package/src/ui/loom-model.js +18 -16
  52. package/src/ui/loom.css +1 -2
  53. package/src/ui/loom.js +6 -6
  54. package/src/ui/rail-model.js +25 -64
  55. package/src/ui/rail.js +48 -60
  56. package/src/ui/seam-model.js +39 -3
  57. package/src/ui/session.js +36 -54
  58. package/src/ui/tree.js +22 -129
  59. package/src/ui-server.js +2 -6
  60. package/src/release-words.js +0 -18
  61. package/src/seam-claims.js +0 -53
@@ -1,8 +1,7 @@
1
- // A read-only view of one shared file, with who's editing it, its claim, and
1
+ // A read-only view of one shared file, with who's editing it, whose unfinished work is boxed on it, and
2
2
  // freshly changed lines highlighted for a few seconds. Its Changes tab lists
3
3
  // every change to the file with its diff (diffview.js).
4
4
  import { esc, bytes, I, loadingNote } from './common.js'
5
- import { claimFolder, claimHolder, claimTitle } from './tree.js'
6
5
  import { historyMarkup, changeCount } from './diffview.js'
7
6
  import { patchesMarkup, blameMarkup, historyCount } from './quiltview.js'
8
7
  import { previewKind, FROM_BYTES, HAS_RAW, textKey, bytesPreviewHtml, prettyAndRawHtml, hydrate } from './preview.js'
@@ -13,7 +12,7 @@ const MAX_LINES = 20000
13
12
  * @param {HTMLElement} el
14
13
  * @param {object} o
15
14
  * @param {object|null} o.file response from /file, or { missing: true }
16
- * @param {object|null} o.meta tree entry ({ edited, claim })
15
+ * @param {object|null} o.meta tree entry ({ edited, box })
17
16
  * @param {string} o.me
18
17
  * @param {string|null} o.prevText previous text, to highlight what changed
19
18
  * @param {'file'|'changes'} [o.tab] which tab is shown
@@ -33,19 +32,16 @@ export function renderFileView (el, { path, file, meta, me, prevText, bannerOnly
33
32
  if (meta && meta.chat) return bannerOnly && scroller && scroller.dataset.tab === 'chat' && scroller.dataset.path === path ? undefined : renderChatFile(el, { path, file, chat: meta.chat, me, href: chatHref, rawHref, keep: scroller && scroller.dataset.path === path ? keep : 0 })
34
33
 
35
34
  const edited = meta && meta.edited
36
- const claim = meta && meta.claim
35
+ const box = meta && meta.box
37
36
  const editedText = edited ? `Edited by ${edited.by === me ? 'you' : esc(edited.by)} ${agoLong(edited.ts)}` : 'Not edited recently'
38
- const claimText = claim
39
- ? `<span class="fv-claim" title="${esc(claimTitle(claim, me))}">${I.lock}Claimed by ${esc(claimHolder(claim, me))}${claimFolder(claim.pattern) !== path ? ` (via <code>${esc(claim.pattern)}</code>)` : ''}${claim.note ? `: ${esc(claim.note)}` : ''}${claim.queue && claim.queue.length ? ` · ${claim.queue.length} waiting` : ''}</span>`
40
- : '<span class="hint">Not claimed</span>'
41
- let action = ''
42
- if (!file || !file.missing) {
43
- if (!claim) action = `<button class="btn sm" data-fv="claim">${I.lock}Claim</button>`
44
- else if (claim.by === me && !(claim.queue || []).length) action = `<button class="btn sm ghost" data-fv="release" data-pattern="${esc(claim.pattern)}">Release</button>`
45
- }
37
+ // Someone's unfinished work on it (a box): shown, never a hold. Anyone may still edit it.
38
+ const mine = box && (box.by === me || box.of === me)
39
+ const boxText = box
40
+ ? `<span class="fv-box" title="${esc(mine ? 'Your unfinished work: in your folder only, until you commit it' : `${box.by}'s unfinished work: not in your folder until they commit it. Editing it opens the box.`)}">${I.box}${mine ? 'Your unfinished work' : `${esc(box.by)}'s unfinished work`}</span>`
41
+ : ''
46
42
 
47
- const banner = `<div class="fv-banner"><span class="fv-path mono">${esc(path)}</span><span class="fv-edited">${editedText}</span>${claimText}<span class="spacer"></span>${action}<span class="tag">Read-only</span></div>`
48
- // Refresh who-edited/claim info without re-rendering (and un-highlighting) the code.
43
+ const banner = `<div class="fv-banner"><span class="fv-path mono">${esc(path)}</span><span class="fv-edited">${editedText}</span>${boxText}<span class="spacer"></span><span class="tag">Read-only</span></div>`
44
+ // Refresh who-edited/box info without re-rendering (and un-highlighting) the code.
49
45
  const existing = el.querySelector('.fv-banner')
50
46
  if (bannerOnly && existing && scroller && scroller.dataset.path === path) { existing.outerHTML = banner; return }
51
47
 
@@ -132,7 +128,7 @@ const IMAGE = /\.(png|jpe?g|gif|webp)$/i
132
128
 
133
129
  /**
134
130
  * A file sent in chat, from the chat files folder: who sent it, a download, and the file itself
135
- * (text, or a picture). No claim and no changes: it is this person's copy, never synced.
131
+ * (text, or a picture). No changes: it is this person's copy, never synced.
136
132
  */
137
133
  function renderChatFile (el, { path, file, chat, me, href, rawHref, keep }) {
138
134
  const who = (n) => n === me ? 'you' : esc(n)
@@ -10,6 +10,7 @@ import { conversations } from './feed-convs.js'
10
10
  export const GAP_MS = 20 * 60 * 1000 // a pause this long between two things gets a "later" divider
11
11
  export const TURN_GAP_MS = 10 * 60 * 1000 // a conversation quiet this long starts a new turn without a prompt
12
12
  export const COLLIDE_MS = 15 * 60 * 1000 // two lanes on one file this close together: shown as a collision
13
+ export const RECENT_EDIT_MS = 15 * 60 * 1000 // a lane head lists the files its person wrote this recently
13
14
  export const MAX_ITEMS = 400 // newest first; older ones drop off the top
14
15
  export const CONV_SLOTS = 8 // a lane's conversations each get a piece of the mark: eight, the corner last
15
16
  export const CONV_QUIET_MS = 30 * 60 * 1000 // a conversation with nothing for this long shows as quiet
@@ -279,7 +280,7 @@ function dayOf (ts) {
279
280
  * lanes of their own. `owners`: AI session name -> its person (chat.js aiOwners). Returns the
280
281
  * buildLoom inputs with those names as their person, and `personOf` (empty: no AI-session lanes).
281
282
  */
282
- export function foldAiLanes ({ people = [], owners = new Map(), feeds = new Map(), messages = [], tasks = [], claims = [] } = {}) {
283
+ export function foldAiLanes ({ people = [], owners = new Map(), feeds = new Map(), messages = [], tasks = [], edits = [] } = {}) {
283
284
  const lane = (name) => owners.get(name) || name
284
285
  const personOf = new Map()
285
286
  // An AI session's own entry (an older app lists them) is its person, who has a lane already.
@@ -297,7 +298,7 @@ export function foldAiLanes ({ people = [], owners = new Map(), feeds = new Map(
297
298
  feeds: folded,
298
299
  messages: (messages || []).map((m) => m && (owners.has(m.by) || owners.has(m.to)) ? { ...m, by: lane(m.by), ...(m.to ? { to: lane(m.to) } : {}) } : m),
299
300
  tasks: (tasks || []).map((t) => t ? { ...by(t), comments: (t.comments || []).map(by) } : t),
300
- claims: (claims || []).map((c) => c ? by(c) : c),
301
+ edits: (edits || []).map((x) => x ? by(x) : x),
301
302
  personOf
302
303
  }
303
304
  }
@@ -319,8 +320,10 @@ export function aiWorking (p) {
319
320
  /**
320
321
  * Everything the Loom shows. `people`: [{ name, color, isMe, kind, tool, online,
321
322
  * agent, optional, focus, focusAt }] in lane order; `feeds`: Map name -> feed entries; `messages`: the
322
- * room's chat (already validated); `tasks`: the board, with comments; `claims`:
323
- * the session's claims. `show`: { chat, tasks } (both on unless false);
323
+ * room's chat (already validated); `tasks`: the board, with comments; `edits`: who wrote each
324
+ * file last ([{ path, by, ts }], the file tree's `edited`): a lane's `recent` lists the files its
325
+ * person wrote in the last RECENT_EDIT_MS, and each file in `files` gets `last`. Presence only:
326
+ * nobody holds files. `show`: { chat, tasks } (both on unless false);
324
327
  * `hidden`: names whose lanes are off; `merged`: one column for everyone (a
325
328
  * narrow window). `width`: the room for lanes, in px (0: as many as there are);
326
329
  * `pinned`, `opened`: see foldPlan; `convNames`: { conv id: name } the person gave conversations
@@ -329,7 +332,7 @@ export function aiWorking (p) {
329
332
  * `col` its column; things in a folded lane aren't cards but `knots`, one per
330
333
  * column and row.
331
334
  */
332
- export function buildLoom ({ people = [], feeds = new Map(), messages = [], tasks = [], claims = [], show = {}, hidden = [], merged = false, width = 0, pinned = [], opened = [], convNames = {}, now = Date.now() } = {}) {
335
+ export function buildLoom ({ people = [], feeds = new Map(), messages = [], tasks = [], edits = [], show = {}, hidden = [], merged = false, width = 0, pinned = [], opened = [], convNames = {}, now = Date.now() } = {}) {
333
336
  const off = new Set(hidden)
334
337
  // Someone `optional` (an AI session working through a person's app) gets a lane only with something in it.
335
338
  const active = new Set([...feeds].filter(([, list]) => Array.isArray(list) && list.length).map(([name]) => name))
@@ -353,8 +356,7 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
353
356
  since: sharing && p.focusAt > 0 ? p.focusAt : 0,
354
357
  focus: sharing && p.focusAt > 0 ? String(p.focus || '') : '',
355
358
  pinned: pinned.includes(p.name),
356
- holds: [],
357
- waiting: 0,
359
+ recent: [],
358
360
  lastTs: 0,
359
361
  fold: 'open',
360
362
  col: 0
@@ -364,11 +366,11 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
364
366
  const names = people.map((p) => p && p.name).filter(Boolean)
365
367
  const agentNames = people.filter((p) => p && p.kind === 'agent').map((p) => p.name)
366
368
 
367
- for (const c of claims || []) {
368
- const i = index.get(c && c.by)
369
- if (i === undefined) continue
370
- lanes[i].holds.push(c.pattern)
371
- lanes[i].waiting += Array.isArray(c.queue) ? c.queue.length : 0
369
+ // Who wrote what lately: presence, never a hold (no-holds, 2026-11-13).
370
+ for (const x of edits || []) {
371
+ const i = index.get(x && x.by)
372
+ if (i === undefined || !x.path || !(now - (Number(x.ts) || 0) < RECENT_EDIT_MS)) continue
373
+ if (!lanes[i].recent.includes(x.path)) lanes[i].recent.push(x.path)
372
374
  }
373
375
 
374
376
  let items = []
@@ -492,16 +494,16 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
492
494
  }
493
495
 
494
496
  // Files: who touched each, in order, and the stitches between lanes.
495
- const files = new Map() // path -> { touches: [{ id, lane, ts }], claim }
497
+ const files = new Map() // path -> { touches: [{ id, lane, ts }], last: { by, ts } | null }
496
498
  for (const it of items) {
497
499
  if (it.type !== 'turn') continue
498
500
  for (const p of it.edits) {
499
- if (!files.has(p)) files.set(p, { touches: [], claim: null })
501
+ if (!files.has(p)) files.set(p, { touches: [], last: null })
500
502
  files.get(p).touches.push({ id: it.id, lane: it.lane, ts: it.ts, end: it.end })
501
503
  }
502
504
  }
503
- for (const c of claims || []) {
504
- if (c && files.has(c.pattern)) files.get(c.pattern).claim = { by: c.by, waiting: Array.isArray(c.queue) ? c.queue.map((r) => r.by) : [] }
505
+ for (const x of edits || []) {
506
+ if (x && files.has(x.path)) files.get(x.path).last = { by: x.by, ts: Number(x.ts) || 0 }
505
507
  }
506
508
  const stitches = []
507
509
  for (const [path, f] of files) {
package/src/ui/loom.css CHANGED
@@ -43,8 +43,7 @@
43
43
  .lh-st.live .pulse { width: 7px; height: 7px; }
44
44
  .lh-st.paused { color: var(--warn); }
45
45
  .lh-st.off { color: var(--faint); }
46
- .lh-holds { color: var(--edit); border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
47
- .lh-holds:hover, .lh-holds:focus-visible, .lh-holds[aria-expanded="true"] { text-decoration: underline; text-underline-offset: 3px; outline: none; }
46
+ .lh-recent { color: var(--edit); cursor: default; }
48
47
  .lh-since { font-variant-numeric: tabular-nums; cursor: default; }
49
48
  /* A narrow lane keeps the name: the stitching time stands in for "working" or "idle" (the pulse still says which). */
50
49
  .loom-head:not(.strip):not(.crowd) { container-type: inline-size; }
package/src/ui/loom.js CHANGED
@@ -201,8 +201,9 @@ function headHtml (l, color) {
201
201
  const status = !l.sharing ? '<span class="lh-st paused">paused</span>'
202
202
  : l.working ? '<span class="lh-st live"><span class="pulse"></span><span class="lh-word">working</span></span>'
203
203
  : l.online ? '<span class="lh-st"><span class="lh-word">idle</span></span>' : '<span class="lh-st off">offline</span>'
204
- const holds = l.holds.length
205
- ? `<button type="button" class="lh-holds" data-loom-holds="${esc(l.name)}" title="${esc(`Holds ${l.holds.join(', ')}. Click for how long, why and who waits`)}">holds ${l.holds.length}${l.waiting ? ` · ${l.waiting} waiting` : ''}</button>`
204
+ // The files they wrote lately: presence only, nobody holds files.
205
+ const recent = l.recent.length
206
+ ? `<span class="lh-recent" title="${esc(`Changed lately: ${l.recent.join(', ')}`)}">${l.recent.length} file${l.recent.length === 1 ? '' : 's'} lately</span>`
206
207
  : ''
207
208
  return `<div class="loom-head" style="--c:${esc(color)}">
208
209
  <button class="lh-who" data-loom-person="${esc(l.name)}" title="${esc(l.isMe ? 'Your AI chat' : `${l.name}'s AI chat`)}">
@@ -211,7 +212,7 @@ function headHtml (l, color) {
211
212
  ${l.tool ? `<span class="lh-tool" title="${esc(toolLabel(l.tool))}">${toolLogo(l.tool)}</span>` : ''}
212
213
  ${l.kind === 'agent' ? '<span class="tag">AI</span>' : ''}
213
214
  </button>
214
- <span class="lh-meta">${status}${sinceHtml(l)}${holds}</span>
215
+ <span class="lh-meta">${status}${sinceHtml(l)}${recent}</span>
215
216
  <button class="lh-pin${l.pinned ? ' on' : ''}" data-loom-pin="${esc(l.name)}" title="${l.pinned ? 'Unpin: let this lane fold when there\'s no room' : 'Pin: keep this lane open'}" aria-pressed="${l.pinned}" aria-label="${esc(`${l.pinned ? 'Unpin' : 'Pin'} ${l.name}'s lane`)}">${PIN}</button>
216
217
  <button class="lh-hide" data-loom-hide="${esc(l.name)}" title="Hide this lane" aria-label="Hide ${esc(l.name)}'s lane">${I.x}</button>
217
218
  ${convsHtml(l)}
@@ -603,10 +604,10 @@ function tipFor (path) {
603
604
  if (!f) return `<b>${esc(path)}</b>`
604
605
  const touches = f.touches.map((t) => `${t.lane} ${clock(t.ts)}`)
605
606
  const lanes = new Set(f.touches.map((t) => t.lane))
606
- const claim = f.claim ? `<div>Held by ${esc(f.claim.by)}${f.claim.waiting.length ? ` · waiting: ${esc(f.claim.waiting.join(', '))}` : ''}</div>` : ''
607
+ const last = f.last && f.last.by ? `<div>Last written by ${esc(f.last.by)} ${clock(f.last.ts)}</div>` : ''
607
608
  return `<b>${esc(path)}</b>
608
609
  <div>Changed by ${esc(touches.slice(-5).join(', '))}${touches.length > 5 ? ` and ${touches.length - 5} more` : ''}</div>
609
- ${lanes.size > 1 ? `<div class="warn">${lanes.size} people's AIs worked on this file</div>` : ''}${claim}
610
+ ${lanes.size > 1 ? `<div class="warn">${lanes.size} people's AIs worked on this file</div>` : ''}${last}
610
611
  <div class="hint">Click to open it</div>`
611
612
  }
612
613
 
@@ -690,7 +691,6 @@ function bind (el) {
690
691
  if (crowdOpen && crowd && !crowd.contains(t)) { crowdOpen = false; crowd.classList.remove('open'); crowd.querySelector('.lcw-list').hidden = true }
691
692
  if ((b = pick('[data-loom-open]'))) { crowdOpen = false; return act('open-lane', b.dataset.loomOpen) }
692
693
  if ((b = pick('[data-loom-pin]'))) return act('pin', b.dataset.loomPin)
693
- if ((b = pick('[data-loom-holds]'))) return act('holds', { name: b.dataset.loomHolds, anchor: b })
694
694
  if ((b = pick('[data-loom-person]'))) return act('person', b.dataset.loomPerson)
695
695
  if ((b = pick('[data-loom-follow]'))) {
696
696
  const same = convFocus && convFocus.lane === b.dataset.lane && convFocus.conv === b.dataset.conv
@@ -1,79 +1,40 @@
1
- // The Files rail (rail.js): the folded Files pane as signals instead of names. Who holds
2
- // what, since when, why, who waits for it and when it frees up on its own.
1
+ // The folded Boxes pane's rail (rail.js): whose unfinished work is boxed, as signals instead of
2
+ // names. Nobody holds files (no-holds, 2026-11-13): a box is someone's unfinished work on one file,
3
+ // kept out of other folders until it is committed; anyone may still edit it (that opens the box).
3
4
  // Pure, so tests can run it without a page.
4
5
  import { stitchTime } from './loom-model.js'
5
6
 
6
- /** A claim whose holder does nothing in the session this long is let go of (the relay's claimIdleMs). */
7
- export const CLAIM_IDLE_MS = 20 * 60 * 1000
8
-
9
- const isFolder = (pattern) => /\/(\*\*)?$/.test(String(pattern))
10
- const claimFolder = (pattern) => String(pattern).replace(/\/\*\*$/, '').replace(/\/+$/, '') // as tree.js
11
-
12
7
  /**
13
- * Everything the rail and its lock list show. `claims`: the session's ({ pattern, by, ts, note,
14
- * active, activeAt, queue }); `me`: your name;
15
- * `owners`: AI session name -> its person (chat.js aiOwners): a person's AI sessions' claims are
16
- * that person's; `aiName` is unused (kept for callers); `files`: the session's paths (to count a
17
- * folder's); `focusOf`: name -> what they
18
- * said they're doing (a lock's why when it has no note); `kindOf`: name -> 'agent' for an AI agent.
19
- * Returns { locks, holders, waiting, mine }, locks oldest first.
8
+ * Everything the rail and its box list show. `boxes`: the session's ({ pattern, by, of?, ts, note,
9
+ * active }); `me`: your name; `owners`: AI session name -> its person (chat.js aiOwners): a person's
10
+ * AI sessions' boxes are that person's; `focusOf`: name -> what they said they're doing (a box's why
11
+ * when it has no note); `kindOf`: name -> 'agent' for an AI agent. Returns { items, people, mine },
12
+ * items oldest first.
20
13
  */
21
- export function railModel ({ claims = [], me = '', owners = new Map(), aiName = (p) => `${p}'s AI`, files = [], focusOf = () => '', kindOf = () => '', now = Date.now(), idleMs = CLAIM_IDLE_MS } = {}) {
22
- const fileSet = new Set(files)
23
- // A person's AI sessions hold their claims as that person ("Daniel · Claude Code 3" is Daniel).
24
- const holderOf = (by) => owners.get(by) || by
25
- const locks = (claims || []).filter((c) => c && c.pattern && c.by).map((c) => {
26
- const bare = claimFolder(c.pattern)
27
- // "src/auth", "src/auth/" and "src/auth/**" all claim the folder (tree.js claimFolder).
28
- const folder = isFolder(c.pattern) || (!fileSet.has(bare) && files.some((f) => f.startsWith(`${bare}/`)))
29
- const path = folder ? bare : String(c.pattern)
30
- const queue = Array.isArray(c.queue) ? c.queue : []
31
- const last = typeof c.activeAt === 'number' ? c.activeAt : c.ts || now
14
+ export function railModel ({ boxes = [], me = '', owners = new Map(), focusOf = () => '', kindOf = () => '', now = Date.now() } = {}) {
15
+ // A person's AI sessions box as that person ("Daniel · Claude Code 3" is Daniel).
16
+ const personOf = (c) => owners.get(c.by) || c.of || c.by
17
+ const items = (boxes || []).filter((c) => c && c.pattern && c.by).map((c) => {
18
+ const person = personOf(c)
32
19
  return {
33
20
  pattern: c.pattern,
34
- path,
35
- folder,
36
- count: folder ? files.filter((f) => f.startsWith(`${path}/`)).length : 1,
37
- by: holderOf(c.by),
38
- holder: holderOf(c.by),
39
- mine: holderOf(c.by) === me,
40
- ours: holderOf(c.by) === me, // yours (your AI sessions are you)
21
+ path: String(c.pattern),
22
+ by: person,
23
+ mine: person === me,
41
24
  away: c.active === false,
42
25
  since: c.ts || now,
43
- why: c.note || focusOf(c.by) || '',
44
- queue: queue.map((r) => ({ by: holderOf(r.by), title: r.title || '' })),
45
- // Unfinished work not committed yet (a box) isn't let go when idle: it stays until it is committed or unpacked.
46
- ...(c.box ? { box: true } : {}),
47
- freesAt: c.box ? null : last + idleMs
26
+ why: c.note && c.note !== 'editing' ? c.note.replace(/^editing: /, '') : focusOf(c.by) || ''
48
27
  }
49
28
  }).sort((a, b) => a.since - b.since)
50
29
 
51
- const holders = []
52
- for (const l of locks) {
53
- let h = holders.find((x) => x.name === l.holder)
54
- if (!h) holders.push(h = { name: l.holder, by: l.holder, ours: l.ours, ai: kindOf(l.holder) === 'agent', locks: 0, waiting: 0 })
55
- h.locks++
56
- h.waiting += l.queue.length
57
- }
58
- return {
59
- locks,
60
- holders,
61
- waiting: locks.filter((l) => l.mine && l.queue.length), // someone waits for a file you hold: yours to act on
62
- mine: locks.filter((l) => l.ours).length
30
+ const people = []
31
+ for (const it of items) {
32
+ let p = people.find((x) => x.name === it.by)
33
+ if (!p) people.push(p = { name: it.by, mine: it.mine, ai: kindOf(it.by) === 'agent', count: 0 })
34
+ p.count++
63
35
  }
36
+ return { items, people, mine: items.filter((it) => it.mine).length }
64
37
  }
65
38
 
66
- /** "25m", how long a lock has been held. */
67
- export const heldFor = (l, now = Date.now()) => stitchTime(l.since, now)
68
-
69
- /**
70
- * When a lock frees up if its holder stays idle: "frees in 12m if idle", or, with someone
71
- * waiting, "goes to Sriram in 12m if idle"; "frees any moment" once that time has come.
72
- */
73
- export function freesText (l, now = Date.now()) {
74
- const next = l.queue[0]
75
- if (l.box) return next ? `goes to ${next.by} once committed` : 'held until committed'
76
- const left = l.freesAt - now
77
- if (left <= 30 * 1000) return next ? `goes to ${next.by} any moment` : 'frees any moment'
78
- return `${next ? `goes to ${next.by}` : 'frees'} in ${stitchTime(now - left, now)} if idle`
79
- }
39
+ /** "25m", how long a box has had unfinished work in it. */
40
+ export const boxedFor = (it, now = Date.now()) => stitchTime(it.since, now)
package/src/ui/rail.js CHANGED
@@ -1,75 +1,63 @@
1
- // The Files rail: the folded Files pane (session.js) as signals instead of names. An hourglass
2
- // when someone waits for a file you hold (it pulses: it's yours to act on), the lock with how
3
- // many files are locked, then one avatar per holder with their count. Each opens the lock list
4
- // beside it (rail-model.js): who holds what, for how long, why, who waits for it, and when it
5
- // frees up on its own. The Loom's "holds" opens the same list for one lane.
1
+ // The Boxes rail: the folded Boxes pane (session.js) as signals instead of names. The box mark with
2
+ // how many files hold unfinished work, then one avatar per person with their count. Each opens the
3
+ // box list beside it (rail-model.js): whose work, on which file, for how long and why. Nobody holds
4
+ // files: a box never stops anyone editing (editing it opens it).
6
5
  import { esc, I, avatar, basename } from './common.js'
7
- import { heldFor, freesText, CLAIM_IDLE_MS } from './rail-model.js'
6
+ import { boxedFor } from './rail-model.js'
8
7
 
9
- export const HOURGLASS = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2h12M6 22h12"/><path d="M7 2v4a5 5 0 0 0 10 0V2"/><path d="M7 22v-4a5 5 0 0 1 10 0v4"/></svg>'
10
- const AVATARS = 5 // holders shown on the rail; past that, a "+N" that opens everyone's
8
+ const AVATARS = 5 // people shown on the rail; past that, a "+N" that opens everyone's
11
9
 
12
- let pop = null // the lock list, once made
10
+ let pop = null // the box list, once made
13
11
  let open = null // { filter, anchor, pinned }: what the open list shows and where
14
12
  let last = null // { model, opts }: the latest model, so an open list follows it
15
13
  let hoverTimer = 0
16
14
  let leaveTimer = 0
17
15
 
18
16
  const who = (name, me) => name === me ? 'You' : name
19
- const whose = (name, me) => name === me ? 'Your locks' : `${name}'s locks`
17
+ const whose = (name, me) => name === me ? 'Your unfinished work' : `${name}'s unfinished work`
20
18
 
21
19
  /** The rail's buttons for model `m` (railModel). */
22
20
  export function railHtml (m, { me, colorOf }) {
23
21
  const out = []
24
- if (m.waiting.length) {
25
- const n = m.waiting.reduce((s, l) => s + l.queue.length, 0)
26
- const what = `${n} waiting for ${m.waiting.length === 1 ? `${basename(m.waiting[0].path)}, which you hold` : `${m.waiting.length} files you hold`}`
27
- out.push(`<button type="button" class="rail-sig waiting" data-rail="waiting" title="${esc(what)}" aria-label="${esc(what)}">${HOURGLASS}<span class="rail-n">${n}</span></button>`)
28
- }
29
- const total = m.locks.length
30
- const lockWhat = total ? `${total} locked${m.mine ? `, ${m.mine} by you or your AI` : ''}. Who holds what, and for how long` : 'Nothing is locked'
31
- out.push(`<button type="button" class="rail-sig lock${m.mine ? ' mine' : ''}${total ? '' : ' none'}" data-rail="all" title="${esc(lockWhat)}" aria-label="${esc(lockWhat)}">${I.lock}${total ? `<span class="rail-n">${total}</span>` : ''}</button>`)
32
- if (m.holders.length) {
22
+ const total = m.items.length
23
+ const what = total ? `${total} file${total === 1 ? '' : 's'} with unfinished work${m.mine ? `, ${m.mine} yours` : ''}` : 'No unfinished work in boxes'
24
+ out.push(`<button type="button" class="rail-sig box${m.mine ? ' mine' : ''}${total ? '' : ' none'}" data-rail="all" title="${esc(what)}" aria-label="${esc(what)}">${I.box}${total ? `<span class="rail-n">${total}</span>` : ''}</button>`)
25
+ if (m.people.length) {
33
26
  out.push('<span class="rail-sep" aria-hidden="true"></span>')
34
- const shown = m.holders.length > AVATARS + 1 ? m.holders.slice(0, AVATARS) : m.holders
35
- for (const h of shown) {
36
- const what = `${who(h.name, me)}: ${h.locks} locked${h.waiting ? `, ${h.waiting} waiting` : ''}`
37
- out.push(`<button type="button" class="rail-who${h.ai ? ' ai' : ''}" data-rail="who" data-name="${esc(h.name)}" title="${esc(what)}" aria-label="${esc(what)}">${avatar(h.name, colorOf(h.by))}<span class="rail-n">${h.locks}</span>${h.waiting ? '<span class="rail-q" aria-hidden="true"></span>' : ''}</button>`)
27
+ const shown = m.people.length > AVATARS + 1 ? m.people.slice(0, AVATARS) : m.people
28
+ for (const p of shown) {
29
+ const say = `${who(p.name, me)}: ${p.count} file${p.count === 1 ? '' : 's'} with unfinished work`
30
+ out.push(`<button type="button" class="rail-who${p.ai ? ' ai' : ''}" data-rail="who" data-name="${esc(p.name)}" title="${esc(say)}" aria-label="${esc(say)}">${avatar(p.name, colorOf(p.name))}<span class="rail-n">${p.count}</span></button>`)
38
31
  }
39
- if (shown.length < m.holders.length) out.push(`<button type="button" class="rail-more" data-rail="all" title="Everyone's locks">+${m.holders.length - shown.length}</button>`)
32
+ if (shown.length < m.people.length) out.push(`<button type="button" class="rail-more" data-rail="all" title="Everyone's unfinished work">+${m.people.length - shown.length}</button>`)
40
33
  }
41
34
  return out.join('')
42
35
  }
43
36
 
44
- /** The lock list for `filter`: 'all', 'waiting', or { who: holder }. */
45
- export function locksHtml (m, filter, { me, colorOf, now = Date.now() }) {
37
+ /** The box list for `filter`: 'all', or { who: person }. */
38
+ export function boxListHtml (m, filter, { me, colorOf, now = Date.now() }) {
46
39
  const byWho = filter && typeof filter === 'object' ? filter.who : null
47
- const rows = filter === 'waiting' ? m.waiting : byWho ? m.locks.filter((l) => l.holder === byWho) : m.locks
48
- const title = filter === 'waiting' ? 'Waiting on you' : byWho ? whose(byWho, me) : 'Locked files'
49
- const row = (l) => {
50
- const dir = l.folder ? '' : l.path.includes('/') ? l.path.slice(0, l.path.lastIndexOf('/') + 1) : ''
51
- const name = l.folder ? `${l.path}/` : basename(l.path)
52
- const queue = l.queue.length
53
- ? `<div class="lk-q">${HOURGLASS}<span>${l.queue.length} waiting: ${esc(l.queue.map((r) => who(r.by, me)).join(', '))} · ${esc(freesText(l, now))}</span></div>`
54
- : `<div class="lk-free">${esc(freesText(l, now))}</div>`
55
- return `<li class="lk-row${l.ours ? ' ours' : ''}">
56
- <button type="button" class="lk-main"${l.folder ? '' : ` data-lk-file="${esc(l.path)}"`} title="${esc(l.folder ? `${l.path}/ and everything in it` : `Open ${l.path}`)}"${l.folder ? ' disabled' : ''}>
57
- <span class="lk-dot" style="--c:${esc(colorOf(l.by))}"></span>
58
- <span class="lk-name">${esc(name)}${l.folder ? `<span class="lk-count">${l.count} file${l.count === 1 ? '' : 's'}</span>` : ''}</span>
59
- <span class="lk-held" title="Held since ${esc(new Date(l.since).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }))}">${esc(heldFor(l, now))}</span>
40
+ const rows = byWho ? m.items.filter((it) => it.by === byWho) : m.items
41
+ const title = byWho ? whose(byWho, me) : 'Unfinished work'
42
+ const row = (it) => {
43
+ const dir = it.path.includes('/') ? it.path.slice(0, it.path.lastIndexOf('/') + 1) : ''
44
+ return `<li class="lk-row${it.mine ? ' ours' : ''}">
45
+ <button type="button" class="lk-main" data-lk-file="${esc(it.path)}" title="${esc(`Open ${it.path}`)}">
46
+ <span class="lk-dot" style="--c:${esc(colorOf(it.by))}"></span>
47
+ <span class="lk-name">${esc(basename(it.path))}</span>
48
+ <span class="lk-held" title="Boxed since ${esc(new Date(it.since).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }))}">${esc(boxedFor(it, now))}</span>
60
49
  </button>
61
50
  ${dir ? `<div class="lk-dir">${esc(dir)}</div>` : ''}
62
- <div class="lk-who"><b>${esc(who(l.holder, me))}</b>${l.holder !== l.by ? ` <i>${esc(l.by)}</i>` : ''}${l.away ? ' <i>(away)</i>' : ''}${l.why ? ` · ${esc(l.why)}` : ''}</div>
63
- ${queue}
51
+ <div class="lk-who"><b>${esc(who(it.by, me))}</b>${it.away ? ' <i>(away)</i>' : ''}${it.why ? ` · ${esc(it.why)}` : ''}</div>
64
52
  </li>`
65
53
  }
66
54
  return `<div class="lk-head"><span>${esc(title)}</span><span class="lk-total">${rows.length}</span></div>
67
- ${rows.length ? `<ul class="lk-list">${rows.map(row).join('')}</ul>` : `<p class="lk-none">${filter === 'waiting' ? 'Nobody is waiting for your files.' : byWho ? 'Nothing locked.' : 'Nothing is locked right now.'}</p>`}
68
- <div class="lk-foot">A lock is let go after ${Math.round(CLAIM_IDLE_MS / 60000)} minutes with no activity from its holder.${rows.some((l) => l.box) ? ' Work not committed yet stays held until it is.' : ''}</div>`
55
+ ${rows.length ? `<ul class="lk-list">${rows.map(row).join('')}</ul>` : '<p class="lk-none">No unfinished work in boxes.</p>'}
56
+ <div class="lk-foot">Unfinished work stays in its owner's folder until they commit it. Anyone can still edit the file: that opens the box.</div>`
69
57
  }
70
58
 
71
59
  /**
72
- * Draws the rail into `el` and keeps an open lock list up to date. `opts`: { me, colorOf, onFile }.
60
+ * Draws the rail into `el` and keeps an open box list up to date. `opts`: { me, colorOf, onFile }.
73
61
  */
74
62
  export function renderRail (el, model, opts) {
75
63
  last = { model, opts }
@@ -93,8 +81,8 @@ function bindRail (el) {
93
81
  const b = e.target.closest('[data-rail]')
94
82
  if (!b) return
95
83
  const filter = filterOf(b)
96
- if (open && open.pinned && same(open.filter, filter)) { closeLocks(); return }
97
- openLocks(b, filter, { pinned: true })
84
+ if (open && open.pinned && same(open.filter, filter)) { closeBoxList(); return }
85
+ openBoxList(b, filter, { pinned: true })
98
86
  })
99
87
  el.addEventListener('pointerover', (e) => {
100
88
  const b = e.target.closest('[data-rail]')
@@ -102,7 +90,7 @@ function bindRail (el) {
102
90
  clearTimeout(leaveTimer)
103
91
  if (open && open.pinned) return
104
92
  clearTimeout(hoverTimer)
105
- hoverTimer = setTimeout(() => openLocks(b, filterOf(b), { pinned: false }), open ? 0 : 250)
93
+ hoverTimer = setTimeout(() => openBoxList(b, filterOf(b), { pinned: false }), open ? 0 : 250)
106
94
  })
107
95
  el.addEventListener('pointerleave', () => { clearTimeout(hoverTimer); leaveSoon() })
108
96
  }
@@ -112,32 +100,32 @@ const same = (a, b) => (a && typeof a === 'object' && b && typeof b === 'object'
112
100
  function leaveSoon () {
113
101
  if (!open || open.pinned) return
114
102
  clearTimeout(leaveTimer)
115
- leaveTimer = setTimeout(closeLocks, 300)
103
+ leaveTimer = setTimeout(closeBoxList, 300)
116
104
  }
117
105
 
118
- /** Opens the lock list beside `anchor`. `pinned`: opened by a click, so it stays until a click elsewhere or Escape. */
119
- export function openLocks (anchor, filter, { pinned = true } = {}) {
106
+ /** Opens the box list beside `anchor`. `pinned`: opened by a click, so it stays until a click elsewhere or Escape. */
107
+ export function openBoxList (anchor, filter, { pinned = true } = {}) {
120
108
  if (!last) return
121
109
  if (!pop) {
122
110
  pop = document.createElement('div')
123
111
  pop.className = 'lk-pop'
124
- pop.id = 'lock-list'
112
+ pop.id = 'box-list'
125
113
  pop.setAttribute('role', 'dialog')
126
- pop.setAttribute('aria-label', 'Locked files')
114
+ pop.setAttribute('aria-label', 'Unfinished work')
127
115
  pop.hidden = true
128
116
  document.body.appendChild(pop)
129
117
  pop.addEventListener('click', (e) => {
130
118
  const f = e.target.closest('[data-lk-file]')
131
- if (f) { closeLocks(); last.opts.onFile(f.dataset.lkFile) }
119
+ if (f) { closeBoxList(); last.opts.onFile(f.dataset.lkFile) }
132
120
  })
133
121
  pop.addEventListener('pointerenter', () => clearTimeout(leaveTimer))
134
122
  pop.addEventListener('pointerleave', leaveSoon)
135
123
  document.addEventListener('pointerdown', (e) => {
136
124
  if (!open || pop.hidden || pop.contains(e.target) || open.anchor.contains(e.target)) return
137
- if (e.target.closest?.('[data-rail], [data-loom-holds]')) return // their own click decides
138
- closeLocks()
125
+ if (e.target.closest?.('[data-rail]')) return // their own click decides
126
+ closeBoxList()
139
127
  }, true)
140
- document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && open && !pop.hidden) { const a = open.anchor; closeLocks(); a.focus?.() } })
128
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && open && !pop.hidden) { const a = open.anchor; closeBoxList(); a.focus?.() } })
141
129
  }
142
130
  clearTimeout(leaveTimer)
143
131
  const fresh = pop.hidden
@@ -145,12 +133,12 @@ export function openLocks (anchor, filter, { pinned = true } = {}) {
145
133
  pop.hidden = false
146
134
  fill()
147
135
  if (fresh) { pop.classList.remove('in'); void pop.offsetWidth; pop.classList.add('in') }
148
- for (const b of document.querySelectorAll('[aria-controls="lock-list"]')) b.setAttribute('aria-expanded', 'false')
149
- anchor.setAttribute('aria-controls', 'lock-list')
136
+ for (const b of document.querySelectorAll('[aria-controls="box-list"]')) b.setAttribute('aria-expanded', 'false')
137
+ anchor.setAttribute('aria-controls', 'box-list')
150
138
  anchor.setAttribute('aria-expanded', 'true')
151
139
  }
152
140
 
153
- export function closeLocks () {
141
+ export function closeBoxList () {
154
142
  clearTimeout(hoverTimer)
155
143
  clearTimeout(leaveTimer)
156
144
  if (open) open.anchor.setAttribute?.('aria-expanded', 'false')
@@ -160,7 +148,7 @@ export function closeLocks () {
160
148
 
161
149
  function fill () {
162
150
  const { model, opts } = last
163
- pop.innerHTML = locksHtml(model, open.filter, opts)
151
+ pop.innerHTML = boxListHtml(model, open.filter, opts)
164
152
  // Beside its button: to the right (the rail, a lane head), else below.
165
153
  const r = open.anchor.getBoundingClientRect()
166
154
  const w = pop.offsetWidth
@@ -102,11 +102,47 @@ export function squareCard (st) {
102
102
  // Opening by itself: the square button says so, no card. Only a try that failed gets one, with the button.
103
103
  if (st.squareless) return st.squareless.error ? { ...squarelessWords(st), open: true } : null
104
104
  if (st.readOnly && !following) return { title: 'Your edits here are not reaching anyone', text: st.readOnly.why }
105
- if (!s) return null
105
+ // Held conflicts are the session's, on git or in Seam alike: said until an AI resolves them.
106
+ const held = heldCard(st)
107
+ if (!s) return held
106
108
  if (s.problem || s.opening) return { title: s.problem ? 'Not following its square yet' : 'Starting to follow its square', text: s.line }
107
109
  // Following its square with nothing to settle: the square button at the top says it, so no card (Daniel, 2026-11-01).
108
- if (!(s.conflicted ?? (s.brought && s.brought.conflicts ? s.brought.conflicts.length : 0))) return null
109
- return { title: 'Main conflicts with this square', text: catchUpWords(s).join(' ') }
110
+ if (!(s.conflicted ?? (s.brought && s.brought.conflicts ? s.brought.conflicts.length : 0))) return held
111
+ const main = catchUpWords(s).join(' ')
112
+ return held ? { title: held.title, text: `${held.text} ${main}` } : { title: 'Main conflicts with this square', text: main }
113
+ }
114
+
115
+ /**
116
+ * Open held conflicts (status `held`, held.js): two edits changed the same lines, or a write removed
117
+ * lines someone just added, or a merge would not parse. The file keeps what landed first and the
118
+ * other lines wait for an AI to resolve them. { title, text }, or null with none open.
119
+ */
120
+ export function heldCard (st) {
121
+ const open = ((st && st.held) || []).filter((r) => r && r.state === 'open')
122
+ if (!open.length) return null
123
+ const me = st.me && st.me.name
124
+ const named = open.slice(0, 3).map((r) => `${r.path} (${r.by === me ? 'yours' : `${r.by}'s`})`).join(', ')
125
+ return {
126
+ title: `${open.length} open conflict${open.length === 1 ? '' : 's'}`,
127
+ text: `Changes to ${named}${open.length > 3 ? ` and ${open.length - 3} more` : ''} were held back: each file keeps the version that landed first, and the held lines wait for an AI to resolve them. Every AI in the session sees ${open.length === 1 ? 'it' : 'them'} at the top of its next answer; ask yours to take ${open.length === 1 ? 'it' : 'them'}.`
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Session settings' row for `stale_write_minutes` (held.js; status `staleWriteMinutes`, default 15): a
133
+ * write that removes lines someone else added this recently is held for its writer to confirm. The
134
+ * owner changes it in place (saved on change, no dialog); everyone else reads it.
135
+ */
136
+ export function staleWriteHtml (st) {
137
+ const n = Number.isFinite(Number(st && st.staleWriteMinutes)) ? Number(st.staleWriteMinutes) : 15
138
+ const owner = !!(st && st.access && st.access.owner)
139
+ const what = 'A write that removes lines someone else added this recently is held for its writer to confirm, so a whole file written from an older read can\'t wipe out a partner\'s new work.'
140
+ const value = owner
141
+ ? `<span class="pm-number-in"><input class="input" type="number" inputmode="numeric" min="0" max="1440" step="1" value="${n}" data-stale-write aria-label="Minutes a partner's new lines are kept"><span class="hint">min</span></span>`
142
+ : `<span class="pm-number-in"><b>${n ? `${n} min` : 'Off'}</b></span>`
143
+ return `<div class="pm-section"><div class="pm-title">Same-line clashes</div><div class="pm-card pm-settings">
144
+ <label class="pm-number"><span><b>Keep a partner's new lines for</b><small>${what} ${owner ? '0 turns it off.' : 'The session\'s owner sets this.'}</small></span>${value}</label>
145
+ </div></div>`
110
146
  }
111
147
 
112
148
  /**