heyquilt 0.3.177 → 0.3.179

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,21 @@ 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.179 — 2026-11-18
15
+
16
+ - **A ticket has its own branch.** A ticket is a unit of work, and its work now lives on a git branch of its own. On the board, **Open ticket** moves your folder onto that branch; **Leave** takes it back to the main one. Everyone who has the same ticket open edits live together there, and nobody else gets that work until it is merged.
17
+ - **The card says who is working on a ticket.** "Ada is working here", or "You and Ada are working here" when you have it open too.
18
+ - **Your unfinished work stays where you made it.** A ticket's branch starts from the latest commit, without the uncommitted work on the branch you leave. What you haven't committed on a ticket is still there when you open it again.
19
+ - **When your AI takes a ticket, your folder goes with it.** `quilt_move_task` to In progress opens the ticket for people's AIs as well as agents. Only an agent's ticket has to be committed and pushed before it can go to QA.
20
+ - **A pushed ticket branch reaches everyone on it.** When someone on the ticket commits and pushes, the others' branches move to that commit by themselves.
21
+ - **Moving a ticket to Done from the app works again.** It failed with an error since 0.3.139.
22
+
23
+ ## 0.3.178 — 2026-11-18
24
+
25
+ - **An agent works on its own branch for each task.** When an agent that is a member of its own takes a task, its folder moves to a git branch for that task alone (`quilt/<agent>/<task>`), made from the latest commit. What it changes stays on that branch: it no longer shows up in the files you and your partner are editing until it is merged. People are never moved: you keep pairing on the branch you are on.
26
+ - **An agent's task reaches QA only when its work is in git.** The agent commits and pushes its branch and opens the pull request itself. Until the branch is committed and pushed, moving the task to QA or Done is refused, with what to do.
27
+ - **When the pull request is merged, the work comes to you.** Your branch moves to the merge by itself, as with any other commit, and your uncommitted work stays.
28
+
14
29
  ## 0.3.177 — 2026-11-17
15
30
 
16
31
  - **No more boxes.** Every edit is shared with everyone as it is made, in a git folder or any other. Nothing is kept out of your folder until someone commits it, and there is nothing to unpack.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.177",
3
+ "version": "0.3.179",
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",
@@ -24,7 +24,19 @@ export const TASK_WORKFLOW =
24
24
  'When finished, move the ticket to QA (not straight to Done) with `qaNotes`: describe the changes you made and how you self-validated them. ' +
25
25
  'Keep qaNotes, verified and task comments brief: a few short sentences, no logs or play-by-play. ' +
26
26
  'Moving to Done still requires `verified` (what you ran and what you saw). Unit tests passing is not enough when the app itself was not exercised. ' +
27
- 'Get the task\'s files into git before you move it to QA: commit only the files you changed and push, on a branch of your own with a pull request you open yourself where the project works that way. Quilt does not commit, push, open pull requests or merge them for anyone. Without a folder you cannot commit: say in `qaNotes` which files need committing. Work only in the session has not shipped.'
27
+ 'Get the task\'s files into git before you move it to QA: commit only the files you changed, and push. Taking a ticket moves your folder onto the ticket\'s own branch (quilt/<ticket>), where everyone who has it open works together: push that branch and open the pull request yourself. An agent\'s ticket moves to QA only once the branch is committed and pushed. Quilt does not commit, push, open pull requests or merge them for anyone. Without a folder you cannot commit: say in `qaNotes` which files need committing. Work only in the session has not shipped.'
28
+
29
+ /**
30
+ * What an AI is told after taking a ticket about the branch its folder is on (Session.openTask's
31
+ * answer): the ticket's branch, or why the folder stayed where it was. '' for nothing.
32
+ */
33
+ export function taskBranchNote (b) {
34
+ if (!b) return ''
35
+ if (b.stayed) return `\n\nYour folder stays on \`${b.stayed}\`: ${b.why}`
36
+ if (!b.branch || b.already) return ''
37
+ const how = b.again ? 'this ticket\'s branch, which this folder had from before' : b.remote ? 'this ticket\'s branch, as a partner pushed it' : `this ticket's branch, made from \`${b.from}\``
38
+ return `\n\nYour folder is now on \`${b.branch}\`, ${how}. Everyone who opens the ticket works there with you, live; nobody else gets this work until it is merged. Commit only the files you changed, push with \`git push -u origin ${b.branch}\`, and open the pull request yourself (\`gh pr create\`). An agent's ticket moves to QA only once the branch is committed and pushed.`
39
+ }
28
40
 
29
41
  /** Markdown bullets for AGENTS.md / CLAUDE.md (same steps as TASK_WORKFLOW). */
30
42
  export const TASK_WORKFLOW_MD =
@@ -36,7 +48,7 @@ export const TASK_WORKFLOW_MD =
36
48
  ' 5. **QA**: move to `qa` (not straight to Done) with `qaNotes` describing the changes and how you self-validated them.\n' +
37
49
  ' Keep `qaNotes`, `verified` and task comments brief: a few short sentences, no logs or play-by-play.\n' +
38
50
  ' 6. **Done** (after QA): `quilt_move_task` to `done` needs `verified`, what you ran and what you saw. Unit tests passing is not enough when the app itself was not exercised.\n' +
39
- ' 7. **Commit and push** before QA: only the files you changed, with a message; on a branch of your own with a pull request you open yourself, where the project works that way. Quilt does not commit, push or merge for anyone. Without a folder you cannot commit: say in `qaNotes` which files need committing. Work only in the session has not shipped.'
51
+ ' 7. **Commit and push** before QA: only the files you changed, with a message. Taking a ticket moves your folder onto the ticket\'s own branch (quilt/<ticket>), where everyone who has it open works together: push that branch and open the pull request yourself. An agent\'s ticket moves to QA only once the branch is committed and pushed. Quilt does not commit, push or merge for anyone. Without a folder you cannot commit: say in `qaNotes` which files need committing. Work only in the session has not shipped.'
40
52
 
