heyquilt 0.3.174 → 0.3.176
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/README.md +6 -3
- package/RELEASES.md +30 -0
- package/bin/quilt.js +1 -75
- package/desktop/main.js +22 -9
- package/package.json +2 -3
- package/src/ai-vm.js +1 -1
- package/src/api/memory-store.js +1 -5
- package/src/api/server.js +4 -45
- package/src/api/supabase-store.js +0 -10
- package/src/autowork.js +7 -142
- package/src/base-pick.js +125 -12
- package/src/branch-view.js +1 -1
- package/src/connection.js +12 -37
- package/src/control.js +16 -93
- package/src/fsutil.js +1 -1
- package/src/git-aside.js +70 -0
- package/src/github-commit.js +1 -2
- package/src/gitstate.js +326 -0
- package/src/held.js +12 -53
- package/src/history.js +1 -25
- package/src/live-merge.js +42 -161
- package/src/mcp.js +6 -90
- package/src/merge3.js +21 -5
- package/src/pathrules.js +1 -1
- package/src/protocol.js +6 -11
- package/src/read-bases.js +3 -5
- package/src/relay-live-write.js +37 -44
- package/src/relay-mcp.js +30 -164
- package/src/relay-prune.js +3 -6
- package/src/relay-turn-sync.js +7 -11
- package/src/runner.js +2 -4
- package/src/server.js +61 -1717
- package/src/session.js +895 -844
- package/src/setup.js +11 -3
- package/src/status.js +2 -5
- package/src/swap-in.js +56 -13
- package/src/turn-sync-plan.js +2 -2
- package/src/turn-sync.js +1 -1
- package/src/ui/agent-guide.js +3 -1
- package/src/ui/app.css +4 -96
- package/src/ui/app.js +1 -1
- package/src/ui/chat.js +2 -6
- package/src/ui/cloud-ai-model.js +0 -13
- package/src/ui/cloud-ai.js +2 -10
- package/src/ui/connections.js +2 -1
- package/src/ui/fileview.js +7 -20
- package/src/ui/git-rule.js +2 -13
- package/src/ui/home.js +2 -8
- package/src/ui/session-words.js +27 -0
- package/src/ui/session.js +34 -407
- package/src/ui-server.js +7 -56
- package/src/api/routes/seam-connect.js +0 -103
- package/src/api/routes/session-migrate.js +0 -39
- package/src/force-date.js +0 -27
- package/src/quilt-default.js +0 -84
- package/src/quilt-history.js +0 -106
- package/src/quilt-remote.js +0 -78
- package/src/seam-access.js +0 -97
- package/src/seam-url.js +0 -15
- package/src/session-follow.js +0 -583
- package/src/session-layout3.js +0 -466
- package/src/session-migrate.js +0 -123
- package/src/session-quilt.js +0 -126
- package/src/session-seam.js +0 -312
- package/src/source-live/bring-in.js +0 -391
- package/src/source-live/land.js +0 -410
- package/src/source-live/live-block.js +0 -1166
- package/src/source-live/live-square.js +0 -116
- package/src/ui/force-words.js +0 -19
- package/src/ui/quiltview.js +0 -213
- package/src/ui/seam-model.js +0 -309
package/src/ui/session.js
CHANGED
|
@@ -15,7 +15,6 @@ import { feedbackDockHtml, bindFeedback } from './feedback.js'
|
|
|
15
15
|
import { conversations } from './feed-convs.js'
|
|
16
16
|
import { renderFileView, renderFileTabs } from './fileview.js'
|
|
17
17
|
import { rolledOff, diffLines } from './diffview.js'
|
|
18
|
-
import { searchMarkup, searchTabMarkup, liveByPerson, fileReadsNeeded, SEARCH_ICON } from './quiltview.js'
|
|
19
18
|
import { changesMarkup, bindChanges, unbindChanges, changesChanged, fileChanges, loadChanges, changedCount, unseenChanges, markChangesSeen } from './changes.js'
|
|
20
19
|
import { quiltMark } from './mark.js'
|
|
21
20
|
import { openSettings } from './home.js'
|
|
@@ -27,7 +26,7 @@ import { workspaceFilePicker } from './files.js'
|
|
|
27
26
|
import { sessionAgentsHtml } from './agent-place.js'
|
|
28
27
|
import { renderCatchUp, bindCatchUp } from './catchup.js'
|
|
29
28
|
import { boxSummary, boxesOf, unplaced, boxesSig, boxListHtml, boxFoldHtml } from './boxes.js'
|
|
30
|
-
import {
|
|
29
|
+
import { heldCard } from './session-words.js'
|
|
31
30
|
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards } from './voice.js'
|
|
32
31
|
|
|
33
32
|
let current = null // session id being shown
|
|
@@ -53,9 +52,7 @@ function ws (id) {
|
|
|
53
52
|
convSel: {}, // person -> pinned conversation id (absent: follow the newest)
|
|
54
53
|
fileTabs: [],
|
|
55
54
|
fileSel: null,
|
|
56
|
-
fileTab: {}, // file path -> 'changes'
|
|
57
|
-
searchTabs: [], // code searches open as tabs, in a session linked to a quilt (quiltview.js)
|
|
58
|
-
searchSel: null,
|
|
55
|
+
fileTab: {}, // file path -> 'changes' when that tab is shown (absent: the file)
|
|
59
56
|
expanded: {},
|
|
60
57
|
boxesCollapsed: false, // the Boxes pane (who is working on what) starts open; folded, it is a rail of boxes (rail.js)
|
|
61
58
|
stale: {}, // file path -> changed while not visible
|
|
@@ -136,7 +133,6 @@ export function mountSession (id) {
|
|
|
136
133
|
<button class="pop-item" role="menuitem" id="leave-btn">Leave this session</button>
|
|
137
134
|
</div>
|
|
138
135
|
</div>
|
|
139
|
-
<form class="qt-topsearch" id="qt-topsearch" role="search" hidden>${SEARCH_ICON}<input id="qt-topsearch-q" name="q" placeholder="Search the code on main" aria-label="Search the code on main" autocomplete="off" spellcheck="false"></form>
|
|
140
136
|
<span class="spacer"></span>
|
|
141
137
|
<span class="relay-problem" id="relay-problem" role="status" hidden></span>
|
|
142
138
|
<span class="access-pill" id="access-pill" hidden></span>
|
|
@@ -150,10 +146,8 @@ export function mountSession (id) {
|
|
|
150
146
|
<div class="popover people-menu" id="people-menu" role="dialog" aria-label="People in this session" hidden></div>
|
|
151
147
|
</div>
|
|
152
148
|
<div class="git-wrap" id="git-wrap">
|
|
153
|
-
<button type="button" class="git-chip quiet" id="git-chip" aria-haspopup="true" aria-expanded="false" aria-controls="git-panel"><span class="git-ico" aria-hidden="true">${I.branch}</span><span class="git-
|
|
154
|
-
<div class="popover git-panel" id="git-panel" role="dialog" aria-label="
|
|
155
|
-
<section class="git-sec branch-menu" id="branch-menu" hidden></section>
|
|
156
|
-
<section class="git-sec commit-panel" id="commit-panel" hidden></section>
|
|
149
|
+
<button type="button" class="git-chip quiet" id="git-chip" aria-haspopup="true" aria-expanded="false" aria-controls="git-panel"><span class="git-ico" aria-hidden="true">${I.branch}</span><span class="git-chg" id="git-chg" hidden>${I.diff}<span class="chg-count" id="chg-count"></span></span><span class="git-say" id="git-say" hidden></span><span class="sd" id="git-dot" hidden></span></button>
|
|
150
|
+
<div class="popover git-panel" id="git-panel" role="dialog" aria-label="Changes" hidden>
|
|
157
151
|
${changesMarkup()}
|
|
158
152
|
</div>
|
|
159
153
|
</div>
|
|
@@ -184,7 +178,7 @@ export function mountSession (id) {
|
|
|
184
178
|
</aside>
|
|
185
179
|
<main class="ws-main">
|
|
186
180
|
<div class="requests catchup" id="catchup" role="region" aria-label="While you were away" hidden></div>
|
|
187
|
-
<div class="requests
|
|
181
|
+
<div class="requests" id="held-card" role="status" aria-label="Open conflicts" hidden></div>
|
|
188
182
|
<div class="requests" id="requests" hidden></div>
|
|
189
183
|
<div class="ws-mainbar" id="mainbar" hidden>
|
|
190
184
|
<div class="ws-tabs" id="main-tabs" role="tablist"></div>
|
|
@@ -228,7 +222,6 @@ export function mountSession (id) {
|
|
|
228
222
|
bindCatchUp($('#catchup'), { sessionId: () => current, onOpen: openFile })
|
|
229
223
|
// Report a bug / Suggest a feature at the bottom of the Boxes pane (feedback.js): onto this session's board.
|
|
230
224
|
bindFeedback($('.ws-boxes'), { session: () => current, where: () => state.sessions.get(current)?.status?.sessionName || 'a session' })
|
|
231
|
-
bindSquareCard()
|
|
232
225
|
bindMain()
|
|
233
226
|
bindTreeEvents()
|
|
234
227
|
applyTreeCollapsed()
|
|
@@ -387,15 +380,6 @@ function bindMenu (btn, menu, onPick) {
|
|
|
387
380
|
}
|
|
388
381
|
|
|
389
382
|
function bindTop () {
|
|
390
|
-
$('#qt-topsearch').onsubmit = (e) => {
|
|
391
|
-
e.preventDefault()
|
|
392
|
-
const box = $('#qt-topsearch-q')
|
|
393
|
-
const q = box.value.trim()
|
|
394
|
-
if (!q) return
|
|
395
|
-
box.value = ''
|
|
396
|
-
box.blur()
|
|
397
|
-
openSearch(q)
|
|
398
|
-
}
|
|
399
383
|
$('#tasks-btn').onclick = () => {
|
|
400
384
|
const w = ws(current)
|
|
401
385
|
if (w.mode === 'tasks') w.mode = w.aiSel ? 'ai' : w.fileSel ? 'files' : 'ai'
|
|
@@ -415,23 +399,17 @@ function bindTop () {
|
|
|
415
399
|
if (!await ask({ title: 'Leave this session?', message: 'Quilt stops syncing this folder. Your files stay where they are, and you can rejoin later.', ok: 'Leave', danger: true })) return
|
|
416
400
|
await api('POST', `/api/sessions/${current}/stop`).catch((err) => toast(err.message))
|
|
417
401
|
}
|
|
418
|
-
// Settings (for every session) from in here: its Version control section starts with this session's git
|
|
419
|
-
//
|
|
402
|
+
// Settings (for every session) from in here: its Version control section starts with this session's git
|
|
403
|
+
// (git-rule.js thisSessionGitHtml).
|
|
420
404
|
$('#settings-btn').onclick = () => {
|
|
421
405
|
const st = sum().status
|
|
422
406
|
openSettings({
|
|
423
407
|
session: {
|
|
424
408
|
name: st.sessionName || basename(sum().dir),
|
|
425
|
-
value: st.agentCommits || 'branches',
|
|
426
|
-
rule: st.agentCommitsBy && st.agentCommitsBy.mode ? st.agentCommitsBy : null,
|
|
427
|
-
words: st.gitForEveryone && st.gitForEveryone.words,
|
|
428
|
-
// In Seam the card says so instead of git's choice (git-rule.js thisSessionGitHtml).
|
|
429
|
-
...(inSeam(st) ? { seam: st.quilt.slug || st.quilt.id } : {}),
|
|
430
409
|
open: (tab) => openSessionSettings(tab)
|
|
431
410
|
}
|
|
432
411
|
})
|
|
433
412
|
}
|
|
434
|
-
bindBranchMenu()
|
|
435
413
|
bindMenu($('#sess-btn'), $('#sess-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings(); if (e.target.closest('[data-gather-rules]')) openGatherRules() })
|
|
436
414
|
bindMenu($('#you-btn'), $('#you-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings() })
|
|
437
415
|
const wrap = $('#people')
|
|
@@ -485,7 +463,6 @@ function bindTop () {
|
|
|
485
463
|
|
|
486
464
|
/** The Session settings window's controls: your AI chat's sharing, and (for the owner) who can get in and what they may do. */
|
|
487
465
|
function bindSessionSettings (root) {
|
|
488
|
-
root.addEventListener('click', (e) => { const b = e.target.closest('[data-make-quilt]'); if (b) makeQuilt(b) })
|
|
489
466
|
root.addEventListener('change', async (e) => {
|
|
490
467
|
if (e.target.matches('[data-share]')) {
|
|
491
468
|
const on = e.target.checked
|
|
@@ -503,15 +480,6 @@ function bindSessionSettings (root) {
|
|
|
503
480
|
} catch (err) { toast(err.message); refreshPeople({ force: true }) }
|
|
504
481
|
return
|
|
505
482
|
}
|
|
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
|
-
}
|
|
515
483
|
if (!e.target.matches('[data-summarize]')) return
|
|
516
484
|
const on = e.target.checked
|
|
517
485
|
try {
|
|
@@ -631,86 +599,10 @@ function agentLine (p) {
|
|
|
631
599
|
return `<span class="ai-state">${a.tool ? `${esc(a.tool)} idle` : 'AI idle'}</span>`
|
|
632
600
|
}
|
|
633
601
|
|
|
634
|
-
// ------------------------------------------------------------- branches --
|
|
635
|
-
let squareBusy = '' // 'commit' or 'merge' while the square panel's button runs (layout 3)
|
|
636
|
-
|
|
637
|
-
function renderBranchMenu () {
|
|
638
|
-
const st = sum().status
|
|
639
|
-
const menu = $('#branch-menu')
|
|
640
|
-
// In Seam: the square this folder follows, and committing and merging it. The branch documents kept
|
|
641
|
-
// for a move back are read-only, and git is set aside here: none of them is listed.
|
|
642
|
-
if (inSeam(st)) {
|
|
643
|
-
menu.hidden = false
|
|
644
|
-
const html = squarePanelHtml(st, { busy: squareBusy })
|
|
645
|
-
if (menu.dataset.html === html) return
|
|
646
|
-
// A commit message being typed survives the redraw.
|
|
647
|
-
const typing = menu.querySelector('[data-square-commit] input')
|
|
648
|
-
const kept = typing ? { value: typing.value, focused: document.activeElement === typing } : null
|
|
649
|
-
menu.dataset.html = html
|
|
650
|
-
menu.innerHTML = html
|
|
651
|
-
const box = kept && menu.querySelector('[data-square-commit] input')
|
|
652
|
-
if (box) { box.value = kept.value; if (kept.focused) box.focus() }
|
|
653
|
-
return
|
|
654
|
-
}
|
|
655
|
-
delete menu.dataset.html
|
|
656
|
-
menu.hidden = true
|
|
657
|
-
menu.innerHTML = ''
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
/** The square panel's Commit and Merge onto main (layout 3): Seam's own tools, as this member (control.js seamTool). */
|
|
661
|
-
async function squareAct (tool, message = '') {
|
|
662
|
-
const id = current
|
|
663
|
-
squareBusy = tool === 'seam_merge' ? 'merge' : tool === 'open_square' ? 'open' : 'commit'
|
|
664
|
-
renderBranchMenu()
|
|
665
|
-
renderSquareCard()
|
|
666
|
-
try {
|
|
667
|
-
const r = await api('POST', `/api/sessions/${id}/seam`, { tool, args: message ? { message } : {} })
|
|
668
|
-
toast(r.text, 8000)
|
|
669
|
-
return true
|
|
670
|
-
} catch (err) { toast(err.message, 8000); return false } finally {
|
|
671
|
-
squareBusy = ''
|
|
672
|
-
if (id === current && !$('#git-panel').hidden) renderBranchMenu()
|
|
673
|
-
if (id === current) renderSquareCard()
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
function bindBranchMenu () {
|
|
678
|
-
const menu = $('#branch-menu')
|
|
679
|
-
menu.addEventListener('submit', async (e) => {
|
|
680
|
-
const form = e.target.closest('[data-square-commit]')
|
|
681
|
-
if (!form) return
|
|
682
|
-
e.preventDefault()
|
|
683
|
-
const input = form.querySelector('input')
|
|
684
|
-
const message = input.value.trim()
|
|
685
|
-
if (!message || squareBusy) return
|
|
686
|
-
if (await squareAct('seam_commit', message)) { input.value = ''; const now = menu.querySelector('[data-square-commit] input'); if (now) now.value = '' }
|
|
687
|
-
})
|
|
688
|
-
menu.addEventListener('click', async (e) => {
|
|
689
|
-
// Merge commits what isn't committed yet first: with the words typed in the box, if any.
|
|
690
|
-
if (e.target.closest('[data-square-open]')) { if (!squareBusy) squareAct('open_square'); return }
|
|
691
|
-
if (e.target.closest('[data-square-merge]')) { if (!squareBusy) squareAct('seam_merge', (menu.querySelector('[data-square-commit] input')?.value || '').trim()) }
|
|
692
|
-
})
|
|
693
|
-
}
|
|
694
|
-
|
|
695
602
|
function renderTop () {
|
|
696
603
|
if (!current || !$('#people-btn')) return
|
|
697
604
|
renderTabs()
|
|
698
605
|
const st = sum().status
|
|
699
|
-
// Code search, only in a session linked to a quilt (the relay reads Seam for it).
|
|
700
|
-
const search = $('#qt-topsearch')
|
|
701
|
-
if (search) search.hidden = !st.quilt
|
|
702
|
-
const label = $('#git-branch')
|
|
703
|
-
const seam = inSeam(st) ? seamChip(st) : null
|
|
704
|
-
if (label && seam) {
|
|
705
|
-
// In Seam: the square this folder follows, by the name Seam gives it.
|
|
706
|
-
label.hidden = !seam.label
|
|
707
|
-
label.innerHTML = seam.label ? `<span class="branch-name">${esc(seam.label)}</span>` : ''
|
|
708
|
-
label.dataset.title = seam.title
|
|
709
|
-
if (!$('#git-panel').hidden) renderBranchMenu()
|
|
710
|
-
} else if (label) {
|
|
711
|
-
label.hidden = true
|
|
712
|
-
label.innerHTML = ''
|
|
713
|
-
}
|
|
714
606
|
const people = [st.me, ...peopleHere(st)]
|
|
715
607
|
const shown = people.slice(0, 4)
|
|
716
608
|
$('#people-btn').innerHTML = `<span class="stack">${shown.map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>
|
|
@@ -727,7 +619,7 @@ function renderTop () {
|
|
|
727
619
|
renderCall()
|
|
728
620
|
renderAccess()
|
|
729
621
|
renderCatchUp($('#catchup'), st.catchUp, { colors: new Map([st.me, ...st.peers].map((p) => [p.name, p.color])) })
|
|
730
|
-
|
|
622
|
+
renderHeldCard()
|
|
731
623
|
renderGitChip()
|
|
732
624
|
$('#sess-name').textContent = st.sessionName || basename(sum().dir)
|
|
733
625
|
const me = state.account || {}
|
|
@@ -741,16 +633,15 @@ function renderTop () {
|
|
|
741
633
|
}
|
|
742
634
|
|
|
743
635
|
// --------------------------------------------------------------- source control --
|
|
744
|
-
// The chip in the top bar:
|
|
745
|
-
// (the panel commits and merges it); otherwise how many files changed in the session.
|
|
636
|
+
// The chip in the top bar: how many files changed in the session. Its panel lists them.
|
|
746
637
|
|
|
747
|
-
/** Opens or closes the source control panel:
|
|
638
|
+
/** Opens or closes the source control panel: what changed in the session. */
|
|
748
639
|
function setGitOpen (open) {
|
|
749
640
|
const panel = $('#git-panel')
|
|
750
641
|
if (!panel) return
|
|
751
642
|
panel.hidden = !open
|
|
752
643
|
$('#git-chip').setAttribute('aria-expanded', String(open))
|
|
753
|
-
if (open) { markChangesSeen();
|
|
644
|
+
if (open) { markChangesSeen(); loadChanges().then(() => { if (!panel.hidden) markChangesSeen() }) }
|
|
754
645
|
}
|
|
755
646
|
|
|
756
647
|
function bindCommitChip () {
|
|
@@ -761,109 +652,33 @@ function bindCommitChip () {
|
|
|
761
652
|
document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target) && !e.target.closest('.modal, .dialog')) setGitOpen(false) }, { signal: mounted.signal })
|
|
762
653
|
}
|
|
763
654
|
|
|
764
|
-
/** The source control chip:
|
|
655
|
+
/** The source control chip: how many files changed in the session. */
|
|
765
656
|
function renderGitChip () {
|
|
766
657
|
const chip = $('#git-chip')
|
|
767
658
|
if (!chip || !sum()) return
|
|
768
|
-
const st = sum().status
|
|
769
659
|
chip.className = 'git-chip quiet'
|
|
770
660
|
$('#git-say').hidden = true
|
|
771
661
|
$('#git-dot').hidden = true
|
|
772
|
-
const branch = $('#git-branch')
|
|
773
|
-
const seam = inSeam(st) ? seamChip(st) : null
|
|
774
|
-
// In Seam the session's own record of changes stopped at the switch (its branch document is kept read-only):
|
|
775
|
-
// the number is the square's work not committed yet, and the panel lists that instead.
|
|
776
|
-
const chg = $('#chg-panel')
|
|
777
|
-
if (chg) chg.hidden = !!seam
|
|
778
|
-
if (seam) {
|
|
779
|
-
$('#chg-count').textContent = seam.count
|
|
780
|
-
$('#git-chg').hidden = !seam.count
|
|
781
|
-
$('#git-sep').hidden = branch.hidden || !seam.count
|
|
782
|
-
chip.title = [seam.title, seam.countLine, 'Click for your square.'].filter(Boolean).join('\n')
|
|
783
|
-
chip.setAttribute('aria-label', seam.aria)
|
|
784
|
-
$('#git-panel').setAttribute('aria-label', 'Square')
|
|
785
|
-
return
|
|
786
|
-
}
|
|
787
662
|
const n = changedCount()
|
|
788
663
|
const fresh = unseenChanges()
|
|
789
664
|
$('#chg-count').textContent = n
|
|
790
665
|
$('#git-chg').hidden = !n
|
|
791
|
-
$('#git-sep').hidden = branch.hidden || !n
|
|
792
|
-
$('#git-panel').setAttribute('aria-label', 'Changes')
|
|
793
666
|
chip.title = [n ? `${n} changed in the session` : '', fresh ? `${fresh} new since you last looked` : '', 'Click for every change.'].filter(Boolean).join('\n')
|
|
794
667
|
chip.setAttribute('aria-label', `Source control${n ? `, ${n} changed` : ''}`)
|
|
795
668
|
}
|
|
796
669
|
|
|
797
|
-
/**
|
|
798
|
-
function
|
|
799
|
-
const
|
|
800
|
-
if (!panel) return
|
|
801
|
-
panel.hidden = true
|
|
802
|
-
panel.innerHTML = ''
|
|
803
|
-
delete panel.dataset.html
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* "Make this a quilt" (Seam's plans/quilt-source-control/16, flag 9), for the session's owner while its
|
|
808
|
-
* code is not in Seam yet: one button. With no git remote the relay makes the quilt and moves the files
|
|
809
|
-
* into its squares at once; with one, it becomes a quilt with its history (makeQuiltWords).
|
|
810
|
-
*/
|
|
811
|
-
function makeQuiltHtml (st) {
|
|
812
|
-
if (inSeam(st)) return ''
|
|
813
|
-
// Everyone hears that live sync stopped at the forced date; only the owner gets the button.
|
|
814
|
-
if (!st.access?.owner) return st.force && st.force.stopped ? `<div class="pm-section"><div class="pm-title">Seam</div><div class="pm-card git-card"><p class="git-line warn">${esc(st.force.stopped.why || '')}</p></div></div>` : ''
|
|
815
|
-
const words = makeQuiltWords({ quilt: st.quilt || null, remote: !!(st.quilt && st.quilt.hasRemote) || !!(st.force && (st.force.remote || st.force.stopped)), moving: !!st.moving, force: st.force || null, importing: st.importing || null, shadow: st.shadow || null })
|
|
816
|
-
return `<div class="pm-section"><div class="pm-title">Seam</div><div class="pm-card git-card">
|
|
817
|
-
<div class="git-head"><h4>Make this a quilt</h4><span class="pill">Seam</span></div>
|
|
818
|
-
${words.note ? `<p class="git-line warn">${esc(words.note)}</p>` : ''}
|
|
819
|
-
<p class="git-line">${esc(words.text)}</p>
|
|
820
|
-
${makeQuiltSteps ? `<div class="git-line"><p>${esc(makeQuiltSteps[0])}</p>${makeQuiltSteps.length > 1 ? `<ol>${makeQuiltSteps.slice(1).map((l) => `<li>${esc(l.replace(/^\d+\. /, ''))}</li>`).join('')}</ol>` : ''}</div>` : ''}
|
|
821
|
-
<button type="button" class="btn primary" data-make-quilt ${words.disabled ? 'disabled' : ''}>${esc(words.button)}</button>
|
|
822
|
-
</div></div>`
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
/** The last answer's steps (lines), shown on the card: what the owner or the repository's GitHub owner does next. */
|
|
826
|
-
let makeQuiltSteps = null
|
|
827
|
-
|
|
828
|
-
async function makeQuilt (btn) {
|
|
829
|
-
makeQuiltSteps = null
|
|
830
|
-
btn.disabled = true
|
|
831
|
-
btn.textContent = 'Moving into Seam…'
|
|
832
|
-
try {
|
|
833
|
-
const r = await api('POST', `/api/sessions/${current}/quilt-make`, {})
|
|
834
|
-
const lines = String(r.text || 'The session is a quilt now.').split('\n')
|
|
835
|
-
// Steps for someone to take (the GitHub owner's ruleset) stay on the card until the next click; a plain answer is a toast.
|
|
836
|
-
if (lines.length > 2 && r.quilt && r.quilt.stage) makeQuiltSteps = lines
|
|
837
|
-
toast(lines[0])
|
|
838
|
-
} catch (err) {
|
|
839
|
-
const lines = String(err.message).split('\n')
|
|
840
|
-
if (lines.length > 1) makeQuiltSteps = lines
|
|
841
|
-
toast(lines[0])
|
|
842
|
-
} finally { renderSessionSettings({ force: true }) }
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* In a session that is a quilt at layout 3: one plain line on where this folder's work goes (the
|
|
847
|
-
* square it follows, and how to commit it; session-follow.js), or why an edit reached nobody.
|
|
848
|
-
*/
|
|
849
|
-
function renderSquareCard () {
|
|
850
|
-
const el = $('#square-card')
|
|
670
|
+
/** The card above the main area while the session has open held conflicts (session-words.js heldCard): said until an AI resolves them. */
|
|
671
|
+
function renderHeldCard () {
|
|
672
|
+
const el = $('#held-card')
|
|
851
673
|
if (!el) return
|
|
852
|
-
const
|
|
853
|
-
const card = squareCard(st)
|
|
674
|
+
const card = heldCard(sum().status)
|
|
854
675
|
el.hidden = !card
|
|
855
|
-
const html = card ? `<div class="gh-card"><div class="gh-text"><b>${esc(card.title)}</b><span>${esc(card.text)}</span></div
|
|
676
|
+
const html = card ? `<div class="gh-card"><div class="gh-text"><b>${esc(card.title)}</b><span>${esc(card.text)}</span></div></div>` : ''
|
|
856
677
|
if (el._html === html) return
|
|
857
678
|
el._html = html
|
|
858
679
|
el.innerHTML = html
|
|
859
680
|
}
|
|
860
681
|
|
|
861
|
-
/** The square card's button: a folder whose branch has no square opens one (layout 3). */
|
|
862
|
-
function bindSquareCard () {
|
|
863
|
-
const el = $('#square-card')
|
|
864
|
-
if (el) el.addEventListener('click', (e) => { if (e.target.closest('[data-square-open]') && !squareBusy) squareAct('open_square') })
|
|
865
|
-
}
|
|
866
|
-
|
|
867
682
|
// ----------------------------------------------------------------- access --
|
|
868
683
|
const roleLabel = (r) => r === 'owner' ? 'Owner' : r === 'viewer' ? 'View only' : 'Can edit'
|
|
869
684
|
const scopesText = (scopes) => (scopes || []).join(', ')
|
|
@@ -1243,20 +1058,15 @@ function renderBoxesSide () {
|
|
|
1243
1058
|
if (!el || !s) return
|
|
1244
1059
|
const st = s.status
|
|
1245
1060
|
const { selfRow, myAiRow, otherRows, awayRows } = peopleRows(st, { fold: true })
|
|
1246
|
-
|
|
1247
|
-
const seam = inSeam(st)
|
|
1248
|
-
const title = el.closest('.ws-boxes')?.querySelector('.pane-title')
|
|
1249
|
-
if (title) title.textContent = seam ? 'Squares' : 'Boxes'
|
|
1250
|
-
el.closest('.ws-boxes')?.setAttribute('aria-label', seam ? 'Squares: who is on which, and what is not committed' : 'Boxes: who is working on what')
|
|
1251
|
-
const n = seam ? 0 : boxView.data.boxes.length
|
|
1061
|
+
const n = boxView.data.boxes.length
|
|
1252
1062
|
const count = $('#box-count')
|
|
1253
1063
|
if (count) { count.textContent = n ? String(n) : ''; count.title = n ? `${n} file${n === 1 ? '' : 's'} boxed: changed, not in everyone's folder yet` : '' }
|
|
1254
|
-
const html =
|
|
1064
|
+
const html = `<div class="pm-list bs-list">
|
|
1255
1065
|
${selfRow}${myAiRow}
|
|
1256
1066
|
${otherRows}
|
|
1257
1067
|
${awayRows.length ? `<div class="pm-sep"></div><div class="bs-head">Away</div>${awayRows.join('')}` : ''}
|
|
1258
1068
|
</div>
|
|
1259
|
-
<p class="bs-hint">${
|
|
1069
|
+
<p class="bs-hint">${boxView.data.on ? 'A box is a file someone is changing that isn\'t in everyone\'s folder yet. Click someone\'s boxes to see the files, and a file to see its change.' : 'What everyone is working on. Their unfinished files show here as boxes.'}</p>`
|
|
1260
1070
|
if (el.dataset.html === html) return
|
|
1261
1071
|
const top = el.scrollTop
|
|
1262
1072
|
el.innerHTML = html
|
|
@@ -1325,7 +1135,6 @@ async function openGatherRules () {
|
|
|
1325
1135
|
// Session settings: one window, a section at a time, picked from the list on its left.
|
|
1326
1136
|
const SS_TABS = [
|
|
1327
1137
|
{ id: 'chat', label: 'Your AI chat', icon: 'chat' },
|
|
1328
|
-
{ id: 'vc', label: 'Version control', icon: 'branch' },
|
|
1329
1138
|
{ id: 'agents', label: 'Agents', icon: 'bot' },
|
|
1330
1139
|
{ id: 'people', label: 'People', icon: 'users' },
|
|
1331
1140
|
// Secrets (secrets.js): only once the accounts API has them switched on.
|
|
@@ -1428,16 +1237,10 @@ function renderSessionSettings ({ force = false } = {}) {
|
|
|
1428
1237
|
if (ssConnections) { ssConnections.destroy(); ssConnections = null }
|
|
1429
1238
|
// Don't redraw under the owner while they change someone's access (unless fresh grants
|
|
1430
1239
|
// 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
|
|
1433
1240
|
const active = box.contains(document.activeElement) && document.activeElement.closest('.pm-member') ? document.activeElement : null
|
|
1434
1241
|
if (!force && active && box.querySelector('.pm-member.edit')) return
|
|
1435
1242
|
const refocus = active && active.name ? [active.closest('.pm-member').dataset.key, active.name] : null
|
|
1436
|
-
|
|
1437
|
-
const vc = inSeam(st) ? seamSettingsHtml(st) : makeQuiltHtml(st)
|
|
1438
|
-
box.innerHTML = ssTab === 'chat' ? sharingHtml(st)
|
|
1439
|
-
: ssTab === 'vc' ? (vc || '<div class="pm-empty">Only the session owner sees where this session\'s history is.</div>') + staleWriteHtml(st)
|
|
1440
|
-
: membersHtml(st, ssTab)
|
|
1243
|
+
box.innerHTML = ssTab === 'chat' ? sharingHtml(st) : membersHtml(st, ssTab)
|
|
1441
1244
|
if (refocus) [...box.querySelectorAll('.pm-member')].find((f) => f.dataset.key === refocus[0])?.elements?.[refocus[1]]?.focus()
|
|
1442
1245
|
}
|
|
1443
1246
|
|
|
@@ -1448,12 +1251,6 @@ function bindMain () {
|
|
|
1448
1251
|
const tab = e.target.closest('[data-tab]')
|
|
1449
1252
|
const w = ws(current)
|
|
1450
1253
|
if (tab && tab.dataset.kind === 'loom') { openLoom(); return }
|
|
1451
|
-
if (close && close.dataset.kind === 'search') {
|
|
1452
|
-
e.stopPropagation()
|
|
1453
|
-
closeSearch(close.dataset.close)
|
|
1454
|
-
return
|
|
1455
|
-
}
|
|
1456
|
-
if (tab && tab.dataset.kind === 'search') { openSearch(tab.dataset.tab); return }
|
|
1457
1254
|
if (close) {
|
|
1458
1255
|
e.stopPropagation()
|
|
1459
1256
|
const key = close.dataset.close
|
|
@@ -1492,23 +1289,6 @@ function bindMain () {
|
|
|
1492
1289
|
if (c) pickConv(c.dataset.conv)
|
|
1493
1290
|
const t = e.target.closest('[data-fvtab]')
|
|
1494
1291
|
if (t) showFileTab(t.dataset.fvtab)
|
|
1495
|
-
// A file's History and Blame, and search hits, in a session linked to a quilt.
|
|
1496
|
-
const qp = e.target.closest('[data-qt-patch]')
|
|
1497
|
-
if (qp) togglePatch(ws(current).fileSel, qp.dataset.qtPatch)
|
|
1498
|
-
const qb = e.target.closest('[data-qt-blame]')
|
|
1499
|
-
if (qb) showPatch(ws(current).fileSel, qb.dataset.qtBlame)
|
|
1500
|
-
const qf = e.target.closest('[data-qt-file]')
|
|
1501
|
-
if (qf) openFile(qf.dataset.qtFile, { tab: 'changes' })
|
|
1502
|
-
const qh = e.target.closest('[data-qt-hit]')
|
|
1503
|
-
if (qh) openFile(qh.dataset.qtHit, { tab: 'file', line: Number(qh.dataset.line) || null })
|
|
1504
|
-
})
|
|
1505
|
-
// Searching again from a search tab's own field.
|
|
1506
|
-
$('#main').addEventListener('submit', (e) => {
|
|
1507
|
-
const form = e.target.closest('[data-qt-search-form]')
|
|
1508
|
-
if (!form) return
|
|
1509
|
-
e.preventDefault()
|
|
1510
|
-
const q = String(new FormData(form).get('q') || '').trim()
|
|
1511
|
-
if (q) openSearch(q, { replace: ws(current).searchSel })
|
|
1512
1292
|
})
|
|
1513
1293
|
}
|
|
1514
1294
|
|
|
@@ -1548,19 +1328,15 @@ function pickConv (conv) {
|
|
|
1548
1328
|
renderMain()
|
|
1549
1329
|
}
|
|
1550
1330
|
|
|
1551
|
-
/** Opens a file tab; `tab: 'changes'` shows its Changes tab, otherwise the tab it was on.
|
|
1552
|
-
function openFile (path, { tab
|
|
1331
|
+
/** Opens a file tab; `tab: 'changes'` shows its Changes tab, otherwise the tab it was on. */
|
|
1332
|
+
function openFile (path, { tab } = {}) {
|
|
1553
1333
|
const w = ws(current)
|
|
1554
1334
|
if (!w.fileTabs.includes(path)) w.fileTabs.push(path)
|
|
1555
1335
|
w.fileSel = path
|
|
1556
1336
|
w.mode = 'files'
|
|
1557
1337
|
if (!w.fileTab) w.fileTab = {}
|
|
1558
1338
|
if (tab === 'changes') w.fileTab[path] = 'changes'
|
|
1559
|
-
else if (tab === 'file') delete w.fileTab[path]
|
|
1560
|
-
if (line) goLine.set(fileKey(path), line)
|
|
1561
|
-
else goLine.delete(fileKey(path))
|
|
1562
1339
|
loadHistory(path)
|
|
1563
|
-
if (fileTabOf(path) === 'blame') loadBlame(path)
|
|
1564
1340
|
const wasStale = w.stale[path]
|
|
1565
1341
|
delete w.stale[path]
|
|
1566
1342
|
saveWs(current)
|
|
@@ -1591,12 +1367,10 @@ function renderMainBar () {
|
|
|
1591
1367
|
}).join('') + (w.fileTabs.length ? '<span class="ws-tab-sep"></span>' : '') +
|
|
1592
1368
|
w.fileTabs.map((path) => `<div class="ws-tab${fileOn(path) ? ' on' : ''}" role="tab" aria-selected="${fileOn(path)}" tabindex="0" data-kind="file" data-tab="${esc(path)}" title="${esc(path)}">
|
|
1593
1369
|
<span class="ico">${I.file}</span><span class="nm">${esc(basename(path))}</span>${w.stale[path] ? '<span class="changed" title="Changed"></span>' : ''}
|
|
1594
|
-
<button class="x" data-kind="file" data-close="${esc(path)}" aria-label="Close ${esc(basename(path))}">${I.x}</button></div>`).join('')
|
|
1595
|
-
((w.searchTabs || []).length && !w.fileTabs.length ? '<span class="ws-tab-sep"></span>' : '') +
|
|
1596
|
-
(w.searchTabs || []).map((q) => searchTabMarkup(q, w.mode === 'search' && w.searchSel === q)).join('')
|
|
1370
|
+
<button class="x" data-kind="file" data-close="${esc(path)}" aria-label="Close ${esc(basename(path))}">${I.x}</button></div>`).join('')
|
|
1597
1371
|
// On Everyone with nothing else open, the row would only name the view you are in: hide it until
|
|
1598
1372
|
// there is a tab to switch to (or, on the Tasks board, Everyone to go back to).
|
|
1599
|
-
$('#mainbar').hidden = loomOn && !w.aiTabs.length && !w.fileTabs.length
|
|
1373
|
+
$('#mainbar').hidden = loomOn && !w.aiTabs.length && !w.fileTabs.length
|
|
1600
1374
|
}
|
|
1601
1375
|
|
|
1602
1376
|
// A card being renamed, or a drag in progress, must not be rebuilt under the pointer.
|
|
@@ -2237,18 +2011,7 @@ function renderMain () {
|
|
|
2237
2011
|
</div>`
|
|
2238
2012
|
return
|
|
2239
2013
|
}
|
|
2240
|
-
if (w.mode
|
|
2241
|
-
if (w.mode === 'search' && !(w.searchSel && (w.searchTabs || []).includes(w.searchSel))) w.mode = w.fileSel ? 'files' : 'ai'
|
|
2242
|
-
if (w.mode === 'search') {
|
|
2243
|
-
if (!searches.has(`${current}\n${w.searchSel}`)) loadSearch(w.searchSel) // a tab put back after a reload
|
|
2244
|
-
const html = searchMarkup({ q: w.searchSel, result: searches.get(`${current}\n${w.searchSel}`) || null })
|
|
2245
|
-
// Status ticks redraw the main area: an unchanged search keeps its field, focus and scroll.
|
|
2246
|
-
if (el.firstElementChild && el.firstElementChild.classList.contains('qt-search') && el.dataset.qtSearch === html) return
|
|
2247
|
-
el.innerHTML = html
|
|
2248
|
-
el.dataset.qtSearch = html
|
|
2249
|
-
return
|
|
2250
|
-
}
|
|
2251
|
-
delete el.dataset.qtSearch
|
|
2014
|
+
if (w.mode !== 'ai' && w.mode !== 'files') w.mode = w.fileSel ? 'files' : 'ai' // a kind of tab an older app saved that this one doesn't have
|
|
2252
2015
|
if (w.mode === 'ai') {
|
|
2253
2016
|
if (!w.aiSel) {
|
|
2254
2017
|
const people = st.peers
|
|
@@ -2281,17 +2044,14 @@ function renderMain () {
|
|
|
2281
2044
|
} else {
|
|
2282
2045
|
if (!w.fileSel) {
|
|
2283
2046
|
el.innerHTML = `<div class="main-empty"><div class="ill">${I.file}</div><h3>Open a file</h3>
|
|
2284
|
-
<p class="hint"
|
|
2047
|
+
<p class="hint">Open one from the git panel's changes, or a box's change from the Boxes list. Lines your partners change light up as they happen.</p></div>`
|
|
2285
2048
|
return
|
|
2286
2049
|
}
|
|
2287
2050
|
const cached = state.files.get(fileKey(w.fileSel))
|
|
2288
2051
|
if (!cached) loadFileOnce(w.fileSel) // a tab put back after a reload has nothing read yet
|
|
2289
|
-
// A tab put back after a reload
|
|
2052
|
+
// A tab put back after a reload has its changes to read too, unless they are being read already.
|
|
2290
2053
|
const fk = fileKey(w.fileSel)
|
|
2291
|
-
|
|
2292
|
-
if (need === 'history') loadHistory(w.fileSel)
|
|
2293
|
-
else loadBlame(w.fileSel)
|
|
2294
|
-
}
|
|
2054
|
+
if (histories.get(fk) === undefined && !historyLoads.has(fk)) loadHistory(w.fileSel)
|
|
2295
2055
|
renderFileView(el, {
|
|
2296
2056
|
path: w.fileSel,
|
|
2297
2057
|
file: cached ? cached.file : null,
|
|
@@ -2300,8 +2060,6 @@ function renderMain () {
|
|
|
2300
2060
|
prevText: cached ? cached.prevText : null,
|
|
2301
2061
|
tab: fileTabOf(w.fileSel),
|
|
2302
2062
|
history: histories.get(fileKey(w.fileSel)) || null,
|
|
2303
|
-
quilt: quiltFileView(w.fileSel),
|
|
2304
|
-
line: takeLine(w.fileSel, cached),
|
|
2305
2063
|
summary: fileChanges(w.fileSel),
|
|
2306
2064
|
people: { who: (name) => name === me() ? 'you' : name, colorOf: (name) => personInfo(name).color },
|
|
2307
2065
|
chatHref: treeMeta(w.fileSel)?.chat ? fileCardHref(current, treeMeta(w.fileSel).chat.id, TOKEN) : null,
|
|
@@ -2314,147 +2072,18 @@ function renderMain () {
|
|
|
2314
2072
|
/** Links to a session's file bytes for the preview, or to download them (GET /api/sessions/<id>/raw). */
|
|
2315
2073
|
const rawHrefFor = (id) => (path, download = false) => `/api/sessions/${encodeURIComponent(id)}/raw?path=${encodeURIComponent(path)}&t=${encodeURIComponent(TOKEN || '')}${download ? '&download=1' : ''}`
|
|
2316
2074
|
const fileKey = (path) => `${current}\n${path}`
|
|
2317
|
-
const fileTabOf = (path) => {
|
|
2318
|
-
const t = (ws(current).fileTab || {})[path]
|
|
2319
|
-
return t === 'changes' ? 'changes' : t === 'blame' && quiltLinked() ? 'blame' : 'file'
|
|
2320
|
-
}
|
|
2075
|
+
const fileTabOf = (path) => (ws(current).fileTab || {})[path] === 'changes' ? 'changes' : 'file'
|
|
2321
2076
|
|
|
2322
2077
|
function showFileTab (tab) {
|
|
2323
2078
|
const w = ws(current)
|
|
2324
2079
|
if (!w.fileSel) return
|
|
2325
2080
|
if (!w.fileTab) w.fileTab = {}
|
|
2326
|
-
if (tab === 'changes'
|
|
2081
|
+
if (tab === 'changes') w.fileTab[w.fileSel] = tab
|
|
2327
2082
|
else delete w.fileTab[w.fileSel]
|
|
2328
2083
|
saveWs(current)
|
|
2329
2084
|
renderMain()
|
|
2330
2085
|
$('#main .fv-tabs [aria-selected="true"]')?.focus()
|
|
2331
2086
|
if (tab === 'changes') loadHistory(w.fileSel)
|
|
2332
|
-
if (tab === 'blame') loadBlame(w.fileSel)
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
// ------------------------------------- History, Blame and search (a linked quilt) --
|
|
2336
|
-
// In a session linked to a quilt (Seam), the relay reads it for the app: a file's patches, who
|
|
2337
|
-
// wrote each line, and code search over main (src/server.js quiltBlame, quiltSearch, quiltShow).
|
|
2338
|
-
const quiltLinked = () => !!sum().status.quilt
|
|
2339
|
-
const patchLists = new Map() // fileKey -> { patches, quilt, note } (absent: the session isn't linked)
|
|
2340
|
-
const openPatches = new Map() // fileKey -> the History row opened: a commit, or live:<name>
|
|
2341
|
-
const patchData = new Map() // `${session}\n${commit}\n${path}` -> { files, diff } or { error }
|
|
2342
|
-
const blames = new Map() // fileKey -> the relay's blame answer
|
|
2343
|
-
const blameTimers = new Map()
|
|
2344
|
-
const searches = new Map() // `${session}\n${q}` -> the relay's search answer
|
|
2345
|
-
const goLine = new Map() // fileKey -> a line to bring into view once (a search hit)
|
|
2346
|
-
|
|
2347
|
-
/** What the file view shows of a linked file's History and Blame, or null when the session isn't linked. */
|
|
2348
|
-
function quiltFileView (path) {
|
|
2349
|
-
if (!quiltLinked()) return null
|
|
2350
|
-
const list = patchLists.get(fileKey(path)) || { patches: null, quilt: sum().status.quilt }
|
|
2351
|
-
const open = openPatches.get(fileKey(path)) || null
|
|
2352
|
-
const live = liveByPerson(histories.get(fileKey(path)) || [])
|
|
2353
|
-
return {
|
|
2354
|
-
...list,
|
|
2355
|
-
open,
|
|
2356
|
-
shown: open && !open.startsWith('live:') ? patchData.get(`${current}\n${open}\n${path}`) || null : null,
|
|
2357
|
-
blame: blames.get(fileKey(path)) || null,
|
|
2358
|
-
liveBy: live.length ? live[0].by : (treeMeta(path)?.edited?.by || '')
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
/** The line a search hit opened the file at, given once its text is there. */
|
|
2363
|
-
function takeLine (path, cached) {
|
|
2364
|
-
const line = goLine.get(fileKey(path))
|
|
2365
|
-
if (!line || !cached || !cached.file || fileTabOf(path) !== 'file') return null
|
|
2366
|
-
goLine.delete(fileKey(path))
|
|
2367
|
-
return line
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
/** Opens or closes a row of a file's History; a patch's diff is read the first time. */
|
|
2371
|
-
function togglePatch (path, which) {
|
|
2372
|
-
if (!path) return
|
|
2373
|
-
const key = fileKey(path)
|
|
2374
|
-
if (openPatches.get(key) === which) openPatches.delete(key)
|
|
2375
|
-
else openPatches.set(key, which)
|
|
2376
|
-
renderMain()
|
|
2377
|
-
if (openPatches.get(key) === which && !which.startsWith('live:')) loadPatch(path, which)
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
/** Blame's patch number: that patch, opened in the file's History. */
|
|
2381
|
-
function showPatch (path, commit) {
|
|
2382
|
-
if (!path) return
|
|
2383
|
-
openPatches.set(fileKey(path), commit)
|
|
2384
|
-
showFileTab('changes')
|
|
2385
|
-
loadPatch(path, commit)
|
|
2386
|
-
requestAnimationFrame(() => $('#main .qt-patch.on')?.scrollIntoView({ block: 'nearest' }))
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
async function loadPatch (path, commit) {
|
|
2390
|
-
const id = current
|
|
2391
|
-
const k = `${id}\n${commit}\n${path}`
|
|
2392
|
-
if (patchData.has(k)) return
|
|
2393
|
-
let shown
|
|
2394
|
-
try {
|
|
2395
|
-
const r = await api('GET', `/api/sessions/${id}/patch?commit=${encodeURIComponent(commit)}&path=${encodeURIComponent(path)}`)
|
|
2396
|
-
shown = r.patch ? r.patch : r.working ? null : { error: r.quilt === null ? 'This session is no longer linked to a quilt.' : 'Seam did not send this patch.' }
|
|
2397
|
-
if (!shown) { setTimeout(() => { if (id === current && openPatches.get(`${id}\n${path}`) === commit) loadPatch(path, commit) }, 2000); return }
|
|
2398
|
-
} catch (err) { shown = { error: err.message } }
|
|
2399
|
-
patchData.set(k, shown)
|
|
2400
|
-
if (id === current && ws(id).fileSel === path && fileTabOf(path) === 'changes') renderMain()
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
/** Who wrote each line of a file: asked again every 2 s while Seam works it out the first time. */
|
|
2404
|
-
async function loadBlame (path, tries = 0) {
|
|
2405
|
-
const id = current
|
|
2406
|
-
const key = fileKey(path)
|
|
2407
|
-
clearTimeout(blameTimers.get(key))
|
|
2408
|
-
if (!blames.has(key)) blames.set(key, null) // being read
|
|
2409
|
-
let r
|
|
2410
|
-
try { r = await api('GET', `/api/sessions/${id}/blame?path=${encodeURIComponent(path)}`) } catch (err) { r = { error: err.message } }
|
|
2411
|
-
if (id !== current) return
|
|
2412
|
-
if (r.quilt === null) r = { error: 'This session is no longer linked to a quilt.' }
|
|
2413
|
-
blames.set(key, r)
|
|
2414
|
-
if (r.working && tries < 60) blameTimers.set(key, setTimeout(() => { if (id === current && ws(id).fileSel === path && fileTabOf(path) === 'blame') loadBlame(path, tries + 1) }, 2000))
|
|
2415
|
-
if (ws(id).fileSel === path && fileTabOf(path) === 'blame') renderMain()
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
/** Opens a code search as a tab (in place of `replace`, a search searched again from its own field). */
|
|
2419
|
-
async function openSearch (q, { replace = null } = {}) {
|
|
2420
|
-
const w = ws(current)
|
|
2421
|
-
if (!w.searchTabs) w.searchTabs = []
|
|
2422
|
-
const at = replace ? w.searchTabs.indexOf(replace) : -1
|
|
2423
|
-
if (!w.searchTabs.includes(q)) { if (at >= 0) w.searchTabs.splice(at, 1, q); else w.searchTabs.push(q) } else if (at >= 0 && replace !== q) w.searchTabs.splice(at, 1)
|
|
2424
|
-
w.searchSel = q
|
|
2425
|
-
w.mode = 'search'
|
|
2426
|
-
saveWs(current)
|
|
2427
|
-
renderMainBar()
|
|
2428
|
-
renderMain()
|
|
2429
|
-
renderTreePane()
|
|
2430
|
-
loadSearch(q)
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
|
-
async function loadSearch (q, tries = 0) {
|
|
2434
|
-
const id = current
|
|
2435
|
-
const k = `${id}\n${q}`
|
|
2436
|
-
if (!tries && searches.has(k) && !searches.get(k)?.error) return
|
|
2437
|
-
if (!tries) searches.set(k, null) // being read
|
|
2438
|
-
let r
|
|
2439
|
-
try { r = await api('GET', `/api/sessions/${id}/search?q=${encodeURIComponent(q)}`) } catch (err) { r = { error: err.message } }
|
|
2440
|
-
searches.set(k, r)
|
|
2441
|
-
if (r.working && tries < 30) setTimeout(() => { if (ws(id).searchTabs?.includes(q)) loadSearch(q, tries + 1) }, 2000)
|
|
2442
|
-
if (id === current && ws(id).mode === 'search' && ws(id).searchSel === q) renderMain()
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
function closeSearch (q) {
|
|
2446
|
-
const w = ws(current)
|
|
2447
|
-
const i = (w.searchTabs || []).indexOf(q)
|
|
2448
|
-
if (i !== -1) w.searchTabs.splice(i, 1)
|
|
2449
|
-
searches.delete(`${current}\n${q}`)
|
|
2450
|
-
if (w.searchSel === q) {
|
|
2451
|
-
w.searchSel = w.searchTabs[Math.min(i, w.searchTabs.length - 1)] || null
|
|
2452
|
-
if (!w.searchSel && w.mode === 'search') w.mode = w.fileSel ? 'files' : 'ai'
|
|
2453
|
-
}
|
|
2454
|
-
saveWs(current)
|
|
2455
|
-
renderMainBar()
|
|
2456
|
-
renderMain()
|
|
2457
|
-
renderTreePane()
|
|
2458
2087
|
}
|
|
2459
2088
|
|
|
2460
2089
|
// ------------------------------------------------------- a file's changes --
|
|
@@ -2474,16 +2103,14 @@ async function loadHistory (path) {
|
|
|
2474
2103
|
historyLoads.add(key)
|
|
2475
2104
|
let read = false
|
|
2476
2105
|
try {
|
|
2477
|
-
const { entries
|
|
2106
|
+
const { entries } = await api('GET', `/api/sessions/${id}/history?path=${encodeURIComponent(path)}`)
|
|
2478
2107
|
if (id !== current) return
|
|
2479
2108
|
histories.set(`${id}\n${path}`, entries)
|
|
2480
2109
|
read = true
|
|
2481
|
-
if (patches) patchLists.set(`${id}\n${path}`, { patches, quilt, ...(note ? { note } : {}) })
|
|
2482
|
-
else patchLists.delete(`${id}\n${path}`)
|
|
2483
2110
|
const w = ws(id)
|
|
2484
2111
|
if (w.mode !== 'files' || w.fileSel !== path) return
|
|
2485
2112
|
if (fileTabOf(path) !== 'file') renderMain()
|
|
2486
|
-
else renderFileTabs($('#main'), { tab: 'file', history: entries, summary: fileChanges(path)
|
|
2113
|
+
else renderFileTabs($('#main'), { tab: 'file', history: entries, summary: fileChanges(path) }) // the count only: freshly changed lines stay lit
|
|
2487
2114
|
} catch {} finally {
|
|
2488
2115
|
if (read) historyLoads.delete(key)
|
|
2489
2116
|
else setTimeout(() => historyLoads.delete(key), 5000)
|
|
@@ -3091,7 +2718,7 @@ function bindMentions (input) {
|
|
|
3091
2718
|
const update = () => {
|
|
3092
2719
|
const s = sum()
|
|
3093
2720
|
if (!s) return close()
|
|
3094
|
-
const asks = relayPrompts(input.value, { owner: !!s.status.access?.owner
|
|
2721
|
+
const asks = relayPrompts(input.value, { owner: !!s.status.access?.owner })
|
|
3095
2722
|
if (asks.length) { at = null; return show(asks.map((q) => ({ question: q.text }))) }
|
|
3096
2723
|
const found = mentionAt(input.value, input.selectionStart)
|
|
3097
2724
|
if (!found) return close()
|