heyquilt 0.3.170 → 0.3.172
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/RELEASES.md +30 -0
- package/bin/quilt.js +16 -9
- package/package.json +2 -2
- package/src/agent-task-workflow.js +2 -9
- package/src/base-pick.js +212 -0
- package/src/boxes.js +6 -7
- package/src/catchup.js +1 -1
- package/src/chat-links.js +1 -3
- package/src/connection.js +24 -5
- package/src/control.js +27 -20
- package/src/duties.js +32 -56
- package/src/github-commit.js +1 -1
- package/src/held.js +323 -0
- package/src/hooks.js +27 -66
- package/src/identity.js +1 -1
- package/src/inbox.js +5 -4
- package/src/key-cli.js +1 -1
- package/src/live-merge.js +599 -0
- package/src/mcp.js +57 -102
- package/src/merge3.js +65 -1
- package/src/now-summary.js +4 -6
- package/src/pathrules.js +1 -1
- package/src/persona.js +1 -1
- package/src/presence.js +2 -0
- package/src/protocol.js +2 -2
- package/src/read-bases.js +123 -0
- package/src/relay-ask.js +2 -2
- package/src/relay-live-write.js +179 -0
- package/src/relay-mcp.js +173 -212
- package/src/relay-prune.js +2 -2
- package/src/relay-turn-sync.js +146 -142
- package/src/runner.js +0 -2
- package/src/server.js +253 -375
- package/src/session-follow.js +3 -1
- package/src/session-quilt.js +2 -21
- package/src/session-seam.js +35 -7
- package/src/session.js +795 -553
- package/src/setup.js +15 -25
- package/src/source-live/bring-in.js +5 -5
- package/src/source-live/land.js +20 -3
- package/src/source-live/live-block.js +503 -52
- package/src/status.js +8 -12
- package/src/swap-in.js +81 -0
- package/src/textdiff.js +54 -0
- package/src/turn-sync-plan.js +6 -18
- package/src/turn-sync.js +28 -21
- package/src/ui/agent-guide.js +13 -13
- package/src/ui/app.css +19 -40
- package/src/ui/boxes.js +8 -16
- package/src/ui/common.js +1 -1
- package/src/ui/fileview.js +11 -15
- package/src/ui/loom-model.js +18 -16
- package/src/ui/loom.css +1 -2
- package/src/ui/loom.js +6 -6
- package/src/ui/rail-model.js +25 -64
- package/src/ui/rail.js +48 -60
- package/src/ui/seam-model.js +39 -3
- package/src/ui/session.js +36 -54
- package/src/ui/tree.js +22 -129
- package/src/ui-server.js +2 -6
- package/src/release-words.js +0 -18
- package/src/seam-claims.js +0 -53
package/src/ui/seam-model.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
109
|
-
|
|
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
|
/**
|
package/src/ui/session.js
CHANGED
|
@@ -10,17 +10,16 @@ import { renderFeed } from './feed.js'
|
|
|
10
10
|
import { renderLoom, resetLoom, focusFile, showsLoom } from './loom.js'
|
|
11
11
|
import { buildLoom, foldAiLanes, aiWorking } from './loom-model.js'
|
|
12
12
|
import { railModel } from './rail-model.js'
|
|
13
|
-
import { renderRail,
|
|
13
|
+
import { renderRail, closeBoxList } from './rail.js'
|
|
14
14
|
import { feedbackDockHtml, bindFeedback } from './feedback.js'
|
|
15
15
|
import { conversations } from './feed-convs.js'
|
|
16
|
-
import { closeTreeMenu } from './tree.js'
|
|
17
16
|
import { renderFileView, renderFileTabs } from './fileview.js'
|
|
18
17
|
import { rolledOff, diffLines } from './diffview.js'
|
|
19
18
|
import { searchMarkup, searchTabMarkup, liveByPerson, fileReadsNeeded, SEARCH_ICON } from './quiltview.js'
|
|
20
19
|
import { changesMarkup, bindChanges, unbindChanges, changesChanged, fileChanges, loadChanges, changedCount, unseenChanges, markChangesSeen } from './changes.js'
|
|
21
20
|
import { quiltMark } from './mark.js'
|
|
22
21
|
import { openSettings } from './home.js'
|
|
23
|
-
import { fileCardHref, renderable, textHtml, mentionAt, mentionCandidates, completeMention, ALL_AGENTS, RELAY_NAME, isRelay, relayPrompts, typingNames, typingHtml, TYPING_MS, foldPersonas, aiOwners,
|
|
22
|
+
import { fileCardHref, renderable, textHtml, mentionAt, mentionCandidates, completeMention, ALL_AGENTS, RELAY_NAME, isRelay, relayPrompts, typingNames, typingHtml, TYPING_MS, foldPersonas, aiOwners, shownName, ownAiChatter } from './chat.js'
|
|
24
23
|
import { toolLogo } from './tool-logo.js'
|
|
25
24
|
import { renderBoard, taskNotesModalHtml, openTaskMenu, foldPlan, matchesSearch } from './board.js'
|
|
26
25
|
import { accessFormValues, accessSaveBody, grantsLoading, grantsLoaded, grantsFailed } from './access-form.js'
|
|
@@ -28,7 +27,7 @@ import { workspaceFilePicker } from './files.js'
|
|
|
28
27
|
import { sessionAgentsHtml } from './agent-place.js'
|
|
29
28
|
import { renderCatchUp, bindCatchUp } from './catchup.js'
|
|
30
29
|
import { boxSummary, boxesOf, unplaced, boxesSig, boxListHtml, boxFoldHtml } from './boxes.js'
|
|
31
|
-
import { inSeam, makeQuiltWords, seamChip, squareCard, squarePanelHtml, seamSettingsHtml, openSquareButton, squaresSideHtml, SEAM_SIDE_HINT } from './seam-model.js'
|
|
30
|
+
import { inSeam, makeQuiltWords, seamChip, squareCard, squarePanelHtml, seamSettingsHtml, openSquareButton, squaresSideHtml, SEAM_SIDE_HINT, staleWriteHtml } from './seam-model.js'
|
|
32
31
|
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards } from './voice.js'
|
|
33
32
|
|
|
34
33
|
let current = null // session id being shown
|
|
@@ -58,7 +57,7 @@ function ws (id) {
|
|
|
58
57
|
searchTabs: [], // code searches open as tabs, in a session linked to a quilt (quiltview.js)
|
|
59
58
|
searchSel: null,
|
|
60
59
|
expanded: {},
|
|
61
|
-
boxesCollapsed: false, // the Boxes pane (who is working on what) starts open; folded, it is a rail of
|
|
60
|
+
boxesCollapsed: false, // the Boxes pane (who is working on what) starts open; folded, it is a rail of boxes (rail.js)
|
|
62
61
|
stale: {}, // file path -> changed while not visible
|
|
63
62
|
loom: { chat: true, tasks: true, density: 'detailed', layout: 'lanes', hidden: [] },
|
|
64
63
|
...(saved || {}),
|
|
@@ -97,8 +96,8 @@ function peopleHere (st) {
|
|
|
97
96
|
/** Whose AI session each name in this session is (chat.js aiOwners). */
|
|
98
97
|
function owners (s) {
|
|
99
98
|
const st = s.status
|
|
100
|
-
//
|
|
101
|
-
return aiOwners({ peers: st.peers, messages: renderable(state.messages.get(current)), people: [st.me?.name, ...humanNames(st.peers), ...humanNames(st.members)], names: [...(st.members || []).map((m) => m.name), ...(st.
|
|
99
|
+
// Boxes and tasks name them too (an older app's AI session): those are their person as well.
|
|
100
|
+
return aiOwners({ peers: st.peers, messages: renderable(state.messages.get(current)), people: [st.me?.name, ...humanNames(st.peers), ...humanNames(st.members)], names: [...(st.members || []).map((m) => m.name), ...(st.boxes || []).map((c) => c && c.by), ...(st.tasks || []).map((t) => t && t.assignee), ...(st.commits || []).map((r) => r && r.by)] })
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
function personInfo (name) {
|
|
@@ -269,8 +268,7 @@ export function sessionUnmount () {
|
|
|
269
268
|
timers = []
|
|
270
269
|
if (mounted) mounted.abort()
|
|
271
270
|
mounted = null
|
|
272
|
-
|
|
273
|
-
closeLocks()
|
|
271
|
+
closeBoxList()
|
|
274
272
|
pendingAssign = null
|
|
275
273
|
unbindChanges()
|
|
276
274
|
current = null
|
|
@@ -447,7 +445,7 @@ function bindTop () {
|
|
|
447
445
|
|
|
448
446
|
menu.addEventListener('click', async (e) => {
|
|
449
447
|
if (e.target.closest('[data-session-settings]')) { openSessionSettings(); return }
|
|
450
|
-
const bx = e.target.closest('[data-box-toggle],[data-unpack]
|
|
448
|
+
const bx = e.target.closest('[data-box-toggle],[data-unpack]')
|
|
451
449
|
if (bx) { boxAction(bx); return }
|
|
452
450
|
const t = e.target.closest('[data-person],[data-dm],[data-sharing]')
|
|
453
451
|
if (!t) return
|
|
@@ -505,6 +503,15 @@ function bindSessionSettings (root) {
|
|
|
505
503
|
} catch (err) { toast(err.message); refreshPeople({ force: true }) }
|
|
506
504
|
return
|
|
507
505
|
}
|
|
506
|
+
if (e.target.matches('[data-stale-write]')) {
|
|
507
|
+
const n = Number(e.target.value)
|
|
508
|
+
if (!Number.isInteger(n) || n < 0 || n > 1440) { toast('A number of minutes from 0 to 1440'); e.target.value = sum().status.staleWriteMinutes ?? 15; return }
|
|
509
|
+
try {
|
|
510
|
+
const r = await api('POST', `/api/sessions/${current}/stale-write`, { minutes: n })
|
|
511
|
+
toast(r.minutes ? `A partner's new lines are kept for ${r.minutes} min` : 'Writes may remove anyone\'s lines now')
|
|
512
|
+
} catch (err) { toast(err.message); e.target.value = sum().status.staleWriteMinutes ?? 15 }
|
|
513
|
+
return
|
|
514
|
+
}
|
|
508
515
|
if (!e.target.matches('[data-summarize]')) return
|
|
509
516
|
const on = e.target.checked
|
|
510
517
|
try {
|
|
@@ -1102,12 +1109,12 @@ function refreshPeople (opts = {}) {
|
|
|
1102
1109
|
}
|
|
1103
1110
|
|
|
1104
1111
|
/**
|
|
1105
|
-
* The boxes the people panel shows, fetched again when the session's
|
|
1112
|
+
* The boxes the people panel shows, fetched again when the session's boxes change (and, while
|
|
1106
1113
|
* the panel is open, every few seconds: a box's change grows with each edit). Redraws when they differ.
|
|
1107
1114
|
*/
|
|
1108
1115
|
function loadBoxes (st, { force = false } = {}) {
|
|
1109
1116
|
const id = current
|
|
1110
|
-
const sig = boxesSig(st.
|
|
1117
|
+
const sig = boxesSig(st.boxes)
|
|
1111
1118
|
if (boxView.loading || (!force && sig === boxView.sig && Date.now() - boxView.at < BOXES_FRESH_MS)) return
|
|
1112
1119
|
if (!force && !sig && sig === boxView.sig) return // nothing boxed, as before: nothing to fetch
|
|
1113
1120
|
boxView.loading = true
|
|
@@ -1121,7 +1128,7 @@ function loadBoxes (st, { force = false } = {}) {
|
|
|
1121
1128
|
}, () => {}).finally(() => { if (boxView.id === id) boxView.loading = false })
|
|
1122
1129
|
}
|
|
1123
1130
|
|
|
1124
|
-
/** A box's controls in the people panel: show its change, Unpack your own
|
|
1131
|
+
/** A box's controls in the people panel: show its change, Unpack your own. */
|
|
1125
1132
|
async function boxAction (el) {
|
|
1126
1133
|
const st = sum().status
|
|
1127
1134
|
if (el.dataset.boxToggle) {
|
|
@@ -1134,15 +1141,9 @@ async function boxAction (el) {
|
|
|
1134
1141
|
}
|
|
1135
1142
|
el.disabled = true
|
|
1136
1143
|
try {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
toast(r.unpacked && r.unpacked.length ? `Unpacked ${basename(p)}: in everyone's folder now` : `${basename(p)} isn't boxed by you anymore`)
|
|
1141
|
-
} else {
|
|
1142
|
-
const p = el.dataset.ask
|
|
1143
|
-
const r = await api('POST', `/api/sessions/${current}/request-file`, { path: p, title: `Needs your change to ${basename(p)}` })
|
|
1144
|
-
toast(`Asked ${r.holder || 'them'} for ${basename(p)}${r.position ? `: ${r.position === 1 ? 'first' : `number ${r.position}`} in line` : ''}`)
|
|
1145
|
-
}
|
|
1144
|
+
const p = el.dataset.unpack
|
|
1145
|
+
const r = await api('POST', `/api/sessions/${current}/unpack`, { paths: [p] })
|
|
1146
|
+
toast(r.unpacked && r.unpacked.length ? `Unpacked ${basename(p)}: in everyone's folder now` : `${basename(p)} isn't boxed by you anymore`)
|
|
1146
1147
|
} catch (err) { toast(err.message); el.disabled = false }
|
|
1147
1148
|
loadBoxes(st, { force: true })
|
|
1148
1149
|
}
|
|
@@ -1427,13 +1428,15 @@ function renderSessionSettings ({ force = false } = {}) {
|
|
|
1427
1428
|
if (ssConnections) { ssConnections.destroy(); ssConnections = null }
|
|
1428
1429
|
// Don't redraw under the owner while they change someone's access (unless fresh grants
|
|
1429
1430
|
// arrived: then the form is redrawn from them, and keeps its focus).
|
|
1431
|
+
// Nor under the owner typing the minutes a partner's new lines are kept (saved when it changes).
|
|
1432
|
+
if (!force && box.contains(document.activeElement) && document.activeElement.matches('[data-stale-write]')) return
|
|
1430
1433
|
const active = box.contains(document.activeElement) && document.activeElement.closest('.pm-member') ? document.activeElement : null
|
|
1431
1434
|
if (!force && active && box.querySelector('.pm-member.edit')) return
|
|
1432
1435
|
const refocus = active && active.name ? [active.closest('.pm-member').dataset.key, active.name] : null
|
|
1433
1436
|
// Source control is Seam's: where the history is (or, for the owner of a session not in Seam yet, the button that moves it there).
|
|
1434
1437
|
const vc = inSeam(st) ? seamSettingsHtml(st) : makeQuiltHtml(st)
|
|
1435
1438
|
box.innerHTML = ssTab === 'chat' ? sharingHtml(st)
|
|
1436
|
-
: ssTab === 'vc' ? (vc || '<div class="pm-empty">Only the session owner sees where this session\'s history is.</div>')
|
|
1439
|
+
: ssTab === 'vc' ? (vc || '<div class="pm-empty">Only the session owner sees where this session\'s history is.</div>') + staleWriteHtml(st)
|
|
1437
1440
|
: membersHtml(st, ssTab)
|
|
1438
1441
|
if (refocus) [...box.querySelectorAll('.pm-member')].find((f) => f.dataset.key === refocus[0])?.elements?.[refocus[1]]?.focus()
|
|
1439
1442
|
}
|
|
@@ -1498,9 +1501,6 @@ function bindMain () {
|
|
|
1498
1501
|
if (qf) openFile(qf.dataset.qtFile, { tab: 'changes' })
|
|
1499
1502
|
const qh = e.target.closest('[data-qt-hit]')
|
|
1500
1503
|
if (qh) openFile(qh.dataset.qtHit, { tab: 'file', line: Number(qh.dataset.line) || null })
|
|
1501
|
-
const f = e.target.closest('[data-fv]')
|
|
1502
|
-
if (f && f.dataset.fv === 'claim') claimPath(ws(current).fileSel, '')
|
|
1503
|
-
if (f && f.dataset.fv === 'release') releasePattern(f.dataset.pattern)
|
|
1504
1504
|
})
|
|
1505
1505
|
// Searching again from a search tab's own field.
|
|
1506
1506
|
$('#main').addEventListener('submit', (e) => {
|
|
@@ -2494,8 +2494,8 @@ function treeMeta (path) {
|
|
|
2494
2494
|
const t = state.trees.get(current)
|
|
2495
2495
|
const f = t && t.files.find((x) => x.path === path)
|
|
2496
2496
|
if (f) return f
|
|
2497
|
-
// Deleted or unknown:
|
|
2498
|
-
return { path, edited: null,
|
|
2497
|
+
// Deleted or unknown: nobody edited it in this session.
|
|
2498
|
+
return { path, edited: null, box: null }
|
|
2499
2499
|
}
|
|
2500
2500
|
|
|
2501
2501
|
const fileLoads = new Set() // fileKey -> being read for the first time
|
|
@@ -2559,7 +2559,8 @@ function renderLoomView (el) {
|
|
|
2559
2559
|
feeds: state.feeds.get(current) || new Map(),
|
|
2560
2560
|
messages: renderable(state.messages.get(current)),
|
|
2561
2561
|
tasks: st.tasks || [],
|
|
2562
|
-
|
|
2562
|
+
// Who wrote each file last (the file tree): the lane heads' recent files, never a hold.
|
|
2563
|
+
edits: (state.trees.get(current)?.files || []).filter((f) => f.edited && f.edited.by).map((f) => ({ path: f.path, by: f.edited.by, ts: f.edited.ts }))
|
|
2563
2564
|
})
|
|
2564
2565
|
loomPersonOf = personOf
|
|
2565
2566
|
const prefs = loomPrefs(ws(current))
|
|
@@ -2581,7 +2582,6 @@ function loomAction (kind, value) {
|
|
|
2581
2582
|
if (kind === 'person') return openPerson(loomPersonOf.get(value) || value)
|
|
2582
2583
|
if (kind === 'conv') { openPerson(loomPersonOf.get(value.name) || value.name); pickConv(value.conv); return }
|
|
2583
2584
|
if (kind === 'file') return openFile(value)
|
|
2584
|
-
if (kind === 'holds') return openLocks(value.anchor, { who: value.name }) // the same lock list as the Files rail
|
|
2585
2585
|
if (kind === 'task') {
|
|
2586
2586
|
const task = (sum().status.tasks || []).find((t) => t.id === value)
|
|
2587
2587
|
if (task) openTaskNotes(task)
|
|
@@ -2643,7 +2643,7 @@ async function loadTree () {
|
|
|
2643
2643
|
renderTreePane()
|
|
2644
2644
|
const w = ws(id)
|
|
2645
2645
|
if (w.mode === 'files' && w.fileSel) {
|
|
2646
|
-
// Keep the banner (editor,
|
|
2646
|
+
// Keep the banner (editor, box) fresh without re-highlighting.
|
|
2647
2647
|
const cached = state.files.get(fileKey(w.fileSel))
|
|
2648
2648
|
const meta = treeMeta(w.fileSel)
|
|
2649
2649
|
if (cached) renderFileView($('#main'), { path: w.fileSel, file: cached.file, meta, me: me(), bannerOnly: true, chatHref: meta?.chat ? fileCardHref(id, meta.chat.id, TOKEN) : null, rawHref: rawHrefFor(id) })
|
|
@@ -2651,7 +2651,7 @@ async function loadTree () {
|
|
|
2651
2651
|
} catch {}
|
|
2652
2652
|
}
|
|
2653
2653
|
|
|
2654
|
-
/** The left pane: the Boxes sidebar and, folded, its rail of
|
|
2654
|
+
/** The left pane: the Boxes sidebar and, folded, its rail of boxes. The file list stays loaded for the file view and the rail. */
|
|
2655
2655
|
function renderTreePane () {
|
|
2656
2656
|
if (!current || !$('#boxes-side')) return
|
|
2657
2657
|
renderBoxesSide()
|
|
@@ -2699,18 +2699,16 @@ function openTaskNotes (task, { instant = false } = {}) {
|
|
|
2699
2699
|
if (instant) back.querySelector('.task-comment-text').focus()
|
|
2700
2700
|
}
|
|
2701
2701
|
|
|
2702
|
-
/** The folded Boxes pane:
|
|
2702
|
+
/** The folded Boxes pane: whose unfinished work is boxed (rail.js). */
|
|
2703
2703
|
function renderRailPane (tree = state.trees.get(current)) {
|
|
2704
2704
|
const el = $('#tree-rail')
|
|
2705
2705
|
const s = sum()
|
|
2706
2706
|
if (!el || !s) return
|
|
2707
2707
|
const st = s.status
|
|
2708
2708
|
const model = railModel({
|
|
2709
|
-
|
|
2709
|
+
boxes: st.boxes || [],
|
|
2710
2710
|
me: st.me.name,
|
|
2711
2711
|
owners: owners(s),
|
|
2712
|
-
aiName,
|
|
2713
|
-
files: tree ? tree.files.map((f) => f.path) : [],
|
|
2714
2712
|
focusOf: (name) => (name === st.me.name ? st.me.focus : st.peers.find((p) => p.name === name)?.focus) || '',
|
|
2715
2713
|
kindOf: (name) => personInfo(name).kind
|
|
2716
2714
|
})
|
|
@@ -2725,7 +2723,7 @@ function applyTreeCollapsed () {
|
|
|
2725
2723
|
body.classList.toggle('tree-collapsed', collapsed)
|
|
2726
2724
|
const rail = $('#tree-rail')
|
|
2727
2725
|
if (rail) rail.toggleAttribute('inert', !collapsed)
|
|
2728
|
-
if (!collapsed)
|
|
2726
|
+
if (!collapsed) closeBoxList()
|
|
2729
2727
|
const scroll = $('#boxes-side')
|
|
2730
2728
|
if (scroll) {
|
|
2731
2729
|
scroll.toggleAttribute('inert', collapsed)
|
|
@@ -2847,7 +2845,7 @@ function bindTreeEvents () {
|
|
|
2847
2845
|
renderBoxesSide()
|
|
2848
2846
|
return
|
|
2849
2847
|
}
|
|
2850
|
-
const bx = e.target.closest('[data-box-toggle],[data-unpack]
|
|
2848
|
+
const bx = e.target.closest('[data-box-toggle],[data-unpack]')
|
|
2851
2849
|
if (bx) { boxAction(bx); return }
|
|
2852
2850
|
const t = e.target.closest('[data-person],[data-dm]')
|
|
2853
2851
|
if (!t) return
|
|
@@ -2863,22 +2861,6 @@ function bindTreeEvents () {
|
|
|
2863
2861
|
})
|
|
2864
2862
|
}
|
|
2865
2863
|
|
|
2866
|
-
async function claimPath (path, note) {
|
|
2867
|
-
try {
|
|
2868
|
-
await api('POST', `/api/sessions/${current}/claim`, { pattern: path, note })
|
|
2869
|
-
toast(`Claimed ${path}`)
|
|
2870
|
-
loadTree()
|
|
2871
|
-
} catch (err) { toast(err.message) }
|
|
2872
|
-
}
|
|
2873
|
-
|
|
2874
|
-
async function releasePattern (pattern) {
|
|
2875
|
-
try {
|
|
2876
|
-
await api('POST', `/api/sessions/${current}/release`, { pattern })
|
|
2877
|
-
toast(`Released ${pattern}`)
|
|
2878
|
-
loadTree()
|
|
2879
|
-
} catch (err) { toast(err.message) }
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
2864
|
// ------------------------------------------------------------------- chat --
|
|
2883
2865
|
function bindChat () {
|
|
2884
2866
|
const id = current
|
package/src/ui/tree.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// The shared project's file tree: who edited what recently,
|
|
1
|
+
// The shared project's file tree: who edited what recently, and whose unfinished work is boxed.
|
|
2
|
+
// Nobody holds files (no-holds, 2026-11-13): a box never stops anyone editing.
|
|
2
3
|
import { esc, I, ago, colorFor, loadingNote } from './common.js'
|
|
3
4
|
|
|
4
5
|
/** Where each person's chat files are kept (CHAT_FILES in pathrules.js, which the page can't load). */
|
|
@@ -11,23 +12,6 @@ const shortAgo = (ts) => {
|
|
|
11
12
|
return s < 60 ? `${s}s` : `${Math.round(s / 60)}m`
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
/** Who holds a claim, as the tree shows it: "you", "Duncan", or "Duncan (away)" when they aren't in the session. */
|
|
15
|
-
export const claimHolder = (c, me) => c.by === me && c.active !== false ? 'you' : `${c.by}${c.active === false ? ' (away)' : ''}`
|
|
16
|
-
|
|
17
|
-
const queueOf = (c) => (c && Array.isArray(c.queue) ? c.queue : [])
|
|
18
|
-
|
|
19
|
-
/** A claim's tooltip: who, since when, their note, the account that holds it, and who waits for it. */
|
|
20
|
-
export const claimTitle = (c, me) => [
|
|
21
|
-
`Claimed by ${claimHolder(c, me)}${c.ts ? ` at ${new Date(c.ts).toLocaleString()}` : ''}`,
|
|
22
|
-
c.note || '',
|
|
23
|
-
c.byId ? `Account: ${c.byId}` : '',
|
|
24
|
-
c.activeAt ? `Last active ${new Date(c.activeAt).toLocaleTimeString()}; let go after 20 minutes with no activity` : '',
|
|
25
|
-
...queueOf(c).map((r, i) => `${i + 1}. ${r.by === me ? 'You' : r.by} waiting: ${r.title}`)
|
|
26
|
-
].filter(Boolean).join('\n')
|
|
27
|
-
|
|
28
|
-
/** "src/auth", "src/auth/", "src/auth/**" all claim the folder src/auth. */
|
|
29
|
-
export const claimFolder = (pattern) => String(pattern).replace(/\/\*\*$/, '').replace(/\/+$/, '')
|
|
30
|
-
|
|
31
15
|
function buildTree (files) {
|
|
32
16
|
const root = { name: '', path: '', dirs: new Map(), files: [] }
|
|
33
17
|
for (const f of files) {
|
|
@@ -43,28 +27,19 @@ function buildTree (files) {
|
|
|
43
27
|
return root
|
|
44
28
|
}
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
export function claimsInside (claims, dir) {
|
|
30
|
+
const boxMineOf = (c, me) => c.by === me || c.of === me
|
|
31
|
+
|
|
32
|
+
/** Boxes on files inside a folder: a collapsed folder shows them, so one deep in the tree is seen without opening every folder. */
|
|
33
|
+
export function boxesInside (boxes, dir) {
|
|
51
34
|
const pre = dir ? `${dir}/` : ''
|
|
52
|
-
return (
|
|
35
|
+
return (boxes || []).filter((c) => c && String(c.pattern).startsWith(pre))
|
|
53
36
|
}
|
|
54
37
|
|
|
55
|
-
/** The badge a collapsed folder shows for the
|
|
56
|
-
export function insideBadge (
|
|
57
|
-
if (!
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const title = claims.map((c) => `${claimFolder(c.pattern)}: ${claimHolder(c, me)}${c.note ? ` (${c.note})` : ''}`).join('\n')
|
|
61
|
-
const away = claims.every((c) => c.active === false)
|
|
62
|
-
// Only boxes inside (boxes.js): the box mark, so a folded folder reads like its files.
|
|
63
|
-
if (claims.every((c) => c.box)) {
|
|
64
|
-
const who = [...new Set(claims.map((c) => c.by === me || c.of === me ? 'you' : c.by))]
|
|
65
|
-
return `<span class="t-badge box inside" title="${esc(`Unfinished work inside:\n${claims.map((c) => `${c.pattern}: ${c.by === me || c.of === me ? 'yours' : c.by}`).join('\n')}`)}">${I.box}${esc(who.length > 1 ? `${who[0]} +${who.length - 1}` : who[0])}</span>`
|
|
66
|
-
}
|
|
67
|
-
return `<span class="t-badge claim inside${away ? ' away' : ''}" title="${esc(`Claimed inside:\n${title}`)}">${I.lock}${esc(label)}</span>`
|
|
38
|
+
/** The badge a collapsed folder shows for the boxes inside it: "Brandon", "you +1", with each box in the tooltip. */
|
|
39
|
+
export function insideBadge (boxes, me) {
|
|
40
|
+
if (!boxes.length) return ''
|
|
41
|
+
const who = [...new Set(boxes.map((c) => boxMineOf(c, me) ? 'you' : c.by))]
|
|
42
|
+
return `<span class="t-badge box inside" title="${esc(`Unfinished work inside:\n${boxes.map((c) => `${c.pattern}: ${boxMineOf(c, me) ? 'yours' : c.by}`).join('\n')}`)}">${I.box}${esc(who.length > 1 ? `${who[0]} +${who.length - 1}` : who[0])}</span>`
|
|
68
43
|
}
|
|
69
44
|
|
|
70
45
|
function hasRecent (node, me) {
|
|
@@ -74,30 +49,26 @@ function hasRecent (node, me) {
|
|
|
74
49
|
|
|
75
50
|
/**
|
|
76
51
|
* @param {HTMLElement} el
|
|
77
|
-
* @param {{ files: object[],
|
|
52
|
+
* @param {{ files: object[], boxes: object[] }} tree
|
|
78
53
|
* @param {{ me: string, expanded: object, selected: string|null }} view
|
|
79
54
|
*/
|
|
80
55
|
export function renderTree (el, tree, { me, expanded, selected }) {
|
|
81
56
|
if (!tree) { el.innerHTML = `<div class="empty-note" style="padding:12px 14px">${loadingNote('Loading files…')}</div>`; return }
|
|
82
57
|
const files = tree.files
|
|
83
58
|
if (!files.length) { el.innerHTML = '<div class="empty-note" style="padding:12px 14px">No shared files yet.</div>'; return }
|
|
84
|
-
const folderClaims = new Map()
|
|
85
|
-
for (const c of tree.claims) folderClaims.set(claimFolder(c.pattern), c)
|
|
86
59
|
const root = buildTree(files)
|
|
87
60
|
const rows = []
|
|
88
61
|
|
|
89
62
|
// A box (boxes.js): someone's unfinished work, marked in amber; theirs isn't in this folder yet.
|
|
90
|
-
const boxMine = (c) => c
|
|
91
|
-
const boxBadge = (c) => `<span class="t-badge box${boxMine(c) ? ' own' : ''}" title="${esc(boxMine(c) ?
|
|
92
|
-
const claimBadge = (c) => c && c.box ? boxBadge(c) : c ? `<span class="t-badge claim${c.active === false ? ' away' : ''}" title="${esc(claimTitle(c, me))}">${I.lock}${esc(claimHolder(c, me))}${queueOf(c).length ? ` · ${queueOf(c).length} waiting` : ''}</span>` : ''
|
|
63
|
+
const boxMine = (c) => boxMineOf(c, me)
|
|
64
|
+
const boxBadge = (c) => c ? `<span class="t-badge box${boxMine(c) ? ' own' : ''}" title="${esc(boxMine(c) ? 'Your unfinished work: in your folder only, until you commit it' : `${c.by}'s unfinished work: not in your folder until they commit it. Editing it opens the box. See it under them in People.`)}">${I.box}${esc(boxMine(c) ? 'you' : c.by)}</span>` : ''
|
|
93
65
|
// Who just edited a file: a button to its Changes tab. Its +/− shows in the row's change card.
|
|
94
66
|
const editBadge = (f, byOther) => `<button type="button" class="t-badge ${byOther ? 'edit' : 'mine'}" data-changes="${esc(f.path)}" aria-label="See what changed in ${esc(f.path)}">${esc(f.edited.by === me ? 'you' : f.edited.by)} · ${shortAgo(f.edited.ts)}</button>`
|
|
95
67
|
const walk = (node, depth) => {
|
|
96
68
|
const dirs = [...node.dirs.values()].sort((a, b) => (a.path === CHAT_FILES) - (b.path === CHAT_FILES) || a.name.localeCompare(b.name)) // chat files last
|
|
97
69
|
for (const d of dirs) {
|
|
98
70
|
const open = expanded[d.path] ?? depth === 0
|
|
99
|
-
|
|
100
|
-
// The chat files folder (session.js): each person's own copy of what was sent in chat, nothing to claim.
|
|
71
|
+
// The chat files folder (session.js): each person's own copy of what was sent in chat.
|
|
101
72
|
if (d.path === CHAT_FILES) {
|
|
102
73
|
rows.push(`<div class="t-row t-dir t-chat" role="treeitem" aria-expanded="${open}" tabindex="-1" data-dir="${esc(d.path)}" style="--depth:${depth}" title="Files sent in this session's chat. Only people in the session get them; never synced or committed.">
|
|
103
74
|
<span class="t-caret${open ? ' open' : ''}">${I.caret}</span><span class="t-name">${esc(d.name)}</span><span class="t-badge chat">${I.lock}session only</span></div>`)
|
|
@@ -106,7 +77,7 @@ export function renderTree (el, tree, { me, expanded, selected }) {
|
|
|
106
77
|
}
|
|
107
78
|
rows.push(`<div class="t-row t-dir" role="treeitem" aria-expanded="${open}" tabindex="-1" data-dir="${esc(d.path)}" style="--depth:${depth}">
|
|
108
79
|
<span class="t-caret${open ? ' open' : ''}">${I.caret}</span><span class="t-name">${esc(d.name)}</span>
|
|
109
|
-
${!open && hasRecent(d, me) ? '<span class="t-dot" title="Recently edited inside"></span>' : ''}${
|
|
80
|
+
${!open && hasRecent(d, me) ? '<span class="t-dot" title="Recently edited inside"></span>' : ''}${!open ? insideBadge(boxesInside(tree.boxes, d.path), me) : ''}
|
|
110
81
|
<button class="t-more" data-more="${esc(d.path)}" data-kind="dir" aria-label="More for ${esc(d.name)}">${I.more}</button></div>`)
|
|
111
82
|
if (open) walk(d, depth + 1)
|
|
112
83
|
}
|
|
@@ -118,13 +89,13 @@ export function renderTree (el, tree, { me, expanded, selected }) {
|
|
|
118
89
|
}
|
|
119
90
|
const recent = !!f.edited && Date.now() - f.edited.ts < RECENT_MS
|
|
120
91
|
const byOther = recent && f.edited.by !== me
|
|
121
|
-
const
|
|
122
|
-
//
|
|
123
|
-
const ghost =
|
|
92
|
+
const box = f.box && f.box.pattern === f.path ? f.box : null
|
|
93
|
+
// Whoever boxed it is the one editing it: their box badge says so, one badge is enough on a narrow row.
|
|
94
|
+
const ghost = box && !boxMine(box)
|
|
124
95
|
rows.push(`<div class="t-row t-file${selected === f.path ? ' on' : ''}${ghost ? ' ghost' : ''}" role="treeitem" tabindex="-1" data-file="${esc(f.path)}" style="--depth:${depth}" title="${esc(f.path)}">
|
|
125
96
|
<span class="t-ico">${I.file}</span><span class="t-name">${esc(f.name)}</span>
|
|
126
|
-
${recent && !(
|
|
127
|
-
${
|
|
97
|
+
${recent && !(box && box.by === f.edited.by) ? editBadge(f, byOther) : ''}
|
|
98
|
+
${boxBadge(box)}
|
|
128
99
|
<button class="t-more" data-more="${esc(f.path)}" data-kind="file" aria-label="More for ${esc(f.name)}">${I.more}</button></div>`)
|
|
129
100
|
}
|
|
130
101
|
}
|
|
@@ -132,84 +103,6 @@ export function renderTree (el, tree, { me, expanded, selected }) {
|
|
|
132
103
|
el.innerHTML = `<div class="t-list" role="tree">${rows.join('')}</div>`
|
|
133
104
|
}
|
|
134
105
|
|
|
135
|
-
/**
|
|
136
|
-
* The ⋯ menu for a file or folder: claim it (with an optional note) or
|
|
137
|
-
* release your claim. Others' claims are shown with their file queue: ask for the file
|
|
138
|
-
* (join the queue) or withdraw; the holder hands it off to the first one waiting, with
|
|
139
|
-
* context. The owner may release anyone's claim (it goes to the first one waiting).
|
|
140
|
-
*/
|
|
141
|
-
export function openTreeMenu (anchor, { path, kind, claim, me, owner, onClaim, onRelease, onClearAway, onRequest, onWithdraw, onHandoff, onOpen }) {
|
|
142
|
-
closeTreeMenu()
|
|
143
|
-
const menu = document.createElement('div')
|
|
144
|
-
menu.className = 'popover tree-menu'
|
|
145
|
-
menu.setAttribute('role', 'menu')
|
|
146
|
-
const isAway = claim && claim.active === false
|
|
147
|
-
const mine = claim && claim.by === me && !isAway
|
|
148
|
-
const theirs = claim && !mine
|
|
149
|
-
const queue = queueOf(claim)
|
|
150
|
-
const myRequest = queue.find((r) => r.by === me)
|
|
151
|
-
// The owner may release anyone's claim; anyone may release one held under their name from before.
|
|
152
|
-
const canRelease = theirs && (owner || (isAway && claim.by === me))
|
|
153
|
-
const waiting = queue.length ? `<div class="pop-queue"><div class="label">File queue</div>${queue.map((r, i) => `<div class="pop-req"><b>${i + 1}. ${esc(r.by === me ? 'You' : r.by)}</b> ${esc(r.title)}${r.description ? `<div class="hint">${esc(r.description)}</div>` : ''}</div>`).join('')}</div>` : ''
|
|
154
|
-
menu.innerHTML = `
|
|
155
|
-
<div class="pop-title">${esc(path)}</div>
|
|
156
|
-
${kind === 'file' ? `<button class="pop-item" data-act="open" role="menuitem">${I.file}Open</button>` : ''}
|
|
157
|
-
${theirs ? `<div class="pop-note" title="${esc(claimTitle(claim, me))}">${I.lock}<span>Claimed by <b>${esc(claimHolder(claim, me))}</b>${claim.note ? `: ${esc(claim.note)}` : ''}</span></div>` : ''}
|
|
158
|
-
${waiting}
|
|
159
|
-
${mine && !queue.length ? `<button class="pop-item" data-act="release" role="menuitem">${I.lock}Release your claim</button>` : ''}
|
|
160
|
-
${mine && queue.length && onHandoff ? `<form class="pop-form" data-form="handoff"><label class="label" for="handoff-context">Hand off to ${esc(queue[0].by)}</label>
|
|
161
|
-
<textarea class="input" id="handoff-context" rows="3" maxlength="2000" placeholder="What you changed, what's left, anything they should know" required></textarea>
|
|
162
|
-
<button class="btn sm primary" type="submit">Hand off</button></form>` : ''}
|
|
163
|
-
${canRelease ? `<button class="pop-item" data-act="release" role="menuitem">${I.lock}${queue.length ? `Release ${esc(claim.by)}'s claim (goes to ${esc(queue[0].by)})` : `Release ${esc(claim.by)}'s claim`}</button>` : ''}
|
|
164
|
-
${isAway && owner && onClearAway ? '<button class="pop-item" data-act="clear-away" role="menuitem">Release every claim held by someone away</button>' : ''}
|
|
165
|
-
${myRequest && onWithdraw ? '<button class="pop-item" data-act="withdraw" role="menuitem">Withdraw your request</button>' : ''}
|
|
166
|
-
${theirs && !myRequest && kind === 'file' && onRequest ? `<form class="pop-form" data-form="request"><label class="label" for="req-title">Ask for this file</label>
|
|
167
|
-
<input class="input" id="req-title" maxlength="120" placeholder="Working on … for …" autocomplete="off" required>
|
|
168
|
-
<textarea class="input" id="req-desc" rows="3" maxlength="300" placeholder="What you plan to change, in short (300 characters)"></textarea>
|
|
169
|
-
<button class="btn sm primary" type="submit">Join the queue</button></form>` : ''}
|
|
170
|
-
${!claim ? `<form class="pop-form" data-form="claim"><label class="label" for="claim-note">Claim this ${kind === 'dir' ? 'folder' : 'file'}</label>
|
|
171
|
-
<input class="input" id="claim-note" placeholder="What are you doing? (optional)" autocomplete="off">
|
|
172
|
-
<button class="btn sm primary" type="submit">${I.lock}Claim</button></form>` : ''}`
|
|
173
|
-
document.body.appendChild(menu)
|
|
174
|
-
const r = anchor.getBoundingClientRect()
|
|
175
|
-
const w = 280
|
|
176
|
-
menu.style.left = `${Math.max(8, Math.min(r.right - w, window.innerWidth - w - 8))}px`
|
|
177
|
-
menu.style.top = `${Math.max(8, Math.min(r.bottom + 4, window.innerHeight - menu.offsetHeight - 8))}px`
|
|
178
|
-
menu.addEventListener('click', (e) => {
|
|
179
|
-
const b = e.target.closest('[data-act]')
|
|
180
|
-
if (!b) return
|
|
181
|
-
if (b.dataset.act === 'open') onOpen()
|
|
182
|
-
if (b.dataset.act === 'release') onRelease()
|
|
183
|
-
if (b.dataset.act === 'clear-away') onClearAway()
|
|
184
|
-
if (b.dataset.act === 'withdraw') onWithdraw(myRequest.id)
|
|
185
|
-
closeTreeMenu()
|
|
186
|
-
})
|
|
187
|
-
const form = menu.querySelector('form')
|
|
188
|
-
const val = (sel) => menu.querySelector(sel).value.trim()
|
|
189
|
-
if (form) {
|
|
190
|
-
form.onsubmit = (e) => {
|
|
191
|
-
e.preventDefault()
|
|
192
|
-
const f = form.dataset.form
|
|
193
|
-
if (f === 'claim') onClaim(val('#claim-note'))
|
|
194
|
-
if (f === 'request') onRequest({ title: val('#req-title'), description: val('#req-desc') })
|
|
195
|
-
if (f === 'handoff') onHandoff({ to: queue[0].id, context: val('#handoff-context') })
|
|
196
|
-
closeTreeMenu()
|
|
197
|
-
}
|
|
198
|
-
setTimeout(() => form.querySelector('.input')?.focus(), 0)
|
|
199
|
-
} else {
|
|
200
|
-
menu.querySelector('.pop-item')?.focus()
|
|
201
|
-
}
|
|
202
|
-
const away = (e) => { if (!menu.contains(e.target) && e.target !== anchor) closeTreeMenu() }
|
|
203
|
-
const esc_ = (e) => { if (e.key === 'Escape') { closeTreeMenu(); anchor.focus?.() } }
|
|
204
|
-
setTimeout(() => document.addEventListener('mousedown', away), 0)
|
|
205
|
-
document.addEventListener('keydown', esc_)
|
|
206
|
-
closeTreeMenu.cleanup = () => { document.removeEventListener('mousedown', away); document.removeEventListener('keydown', esc_); menu.remove() }
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function closeTreeMenu () {
|
|
210
|
-
if (closeTreeMenu.cleanup) { closeTreeMenu.cleanup(); closeTreeMenu.cleanup = null }
|
|
211
|
-
}
|
|
212
|
-
|
|
213
106
|
// ------------------------------------------------------------ change card --
|
|
214
107
|
// Hovering (or arrowing to) a file the session changed shows a card beside the
|
|
215
108
|
// row: its +/− in this session, who made them and when. session.js decides when.
|
package/src/ui-server.js
CHANGED
|
@@ -1157,15 +1157,9 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
1157
1157
|
'GET /api/sessions/:id/voice/speech-stream': (b, id, url) => voiceSpeechStream(get(id), url.searchParams.get('line') || ''),
|
|
1158
1158
|
// The composer says while someone types (and stops when they clear it or send).
|
|
1159
1159
|
'POST /api/sessions/:id/typing': (b, id) => get(id).setTyping(b.on !== false, { to: b.to || null }),
|
|
1160
|
-
'POST /api/sessions/:id/claim': (b, id) => get(id).claim(b.pattern, b.note),
|
|
1161
|
-
'POST /api/sessions/:id/release': async (b, id) => ({ released: await get(id).release(b.pattern) }),
|
|
1162
|
-
'POST /api/sessions/:id/clear-claims': async (b, id) => ({ released: await get(id).clearInactiveClaims() }),
|
|
1163
|
-
'POST /api/sessions/:id/request-file': (b, id) => get(id).requestFile(b.path, { title: b.title, description: b.description }),
|
|
1164
1160
|
// Boxes (boxes.js): each one's change, for the people panel; and opening your own early (quilt_unpack).
|
|
1165
1161
|
'GET /api/sessions/:id/boxes': (b, id) => get(id).boxes(),
|
|
1166
1162
|
'POST /api/sessions/:id/unpack': async (b, id) => { const r = await get(id).unpack(Array.isArray(b.paths) ? b.paths : [b.path]); pushStatus(id); return r },
|
|
1167
|
-
'POST /api/sessions/:id/withdraw-request': async (b, id) => ({ withdrawn: await get(id).withdrawRequest(b.request) }),
|
|
1168
|
-
'POST /api/sessions/:id/handoff': (b, id) => get(id).handoff(b.path, { to: b.to, context: b.context }),
|
|
1169
1163
|
'POST /api/sessions/:id/attach-from-workspace': async (b, id) => {
|
|
1170
1164
|
const s = get(id)
|
|
1171
1165
|
const workspace = (readConfig(s.root) || {}).workspace
|
|
@@ -1250,6 +1244,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
1250
1244
|
return { on: r.run.session.setSummarize(b.on ? r.run.summarizer() : null) }
|
|
1251
1245
|
},
|
|
1252
1246
|
'POST /api/sessions/:id/sharing': (b, id) => ({ on: get(id).setAgentSharing(b.on !== false) }),
|
|
1247
|
+
// The owner's stale_write_minutes (held.js): how long a write may not remove lines someone else added (0: off).
|
|
1248
|
+
'POST /api/sessions/:id/stale-write': (b, id) => owned(id).setStaleWrite(b.minutes),
|
|
1253
1249
|
'POST /api/recent/forget': (b) => {
|
|
1254
1250
|
const dir = path.resolve(expandHome(String(b.dir || '')))
|
|
1255
1251
|
const room = readConfig(dir)?.room
|
package/src/release-words.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// What `quilt release` and quilt_release say about the relay's reply (Room.claimRequestOp 'release'):
|
|
2
|
-
// how many claims went, where, and why a path let go of nothing (task 7b480c8b07c4fa02: a release that
|
|
3
|
-
// said "released 0 claim(s)" while Quilt still said the file was held). Pure: no I/O.
|
|
4
|
-
|
|
5
|
-
const list = (xs) => xs.length === 1 ? xs[0] : `${xs.slice(0, -1).join(', ')} and ${xs[xs.length - 1]}`
|
|
6
|
-
|
|
7
|
-
/** r: { released, held?, seam? (claims are Seam's: layout 3), branches?, coveredBy?, holder?, yours? }; `cli`: the command to name (quilt release, or quilt_release). */
|
|
8
|
-
export function releaseWords (r, { cli = 'quilt release' } = {}) {
|
|
9
|
-
const n = (r && r.released) || 0
|
|
10
|
-
let s = `Released ${n} claim(s)${r && r.branches && r.branches.length ? ` (on ${list([...new Set(r.branches)])})` : ''}.`
|
|
11
|
-
if (r && r.coveredBy) {
|
|
12
|
-
s += r.yours
|
|
13
|
-
? ` That path is not a claim of its own: your claim on ${r.coveredBy} covers it. Let go of that with ${cli} ${r.coveredBy}.`
|
|
14
|
-
: ` That path is not a claim of its own: ${r.holder || 'someone'}'s claim on ${r.coveredBy} covers it; only they (or the session owner) can let go of it.`
|
|
15
|
-
}
|
|
16
|
-
if (r && r.held && r.held.length) s += ` Kept ${r.held.join(', ')}: someone is waiting for ${r.held.length === 1 ? 'it' : 'them'}; ${r.seam ? `hand it on in Seam with a note (seam claim handoff ${r.held[0]} --note "…")` : 'hand off with quilt_handoff'}.`
|
|
17
|
-
return s
|
|
18
|
-
}
|
package/src/seam-claims.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Letting go of claims in a session that is a quilt (layout 3): its claims are Seam's, and each
|
|
2
|
-
// member lets go of theirs in Seam as themselves (Session.releaseInSeam). The move into Seam made
|
|
3
|
-
// the session's claims as the member who moved it (Seam makes a claim only as its caller), so the
|
|
4
|
-
// relay keeps whose each was (`moved`, server.js quilt-claims): those are their claimant's to let
|
|
5
|
-
// go of, not the mover's, and the session owner may let go of any one named.
|
|
6
|
-
import { seamWhoAmI } from './seam-access.js'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Which of Seam's `claims` this member lets go of for `pattern` ('*': all of theirs): { release,
|
|
10
|
-
* notYours: [{ pattern, holder }] }. `me`: the member's Seam id; `moved`: the relay's records of the
|
|
11
|
-
* move's claims ({ id, by, mine }); `owner`: the session owner, who lets go of any claim it names.
|
|
12
|
-
*/
|
|
13
|
-
export function claimsToRelease ({ claims = [], me = '', moved = [], pattern = '*', owner = false }) {
|
|
14
|
-
const all = !pattern || pattern === '*'
|
|
15
|
-
const rec = new Map((moved || []).map((m) => [m.id, m]))
|
|
16
|
-
const release = []
|
|
17
|
-
const notYours = []
|
|
18
|
-
for (const c of claims || []) {
|
|
19
|
-
if (!c || c.conflict || (!all && c.pattern !== pattern)) continue
|
|
20
|
-
const m = rec.get(c.id)
|
|
21
|
-
const theirs = m ? !!m.mine : !!me && c.holder === me
|
|
22
|
-
if (theirs || (owner && !all)) release.push(c)
|
|
23
|
-
else if (!all) notYours.push({ pattern: c.pattern, holder: m ? `${m.by || 'someone'} (moved into Seam with the session)` : (c.holder_name || c.holder) })
|
|
24
|
-
}
|
|
25
|
-
return { release, notYours }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Lets go of this member's claims for `pattern` in Seam: `access` is the member's seamAccess (a
|
|
30
|
-
* person's sign-in, or an agent's key traded for a token that reaches the claims' squares); `asked`
|
|
31
|
-
* the relay's quilt-claims answer ({ moved, owner }). Resolves to { released, seam: true, held?,
|
|
32
|
-
* gone: [claim ids let go of] }; throws naming the holder when the one named is someone else's.
|
|
33
|
-
*/
|
|
34
|
-
export async function releaseInSeam ({ access, api, quilt, asked = {}, pattern = '*' }) {
|
|
35
|
-
const { client: reader, token } = await access.client(quilt, [], { read: true })
|
|
36
|
-
const me = await seamWhoAmI(api, token)
|
|
37
|
-
const got = await reader.claims(quilt)
|
|
38
|
-
const claims = Array.isArray(got) ? got : (got && got.claims) || []
|
|
39
|
-
const pick = claimsToRelease({ claims, me: (me && me.member_id) || '', moved: asked.moved, owner: !!asked.owner, pattern })
|
|
40
|
-
if (!pick.release.length && pick.notYours.length) throw new Error(`${pattern} is claimed by ${pick.notYours[0].holder}; only they can release it (or the session owner)`)
|
|
41
|
-
if (!pick.release.length) return { released: 0, seam: true, gone: [] }
|
|
42
|
-
const { client } = await access.client(quilt, [...new Set(pick.release.map((c) => c.square_id))])
|
|
43
|
-
const gone = []
|
|
44
|
-
const held = []
|
|
45
|
-
for (const c of pick.release) {
|
|
46
|
-
try { await client.unclaim(quilt, c.square_id, c.id); gone.push(c.id) } catch (err) {
|
|
47
|
-
if (err.code === 'claim_queued') { held.push(c.pattern); continue }
|
|
48
|
-
if (err.status === 404) { gone.push(c.id); continue } // let go of already
|
|
49
|
-
throw err
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return { released: gone.length, seam: true, gone, ...(held.length ? { held } : {}) }
|
|
53
|
-
}
|