41
53
  /** Scaffolded into AGENTS.md by `quilt setup` when the project has no checklist yet. Owners edit it in place. */
42
54
  export const CHECKLIST_SCAFFOLD = `${CHECKLIST_HEADING}
package/src/control.js CHANGED
@@ -133,14 +133,24 @@ export async function startControl (session, extras = {}) {
133
133
  session.noteTaskChange(null, task, b.via)
134
134
  return { task, tasks: session.taskList() }
135
135
  },
136
- 'POST /tasks/update': (b) => {
136
+ 'POST /tasks/update': async (b) => {
137
137
  const before = session.taskList().find((t) => t.id === b.id) || null
138
+ // An agent on a ticket's branch moves a task to QA or Done only once its work there is committed and pushed (session.js taskInGit).
139
+ if ((b.column === 'qa' || b.column === 'done') && before && before.column !== b.column) {
140
+ const inGit = await session.taskInGit()
141
+ if (inGit && !inGit.ok) throw new Error(inGit.why)
142
+ }
138
143
  const task = session.updateTask(b)
139
144
  session.noteTaskChange(before, task, b.via)
140
145
  if (b.column === 'doing' && task) session.personaSays(b.via, task.title) // taking a task can name an AI session
141
146
  if (task && (b.column === 'doing' || b.column === 'done')) session.stitchClock(b.via, b.column === 'doing')
142
- return { task, tasks: session.taskList() }
147
+ // Taking a ticket opens it: this folder moves onto the ticket's branch (session.js openTask).
148
+ const branch = b.column === 'doing' && task ? await session.openTask(task.id).catch(() => null) : null
149
+ return { task: branch ? session.taskList().find((t) => t.id === task.id) || task : task, tasks: session.taskList(), ...(branch && !branch.already ? { branch } : {}) }
143
150
  },
151
+ // Opening a ticket without moving it on the board, and going back to the default branch.
152
+ 'POST /tasks/open': async (b) => ({ branch: await session.openTask(b.id), tasks: session.taskList() }),
153
+ 'POST /tasks/leave': async () => ({ branch: await session.leaveTask() }),
144
154
  // What an agent gets when it picks a task up: history for its files, the project's checks.
145
155
  'POST /tasks/brief': (b) => session.taskBrief(b.id),
146
156
  'POST /tasks/comment': (b) => {
package/src/gitstate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // What git is doing to a synced folder: which branch (or commit) the folder is on, whether git is
2
2
  // at work in it, and what a file looked like at a commit, so a checkout of another branch is told
3
3
  // apart from edits and the folder can follow its branch (session.js). Quilt does two things to git
4
- // itself, both at the end of this file: it fetches the branch's upstream, and it moves the branch
5
- // forward to a commit it is behind (never merging history). Every git call is asynchronous (the
4
+ // itself, all at the end of this file: it fetches the branch's upstream, it moves the branch forward
5
+ // to a commit it is behind (never merging history), and it checks out the branch of a ticket someone opens. Every git call is asynchronous (the
6
6
  // app's window and its relay connection never wait on git); the file reads below are synchronous.
7
7
  import fs from 'node:fs'
8
8
  import path from 'node:path'
@@ -403,6 +403,39 @@ export async function changesBetween (root, from, to) {
403
403
  return changes
404
404
  }
405
405
 
406
+ /** Whether the repository has a local branch called `name`. */
407
+ export async function hasBranch (root, name) {
408
+ return (await call(root, ['rev-parse', '-q', '--verify', `refs/heads/${name}`])).out !== null
409
+ }
410
+
411
+ /**
412
+ * Checks out `branch` in the folder, as `git checkout` does. `create`: a new branch, from the commit
413
+ * the folder is at, or from `track` (a remote's branch, "origin/x", which it then follows). `force`:
414
+ * tracked files become the commit's, whatever was changed in them (-f). '' when git did it, else
415
+ * git's own words for why not.
416
+ */
417
+ export async function switchBranch (root, branch, { create = false, force = false, track = null } = {}) {
418
+ const r = await call(root, ['checkout', '-q', ...(force ? ['-f'] : []), ...(create ? ['-b'] : []), branch, ...(create && track ? ['--track', track] : [])], { timeout: 20000 })
419
+ return r.out !== null ? '' : (r.stderr || '').trim().split('\n')[0] || 'git could not check it out'
420
+ }
421
+
422
+ /** The remote a branch with no upstream of its own would use: "origin" when the repository has it, else its only remote, else null. */
423
+ export async function defaultRemote (root) {
424
+ const names = ((await run(root, ['remote'])) || '').split('\n').map((l) => l.trim()).filter(Boolean)
425
+ return names.includes('origin') ? 'origin' : names.length === 1 ? names[0] : null
426
+ }
427
+
428
+ /** "<remote>/<branch>" when the repository knows that branch on the remote (as of its last fetch), else null. */
429
+ export async function remoteBranch (root, remote, branch) {
430
+ if (!remote || !branch) return null
431
+ return (await call(root, ['rev-parse', '-q', '--verify', `refs/remotes/${remote}/${branch}^{commit}`])).out !== null ? `${remote}/${branch}` : null
432
+ }
433
+
434
+ /** Makes local `branch` follow `upstream` ("origin/x"), as `git branch --set-upstream-to` does; whether git did. */
435
+ export async function follow (root, branch, upstream) {
436
+ return (await call(root, ['branch', '-q', `--set-upstream-to=${upstream}`, branch])).out !== null
437
+ }
438
+
406
439
  /** Stages `rels` as they are in the folder (git add); whether git did. */
407
440
  export async function stage (root, rels) {
408
441
  for (let i = 0; i < rels.length; i += MAX_PATHSPECS) {
package/src/mcp.js CHANGED
@@ -29,7 +29,7 @@ import { pickAgent, agentWhoami, agentAccess, readAgent, savedAgents } from './a
29
29
  import { setSessionWorkspace, announceSessionStarted, announceWhenReported, apiUrl, readAccount, resumeAccount } from './account.js'
30
30
  import { registerWorkspaceTools, bytesFetcher, isInside } from './workspace-tools.js'
31
31
  import { quiltHome } from './legacy.js'
32
- import { TASK_WORKFLOW, pickupBrief, doneRefusal, verifiedEnough, verifiedLine, qaRefusal, qaNotesEnough, qaNotesLine, MAX_VERIFIED } from './agent-task-workflow.js'
32
+ import { TASK_WORKFLOW, pickupBrief, taskBranchNote, doneRefusal, verifiedEnough, verifiedLine, qaRefusal, qaNotesEnough, qaNotesLine, MAX_VERIFIED } from './agent-task-workflow.js'
33
33
  import { formatHistory } from './history.js'
34
34
  import { renderInbox, describeEvent, INBOX_HOW } from './inbox.js'
35
35
  import { renderConversation, renderContext, CONVERSATION_DESCRIPTION } from './conversation.js'
@@ -259,8 +259,8 @@ export async function runMcp () {
259
259
  }, { gate: gateFor('quilt_add_task') }))
260
260
 
261
261
  server.registerTool('quilt_move_task', {
262
- description: 'Move a task on the shared board. "doing" when you start it: you get a briefing (its files, recent changes to them, the project\'s checks). ' +
263
- '"qa" when you finish implementing and testing: requires `qaNotes` (what changed and how you self-validated); without it the move is refused. ' +
262
+ description: 'Move a task on the shared board. "doing" when you start it: you get a briefing (its files, recent changes to them, the project\'s checks), and your folder moves onto the ticket\'s own git branch (quilt/<ticket>), where everyone who has the ticket open works together. ' +
263
+ '"qa" when you finish implementing and testing: requires `qaNotes` (what changed and how you self-validated); without it the move is refused, and so is an agent\'s move while the ticket\'s branch is not committed and pushed. ' +
264
264
  '"done" after QA: requires `verified`, what you ran and what you saw; without it the move is refused.',
265
265
  inputSchema: {
266
266
  id: z.string().describe('Task id from quilt_tasks'),
@@ -275,8 +275,8 @@ export async function runMcp () {
275
275
  const patch = { id, column }
276
276
  if (column === 'qa') patch.qaNotes = qaNotes
277
277
  if (column === 'done') patch.verified = verified
278
- const { task } = await call(d, 'POST', '/tasks/update', patch)
279
- if (column === 'doing') return pickupBrief({ ...brief, task: { ...task, comments: brief.task.comments } })
278
+ const { task, branch } = await call(d, 'POST', '/tasks/update', patch)
279
+ if (column === 'doing') return pickupBrief({ ...brief, task: { ...task, comments: brief.task.comments } }) + taskBranchNote(branch)
280
280
  if (column === 'qa') return `Moved "${task.title}" to QA. Notes: ${qaNotesLine(task)}` + await nextUp(d)
281
281
  if (column === 'done') return `Moved "${task.title}" to Done. Verified: ${verifiedLine(task)}` + await nextUp(d)
282
282
  return `Moved "${task.title}" to ${columnName(task.column)}.`
package/src/session.js CHANGED
@@ -53,7 +53,7 @@ import { HELD_MAP, readHeld, findHeld, settleHeld, renderHeld, versionsOf, versi
53
53
  import { RELAY_NAME as RELAY_BY, isRelay } from './ui/chat.js'
54
54
  import { cleanTyping, TYPING_MS, AGENT_TYPING_MS } from './ui/chat.js'
55
55
  import { DEFAULT_KEY } from './branchdocs.js'
56
- 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 } from './gitstate.js'
56
+ 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 } from './gitstate.js'
57
57
  import { cleanVoice, 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'
58
58
  import { toolInUse } from './agents/common.js'
59
59
 
@@ -66,6 +66,9 @@ function slug (s, max = 40) {
66
66
  return String(s || '').toLowerCase().normalize('NFKD').replace(/[^\w\s-]/g, '').trim().replace(/[\s_]+/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '').slice(0, max).replace(/-$/, '') || 'work'
67
67
  }
68
68
 
69
+ /** A ticket's branch is quilt/<the ticket's title, shortened>. */
70
+ export const TICKET_PREFIX = 'quilt/'
71
+
69
72
  /** Whether `root` is a git checkout (a .git folder, or a worktree's pointer file). */
70
73
  function hasGitDir (root) {
71
74
  try { fs.statSync(path.join(root, '.git')); return true } catch { return false }
@@ -2350,7 +2353,14 @@ export class Session extends EventEmitter {
2350
2353
  async checkUpstream ({ fetch = false } = {}) {
2351
2354
  if (this.stopped || !this.ready || !this.git || !this.git.branch) return
2352
2355
  const branch = this.git.branch
2353
- const up = await upstreamOf(this.root)
2356
+ let up = await upstreamOf(this.root)
2357
+ if (!up && branch.startsWith(TICKET_PREFIX)) {
2358
+ // A ticket's branch made here follows nothing yet. Once a partner pushes it, it follows theirs, so their commits come in here too.
2359
+ const remote = await defaultRemote(this.root)
2360
+ if (remote && fetch) await fetchUpstream(this.root, remote)
2361
+ const theirs = await remoteBranch(this.root, remote, branch)
2362
+ if (theirs && !this.stopped && headName(this.root) === branch && await follow(this.root, branch, theirs)) up = await upstreamOf(this.root)
2363
+ }
2354
2364
  if (!up || !up.remote || up.remote === '.') { this.setUpstream(null); return }
2355
2365
  if (fetch) {
2356
2366
  const f = await fetchUpstream(this.root, up.remote)
@@ -2508,6 +2518,183 @@ export class Session extends EventEmitter {
2508
2518
  this.setUpstream({ name: facts.name, sha: to, behind: 0, ahead: 0, brought: { count: facts.behind, files: written, at: Date.now() } })
2509
2519
  }
2510
2520
 
2521
+ // ------------------------------------------------------ ticket branches --
2522
+ // A ticket is a unit of work, and its work is on a branch of its own: quilt/<ticket> (Daniel,
2523
+ // 2026-11-18). Opening a ticket (from the board, or an AI taking it) moves this folder, a git clone,
2524
+ // onto that branch. Everyone who has the ticket open edits live together there, and nobody else
2525
+ // gets that work until it is merged. The first to open a ticket makes its branch from the latest
2526
+ // commit of the branch they are on, without the uncommitted work everyone has there (the session
2527
+ // keeps that there). An agent's ticket moves to QA only once its work on the branch is committed
2528
+ // and pushed. Nobody has to open a ticket: a folder stays on whatever branch git has it on.
2529
+
2530
+ /** One move between branches at a time in this folder (two at once fought over git's index). */
2531
+ branchMove (fn) {
2532
+ const p = (this.branchMoves || Promise.resolve()).then(fn)
2533
+ this.branchMoves = p.catch(() => {})
2534
+ return p
2535
+ }
2536
+
2537
+ /** Opens ticket `id`: see openTaskNow. */
2538
+ openTask (id) { return this.branchMove(() => this.openTaskNow(id)) }
2539
+
2540
+ /** Leaves the ticket this folder has open: see leaveTaskNow. */
2541
+ leaveTask () { return this.branchMove(() => this.leaveTaskNow()) }
2542
+
2543
+ /** Waits, a few seconds at most, for git and a move between branches in this folder to finish; whether they have. */
2544
+ async gitQuiet (ms = 8000) {
2545
+ const busy = () => !!(this.hold || this.pendingMove || this.gitBusy())
2546
+ const until = Date.now() + ms
2547
+ while (busy() && Date.now() < until) await new Promise((resolve) => setTimeout(resolve, 200))
2548
+ return !busy()
2549
+ }
2550
+
2551
+ /**
2552
+ * Before Quilt itself checks out another branch: what was saved in this folder is in the session
2553
+ * first. A save the watcher has not reported yet is looked for, git's own work here is waited out,
2554
+ * and so is every save on its way to the relay (`ms` at most). The checkout would otherwise take
2555
+ * the file away before it was shared: lost when it was not committed, and written back over by
2556
+ * the session's older version when the folder came back to the branch. Whether the folder is quiet.
2557
+ */
2558
+ async savesSent (ms = 8000) {
2559
+ this.scanDisk()
2560
+ this.flushPending()
2561
+ const busy = () => !!(this.hold || this.pendingMove || this.gitBusy() || this.pending.size || this.relayWriting.size)
2562
+ const until = Date.now() + ms
2563
+ while (busy() && Date.now() < until && !this.stopped) await new Promise((resolve) => setTimeout(resolve, 100))
2564
+ return !busy()
2565
+ }
2566
+
2567
+ /** The folder has arrived on `branch` in git and in the session, and is quiet: waited for, for `ms` at most. */
2568
+ async arrivedOn (branch, ms = 20000) {
2569
+ const there = () => !!this.git && this.git.branch === branch && !this.hold && !this.pendingMove
2570
+ const until = Date.now() + ms
2571
+ while (!there() && Date.now() < until) await new Promise((resolve) => setTimeout(resolve, 200))
2572
+ return there()
2573
+ }
2574
+
2575
+ /** The session's default branch, as git names it. */
2576
+ defaultBranch () { return (this.branchList.find((b) => b && b.default) || {}).key || 'main' }
2577
+
2578
+ /** The ticket whose branch this folder is on, or null. */
2579
+ openedTask () {
2580
+ const here = this.git && this.git.branch
2581
+ return (here && this.taskList().find((t) => t && !t.archived && t.branch === here)) || null
2582
+ }
2583
+
2584
+ /** The ticket's branch: the one it has, or a new name for it (kept on the ticket, so everyone uses the same). */
2585
+ branchOfTask (task) {
2586
+ if (task.branch) return task.branch
2587
+ const taken = new Set(this.taskList().map((t) => t && t.branch).filter(Boolean))
2588
+ const base = `${TICKET_PREFIX}${slug(task.title)}`
2589
+ let name = base
2590
+ for (let n = 2; taken.has(name); n++) name = `${base}-${n}`
2591
+ this.updateTask({ id: task.id, branch: name })
2592
+ return name
2593
+ }
2594
+
2595
+ /**
2596
+ * Moves this folder onto ticket `id`'s branch. Returns { branch, from } (`already`: it was on it;
2597
+ * `again`: this folder had the branch from before; `remote`: made from the branch a partner
2598
+ * pushed), { stayed, why } when the folder stays where it is, or null when the folder is not a git
2599
+ * clone on a branch (tickets have no branch there).
2600
+ */
2601
+ async openTaskNow (id) {
2602
+ const task = this.taskList().find((t) => t && t.id === id)
2603
+ if (!task) throw new Error('no such task')
2604
+ if (this.stopped || !this.git || !this.git.branch) return null
2605
+ let from = this.git.branch
2606
+ const stays = (why) => { this.log(`🌿 staying on ${from}: ${why}`); return { stayed: from, why } }
2607
+ if (!(await this.savesSent())) return stays('git is at work in this folder. Try again in a moment.')
2608
+ from = this.git.branch
2609
+ const name = this.branchOfTask(task)
2610
+ if (from === name) return { branch: name, from, already: true }
2611
+ const again = await hasBranch(this.root, name)
2612
+ let remote = null
2613
+ if (!again) {
2614
+ // A new branch is not made on top of another ticket's commits: from the default branch instead.
2615
+ if (from.startsWith(TICKET_PREFIX)) {
2616
+ const main = this.defaultBranch()
2617
+ const back = await switchBranch(this.root, main, { force: true })
2618
+ if (back || !(await this.arrivedOn(main))) return stays(`git could not go back to ${main} from it${back ? ` (${back})` : ''}.`)
2619
+ from = main
2620
+ }
2621
+ // It starts from the latest the remote has (a ticket merged meanwhile is then in it): fetched and brought in now, when that is all it takes.
2622
+ if (this.bringInUpstream) await this.caughtUp(from)
2623
+ if (!(await this.gitQuiet()) || !this.git || this.git.branch !== from) return stays('git is at work in this folder. Try again in a moment.')
2624
+ // A partner who opened the ticket first may have pushed its branch: this folder's then starts from theirs, and follows it.
2625
+ remote = await remoteBranch(this.root, await defaultRemote(this.root), name)
2626
+ }
2627
+ const said = await switchBranch(this.root, name, { create: !again, force: true, track: remote })
2628
+ if (said || !(await this.arrivedOn(name))) return stays(`git could not ${again ? 'check out' : 'make'} ${name}${said ? ` (${said})` : ''}.`)
2629
+ this.log(`🌿 on ${name} for "${task.title}"${again ? '' : ` (made from ${remote || from})`}`)
2630
+ return { branch: name, from, ...(again ? { again: true } : {}), ...(remote ? { remote: true } : {}) }
2631
+ }
2632
+
2633
+ /** Back to the session's default branch from a ticket's. { branch, from }, { stayed, why }, or null when no ticket's branch is checked out. */
2634
+ async leaveTaskNow () {
2635
+ if (this.stopped || !this.git || !this.git.branch || !this.git.branch.startsWith(TICKET_PREFIX)) return null
2636
+ const from = this.git.branch
2637
+ const main = this.defaultBranch()
2638
+ const stays = (why) => { this.log(`🌿 staying on ${from}: ${why}`); return { stayed: from, why } }
2639
+ if (!(await this.savesSent())) return stays('git is at work in this folder. Try again in a moment.')
2640
+ const said = await switchBranch(this.root, main, { force: true })
2641
+ if (said || !(await this.arrivedOn(main))) return stays(`git could not check out ${main}${said ? ` (${said})` : ''}.`)
2642
+ this.log(`🌿 back on ${main}; what you had not committed on ${from} stays there in the session`)
2643
+ return { branch: main, from }
2644
+ }
2645
+
2646
+ /**
2647
+ * Fetches `branch`'s upstream and waits, `ms` at most, for the folder to have its commits (bringIn
2648
+ * runs once the folder is in step with the session, which takes a moment just after arriving on the
2649
+ * branch). Whether the branch is at its upstream; false too when its commits are left to the person's git.
2650
+ */
2651
+ async caughtUp (branch, ms = 15000) {
2652
+ const until = Date.now() + ms
2653
+ for (let first = true; Date.now() < until; first = false) {
2654
+ await this.gitQuiet()
2655
+ await this.checkUpstream({ fetch: first }).catch(() => {})
2656
+ const up = await upstreamOf(this.root)
2657
+ const tip = await branchTip(this.root, branch)
2658
+ if (!up || !up.sha || !tip || this.stopped) return false
2659
+ if (up.sha === tip) return true
2660
+ const n = await aheadBehind(this.root, tip, up.sha)
2661
+ if (!n || !n.behind || (this.upstream && this.upstream.sha === up.sha && this.upstream.waiting)) return false
2662
+ await new Promise((resolve) => setTimeout(resolve, 1000))
2663
+ }
2664
+ return false
2665
+ }
2666
+
2667
+ /** The files this member wrote on the branch it is on (by the session's record) that git has not committed, sorted. */
2668
+ async ownUncommitted () {
2669
+ const mine = new Set()
2670
+ for (const a of this.activity) if (a && a.by === this.name && a.branch === this.branch && typeof a.path === 'string' && a.path) mine.add(a.path)
2671
+ if (!mine.size) return []
2672
+ const st = await treeState(this.root, [...mine])
2673
+ return st ? [...mine].filter((rel) => st.dirty.has(rel)).sort() : []
2674
+ }
2675
+
2676
+ /**
2677
+ * Whether an agent's work on a ticket is in git, asked when it moves a task to QA or Done: null when
2678
+ * there is nothing to hold it to (a person, no git clone, a folder not on a ticket's branch), else
2679
+ * { ok: true, branch } or { ok: false, why } with what to do.
2680
+ */
2681
+ async taskInGit () {
2682
+ if (this.kind !== 'agent' || !this.git || !this.git.branch || !this.git.branch.startsWith(TICKET_PREFIX)) return null
2683
+ const branch = this.git.branch
2684
+ const dirty = await this.ownUncommitted()
2685
+ if (dirty.length) {
2686
+ return { ok: false, why: `Get this ticket's work into git first: ${dirty.slice(0, 6).join(', ')}${dirty.length > 6 ? ` and ${dirty.length - 6} more` : ''} ${dirty.length === 1 ? 'is' : 'are'} not committed on ${branch}. Commit only the files you changed, push with \`git push -u origin ${branch}\`, then move the task again.` }
2687
+ }
2688
+ const up = await upstreamOf(this.root)
2689
+ const tip = await branchTip(this.root, branch)
2690
+ if (!up || !up.sha || !tip) return { ok: false, why: `Push ${branch} first: \`git push -u origin ${branch}\`. Open the pull request yourself (\`gh pr create\`), then move the task again.` }
2691
+ if (up.sha !== tip) {
2692
+ const n = await aheadBehind(this.root, tip, up.sha)
2693
+ if (!n || n.ahead) return { ok: false, why: `Push ${branch} first: it has ${n ? `${n.ahead} commit${n.ahead === 1 ? '' : 's'}` : 'commits'} the remote doesn't (\`git push\`). Then move the task again.` }
2694
+ }
2695
+ return { ok: true, branch }
2696
+ }
2697
+
2511
2698
  /**
2512
2699
  * Puts back the .git an older Quilt set aside in this folder (git-aside.js), once, when the session
2513
2700
  * starts and the relay has synced. A folder that got a new .git meanwhile keeps both. Whether git came back.
package/src/tasks.js CHANGED
@@ -144,10 +144,11 @@ export function publicTask (value) {
144
144
  // When it was archived. Tasks archived before this was kept have none; a bad value is dropped, not the task.
145
145
  const archivedAt = archived && Number.isFinite(value.archivedAt) && value.archivedAt > 0 ? value.archivedAt : 0
146
146
  const pr = storedPull(value.pr)
147
+ const branch = storedBranch(value.branch)
147
148
  // "Not for auto pickup": no AI takes it from the board by itself (nextTask, autowork.js) until someone clears it. Kept only when on.
148
149
  const noPickup = storedFlag(value.noPickup)
149
150
  if (noPickup == null) return null
150
- return { id: value.id, title, column: value.column, by: value.by, order: value.order, ts: value.ts, ...who, files, conv, verified, qaNotes, recurring, cron, archived, ...(archivedAt ? { archivedAt } : {}), ...(pr ? { pr } : {}), ...(noPickup ? { noPickup: true } : {}) }
151
+ return { id: value.id, title, column: value.column, by: value.by, order: value.order, ts: value.ts, ...who, files, conv, verified, qaNotes, recurring, cron, archived, ...(archivedAt ? { archivedAt } : {}), ...(pr ? { pr } : {}), ...(branch ? { branch } : {}), ...(noPickup ? { noPickup: true } : {}) }
151
152
  }
152
153
 
153
154
  /** Tasks still on the board: archived ones are kept, but off the board and out of every listing. */
