heyquilt 0.3.195 → 0.3.196
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 +13 -0
- package/package.json +1 -1
- package/src/discard.js +119 -0
- package/src/gitstate.js +29 -1
- package/src/merge3.js +8 -0
- package/src/session.js +181 -10
- package/src/setup.js +5 -1
- package/src/ui/agent-guide.js +1 -1
- package/src/ui/app.css +7 -4
- package/src/ui/projects.js +14 -14
- package/src/ui/session.js +4 -2
package/RELEASES.md
CHANGED
|
@@ -11,6 +11,19 @@ Format: `## <version> — <YYYY-MM-DD>`, an optional one-line summary, then bull
|
|
|
11
11
|
Lead each bullet with a short bold phrase. Inline `code` and **bold** are rendered;
|
|
12
12
|
nothing else is.
|
|
13
13
|
|
|
14
|
+
## 0.3.196 — 2026-11-23
|
|
15
|
+
|
|
16
|
+
Git can throw away only your own uncommitted work.
|
|
17
|
+
|
|
18
|
+
- **A reset or a restore takes out only your own work.** Your folder holds everyone's uncommitted work on the branch you are on. When git puts files back as the last commit has them (`git reset --hard`, `git restore`, `git checkout -- <file>`), your own uncommitted changes go, for everyone, as you asked. Your partners' changes are written back into your files, and nobody else's folder loses anything. Before, their lines could be taken out of everyone's folder, and a second reset always took them.
|
|
19
|
+
- **Quilt says whose work stayed.** You and your AI are told which files still differ from the commit and whose changes are in them. A change with no author on record stays when someone else has also changed that file.
|
|
20
|
+
- **`git reset --hard <commit>` carries your partners' work along.** Their uncommitted changes are put onto the commit you reset to. Where the commits changed the same lines, the file stays as the codebase has it.
|
|
21
|
+
- **A stash is all or nothing.** `git stash` with only your own work does what git does: your partners see it go, and `git stash pop` brings it back. When a stashed file also holds someone else's work, every stashed file goes back as it was and nothing is shared. The stash keeps its copy: `git stash drop` removes it.
|
|
22
|
+
- **A stash that pops into a conflict is not shared.** The file keeps git's conflict markers in your folder only. Once you have settled them and saved, it is shared, with what your partners changed meanwhile merged in.
|
|
23
|
+
- **A commit that took in someone else's work says so.** After a commit, you and your AI are told which of its files held uncommitted work that was not yours, and whose, with how to undo the commit if you didn't mean it. Nothing is refused.
|
|
24
|
+
- **Quilt's own folder stays out of git.** `.quilt/` is kept out of `git status`, `git add -A`, `git stash -u` and `git clean` in every folder that is a git clone, not only the ones Quilt set up. It is listed in `.git/info/exclude`, on your computer only.
|
|
25
|
+
- **The sidebar's button stays in one place.** A small chip on the edge of the strip of projects, halfway down the window, hides the sidebar and shows it again. It replaces the row at the bottom of the sidebar and the button in the header.
|
|
26
|
+
|
|
14
27
|
## 0.3.195 — 2026-11-23
|
|
15
28
|
|
|
16
29
|
- **A project's channels inside a codebase.** A codebase's sidebar lists its project's channels after its own, with the plus to make one, and what is new in each. A channel opens on the codebase's page, so you stay where you are.
|
package/package.json
CHANGED
package/src/discard.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// What git throwing a file's uncommitted work away means in a session. A folder holds everyone's
|
|
2
|
+
// uncommitted work on its branch, so when git puts a file back as a commit has it (a reset, a restore,
|
|
3
|
+
// a checkout of the file, a stash), only the work of the folder's own member goes; everyone else's
|
|
4
|
+
// stays (2026-11-22, Daniel: the folder threw work away, the person did not delete those lines).
|
|
5
|
+
//
|
|
6
|
+
// Whose a change is comes from the session's history (history.js): each entry has who made it and the
|
|
7
|
+
// lines it added and removed. Read with care, since a wrong "yours" loses someone's work and a wrong
|
|
8
|
+
// "theirs" only leaves a change in the file:
|
|
9
|
+
//
|
|
10
|
+
// theirs a line of the change was last added or removed by someone else
|
|
11
|
+
// yours a line of it was last added or removed by you, and no one else's entry has that line
|
|
12
|
+
// unknown nothing on record for it (the history is capped): yours only when nobody else has an
|
|
13
|
+
// entry for the file at all
|
|
14
|
+
import { diffLines } from './textdiff.js'
|
|
15
|
+
|
|
16
|
+
const lines = (s) => String(s).split('\n')
|
|
17
|
+
/** A line that says whose a change is: not blank, not only brackets and punctuation. */
|
|
18
|
+
const telling = (l) => l.replace(/[\s{}()[\];,]/g, '').length >= 2
|
|
19
|
+
/** At most this many names in a message. */
|
|
20
|
+
export const MAX_NAMES = 3
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `session` (a file as the session has it) without the uncommitted changes `me` made to `head` (the
|
|
24
|
+
* same file as git's commit has it); null for either: no file there. `entries`: the file's history,
|
|
25
|
+
* oldest first. `binary`: no lines to tell apart, so the file is one change, its newest entry's.
|
|
26
|
+
* Returns { text, mine, kept, others, unknown }: `text` is what the file should hold (null: no file),
|
|
27
|
+
* `mine` the changes taken out, `kept` the ones left in, `others` whose those are (names, in the
|
|
28
|
+
* order they come) and `unknown` how many of them nobody is on record for.
|
|
29
|
+
* A file new to git or gone from the session is one change: all of it goes, or none.
|
|
30
|
+
*/
|
|
31
|
+
export function withoutMine ({ head = null, session = null, entries = [], me, binary = false }) {
|
|
32
|
+
const log = [...entries].reverse().filter((e) => e && !e.pulled && e.by)
|
|
33
|
+
const strangers = log.some((e) => e.by !== me)
|
|
34
|
+
if (binary) {
|
|
35
|
+
const mine = log.length ? log[0].by === me : true
|
|
36
|
+
return mine ? { text: head, mine: 1, kept: 0, others: [], unknown: 0 } : { text: session, mine: 0, kept: 1, others: [log[0].by], unknown: 0 }
|
|
37
|
+
}
|
|
38
|
+
const diffs = log.filter((e) => typeof e.diff === 'string' && e.diff).map((e) => ({ by: e.by, lines: new Set(e.diff.split('\n')) }))
|
|
39
|
+
const author = (signed) => { const e = diffs.find((x) => x.lines.has(signed)); return e ? e.by : null }
|
|
40
|
+
const noOneElses = (signed) => !diffs.some((x) => x.by !== me && x.lines.has(signed))
|
|
41
|
+
const a = head === null ? [] : lines(head)
|
|
42
|
+
const b = session === null ? [] : lines(session)
|
|
43
|
+
const others = []
|
|
44
|
+
let unknown = 0
|
|
45
|
+
const hunks = diffLines(a, b).map((h) => {
|
|
46
|
+
const signed = [...h.buffer1Content.filter(telling).map((l) => `-${l}`), ...h.buffer2Content.filter(telling).map((l) => `+${l}`)]
|
|
47
|
+
const who = signed.map(author)
|
|
48
|
+
const theirs = [...new Set(who.filter((n) => n && n !== me))]
|
|
49
|
+
let mine
|
|
50
|
+
if (theirs.length) mine = false
|
|
51
|
+
else if (who.some(Boolean)) mine = signed.some((s, i) => who[i] === me && noOneElses(s))
|
|
52
|
+
else mine = !strangers
|
|
53
|
+
if (!mine) {
|
|
54
|
+
for (const n of theirs) if (!others.includes(n)) others.push(n)
|
|
55
|
+
if (!theirs.length) unknown++
|
|
56
|
+
}
|
|
57
|
+
return { ...h, mine }
|
|
58
|
+
})
|
|
59
|
+
const mine = hunks.filter((h) => h.mine).length
|
|
60
|
+
const kept = hunks.length - mine
|
|
61
|
+
if (!kept) return { text: head, mine, kept: 0, others: [], unknown: 0 }
|
|
62
|
+
// No file at one end: nothing to put a part of the change back onto.
|
|
63
|
+
if (head === null || session === null || !mine) return { text: session, mine: 0, kept: hunks.length, others, unknown }
|
|
64
|
+
const out = []
|
|
65
|
+
let at = 0
|
|
66
|
+
for (const h of hunks) {
|
|
67
|
+
const [start, n] = h.buffer2
|
|
68
|
+
out.push(...b.slice(at, start), ...(h.mine ? h.buffer1Content : b.slice(start, start + n)))
|
|
69
|
+
at = start + n
|
|
70
|
+
}
|
|
71
|
+
out.push(...b.slice(at))
|
|
72
|
+
return { text: out.join('\n'), mine, kept, others, unknown }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** "Ada", "Ada and Brandon", "Ada, Brandon and 2 others"; "someone else" for nobody known. */
|
|
76
|
+
export function whose (names) {
|
|
77
|
+
if (!names.length) return 'someone else'
|
|
78
|
+
if (names.length === 1) return names[0]
|
|
79
|
+
if (names.length <= MAX_NAMES) return `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`
|
|
80
|
+
return `${names.slice(0, MAX_NAMES - 1).join(', ')} and ${names.length - MAX_NAMES + 1} others`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const some = (paths) => paths.slice(0, 3).join(', ') + (paths.length > 3 ? ` and ${paths.length - 3} more` : '')
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* What a member is told after git put files back and other people's uncommitted work stayed.
|
|
87
|
+
* `files`: [{ path, mine, kept, others, unknown }] for each file with work left in it; `stash`: the
|
|
88
|
+
* work was stashed (then every file is back as it was, `mine` 0).
|
|
89
|
+
*/
|
|
90
|
+
export function discardNotice (files, { stash = false } = {}) {
|
|
91
|
+
if (!files.length) return ''
|
|
92
|
+
const names = []
|
|
93
|
+
for (const f of files) for (const n of f.others) if (!names.includes(n)) names.push(n)
|
|
94
|
+
const unknown = files.some((f) => f.unknown)
|
|
95
|
+
const who = names.length ? `${whose(names)}'s${unknown ? ' (and some Quilt has no author on record for)' : ''}` : 'not on record as yours'
|
|
96
|
+
const list = some(files.map((f) => f.path))
|
|
97
|
+
const why = 'This folder holds everyone\'s uncommitted work on this branch, and git can only throw away your own.'
|
|
98
|
+
if (stash) {
|
|
99
|
+
return `git stash set work aside here, but ${list} ${files.length === 1 ? 'has' : 'have'} uncommitted changes that are ${who}, so Quilt put every stashed file back as it was: nothing was shared and nothing is lost. ${why} The stash still holds a copy: remove it with \`git stash drop\`. To change branch, use \`git checkout -f <branch>\`.`
|
|
100
|
+
}
|
|
101
|
+
const part = files.filter((f) => f.mine)
|
|
102
|
+
const whole = files.filter((f) => !f.mine)
|
|
103
|
+
const said = []
|
|
104
|
+
if (part.length) said.push(`your own uncommitted changes to ${some(part.map((f) => f.path))} are gone, and the rest ${part.length === 1 ? 'is' : 'are'} still in ${part.length === 1 ? 'it' : 'them'}`)
|
|
105
|
+
if (whole.length) said.push(`${some(whole.map((f) => f.path))} ${whole.length === 1 ? 'is' : 'are'} back as ${whole.length === 1 ? 'it was' : 'they were'}`)
|
|
106
|
+
return `git put ${list} back as the commit has ${files.length === 1 ? 'it' : 'them'}, but the uncommitted changes there are ${who}: ${said.join('; ')}. Nothing of theirs was lost. ${why} To take a change of theirs out, edit the file.`
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** What a member is told when its commit took in work that is not its own. `files`: [{ path, others }]. */
|
|
110
|
+
export function commitNotice (sha, files) {
|
|
111
|
+
if (!files.length) return ''
|
|
112
|
+
const list = files.slice(0, 4).map((f) => `${f.path} (${whose(f.others)})`).join(', ') + (files.length > 4 ? ` and ${files.length - 4} more` : '')
|
|
113
|
+
return `Your commit ${String(sha).slice(0, 7)} took in uncommitted work that is not yours: ${list}. That is fine if you meant to commit it for them. If not, undo the commit with \`git reset --soft HEAD@{1}\`, stage only your own changes (\`git add -p\`) and commit again.`
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** What a member is told when git left a conflict in a file of this folder (a stash popped onto lines that changed since). */
|
|
117
|
+
export function gitConflictNotice (p) {
|
|
118
|
+
return `⚖️ git left a conflict in ${p} (a stash applied onto lines that changed since): it has git's conflict markers ("<<<<<<<", "=======", ">>>>>>>"), so it is not shared yet and nobody's later change is written over it. Edit ${p} to what it should be, delete the marker lines and save: it is shared then.`
|
|
119
|
+
}
|
package/src/gitstate.js
CHANGED
|
@@ -315,6 +315,32 @@ export async function treeState (root, paths) {
|
|
|
315
315
|
return { dirty, unmerged, tracked: new Set(listed.split('\0').filter(Boolean)) }
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
/** How many stashes git holds here (0: none); null when git can't be run. */
|
|
319
|
+
export async function stashCount (root) {
|
|
320
|
+
const r = await call(root, ['rev-list', '-g', '--count', 'refs/stash'])
|
|
321
|
+
if (r.missing || r.timedOut) return null
|
|
322
|
+
const n = r.out === null ? 0 : Number(r.out.trim()) // no refs/stash: git fails, and there are none
|
|
323
|
+
return Number.isInteger(n) ? n : null
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** What last moved HEAD, in git's own words ("commit: …", "reset: moving to …", "pull: Fast-forward"); '' when git can't say. */
|
|
327
|
+
export async function lastMove (root) {
|
|
328
|
+
const out = await run(root, ['reflog', '-1', '--format=%gs'])
|
|
329
|
+
return out ? out.trim() : ''
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The paths git has a conflict open on: unmerged in its index, as a stash popped onto changed lines
|
|
334
|
+
* leaves them (no merge is under way then, so `busy` says nothing). Null when git fails.
|
|
335
|
+
*/
|
|
336
|
+
export async function unmergedPaths (root) {
|
|
337
|
+
const out = await run(root, ['ls-files', '-u', '-z'])
|
|
338
|
+
if (out === null) return null
|
|
339
|
+
const paths = new Set()
|
|
340
|
+
for (const e of out.split('\0')) { const i = e.indexOf('\t'); if (i >= 0) paths.add(e.slice(i + 1)) }
|
|
341
|
+
return paths
|
|
342
|
+
}
|
|
343
|
+
|
|
318
344
|
/**
|
|
319
345
|
* Watches the folder's .git for HEAD moving, the index being written and git starting or
|
|
320
346
|
* finishing work (see busy); events: head, index, busy, idle.
|
|
@@ -550,9 +576,11 @@ export async function cloneRepo (url, dir) {
|
|
|
550
576
|
|
|
551
577
|
/** Git never offers Quilt's own state in a folder (.quilt/) for a commit: said in the repository's own exclude file, which is not shared. */
|
|
552
578
|
export function keepQuiltOut (root) {
|
|
553
|
-
|
|
579
|
+
let dir = gitDir(root)
|
|
554
580
|
if (!dir) return
|
|
555
581
|
try {
|
|
582
|
+
// A worktree's own .git has no exclude file git reads: the repository's (its `commondir`) is the one.
|
|
583
|
+
try { dir = path.resolve(dir, fs.readFileSync(path.join(dir, 'commondir'), 'utf8').trim()) } catch {}
|
|
556
584
|
const file = path.join(dir, 'info', 'exclude')
|
|
557
585
|
let text = ''
|
|
558
586
|
try { text = fs.readFileSync(file, 'utf8') } catch {}
|
package/src/merge3.js
CHANGED
|
@@ -92,6 +92,14 @@ export function hasMarkers (text) {
|
|
|
92
92
|
return typeof text === 'string' && text.split('\n').some((l) => l.startsWith(`${MARK.start} (`) || l.startsWith(`${MARK.end} (`))
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/** True when the text holds a conflict as git writes one: a line starting "<<<<<<< " and, after it, one starting ">>>>>>> ". */
|
|
96
|
+
export function hasGitMarkers (text) {
|
|
97
|
+
if (typeof text !== 'string') return false
|
|
98
|
+
const ls = text.split('\n')
|
|
99
|
+
const start = ls.findIndex((l) => l.startsWith('<<<<<<< '))
|
|
100
|
+
return start >= 0 && ls.slice(start + 1).some((l) => l.startsWith('>>>>>>> '))
|
|
101
|
+
}
|
|
102
|
+
|
|
95
103
|
/**
|
|
96
104
|
* merge3, plus the clashes where neither side lost anything, resolved the way a person would:
|
|
97
105
|
* - both sides only added lines in the same place (base had nothing there): ours, then theirs,
|
package/src/session.js
CHANGED
|
@@ -41,7 +41,8 @@ import { MentionRunner, parseOnMention, readOnMention, writeOnMention } from './
|
|
|
41
41
|
import { pickChecklist } from './agent-task-workflow.js'
|
|
42
42
|
import { changeRefusal, TALK_REFUSED } from './session-access.js'
|
|
43
43
|
import { canAdmit } from './admit-policy.js'
|
|
44
|
-
import { merge3, mergeAuto, hasMarkers, mergeLive } from './merge3.js'
|
|
44
|
+
import { merge3, mergeAuto, hasMarkers, hasGitMarkers, mergeLive } from './merge3.js'
|
|
45
|
+
import { withoutMine, discardNotice, commitNotice, gitConflictNotice } from './discard.js'
|
|
45
46
|
import { sameEditClient, asClient } from './same-edit.js'
|
|
46
47
|
import { openMerge, updateMerge, readMerges, pruneMerges, cleanName } from './merges.js'
|
|
47
48
|
import { LiveRules, applyMine, findUses, removedNameWarning, clashNotice, clashStillNotice } from './live-merge.js'
|
|
@@ -54,7 +55,7 @@ import { RELAY_NAME as RELAY_BY, isRelay } from './ui/chat.js'
|
|
|
54
55
|
import { cleanTyping, TYPING_MS, AGENT_TYPING_MS } from './ui/chat.js'
|
|
55
56
|
import { DEFAULT_KEY, validBranchKey } from './branchdocs.js'
|
|
56
57
|
import { cleanPreview, previewId, previewList, previewsView, branchChoices, hasDevScript, cleanLooking, cleanRunning, describePreviews, APP_ID, MAX_PREVIEWS } from './previews.js'
|
|
57
|
-
import { headKey, headName, branchTip, busy as gitBusy, leftoverLock, indexStamp, filesAt, blobAt, treeState, watchGit, SETTLE_MS as GIT_SETTLE_MS, STALE_LOCK_MS, upstreamOf, fetchUpstream, aheadBehind, changesBetween, fastForward, stage, hasBranch, switchBranch, defaultRemote, remoteBranch, follow, adoptRepo, originUrl } from './gitstate.js'
|
|
58
|
+
import { headKey, headName, branchTip, busy as gitBusy, leftoverLock, indexStamp, filesAt, blobAt, treeState, watchGit, stashCount, lastMove, unmergedPaths, keepQuiltOut, SETTLE_MS as GIT_SETTLE_MS, STALE_LOCK_MS, upstreamOf, fetchUpstream, aheadBehind, changesBetween, fastForward, stage, hasBranch, switchBranch, defaultRemote, remoteBranch, follow, adoptRepo, originUrl } from './gitstate.js'
|
|
58
59
|
import { shareableRemote, repoLabel } from './repo-ref.js'
|
|
59
60
|
import { cleanVoice, cleanDmVoice, dmVoiceView, dmCallers, newCallId, voiceView, inVoice, transcribeSetting, setTranscribe, addLine, readLines, MAX_IN_CALL, CALL_FULL, callAgents, setAgentLeft, notInCall, agentSays, markCallForAgents, namedAgents, callPing, spokenReply, AGENT_REPLY_MS } from './voice.js'
|
|
60
61
|
import { toolInUse } from './agents/common.js'
|
|
@@ -377,8 +378,8 @@ export class Session extends EventEmitter {
|
|
|
377
378
|
this.hold = null // { kind: 'busy'|'switching', since, to?, waiting? } while this folder's sync is held (git at work; moving to another branch)
|
|
378
379
|
this.upstreamAfterHold = null // a look at the upstream asked while held ({ fetch }): asked again when the hold ends
|
|
379
380
|
this.heldPaths = new Set() // paths that changed (here or in the room) while held
|
|
380
|
-
this.
|
|
381
|
-
this.stashSeen =
|
|
381
|
+
this.gitConflicts = new Map() // path -> its text with git's conflict markers, as last told (null: not yet): not shared until they are gone (gitWork)
|
|
382
|
+
this.stashSeen = undefined // how many stashes git had when the folder was last quiet (undefined: not read yet): one more by the settle means the person stashed
|
|
382
383
|
this.headChangedAt = 0
|
|
383
384
|
this.settleTimer = null
|
|
384
385
|
this.savedGit = null // { key, sha } from state.json: the branch this folder synced at the last stop
|
|
@@ -1607,8 +1608,10 @@ export class Session extends EventEmitter {
|
|
|
1607
1608
|
// the session. While git is at work in the folder (its index lock is there, or a rebase or a
|
|
1608
1609
|
// bisect has HEAD off its branch) and while a move is under way, the folder's sync is held:
|
|
1609
1610
|
// nothing is taken in and nothing from the session is written out. Git work that leaves the
|
|
1610
|
-
// folder on its branch (a commit, a
|
|
1611
|
-
// made, like any other change to the files
|
|
1611
|
+
// folder on its branch (a commit, a pull, a stash popped) is shared afterwards as the edits it
|
|
1612
|
+
// made, like any other change to the files, with one exception: git putting files back as a
|
|
1613
|
+
// commit has them (a reset, a restore, a stash) throws away only this member's own uncommitted
|
|
1614
|
+
// work, and everyone else's is written back (gitWork, discard.js).
|
|
1612
1615
|
|
|
1613
1616
|
/**
|
|
1614
1617
|
* Where git has the folder now: { key, branch, sha } (a branch, or a detached commit keyed `@<sha>`).
|
|
@@ -1744,6 +1747,11 @@ export class Session extends EventEmitter {
|
|
|
1744
1747
|
this.followHead(head.key)
|
|
1745
1748
|
return
|
|
1746
1749
|
}
|
|
1750
|
+
// What git did to the files it wrote, read before anything is changed: a file put back as a commit has it is
|
|
1751
|
+
// uncommitted work thrown away, which is no edit of the session's text (gitWork).
|
|
1752
|
+
const work = await this.gitWork([...this.heldPaths], this.git, head)
|
|
1753
|
+
if (!this.settleable()) return
|
|
1754
|
+
if (this.gitBusy() || gen !== this.settleGen || head.key !== headName(this.root)) { this.settleHoldSoon(); return }
|
|
1747
1755
|
this.git = head
|
|
1748
1756
|
this.gitSeen = head
|
|
1749
1757
|
// What git wrote is accounted for here: the next flush is an edit unless git moves again.
|
|
@@ -1755,7 +1763,152 @@ export class Session extends EventEmitter {
|
|
|
1755
1763
|
if (this.rejoin) for (const rel of [...this.sharedPaths(), ...walk(this.root, this.ig)]) late.add(rel)
|
|
1756
1764
|
this.rejoin = false
|
|
1757
1765
|
this.releaseHold()
|
|
1758
|
-
this.resumeHeld([...late])
|
|
1766
|
+
this.resumeHeld([...late], work)
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* What git did in this folder while it was held, for the `paths` that changed (`was`, `head`: where HEAD
|
|
1771
|
+
* was before and is now, on the same branch). Nothing is changed here: resumeHeld acts on it once the hold
|
|
1772
|
+
* is known to be over.
|
|
1773
|
+
* discards rel -> { key, shared, put, info }: git put the file back as a commit has it (a reset, a
|
|
1774
|
+
* restore, a checkout of the file, a stash) while the session has uncommitted work in it. `put`
|
|
1775
|
+
* is what the file gets: the session's version without this member's own changes (discard.js).
|
|
1776
|
+
* After `git reset --hard <commit>`, everyone else's work is carried onto the new commit's
|
|
1777
|
+
* version; where it can't be (the same lines), the session's version stays.
|
|
1778
|
+
* stash the work was stashed: then no file loses anything unless every one can (a stash that came
|
|
1779
|
+
* back in part could not be popped)
|
|
1780
|
+
* unmerged the paths git has a conflict open on (a stash popped onto changed lines)
|
|
1781
|
+
* commit { sha, files: [{ path, others }] }: this folder's commit took in other people's uncommitted work
|
|
1782
|
+
*/
|
|
1783
|
+
async gitWork (paths, was, head) {
|
|
1784
|
+
const work = { discards: new Map(), stash: false, stashes: undefined, unmerged: null, commit: null }
|
|
1785
|
+
if (!head || !head.sha) return work
|
|
1786
|
+
work.stashes = await stashCount(this.root)
|
|
1787
|
+
work.stash = typeof this.stashSeen === 'number' && typeof work.stashes === 'number' && work.stashes > this.stashSeen
|
|
1788
|
+
work.unmerged = await unmergedPaths(this.root)
|
|
1789
|
+
const moved = !!(was && was.sha && was.sha !== head.sha)
|
|
1790
|
+
const move = moved ? await lastMove(this.root) : ''
|
|
1791
|
+
const isText = (k) => k === null || (typeof k === 'string' && !/^bin:[0-9a-f]{40}$/.test(k))
|
|
1792
|
+
const history = () => {
|
|
1793
|
+
const by = new Map()
|
|
1794
|
+
for (const e of this.history.entries()) { if (!by.has(e.path)) by.set(e.path, []); by.get(e.path).push(e) }
|
|
1795
|
+
return by
|
|
1796
|
+
}
|
|
1797
|
+
const cands = []
|
|
1798
|
+
for (const rel of paths) {
|
|
1799
|
+
if (!this.syncable(rel) || this.merging.has(rel) || this.followsGit(rel) || this.clashed.has(rel) || this.relayWriting.has(rel)) continue
|
|
1800
|
+
let disk
|
|
1801
|
+
try { disk = this.readDisk(rel) } catch { continue }
|
|
1802
|
+
if (disk && (disk.skip || disk.tooLarge)) continue
|
|
1803
|
+
const key = disk ? disk.key : undefined
|
|
1804
|
+
const shared = this.sharedKey(rel)
|
|
1805
|
+
// As this folder last had it (git didn't touch it), or as the session has it: nothing was thrown away.
|
|
1806
|
+
if (key === this.lastKnown.get(rel) || key === shared) continue
|
|
1807
|
+
cands.push({ rel, key, shared })
|
|
1808
|
+
}
|
|
1809
|
+
if (cands.length) {
|
|
1810
|
+
const rels = cands.map((c) => c.rel)
|
|
1811
|
+
const now = await filesAt(this.root, head.sha, rels)
|
|
1812
|
+
const before = moved ? await filesAt(this.root, was.sha, rels) : now
|
|
1813
|
+
const entries = now && before ? history() : null
|
|
1814
|
+
for (const { rel, key, shared } of entries ? cands : []) {
|
|
1815
|
+
const [hNow, hWas] = [now.get(rel), before.get(rel)]
|
|
1816
|
+
if (hNow === undefined || hWas === undefined) continue // git couldn't read it
|
|
1817
|
+
if ((key ?? null) !== hNow) continue // not as the commit has it: an edit, taken in as one
|
|
1818
|
+
// The commit under it changed too: only a reset throws work away then (a commit of a save just made, or a pull, is what git brought).
|
|
1819
|
+
if (hNow !== hWas && !/^reset:/.test(move)) continue
|
|
1820
|
+
const session = shared ?? null
|
|
1821
|
+
if (session === hWas) continue // no uncommitted work in it
|
|
1822
|
+
const text = isText(hWas) && isText(session)
|
|
1823
|
+
const r = withoutMine({ head: hWas, session, entries: entries.get(rel) || [], me: this.name, binary: !text })
|
|
1824
|
+
let put = r.text
|
|
1825
|
+
if (hNow !== hWas) {
|
|
1826
|
+
if (!r.kept) put = hNow
|
|
1827
|
+
else {
|
|
1828
|
+
// Everyone else's work, made on the commit the branch left, goes onto the one it is at now.
|
|
1829
|
+
const m = text && typeof hWas === 'string' && typeof hNow === 'string' && typeof put === 'string' ? mergeLive(hWas, hNow, put) : null
|
|
1830
|
+
if (m && !m.held.length) put = m.text
|
|
1831
|
+
else { put = session; r.mine = 0 }
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
work.discards.set(rel, { key, shared, put, info: { path: rel, mine: r.mine, kept: r.kept, others: r.others, unknown: r.unknown } })
|
|
1835
|
+
}
|
|
1836
|
+
// Stashed, and someone else's work is in a stashed file: every file goes back as it was.
|
|
1837
|
+
if (work.stash && [...work.discards.values()].some((d) => d.info.kept)) {
|
|
1838
|
+
for (const d of work.discards.values()) { d.put = d.shared ?? null; d.info.mine = 0 }
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
if (moved && /^commit( \(amend\))?:/.test(move)) {
|
|
1842
|
+
const changes = await changesBetween(this.root, was.sha, head.sha)
|
|
1843
|
+
const rels = changes ? [...changes.keys()].filter((rel) => this.syncable(rel)).slice(0, 200) : []
|
|
1844
|
+
const [a, b] = rels.length ? [await filesAt(this.root, was.sha, rels), await filesAt(this.root, head.sha, rels)] : [null, null]
|
|
1845
|
+
if (a && b) {
|
|
1846
|
+
const entries = history()
|
|
1847
|
+
const files = []
|
|
1848
|
+
for (const rel of rels) {
|
|
1849
|
+
const [x, y] = [a.get(rel), b.get(rel)]
|
|
1850
|
+
if (!isText(x) || !isText(y)) continue
|
|
1851
|
+
const others = blameChange({ before: x ?? '', after: y ?? '', entries: entries.get(rel) || [] }).filter((n) => n !== this.name)
|
|
1852
|
+
if (others.length) files.push({ path: rel, others })
|
|
1853
|
+
}
|
|
1854
|
+
if (files.length) work.commit = { sha: head.sha, files }
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
return work
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* Acts on what git did while the folder was held (gitWork), now that the hold is over. Returns the paths
|
|
1862
|
+
* dealt with here. A file that changed again since gitWork looked is left to resumeHeld, as any save.
|
|
1863
|
+
*/
|
|
1864
|
+
applyGitWork (work) {
|
|
1865
|
+
const done = new Set()
|
|
1866
|
+
if (typeof work.stashes === 'number') this.stashSeen = work.stashes
|
|
1867
|
+
if (work.unmerged) {
|
|
1868
|
+
for (const rel of work.unmerged) if (!this.gitConflicts.has(rel)) this.gitConflicts.set(rel, null)
|
|
1869
|
+
for (const rel of [...this.gitConflicts.keys()]) if (!work.unmerged.has(rel)) this.gitConflicts.delete(rel)
|
|
1870
|
+
}
|
|
1871
|
+
const told = []
|
|
1872
|
+
for (const [rel, d] of work.discards) {
|
|
1873
|
+
let disk
|
|
1874
|
+
try { disk = this.readDisk(rel) } catch { continue }
|
|
1875
|
+
if (disk && (disk.skip || disk.tooLarge || disk.unsettled)) continue
|
|
1876
|
+
const key = disk ? disk.key : undefined
|
|
1877
|
+
if (key !== d.key || this.sharedKey(rel) !== d.shared) continue
|
|
1878
|
+
done.add(rel)
|
|
1879
|
+
if (d.put === (d.shared ?? null)) {
|
|
1880
|
+
// Nothing of this member's in it: the session's version goes back on disk, and nothing is shared.
|
|
1881
|
+
if (key === undefined) this.lastKnown.delete(rel); else this.lastKnown.set(rel, key)
|
|
1882
|
+
this.tryWrite(rel)
|
|
1883
|
+
} else {
|
|
1884
|
+
// This member's own work goes, as an edit of the session's version made by them; the rest is written back.
|
|
1885
|
+
if (typeof d.put === 'string' && d.put !== key) {
|
|
1886
|
+
try {
|
|
1887
|
+
const abs = resolveInside(this.root, rel)
|
|
1888
|
+
const over = this.writeOver(rel, abs, d.put, disk)
|
|
1889
|
+
if (over === false) { done.delete(rel); continue } // saved again in that instant: taken in as a save
|
|
1890
|
+
if (over === null) this.writeFile(rel, abs, d.put)
|
|
1891
|
+
} catch (err) { this.log(`could not write ${rel}: ${err.message}`); continue }
|
|
1892
|
+
}
|
|
1893
|
+
if (d.shared === undefined) this.lastKnown.delete(rel); else this.lastKnown.set(rel, d.shared)
|
|
1894
|
+
// Made from the session's version as it is now, whatever older text it looks like (base-pick.js).
|
|
1895
|
+
if (typeof d.put === 'string') this.overwritten.told(rel, d.put)
|
|
1896
|
+
this.ingestAll([rel])
|
|
1897
|
+
}
|
|
1898
|
+
if (d.info.kept) told.push(d.info)
|
|
1899
|
+
}
|
|
1900
|
+
if (told.length) {
|
|
1901
|
+
told.sort((a, b) => (a.path < b.path ? -1 : 1))
|
|
1902
|
+
const text = discardNotice(told, { stash: work.stash })
|
|
1903
|
+
this.notice(text)
|
|
1904
|
+
this.log(`↩️ ${text}`)
|
|
1905
|
+
}
|
|
1906
|
+
if (work.commit) {
|
|
1907
|
+
const text = commitNotice(work.commit.sha, work.commit.files)
|
|
1908
|
+
this.notice(text)
|
|
1909
|
+
this.log(`📦 ${text}`)
|
|
1910
|
+
}
|
|
1911
|
+
return done
|
|
1759
1912
|
}
|
|
1760
1913
|
|
|
1761
1914
|
/**
|
|
@@ -1763,9 +1916,10 @@ export class Session extends EventEmitter {
|
|
|
1763
1916
|
* the disk is as Quilt left it, the session's version is written out; where it changed here (git
|
|
1764
1917
|
* rewrote it, or someone saved it), it is taken in as an edit, merged with the session's as any save is.
|
|
1765
1918
|
*/
|
|
1766
|
-
resumeHeld (paths) {
|
|
1919
|
+
resumeHeld (paths, work = null) {
|
|
1920
|
+
const done = work ? this.applyGitWork(work) : null
|
|
1767
1921
|
for (const rel of paths) {
|
|
1768
|
-
if (!this.syncable(rel) || this.merging.has(rel)) continue
|
|
1922
|
+
if (!this.syncable(rel) || this.merging.has(rel) || (done && done.has(rel))) continue
|
|
1769
1923
|
if (this.untouchedHere(rel)) this.tryWrite(rel)
|
|
1770
1924
|
else this.ingestAll([rel])
|
|
1771
1925
|
}
|
|
@@ -2289,6 +2443,9 @@ export class Session extends EventEmitter {
|
|
|
2289
2443
|
/** Watches the folder's .git: HEAD moving is looked at with the next flush, and git starting work holds the folder at once. */
|
|
2290
2444
|
startGitWatch () {
|
|
2291
2445
|
if (this.gitWatcher || !this.git) return
|
|
2446
|
+
// Quilt's own folder is never git's to add, stash or clean away (a clone made before Quilt kept it out, or joined from a terminal).
|
|
2447
|
+
keepQuiltOut(this.root)
|
|
2448
|
+
stashCount(this.root).then((n) => { if (this.stashSeen === undefined && typeof n === 'number') this.stashSeen = n }, () => {})
|
|
2292
2449
|
this.gitWatcher = watchGit(this.root, (e) => {
|
|
2293
2450
|
if (this.stopped) return
|
|
2294
2451
|
if (e.type === 'head') { this.headChangedAt = Date.now(); this.queue(HEAD_CHANGED) } else if (e.type === 'busy') { this.setHold('busy'); this.settleHoldSoon() } else this.settleHoldSoon() // idle, index
|
|
@@ -2529,7 +2686,7 @@ export class Session extends EventEmitter {
|
|
|
2529
2686
|
const o = !d ? null : d.skip || d.tooLarge ? undefined : d.key
|
|
2530
2687
|
if (!changes.get(rel).plain || b === undefined || t === undefined || o === undefined) { unread.push(rel); continue }
|
|
2531
2688
|
// A file whose clash is still in this folder (its own lines between markers) is its writer's to settle first.
|
|
2532
|
-
if (this.clashed.has(rel)) { clashes.push(rel); continue }
|
|
2689
|
+
if (this.clashed.has(rel) || this.gitConflicts.get(rel)) { clashes.push(rel); continue }
|
|
2533
2690
|
// The session and this folder must agree first: a change still on its way waits for the next look.
|
|
2534
2691
|
if (this.syncable(rel) && !this.followsGit(rel) && (o ?? undefined) !== this.sharedKey(rel)) { this.upstreamLater(); return }
|
|
2535
2692
|
if (o === t) continue // the session has it already (a partner committed what everyone was editing)
|
|
@@ -2957,6 +3114,20 @@ export class Session extends EventEmitter {
|
|
|
2957
3114
|
return false
|
|
2958
3115
|
}
|
|
2959
3116
|
if (this.clashed.delete(rel)) this.log(`⚖️ ${rel}: its conflict markers are gone; sharing it`)
|
|
3117
|
+
// A conflict git left in this file (a stash popped onto lines that changed since: gitWork): not shared
|
|
3118
|
+
// while git's own markers are in it. Settled by hand, or marked resolved in git, it is shared as any save.
|
|
3119
|
+
if (this.gitConflicts.has(rel)) {
|
|
3120
|
+
if (!disk.binary && hasGitMarkers(disk.text)) {
|
|
3121
|
+
if (this.gitConflicts.get(rel) !== disk.text) {
|
|
3122
|
+
this.gitConflicts.set(rel, disk.text)
|
|
3123
|
+
this.notice(gitConflictNotice(rel))
|
|
3124
|
+
this.log(`⚖️ ${rel}: git left a conflict in it, so it is not shared until its markers are gone`)
|
|
3125
|
+
}
|
|
3126
|
+
return false
|
|
3127
|
+
}
|
|
3128
|
+
if (this.gitConflicts.get(rel)) this.log(`⚖️ ${rel}: git's conflict markers are gone; sharing it`)
|
|
3129
|
+
this.gitConflicts.delete(rel)
|
|
3130
|
+
}
|
|
2960
3131
|
if (disk.key === this.sharedKey(rel)) {
|
|
2961
3132
|
this.lastKnown.set(rel, disk.key)
|
|
2962
3133
|
if (stored && stored.stored) this.setOnDisk(rel, stored.hash)
|
package/src/setup.js
CHANGED
|
@@ -88,7 +88,11 @@ ${TASK_WORKFLOW_MD}
|
|
|
88
88
|
If git refuses a checkout because local changes would be overwritten,
|
|
89
89
|
those are the codebase's uncommitted work, which the codebase keeps: switch with
|
|
90
90
|
\`git checkout -f <branch>\` (or \`git stash && git checkout <branch>\` in one
|
|
91
|
-
command
|
|
91
|
+
command). git throws away only your own uncommitted work: after
|
|
92
|
+
\`git reset --hard\`, \`git restore\` or \`git stash\` your changes are gone and
|
|
93
|
+
other people's are still in the files (a stash whose files hold someone else's
|
|
94
|
+
work is put back whole: \`git stash drop\` it). When a commit of yours took in
|
|
95
|
+
someone else's uncommitted work, Quilt tells you which files.
|
|
92
96
|
Deleting a file deletes it for everyone.
|
|
93
97
|
${END}`
|
|
94
98
|
|
package/src/ui/agent-guide.js
CHANGED
|
@@ -99,7 +99,7 @@ export function agentGuide ({ apiUrl = 'https://api.heyquilt.com', via = 'both'
|
|
|
99
99
|
'### Getting your work into git',
|
|
100
100
|
'- Work that is only in the codebase has not shipped. Get it into git yourself as soon as it is finished and tested, before you move its task to QA.',
|
|
101
101
|
cli ? `- ${both ? 'With the CLI, join' : 'Join'} from a git clone of the repository (\`git clone <url>\` first, then \`quilt join\` in it). Git is yours to run, with your own sign-in. A ticket is a unit of work, and its work is on a branch of its own, quilt/<ticket>. Taking a ticket (\`quilt_move_task\` to doing) moves your folder onto that branch, made from the latest commit when nobody opened the ticket before (an agent's folder only: a person's stays where it is unless they open the ticket from the board). Everyone who has the ticket open works there together, live; nobody else gets that work until it is merged. Commit only the files you changed there (never \`git add -A\` or \`git commit -a\`), \`git push -u origin <that branch>\`, and open the pull request yourself (\`gh pr create\`). Your ticket moves to QA only once the branch is committed and pushed. When your ticket is Done, your folder goes back to the main branch by itself; a quick fix that needs no ticket can be made there. Quilt does not commit, push, open pull requests or merge them for anyone.` : null,
|
|
102
|
-
cli ? `- ${both ? 'With the CLI: s' : 'S'}witching branches moves your folder to that branch's work in the codebase, and the branch you left keeps its own. Your folder also holds everyone's uncommitted work on the branch you are on, so git may refuse a checkout ("local changes would be overwritten"): switch with \`git checkout -f <branch>\`. Nothing is lost, because the codebase keeps that work on the branch you leave.
|
|
102
|
+
cli ? `- ${both ? 'With the CLI: s' : 'S'}witching branches moves your folder to that branch's work in the codebase, and the branch you left keeps its own. Your folder also holds everyone's uncommitted work on the branch you are on, so git may refuse a checkout ("local changes would be overwritten"): switch with \`git checkout -f <branch>\`. Nothing is lost, because the codebase keeps that work on the branch you leave. git throws away only your own uncommitted work: after \`git reset --hard\`, \`git restore\` or \`git stash\` your changes are gone and other people's are still in the files, and Quilt says whose (a stash whose files hold someone else's work is put back whole: \`git stash drop\` it). When a commit of yours took in someone else's uncommitted work, Quilt tells you which files.` : null,
|
|
103
103
|
cli ? `- ${both ? 'With the CLI: c' : 'C'}ommits pushed to your branch's upstream (a partner's push, a pull request merged on GitHub) come into your folder by themselves: about once a minute, and when a partner's folder moves, Quilt fetches the upstream and moves your branch forward to them, keeping the codebase's uncommitted work. There is nothing to pull. For that the folder needs fetch credentials that work without a prompt (a credential helper, an SSH key, or a token in the remote's URL). Quilt leaves two cases to your own git, and \`quilt_status\` says so under "Git": your branch has commits of its own that the upstream hasn't, and a commit changed the same lines as uncommitted work (commit it first). In both, pull with \`git pull --rebase --autostash\` (or \`--no-rebase\` to merge) and settle any conflict. While git is stopped on a conflict (a merge, rebase, cherry-pick or revert) your folder is paused: nothing is shared from it or written to it until you settle it and commit. Quilt never rewrites or force-pushes history, and neither should you.` : null,
|
|
104
104
|
http ? `- ${both ? 'Over HTTP you have no folder, so ' : 'You have no folder, so '}you cannot commit. What you write is in the codebase and in every member's folder, and someone with a folder commits it: say in your task's \`qaNotes\` which files need committing. Quilt never rewrites or force-pushes history.` : null,
|
|
105
105
|
cliOnly('- Quilt merges on its own: changes made offline or by a pull are combined with the codebase\'s by Quilt, as live edits are (below)'),
|
package/src/ui/app.css
CHANGED
|
@@ -1611,10 +1611,13 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1611
1611
|
.pj-crumb { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 30px; padding: 0 8px; border: 0; border-radius: 4px; background: none; color: var(--text); font: 600 14px var(--sans); cursor: pointer; }
|
|
1612
1612
|
.pj-crumb > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1613
1613
|
.pj-crumb:hover { background: var(--panel-2); }
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1614
|
+
/* The sidebar's one button: a chip half over the right edge of the strip of projects, halfway down
|
|
1615
|
+
the window. It never moves: its arrow points left while the sidebar is open, right while it is closed. */
|
|
1616
|
+
.pj-side-chip { position: fixed; left: 52px; top: 50%; z-index: 7; width: 16px; height: 44px; margin-top: -22px; padding: 0; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel); color: var(--muted); cursor: pointer; box-shadow: var(--card); }
|
|
1617
|
+
.pj-side-chip:hover, .pj-side-chip:focus-visible { color: var(--text); border-color: var(--text); }
|
|
1618
|
+
.pj-side-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
1619
|
+
.pj-side-chip svg { width: 12px; height: 12px; transition: transform var(--side-slide, 0s); }
|
|
1620
|
+
[data-side="shut"] .pj-side-chip svg { transform: rotate(180deg); }
|
|
1618
1621
|
.pj-home .ws-top .spacer { flex: 1; }
|
|
1619
1622
|
.pj-home .ws-top .brand .qm-word { transform: translateY(11%); }
|
|
1620
1623
|
.pj-home .page { flex: 1; min-height: 0; padding: 16px 24px 32px; overflow-y: auto; }
|
package/src/ui/projects.js
CHANGED
|
@@ -19,7 +19,6 @@ import { previewRowHtml } from './preview-page.js'
|
|
|
19
19
|
const colorOf = (w) => COLORS[w.color] || COLORS.lilac
|
|
20
20
|
const tile = (w, size = '') => `<span class="pj-tile ${size}" style="background:${esc(colorOf(w))}">${esc(tileLetter(w.name))}</span>`
|
|
21
21
|
const faces = (list) => list.length ? `<span class="pj-faces sm">${list.map((f) => avatar(f.name, f.color)).join('')}</span>` : ''
|
|
22
|
-
const panelIcon = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2.5"/><path d="M9 4v16"/></svg>'
|
|
23
22
|
|
|
24
23
|
// Kept on this computer: whether the sidebar is closed, and which of its sections are folded.
|
|
25
24
|
const saved = (key) => { try { return localStorage.getItem(key) } catch { return null } }
|
|
@@ -29,17 +28,19 @@ const foldedNow = () => (folded ||= readFolded(saved('quilt.sideFolded')))
|
|
|
29
28
|
/** Whether the sidebar of a project or a codebase is closed (one choice for both, kept on this computer). */
|
|
30
29
|
export const sideShut = () => saved('quilt.projectSide') === 'shut'
|
|
31
30
|
export const toggleSideShut = () => save('quilt.projectSide', sideShut() ? 'open' : 'shut')
|
|
32
|
-
// The sidebar's
|
|
33
|
-
//
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
/** Shows the sidebar closed or open, as it was just set: on the page's shell (`ws`), where it slides. The button now showing takes the focus the other had. */
|
|
31
|
+
// The sidebar's one button: a chip on the right edge of the strip of projects, half over it. It is
|
|
32
|
+
// in the same place whether the sidebar is open or closed, and its arrow says which way it goes.
|
|
33
|
+
const sideBtn = () => { const shut = sideShut(); return `<button type="button" class="pj-side-chip" id="pj-side-btn" aria-expanded="${!shut}" title="${shut ? 'Show' : 'Hide'} the sidebar" aria-label="${shut ? 'Show' : 'Hide'} the sidebar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 6-6 6 6 6"/></svg></button>` }
|
|
34
|
+
/** Shows the sidebar closed or open, as it was just set: on the page's shell (`ws`), where it slides. Its button says what it does now. */
|
|
37
35
|
export function drawSideShut (ws) {
|
|
38
36
|
const shut = sideShut()
|
|
39
37
|
if (!ws) return
|
|
40
|
-
const had = ws.contains(document.activeElement) && document.activeElement.matches('#pj-side-btn, [data-side-toggle]')
|
|
41
38
|
ws.dataset.side = shut ? 'shut' : 'open'
|
|
42
|
-
|
|
39
|
+
const b = ws.querySelector('#pj-side-btn')
|
|
40
|
+
if (!b) return
|
|
41
|
+
b.setAttribute('aria-expanded', String(!shut))
|
|
42
|
+
b.title = `${shut ? 'Show' : 'Hide'} the sidebar`
|
|
43
|
+
b.setAttribute('aria-label', b.title)
|
|
43
44
|
}
|
|
44
45
|
// The plus beside Channels, in a project's sidebar and a codebase's: a row to name the new one in, in the list.
|
|
45
46
|
const newChannelBtn = `<button type="button" class="btn sm ghost icon" data-new-channel title="New channel" aria-label="New channel">${I.plus}</button>`
|
|
@@ -109,7 +110,7 @@ function headerHtml (p) {
|
|
|
109
110
|
return `
|
|
110
111
|
<header class="ws-top">
|
|
111
112
|
<button class="brand" data-go="home" aria-label="Home">${quiltMark({ sew: 'first' })}</button>
|
|
112
|
-
${p ? `${
|
|
113
|
+
${p ? `${sideBtn()}
|
|
113
114
|
<button type="button" class="pj-crumb" data-go="ws:${esc(p.id)}" title="${esc(p.description || p.name)}">${tile(p, 'xs')}<span>${esc(p.name)}</span></button>` : ''}
|
|
114
115
|
<span class="spacer"></span>
|
|
115
116
|
${p ? '' : `<div class="menu-wrap pj-new"><button type="button" class="btn sm primary" id="pj-new-btn" aria-haspopup="true" aria-expanded="false">${I.plus}<span>New</span><span class="caret">${I.caret}</span></button>
|
|
@@ -285,7 +286,6 @@ function sideHtml (p, d, page) {
|
|
|
285
286
|
<div class="side-foot side-nav">
|
|
286
287
|
<button type="button" data-team title="People and agents in this project"><span class="pj-faces sm">${team.slice(0, 3).map((m) => avatar(m.name)).join('')}</span><span class="nm">Team</span><span class="ct">${count}</span></button>
|
|
287
288
|
${d.access?.admin ? `<button type="button" data-invite-project>${I.link}<span class="nm">Invite</span></button>` : ''}
|
|
288
|
-
${sideHideBtn()}
|
|
289
289
|
</div>
|
|
290
290
|
</aside>`
|
|
291
291
|
}
|
|
@@ -294,9 +294,9 @@ function sideHtml (p, d, page) {
|
|
|
294
294
|
// A codebase's page (session.js) wears the same sidebar, trimmed to that codebase: Loom in place
|
|
295
295
|
// of Overview (the loom is a codebase's main page), no list of codebases, and its chat as a channel.
|
|
296
296
|
|
|
297
|
-
/** Beside the logo on a codebase's page: the button
|
|
297
|
+
/** Beside the logo on a codebase's page: the sidebar's button (drawn on the strip's edge), then the project it is in, if any. */
|
|
298
298
|
export function codeCrumbHtml (project) {
|
|
299
|
-
return `${
|
|
299
|
+
return `${sideBtn()}${project ? `
|
|
300
300
|
<button type="button" class="pj-crumb" data-go="ws:${esc(project.id)}" title="${esc(project.description || project.name)}">${tile(project, 'xs')}<span>${esc(project.name)}</span></button><span class="pj-crumb-sep">/</span>` : ''}`
|
|
301
301
|
}
|
|
302
302
|
|
|
@@ -332,7 +332,6 @@ export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, c
|
|
|
332
332
|
<div class="side-foot side-nav">
|
|
333
333
|
<button type="button" data-code-team title="People in this codebase"><span class="pj-faces sm">${people.slice(0, 3).map((m) => avatar(m.name, m.color)).join('')}</span><span class="nm">Team</span><span class="ct">${people.length}</span></button>
|
|
334
334
|
${canInvite ? `<button type="button" data-code-invite>${I.link}<span class="nm">Invite</span></button>` : ''}
|
|
335
|
-
${sideHideBtn()}
|
|
336
335
|
</div>`
|
|
337
336
|
}
|
|
338
337
|
|
|
@@ -472,7 +471,8 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
|
|
|
472
471
|
root.querySelectorAll('[data-manage-connections]').forEach((b) => { b.onclick = () => { state.settingsTab = 'connections'; openSettings() } })
|
|
473
472
|
if (!p) return
|
|
474
473
|
// The sidebar: its pages, closing it, folding a section.
|
|
475
|
-
root.
|
|
474
|
+
const sideBtnEl = root.querySelector('#pj-side-btn')
|
|
475
|
+
if (sideBtnEl) sideBtnEl.onclick = () => { toggleSideShut(); drawSideShut(root) }
|
|
476
476
|
root.querySelectorAll('[data-page]').forEach((b) => {
|
|
477
477
|
b.onclick = () => {
|
|
478
478
|
const page = b.dataset.page
|
package/src/ui/session.js
CHANGED
|
@@ -450,7 +450,10 @@ function renderCodeSide () {
|
|
|
450
450
|
}
|
|
451
451
|
const root = $('#ws')
|
|
452
452
|
root.dataset.sidePage = side
|
|
453
|
-
|
|
453
|
+
// Drawn only when it changes: the sidebar's chip is in it, and a press on it must not be lost to a redraw.
|
|
454
|
+
const crumb = codeCrumbHtml(p)
|
|
455
|
+
const crumbEl = $('#code-crumb')
|
|
456
|
+
if (crumbEl.dataset.drawn !== crumb) { crumbEl.innerHTML = crumb; crumbEl.dataset.drawn = crumb }
|
|
454
457
|
// The pages drawn over the middle in their own box: Connections, the project's Artifacts, and one of the project's channels.
|
|
455
458
|
// Drawn when the page changes, not every time the sidebar is: an artifact that is running stays as it is.
|
|
456
459
|
const extra = $('#code-extra')
|
|
@@ -550,7 +553,6 @@ function bindCodeSide () {
|
|
|
550
553
|
if (b.dataset.dm !== undefined) { state.to = b.dataset.dm; showCodePage('chat'); renderRecipients(); updatePlaceholder(); return renderCodeSide() }
|
|
551
554
|
if (b.dataset.codePage) return showCodePage(b.dataset.codePage)
|
|
552
555
|
if (b.hasAttribute('data-new-channel')) { const p = projectHere(); if (p) { startNewChannel(p.id); renderCodeSide() } return }
|
|
553
|
-
if (b.hasAttribute('data-side-toggle')) { toggleSideShut(); return drawSideShut($('#ws')) }
|
|
554
556
|
if (b.dataset.fold) return foldSection(b.dataset.fold, renderCodeSide)
|
|
555
557
|
if (b.dataset.go) return go(b.dataset.go)
|
|
556
558
|
if (b.hasAttribute('data-code-team')) { e.stopPropagation(); return $('#people-btn').click() }
|