heyquilt 0.3.194 → 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 CHANGED
@@ -11,6 +11,25 @@ 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
+
27
+ ## 0.3.195 — 2026-11-23
28
+
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.
30
+ - **Hide sidebar is a row at the bottom of the sidebar**, under Team and Invite, in place of the button over its first row.
31
+ - **Fixed: a new, empty channel kept saying "Loading".**
32
+
14
33
  ## 0.3.194 — 2026-11-23
15
34
 
16
35
  - **Make channels in a project.** A plus beside Channels in a project's sidebar: name the channel in the list and press Enter. Everyone in the project and its agents can read and write it, as with the project's own channel, and its row says how much is new. Anyone who can change the project can make one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.194",
3
+ "version": "0.3.196",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
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
- const dir = gitDir(root)
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.heldConflicts = new Set() // paths git left a conflict in during this hold (see noteConflict)
381
- this.stashSeen = null // the stash's mark when the folder was last quiet: a change by the settle means the person stashed
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 stash, a reset, a pull) is shared afterwards as the edits it
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; a stash on its own is put back a moment later).
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
 
@@ -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. A \`git stash\` on its own is put back a moment later.` : 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. 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,13 +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
- #pj-side-btn { flex: none; margin-left: 6px; }
1615
- /* The sidebar's button is in the sidebar, top right, beside its first row. Only while the sidebar
1616
- is closed is there one in the header, to open it again. */
1617
- :is(.pj-home, .ws.pj-cb):not([data-side="shut"]) #pj-side-btn { display: none; }
1618
- .pj-side-hide { position: absolute; top: 13px; right: 9px; z-index: 1; color: var(--muted); }
1619
- .pj-side-hide:hover { color: var(--text); }
1620
- .pj-side > nav.side-nav > button:first-child { margin-right: 34px; }
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); }
1621
1621
  .pj-home .ws-top .spacer { flex: 1; }
1622
1622
  .pj-home .ws-top .brand .qm-word { transform: translateY(11%); }
1623
1623
  .pj-home .page { flex: 1; min-height: 0; padding: 16px 24px 32px; overflow-y: auto; }
@@ -1780,7 +1780,7 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
1780
1780
  .ws.pj-cb .chat-resize, .ws.pj-cb .chat-rail, .ws.pj-cb #collapse-chat { display: none; }
1781
1781
  .ws.pj-cb[data-side-page="chat"] .ws-main { display: none; }
1782
1782
  .ws.pj-cb[data-side-page="chat"] .ws-chat { display: flex; }