@@ -191,6 +192,11 @@ function storedFlag (v) {
191
192
  return v
192
193
  }
193
194
 
195
+ /** The git branch a ticket's work is on (set when someone first opens the ticket), or ''; a bad value reads as none. */
196
+ export function storedBranch (v) {
197
+ return typeof v === 'string' && v.length <= 200 && /^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(v) && !v.includes('..') && !v.endsWith('/') && !v.endsWith('.lock') ? v : ''
198
+ }
199
+
194
200
  /** The pull request a task's work is in ({ number, url, branch, base }, set by the relay when the branch is pushed), or null; a bad value reads as none. */
195
201
  function storedPull (v) {
196
202
  if (!v || typeof v !== 'object' || !Number.isInteger(v.number) || v.number < 1 || typeof v.url !== 'string' || v.url.length > 400) return null
@@ -348,7 +354,7 @@ export function addTask (doc, map, { id = null, title, by, assignee = '', forAi
348
354
  * Moving an archived task to another column brings it back onto the board.
349
355
  * `cron` is 5-field cron or a phrase such as "daily at 9". A schedule turns `recurring` on.
350
356
  */
351
- export function updateTask (doc, map, { id, title, column, before, assignee, forAi, tool, files, verified, qaNotes, recurring, cron, archived, pr, noPickup } = {}, origin) {
357
+ export function updateTask (doc, map, { id, title, column, before, assignee, forAi, tool, files, verified, qaNotes, recurring, cron, archived, pr, noPickup, branch } = {}, origin) {
352
358
  const { valid } = split(map)
353
359
  const cur = valid.find((t) => t.id === id)
354
360
  if (!cur) throw new Error('no such task')
@@ -358,6 +364,10 @@ export function updateTask (doc, map, { id, title, column, before, assignee, for
358
364
  const clean = pr === null ? null : storedPull(pr)
359
365
  if (JSON.stringify(clean) !== JSON.stringify(cur.pr || null)) { if (clean) next.pr = clean; else delete next.pr; changed = true }
360
366
  }
367
+ if (branch !== undefined) {
368
+ const clean = storedBranch(branch)
369
+ if (clean !== (cur.branch || '')) { if (clean) next.branch = clean; else delete next.branch; changed = true }
370
+ }
361
371
  if (title !== undefined) {
362
372
  const clean = cleanTitle(title)
363
373
  if (!clean) throw new Error('say what the task is')
@@ -97,7 +97,7 @@ export function agentGuide ({ apiUrl = 'https://api.heyquilt.com', via = 'both'
97
97
  '',
98
98
  '### Getting your work into git',
99
99
  '- Work that is only in the session has not shipped. Get it into git yourself as soon as it is finished and tested, before you move its task to QA.',
100
- 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: commit only the files you changed (never \`git add -A\` or \`git commit -a\`: the folder holds other people's unfinished work), and push. Where the project works by pull requests, make a branch of your own (\`git checkout -b <name>\`) and open the pull request yourself. Quilt does not commit, push, open pull requests or merge them for anyone.` : null,
100
+ 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. 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. Quilt does not commit, push, open pull requests or merge them for anyone.` : null,
101
101
  cli ? `- ${both ? 'With the CLI: s' : 'S'}witching branches moves your folder to that branch's work in the session, 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 session keeps that work on the branch you leave. A \`git stash\` on its own is put back a moment later.` : null,
102
102
  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 session'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,
103
103
  http ? `- ${both ? 'Over HTTP you have no folder, so ' : 'You have no folder, so '}you cannot commit. What you write is in the session 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,
package/src/ui/app.css CHANGED
@@ -2776,6 +2776,17 @@ body.has-asks .ws { height: calc(100vh - var(--update-bar, 0px) - var(--asks-bar
2776
2776
  .task-nopickup-x { margin-left: 2px; opacity: .55; font-weight: 700; }
2777
2777
  .task-nopickup:hover .task-nopickup-x, .task-nopickup:focus-visible .task-nopickup-x { opacity: 1; }
2778
2778
  .task-nopickup:hover, .task-nopickup:focus-visible { background: color-mix(in srgb, var(--warn) 20%, transparent); outline: none; }
2779
+ /* A ticket's branch on its card (board.js ticketHtml): who is working there, and Open or Leave. */
2780
+ .task-ticket { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; min-height: 24px; }
2781
+ .task-ticket-who { display: inline-flex; align-items: center; gap: 5px; flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted); }
2782
+ .task-ticket-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2783
+ .task-ticket-who svg { width: 12px; height: 12px; flex: none; }
2784
+ .task-ticket.here .task-ticket-who { color: var(--accent); }
2785
+ .task button.task-ticket-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; margin-left: auto; padding: 2px 9px; border: 1px solid var(--border-strong); border-radius: 999px; background: transparent; color: var(--text); font: inherit; font-size: 11.5px; cursor: pointer; }
2786
+ .task-ticket > .task-ticket-btn:only-child { flex: 1; margin-left: 0; }
2787
+ .task button.task-ticket-btn svg { width: 12px; height: 12px; flex: none; }
2788
+ .task button.task-ticket-btn:hover, .task button.task-ticket-btn:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
2789
+ .task button.task-ticket-btn:disabled { opacity: .5; cursor: default; }
2779
2790
  /* A cloud AI's own name in chat, then whose AI it is ("Juniper Daniel's AI"). */
2780
2791
  .msg .head .ai-tag { font-size: 10.5px; padding: 0 7px; }
2781
2792
  .signup-form { width: 100%; text-align: left; }
package/src/ui/board.js CHANGED
@@ -25,7 +25,7 @@ const COLUMNS = [
25
25
  * `archived` shows the archived tasks in place of the columns. `show` keeps only some tasks:
26
26
  * '' everyone's, 'none' unassigned ones, `p:name` a person's, `a:name` that person's AI's.
27
27
  */
28
- export function renderBoard (tasks, me, people = [], assignTo = '', { archived = false, show = '', closedGroups = [] } = {}) {
28
+ export function renderBoard (tasks, me, people = [], assignTo = '', { archived = false, show = '', closedGroups = [], git = null } = {}) {
29
29
  const every = (Array.isArray(tasks) ? tasks : []).filter(Boolean)
30
30
  const all = every.filter((t) => showsTask(t, show))
31
31
  const list = all.filter((t) => !t.archived)
@@ -34,7 +34,7 @@ export function renderBoard (tasks, me, people = [], assignTo = '', { archived =
34
34
  const cols = COLUMNS.map((col) => {
35
35
  const cards = list.filter((t) => t && t.column === col.id)
36
36
  const body = cards.length
37
- ? cards.map((t) => card(t, col, me, people)).join('')
37
+ ? cards.map((t) => card(t, col, me, people, git)).join('')
38
38
  : `<p class="board-empty">${col.id === 'todo' ? 'Nothing here yet.' : 'Nothing here.'}</p>`
39
39
  const n = cards.length
40
40
  // When the board is too narrow for every column, session.js folds some to a strip:
@@ -444,7 +444,28 @@ export function matchesSearch (text, query) {
444
444
  return words.every((w) => text.includes(w))
445
445
  }
446
446
 
447
- function card (t, col, me, people) {
447
+ /**
448
+ * A ticket's branch on its card. `git`: { branch: the branch this folder is on, on: Map of a branch
449
+ * to the others whose folders are on it }, or null when this folder is not a git clone (tickets
450
+ * have no branch here: nothing is shown). Opening a ticket moves your folder onto its branch;
451
+ * everyone who has it open works there together. Open: Leave takes your folder back.
452
+ */
453
+ export function ticketHtml (t, git) {
454
+ if (!git || !git.branch) return ''
455
+ const here = !!t.branch && t.branch === git.branch
456
+ const others = (t.branch && git.on && git.on.get(t.branch)) || []
457
+ const names = others.length > 2 ? `${others.slice(0, 2).join(', ')} +${others.length - 2}` : others.join(' and ')
458
+ const who = here ? (names ? `You and ${names} are working here` : 'You are working here') : names ? `${names} ${others.length === 1 ? 'is' : 'are'} working here` : ''
459
+ const tip = t.branch ? `Its branch: ${t.branch}` : 'It gets a branch of its own when someone opens it'
460
+ return `<div class="task-ticket${here ? ' here' : ''}" title="${esc(tip)}">
461
+ ${who ? `<span class="task-ticket-who">${I.branch}<span>${esc(who)}</span></span>` : ''}
462
+ ${here
463
+ ? `<button type="button" class="task-ticket-btn" data-task-leave title="Take your folder back to the session's main branch. What you have not committed stays on this ticket.">Leave</button>`
464
+ : `<button type="button" class="task-ticket-btn" data-task-open title="Move your folder onto this ticket's branch. Everyone who has the ticket open works there together.">${I.branch}<span>Open ticket</span></button>`}
465
+ </div>`
466
+ }
467
+
468
+ function card (t, col, me, people, git = null) {
448
469
  const who = t.by === me ? 'You' : (t.by || '')
449
470
  const mine = t.assignee === me && !t.forAi ? ' mine' : t.assignee === me && t.forAi ? ' mine-ai' : ''
450
471
  const moves = col.moves.map((m) =>
@@ -462,6 +483,7 @@ function card (t, col, me, people) {
462
483
  <p class="task-title" title="Click to rename">${esc(t.title)}</p>
463
484
  </div>
464
485
  ${noPickupHtml(t)}
486
+ ${ticketHtml(t, git)}
465
487
  <select class="task-assign" aria-label="Assign ${esc(t.title)}">${assignOptions(t, me, people)}</select>
466
488
  ${recurHtml(t)}
467
489
  ${filesHtml(t.files)}
package/src/ui/session.js CHANGED
@@ -1770,6 +1770,29 @@ function bindBoard () {
1770
1770
  catch (err) { toast(err.message) }
1771
1771
  return
1772
1772
  }
1773
+ const ticket = e.target.closest('[data-task-open], [data-task-leave]')
1774
+ if (ticket) {
1775
+ // Opening a ticket moves this folder onto its branch; leaving takes it back (session.js openTask, leaveTask).
1776
+ const id = ticket.closest('.task')?.dataset.task
1777
+ const task = (sum()?.status.tasks || []).find((t) => t.id === id)
1778
+ if (!id || !task || ticket.disabled) return
1779
+ const opening = ticket.matches('[data-task-open]')
1780
+ ticket.disabled = true
1781
+ try {
1782
+ const sid = current
1783
+ const r = await api('POST', `/api/sessions/${sid}/tasks/${opening ? 'open' : 'leave'}`, opening ? { id } : {})
1784
+ if (sid !== current) return
1785
+ const s = state.sessions.get(sid)
1786
+ if (s && r.tasks) s.status.tasks = r.tasks
1787
+ const b = r.branch
1788
+ if (!b) toast(opening ? 'This folder is not a git clone, so tickets have no branch here.' : 'You are not on a ticket\'s branch.')
1789
+ else if (b.stayed) toast(`Your folder stays on ${b.stayed}: ${b.why}`)
1790
+ else if (opening) toast(`Your folder is on "${task.title}" now (${b.branch}).`)
1791
+ else toast(`Your folder is back on ${b.branch}. What you had not committed stays on the ticket.`)
1792
+ paintBoard({ force: true })
1793
+ } catch (err) { toast(err.message) } finally { ticket.disabled = false }
1794
+ return
1795
+ }
1773
1796
  const removeFile = e.target.closest('[data-file-remove]')
1774
1797
  if (removeFile) {
1775
1798
  const id = removeFile.closest('.task')?.dataset.task
@@ -1910,7 +1933,11 @@ function renderMain () {
1910
1933
  // A task an older app gave to one of someone's AI sessions ("Dana · login") is that person's.
1911
1934
  const who = owners(sum())
1912
1935
  const tasks = (st.tasks || []).map((t) => (t && who.has(t.assignee) ? { ...t, assignee: who.get(t.assignee) } : t))
1913
- const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || [] })
1936
+ // Tickets and their branches: where this folder is in git, and who else is on which branch.
1937
+ const on = new Map()
1938
+ for (const p of st.peers || []) if (p && p.branch && p.name !== st.me.name) on.set(p.branch, [...new Set([...(on.get(p.branch) || []), p.name])])
1939
+ const git = st.git && st.git.branch ? { branch: st.git.branch, on } : null
1940
+ const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || [], git })
1914
1941
  // Status ticks arrive every few seconds. Re-rendering an unchanged board
1915
1942
  // would throw away hover, selection and scroll for nothing.
1916
1943
  if (html === lastBoard.html && lastBoard.el && el.firstElementChild === lastBoard.el) return
package/src/ui-server.js CHANGED
@@ -1183,11 +1183,11 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1183
1183
  'POST /api/sessions/:id/tasks': (b, id) => ({ task: get(id).addTask(b), tasks: get(id).taskList() }),
1184
1184
  'POST /api/sessions/:id/tasks/update': async (b, id) => {
1185
1185
  const s = get(id)
1186
- const before = s.taskList().find((t) => t.id === b.id) || null
1187
- // Done merges the task's pull request first (relay-commit.js): refused with the reason when it can't be.
1188
- const finished = b.column === 'done' && before && before.column !== 'done' ? await s.finishTask(b.id) : null
1189
- return { task: s.updateTask(b), tasks: s.taskList(), ...(finished && finished.merged ? { merged: finished.merged } : {}) }
1186
+ return { task: s.updateTask(b), tasks: s.taskList() }
1190
1187
  },
1188
+ // Opening a ticket moves this folder onto the ticket's branch (session.js openTask); leaving goes back to the default branch.
1189
+ 'POST /api/sessions/:id/tasks/open': async (b, id) => { const s = get(id); const branch = await s.openTask(b.id); pushStatus(id); return { branch, tasks: s.taskList() } },
1190
+ 'POST /api/sessions/:id/tasks/leave': async (b, id) => { const branch = await get(id).leaveTask(); pushStatus(id); return { branch } },
1191
1191
  'POST /api/sessions/:id/tasks/delete': (b, id) => { get(id).deleteTask(b.id); return { tasks: get(id).taskList() } },
1192
1192
  'POST /api/sessions/:id/tasks/comment': (b, id) => ({ ...get(id).commentTask(b), tasks: get(id).taskList() }),
1193
1193
  'GET /api/sessions/:id/feed': (b, id, url) => {