1783
- .ws.pj-cb:is([data-side-page="connections"], [data-side-page="artifacts"], [data-side-page^="preview:"]) :is(#main, #mainbar) { display: none; }
1783
+ .ws.pj-cb:is([data-side-page="connections"], [data-side-page="artifacts"], [data-side-page^="preview:"], [data-side-page^="channel:"]) :is(#main, #mainbar) { display: none; }
1784
1784
 
1785
1785
  /* ---- Previews of a codebase (preview-page.js): rows in the sidebars, and a preview's page: its head with the
1786
1786
  branch picker, and under it the app in a frame, or what it says while it starts. ---- */
@@ -15,12 +15,12 @@ let live = null // the channel on the page: { el, key }
15
15
 
16
16
  // The channels people made in each project, as last heard: project id -> { list: [{ id, name, unread }], canAdd, asked }.
17
17
  const made = new Map()
18
- const madeIn = (id) => { if (!made.has(id)) made.set(id, { list: [], canAdd: false, asked: 0 }); return made.get(id) }
18
+ const madeIn = (id) => { if (!made.has(id)) made.set(id, { list: [], canAdd: false, asked: 0, loaded: false }); return made.get(id) }
19
19
 
20
20
  /** How many messages are new for you in a project's channel, as last heard. */
21
21
  export const channelUnread = (id) => chan(id).unread
22
22
 
23
- /** The channels people made in a project, oldest first, each with what is new for you ({ id, name, unread }); `canAdd`: you may make one. */
23
+ /** The channels people made in a project, oldest first, each with what is new for you ({ id, name, unread }); `canAdd`: you may make one; `loaded`: the server has answered once. */
24
24
  export const projectChannels = (id) => madeIn(id)
25
25
 
26
26
  /**
@@ -38,8 +38,10 @@ export async function loadChannels (id, changed = () => {}, { now = false } = {}
38
38
  // The one that is open and being read has nothing new, whatever was counted a moment ago.
39
39
  m.list = (r.channels || []).map((c) => ({ id: c.id, name: c.name, unread: live && live.key === keyOf(id, c.id) && live.el.isConnected && document.hasFocus() ? 0 : c.unread || 0 }))
40
40
  m.canAdd = !!r.canAdd
41
- if (JSON.stringify([m.list, m.canAdd]) !== was) changed()
42
- } catch {} // the list stays as it was: the project's own channel does not depend on it
41
+ const first = !m.loaded
42
+ m.loaded = true
43
+ if (first || JSON.stringify([m.list, m.canAdd]) !== was) changed()
44
+ } catch { if (!m.loaded) { m.loaded = true; changed() } } // the list stays as it was: the project's own channel does not depend on it
43
45
  }
44
46
 
45
47
  /** Makes a channel in a project. Resolves to it ({ id, name }); rejects with what the accounts API said. */
@@ -64,13 +66,13 @@ export async function loadChannel (id, changed = () => {}, { now = false, channe
64
66
  try {
65
67
  const after = c.messages.length ? c.messages[c.messages.length - 1].at : 0
66
68
  const r = await api('GET', `${urlOf(id, channel)}${after ? `?after=${after}` : ''}`)
67
- const had = c.messages.length; const was = c.unread
69
+ const had = c.messages.length; const was = c.unread; const first = !c.loaded
68
70
  const known = new Set(c.messages.map((m) => m.id))
69
71
  for (const m of r.messages) if (!known.has(m.id)) c.messages.push(m)
70
72
  c.loaded = true; c.failed = ''
71
73
  c.unread = r.unread
72
74
  const open = live && live.key === key && live.el.isConnected
73
- if (open && (c.messages.length !== had || !live.drawn)) live.draw()
75
+ if (open && (c.messages.length !== had || !live.drawn || first)) live.draw() // the first answer too: an empty channel stops saying it is loading
74
76
  // Reading it on the page is reading it: what came in while it is open is not new.
75
77
  if (open && c.unread && document.hasFocus()) { c.unread = 0; api('POST', `${urlOf(id, channel)}/read`).catch(() => {}) }
76
78
  mirror()
@@ -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,50 @@ 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 own button, top right in it, closes it. While it is closed the button that opens
33
- // it again is in the header, where the sidebar's edge was (the styles show one or the other).
34
- const sideHideBtn = () => `<button type="button" class="btn sm ghost icon pj-side-hide" data-side-toggle aria-expanded="true" title="Hide the sidebar" aria-label="Hide the sidebar">${panelIcon}</button>`
35
- const sideShowBtn = () => `<button type="button" class="btn sm ghost icon" id="pj-side-btn" aria-expanded="false" title="Show the sidebar" aria-label="Show the sidebar">${panelIcon}</button>`
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
- if (had) ws.querySelector(shut ? '#pj-side-btn' : '.pj-side [data-side-toggle]')?.focus({ preventScroll: true })
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)
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.
46
+ const newChannelBtn = `<button type="button" class="btn sm ghost icon" data-new-channel title="New channel" aria-label="New channel">${I.plus}</button>`
47
+ const newChannelRow = () => `<form class="pj-newchan" data-new-channel-form autocomplete="off"><span class="pj-hash">#</span><input name="name" maxlength="40" placeholder="Name the channel" aria-label="The new channel's name" value="${esc(state.newChannelDraft || '')}" spellcheck="false"></form>`
48
+ /** The plus beside Channels was pressed in project `id`: its row to name the new one shows, in an open section. */
49
+ export function startNewChannel (id) { if (foldedNow().has('channels')) toggleFolded('channels'); state.newChannel = id; state.newChannelDraft = '' }
50
+ /**
51
+ * Makes the row a new channel is named in work, when `root` has one: Enter makes it in project `id`
52
+ * and calls `made(channel)`; Escape, or leaving it empty, takes the row away (`redraw` draws the
53
+ * sidebar again). `focus` false leaves the cursor where it is (the sidebar was only drawn again).
54
+ */
55
+ export function bindNewChannel (root, id, { redraw, made, focus = true }) {
56
+ const naming = root.querySelector('[data-new-channel-form]')
57
+ if (!naming) return
58
+ const box = naming.elements.name
59
+ const stop = () => { state.newChannel = null; state.newChannelDraft = ''; redraw() }
60
+ if (focus) { box.focus(); box.setSelectionRange(box.value.length, box.value.length) }
61
+ box.oninput = () => { state.newChannelDraft = box.value }
62
+ box.onkeydown = (e) => { if (e.key === 'Escape') { e.preventDefault(); stop() } }
63
+ box.onblur = () => { if (!box.value.trim() && state.newChannel === id && root.isConnected && !naming.dataset.busy) setTimeout(() => { if (document.activeElement !== box && box.isConnected) stop() }, 0) }
64
+ naming.onsubmit = async (e) => {
65
+ e.preventDefault()
66
+ const name = box.value.trim()
67
+ if (!name || naming.dataset.busy) return
68
+ naming.dataset.busy = '1'
69
+ try {
70
+ const channel = await addChannel(id, name)
71
+ state.newChannel = null; state.newChannelDraft = ''
72
+ made(channel)
73
+ } catch (err) { delete naming.dataset.busy; toast(err.message); box.focus() }
74
+ }
43
75
  }
44
76
  /** Folds or unfolds one of the sidebar's sections. */
45
77
  export function toggleFolded (k) { const f = foldedNow(); f.has(k) ? f.delete(k) : f.add(k); save('quilt.sideFolded', JSON.stringify([...f])) }
@@ -78,7 +110,7 @@ function headerHtml (p) {
78
110
  return `
79
111
  <header class="ws-top">
80
112
  <button class="brand" data-go="home" aria-label="Home">${quiltMark({ sew: 'first' })}</button>
81
- ${p ? `${sideShowBtn()}
113
+ ${p ? `${sideBtn()}
82
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>` : ''}
83
115
  <span class="spacer"></span>
84
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>
@@ -240,15 +272,14 @@ function sideHtml (p, d, page) {
240
272
  }
241
273
  return `
242
274
  <aside class="pj-side" aria-label="${esc(p.name)}">
243
- ${sideHideBtn()}
244
275
  <nav class="side-nav" aria-label="Pages">${nav('', I.grid, 'Overview')}${nav('tasks', I.board, 'Tasks', projectOpenTasks(d))}${nav('artifacts', I.folder, 'Artifacts', files)}${state.connectionsOn ? nav('connections', I.link, 'Connections') : ''}</nav>
245
276
  ${label('codebases', 'Codebases', list.length, d.access?.access === 'edit' ? `<button type="button" class="btn sm ghost icon" data-new-codebase title="New codebase" aria-label="New codebase">${I.plus}</button>` : '')}
246
277
  <div class="side-sessions">${isFolded('codebases') ? '' : list.map(row).join('')}</div>
247
- ${label('channels', 'Channels', newHere, made.canAdd ? `<button type="button" class="btn sm ghost icon" data-new-channel title="New channel" aria-label="New channel">${I.plus}</button>` : '')}
278
+ ${label('channels', 'Channels', newHere, made.canAdd ? newChannelBtn : '')}
248
279
  <div class="side-sessions pj-rooms">${isFolded('channels') && page !== 'channel' && !newHere && !naming ? '' : `
249
280
  ${isFolded('channels') && onChannel !== '' && !own ? '' : room(`data-page="channel" title="Everyone in ${esc(p.name)}"`, p.name, own, onChannel === '')}
250
281
  ${made.list.filter((c) => !isFolded('channels') || c.id === onChannel || c.unread).map((c) => room(`data-channel="${esc(c.id)}" title="Everyone in ${esc(p.name)}"`, c.name, c.unread, c.id === onChannel)).join('')}
251
- ${naming ? `<form class="pj-newchan" data-new-channel-form autocomplete="off"><span class="pj-hash">#</span><input name="name" maxlength="40" placeholder="Name the channel" aria-label="The new channel's name" value="${esc(state.newChannelDraft || '')}" spellcheck="false"></form>` : ''}
282
+ ${naming ? newChannelRow() : ''}
252
283
  ${isFolded('channels') ? '' : open.map((c) => room(`data-go-chat="${esc(c.id)}" title="Everyone working in ${esc(c.name)}"`, c.name, (state.sessions.get(c.id)?.status.unread) || 0, false)).join('')}`}</div>
253
284
  ${dms.length ? `${label('dms', 'Direct messages')}
254
285
  <div class="side-sessions pj-rooms">${isFolded('dms') ? '' : dms.map((t) => `<button type="button" data-go-dm="${esc(t.code)}" data-name="${esc(t.name)}" title="You and ${esc(t.name)}, in ${esc(t.codeName)}">${avatar(t.name)}<span class="nm">${esc(t.name)}</span></button>`).join('')}</div>` : ''}
@@ -263,18 +294,18 @@ function sideHtml (p, d, page) {
263
294
  // A codebase's page (session.js) wears the same sidebar, trimmed to that codebase: Loom in place
264
295
  // of Overview (the loom is a codebase's main page), no list of codebases, and its chat as a channel.
265
296
 
266
- /** Beside the logo on a codebase's page: the button that closes the sidebar, then the project it is in, if any. */
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. */
267
298
  export function codeCrumbHtml (project) {
268
- return `${sideShowBtn()}${project ? `
299
+ return `${sideBtn()}${project ? `
269
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>` : ''}`
270
301
  }
271
302
 
272
303
  /**
273
304
  * The sidebar of a codebase's page. `page`: the row that is on ('loom', 'tasks', 'artifacts', 'chat', 'connections');
274
305
  * `tasks`: its open tasks; `artifacts`: how many the project has, once known; `chatNew`: messages in its channel since it was last looked at;
275
- * `people`: who is in it, you first ({ name, color }).
306
+ * `people`: who is in it, you first ({ name, color }); `channels`: its project's ({ own: what is new in the project's own, list: [{ id, name, unread }], canAdd, naming: the row to name a new one shows }).
276
307
  */
277
- export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, chatNew = 0, people = [], connections = false, canInvite = true, dms = [], dmOn = '', call = 0, previews = null, canEdit = false }) {
308
+ export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, chatNew = 0, people = [], connections = false, canInvite = true, dms = [], dmOn = '', call = 0, previews = null, canEdit = false, channels = null }) {
278
309
  const nav = (v, icon, label, n, attr = `data-code-page="${v}"`) => `<button type="button" class="${page === v ? 'on' : ''}" ${attr}${page === v ? ' aria-current="page"' : ''}>${icon}<span class="nm">${label}</span>${n ? `<span class="ct">${n}</span>` : ''}</button>`
279
310
  const isFolded = (k) => foldedNow().has(k)
280
311
  const label = (k, text, n, extra = '') => `<div class="side-label pj-side-label"><button type="button" class="pj-fold" data-fold="${k}" aria-expanded="${!isFolded(k)}" title="${isFolded(k) ? 'Show' : 'Hide'} ${text.toLowerCase()}"><span>${text}</span>${I.chevDown}</button>${isFolded(k) && n ? `<span class="ct new">${n}</span>` : ''}${extra}</div>`
@@ -286,12 +317,16 @@ export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, c
286
317
  // A folded section keeps the row you are on, what is new, and a call going on.
287
318
  const channel = !isFolded('channels') || page === 'chat' || chatNew || call
288
319
  const inDm = page === 'chat' ? dmOn : ''
320
+ // Its project's channels, after its own: the project's own, then the ones its people made. They open on this page.
321
+ const ch = project && channels
322
+ const onCh = page.startsWith('channel:') ? page.slice('channel:'.length) : null
323
+ const chNew = ch ? ch.own + ch.list.reduce((n, c) => n + c.unread, 0) : 0
324
+ const room = (id, nm, n) => !isFolded('channels') || onCh === id || n ? `<button type="button" class="${onCh === id ? 'on' : ''}" data-code-page="channel:${esc(id)}" title="Everyone in ${esc(project.name)}"${onCh === id ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(nm)}</span>${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>` : ''
289
325
  return `
290
- ${sideHideBtn()}
291
326
  <nav class="side-nav" aria-label="Pages">${nav('loom', I.users, 'Loom')}${nav('tasks', I.board, 'Tasks', tasks)}${project ? nav('artifacts', I.folder, 'Artifacts', artifacts) : ''}${connections ? nav('connections', I.link, 'Connections') : ''}</nav>
292
327
  ${pvHtml}
293
- ${label('channels', 'Channels', chatNew)}
294
- <div class="side-sessions pj-rooms">${channel ? `<button type="button" class="${page === 'chat' && !inDm ? 'on' : ''}" data-code-page="chat" data-dm="" title="Everyone working in ${esc(name)}"${page === 'chat' && !inDm ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${call ? `<span class="pj-call" title="${call === 1 ? '1 person is' : `${call} people are`} in a call here">${I.headset}${call}</span>` : ''}${chatNew ? `<span class="ct new">${chatNew > 99 ? '99+' : chatNew}</span>` : ''}</button>` : ''}</div>
328
+ ${label('channels', 'Channels', chatNew + chNew, ch && ch.canAdd ? newChannelBtn : '')}
329
+ <div class="side-sessions pj-rooms">${channel ? `<button type="button" class="${page === 'chat' && !inDm ? 'on' : ''}" data-code-page="chat" data-dm="" title="Everyone working in ${esc(name)}"${page === 'chat' && !inDm ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${call ? `<span class="pj-call" title="${call === 1 ? '1 person is' : `${call} people are`} in a call here">${I.headset}${call}</span>` : ''}${chatNew ? `<span class="ct new">${chatNew > 99 ? '99+' : chatNew}</span>` : ''}</button>` : ''}${ch ? `${room('', project.name, ch.own)}${ch.list.map((c) => room(c.id, c.name, c.unread)).join('')}${ch.naming && ch.canAdd ? newChannelRow() : ''}` : ''}</div>
295
330
  ${dms.length ? `${label('dms', 'Direct messages')}
296
331
  <div class="side-sessions pj-rooms">${isFolded('dms') && !inDm && !dms.some((t) => t.n || t.call) ? '' : dms.filter((t) => !isFolded('dms') || t.name === inDm || t.n || t.call).map((t) => `<button type="button" class="${t.name === inDm ? 'on' : ''}" data-dm="${esc(t.name)}" title="You and ${esc(t.name)}"${t.name === inDm ? ' aria-current="page"' : ''}>${avatar(t.name)}<span class="nm">${esc(t.name)}</span>${t.call ? `<span class="pj-call" title="${t.call === 1 ? `${esc(t.name)} is calling you` : `You and ${esc(t.name)} are in a call`}">${I.headset}${t.call}</span>` : ''}${t.n ? `<span class="ct new">${t.n > 99 ? '99+' : t.n}</span>` : ''}</button>`).join('')}</div>` : ''}
297
332
  <div class="side-foot side-nav">
@@ -436,7 +471,8 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
436
471
  root.querySelectorAll('[data-manage-connections]').forEach((b) => { b.onclick = () => { state.settingsTab = 'connections'; openSettings() } })
437
472
  if (!p) return
438
473
  // The sidebar: its pages, closing it, folding a section.
439
- root.querySelectorAll('#pj-side-btn, [data-side-toggle]').forEach((b) => { b.onclick = () => { toggleSideShut(); drawSideShut(root) } })
474
+ const sideBtnEl = root.querySelector('#pj-side-btn')
475
+ if (sideBtnEl) sideBtnEl.onclick = () => { toggleSideShut(); drawSideShut(root) }
440
476
  root.querySelectorAll('[data-page]').forEach((b) => {
441
477
  b.onclick = () => {
442
478
  const page = b.dataset.page
@@ -485,28 +521,8 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
485
521
  root.querySelectorAll('.pj-side [data-channel]').forEach((b) => { b.onclick = () => { state.projectPage = 'channel'; state.projectChannel = b.dataset.channel; if (state.view === `ws:${p.id}`) rerender(); else go(`ws:${p.id}`) } })
486
522
  // The plus beside Channels: a row to name the new one in, in the list. Enter makes it and opens it; Escape, or leaving it empty, takes the row away.
487
523
  const plus = root.querySelector('[data-new-channel]')
488
- if (plus) plus.onclick = () => { if (foldedNow().has('channels')) toggleFolded('channels'); state.newChannel = p.id; state.newChannelDraft = ''; rerender() }
489
- const naming = root.querySelector('[data-new-channel-form]')
490
- if (naming) {
491
- const box = naming.elements.name
492
- const stop = () => { state.newChannel = null; state.newChannelDraft = ''; rerender() }
493
- box.focus(); box.setSelectionRange(box.value.length, box.value.length)
494
- box.oninput = () => { state.newChannelDraft = box.value }
495
- box.onkeydown = (e) => { if (e.key === 'Escape') { e.preventDefault(); stop() } }
496
- box.onblur = () => { if (!box.value.trim() && state.newChannel === p.id && root.isConnected && !naming.dataset.busy) setTimeout(() => { if (document.activeElement !== box && box.isConnected) stop() }, 0) }
497
- naming.onsubmit = async (e) => {
498
- e.preventDefault()
499
- const name = box.value.trim()
500
- if (!name || naming.dataset.busy) return
501
- naming.dataset.busy = '1'
502
- try {
503
- const made = await addChannel(p.id, name)
504
- state.newChannel = null; state.newChannelDraft = ''
505
- state.projectPage = 'channel'; state.projectChannel = made.id
506
- if (state.view === `ws:${p.id}`) rerender(); else go(`ws:${p.id}`)
507
- } catch (err) { delete naming.dataset.busy; toast(err.message); box.focus() }
508
- }
509
- }
524
+ if (plus) plus.onclick = () => { startNewChannel(p.id); rerender() }
525
+ bindNewChannel(root, p.id, { redraw: rerender, made: (c) => { state.projectPage = 'channel'; state.projectChannel = c.id; if (state.view === `ws:${p.id}`) rerender(); else go(`ws:${p.id}`) } })
510
526
  // A codebase's channel, or a direct message in it: the codebase opens on its chat.
511
527
  root.querySelectorAll('[data-go-chat]').forEach((b) => { b.onclick = () => { state.openChat = b.dataset.goChat; state.to = ''; go(b.dataset.goChat) } })
512
528
  root.querySelectorAll('[data-go-preview]').forEach((b) => { b.onclick = () => { state.openPreview = { id: b.dataset.goPreview, preview: b.dataset.preview }; go(b.dataset.goPreview) } })
package/src/ui/session.js CHANGED
@@ -27,7 +27,8 @@ import { sessionAgentsHtml } from './agent-place.js'
27
27
  import { renderCatchUp, bindCatchUp } from './catchup.js'
28
28
  import { heldCard } from './session-words.js'
29
29
  import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, callCounts, callScope } from './voice.js'
30
- import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, drawSideShut, foldSection } from './projects.js'
30
+ import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, drawSideShut, foldSection, startNewChannel, bindNewChannel } from './projects.js'
31
+ import { mountChannel, loadChannel, loadChannels, channelUnread, projectChannels } from './project-channel.js'
31
32
  import { mountPreview } from './preview-page.js'
32
33
  import { dmThreads } from './project-model.js'
33
34
 
@@ -269,6 +270,7 @@ export function mountSession (id) {
269
270
  loadNewPeople(id)
270
271
  // Relative times ("4s ago") and recent-edit badges age out.
271
272
  timers.push(setInterval(() => { renderTreePane(); renderTop() }, 15000))
273
+ if (pj()) { timers.push(setInterval(askChannels, 4000)); askChannels() }
272
274
  }
273
275
 
274
276
  export function sessionUnmount () {
@@ -418,7 +420,14 @@ function renderCodeSide () {
418
420
  if (!el || !current || !sum()) return
419
421
  const w = ws(current)
420
422
  const st = sum().status
423
+ // One of its project's channels on this page ('channel:' and the id of one someone made, or nothing for the project's own).
424
+ // Out of the project, back to the Loom; a channel that is gone, the project's own.
425
+ const p = projectHere()
426
+ const made = p ? projectChannels(p.id) : null
427
+ if ((w.side || '').startsWith('channel:') && !p) w.side = ''
428
+ else if ((w.side || '').startsWith('channel:') && w.side !== 'channel:' && made.loaded && !made.list.some((c) => `channel:${c.id}` === w.side)) w.side = 'channel:'
421
429
  const side = w.side || ''
430
+ const onChannel = side.startsWith('channel:') ? side.slice('channel:'.length) : null
422
431
  const page = side || (w.mode === 'tasks' ? 'tasks' : 'loom')
423
432
  const open = (st.tasks || []).filter((t) => !t.archived && (t.column === 'todo' || t.column === 'doing')).length
424
433
  const people = [st.me, ...peopleHere(st)]
@@ -431,14 +440,26 @@ function renderCodeSide () {
431
440
  // So does the conversation on screen, before anything is written in it.
432
441
  if (side === 'chat' && state.to && !dms.some((t) => t.name === state.to)) dms.unshift({ name: state.to, ts: Date.now(), n: 0, call: 0 })
433
442
  if ($('#chat-sub')) $('#chat-sub').textContent = chatSub(st)
434
- el.innerHTML = codeSideHtml({ page, name: st.sessionName || basename(sum().dir), project: projectHere(), tasks: open, artifacts: (projectData()?.files || []).filter((f) => f.kind !== 'folder').length, chatNew, people, dms, dmOn: state.to || '', connections: !!state.connectionsOn, canInvite: !!st.access?.owner || st.access?.role !== 'viewer', call: calls.channel, previews: state.previewsOn ? st.previews || [] : null, canEdit: st.access?.role !== 'viewer' })
443
+ // The sidebar is drawn again as the codebase changes: a channel being named keeps what was typed, and the cursor if it was there.
444
+ const naming = el.querySelector('[data-new-channel-form] input')
445
+ const caret = naming && document.activeElement === naming ? [naming.selectionStart, naming.selectionEnd] : null
446
+ el.innerHTML = codeSideHtml({ page, name: st.sessionName || basename(sum().dir), project: p, channels: p ? { own: channelUnread(p.id), list: made.list, canAdd: made.canAdd, naming: state.newChannel === p.id } : null, tasks: open, artifacts: (projectData()?.files || []).filter((f) => f.kind !== 'folder').length, chatNew, people, dms, dmOn: state.to || '', connections: !!state.connectionsOn, canInvite: !!st.access?.owner || st.access?.role !== 'viewer', call: calls.channel, previews: state.previewsOn ? st.previews || [] : null, canEdit: st.access?.role !== 'viewer' })
447
+ if (p) {
448
+ bindNewChannel(el, p.id, { focus: !naming || !!caret, redraw: renderCodeSide, made: (c) => showCodePage(`channel:${c.id}`) })
449
+ if (caret) el.querySelector('[data-new-channel-form] input')?.setSelectionRange(caret[0], caret[1])
450
+ }
435
451
  const root = $('#ws')
436
452
  root.dataset.sidePage = side
437
- $('#code-crumb').innerHTML = codeCrumbHtml(projectHere())
438
- // The pages drawn over the middle in their own box: Connections, and the project's Artifacts.
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 }
457
+ // The pages drawn over the middle in their own box: Connections, the project's Artifacts, and one of the project's channels.
439
458
  // Drawn when the page changes, not every time the sidebar is: an artifact that is running stays as it is.
440
459
  const extra = $('#code-extra')
441
- const boxed = side === 'connections' || side === 'artifacts' || side.startsWith('preview:') ? side : ''
460
+ // A channel someone made waits for the list of them, to be drawn by its name.
461
+ const boxed = side === 'connections' || side === 'artifacts' || side.startsWith('preview:') ? side : onChannel === null ? '' : onChannel && !made.loaded ? 'channel?' : side
462
+ extra.hidden = !boxed // shown before it is filled: a channel puts the cursor in its box
442
463
  if ((extra.dataset.page || '') !== boxed) {
443
464
  if (codeConns) { codeConns.destroy(); codeConns = null }
444
465
  if (codePreview) { codePreview.destroy(); codePreview = null }
@@ -446,6 +467,12 @@ function renderCodeSide () {
446
467
  extra.dataset.page = boxed
447
468
  extra.classList.toggle('pj-files', boxed === 'artifacts')
448
469
  extra.classList.toggle('pv-view', boxed.startsWith('preview:'))
470
+ extra.classList.toggle('pj-chat', boxed.startsWith('channel:'))
471
+ if (boxed === 'channel?') extra.innerHTML = `<p class="hint">${loadingNote()}</p>`
472
+ if (boxed.startsWith('channel:')) {
473
+ extra.innerHTML = '<div class="pj-chanpage" data-project-channel></div>'
474
+ mountChannel(extra.firstElementChild, { d: projectData() || { workspace: p }, changed: renderCodeSide, channel: made.list.find((c) => c.id === onChannel) || null })
475
+ }
449
476
  if (boxed.startsWith('preview:')) {
450
477
  const id = current
451
478
  if (!pvPick.has(id)) pvPick.set(id, {})
@@ -466,7 +493,16 @@ function renderCodeSide () {
466
493
  }
467
494
  if (boxed === 'artifacts') { drawCodeArtifacts(); loadCodeArtifacts() }
468
495
  } else if (codePreview) codePreview.update()
469
- extra.hidden = !boxed
496
+ }
497
+
498
+ /** Asks for what is new in the project's channels (every few seconds while its codebase is open): the sidebar shows it, and the one on the page draws itself. */
499
+ function askChannels () {
500
+ const p = pj() && current && sum() ? projectHere() : null
501
+ if (!p) return
502
+ loadChannel(p.id, renderCodeSide)
503
+ loadChannels(p.id, renderCodeSide)
504
+ const on = (ws(current).side || '').startsWith('channel:') ? ws(current).side.slice('channel:'.length) : ''
505
+ if (on) loadChannel(p.id, renderCodeSide, { channel: on })
470
506
  }
471
507
 
472
508
  /** The project's data, when it is the one this codebase is in. */
@@ -492,7 +528,7 @@ async function loadCodeArtifacts () {
492
528
  renderCodeSide()
493
529
  }
494
530
 
495
- /** Shows one of the sidebar's pages: 'loom', 'tasks', the channel ('chat'), 'connections' or the project's 'artifacts'. */
531
+ /** Shows one of the sidebar's pages: 'loom', 'tasks', the channel ('chat'), 'connections', the project's 'artifacts' or one of the project's channels ('channel:' and its id). */
496
532
  function showCodePage (page) {
497
533
  const w = ws(current)
498
534
  const was = w.side || ''
@@ -516,7 +552,7 @@ function bindCodeSide () {
516
552
  // The channel is for everyone; a direct message's row is that person alone.
517
553
  if (b.dataset.dm !== undefined) { state.to = b.dataset.dm; showCodePage('chat'); renderRecipients(); updatePlaceholder(); return renderCodeSide() }
518
554
  if (b.dataset.codePage) return showCodePage(b.dataset.codePage)
519
- if (b.hasAttribute('data-side-toggle')) { toggleSideShut(); return drawSideShut($('#ws')) }
555
+ if (b.hasAttribute('data-new-channel')) { const p = projectHere(); if (p) { startNewChannel(p.id); renderCodeSide() } return }
520
556
  if (b.dataset.fold) return foldSection(b.dataset.fold, renderCodeSide)
521
557
  if (b.dataset.go) return go(b.dataset.go)
522
558
  if (b.hasAttribute('data-code-team')) { e.stopPropagation(); return $('#people-btn').click() }