heyquilt 0.3.182 → 0.3.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -97
- package/RELEASES.md +8 -0
- package/bin/quilt.js +32 -32
- package/desktop/main.js +1 -1
- package/package.json +1 -1
- package/src/account.js +2 -2
- package/src/admit-policy.js +2 -2
- package/src/agent-join.js +3 -3
- package/src/agent-task-workflow.js +14 -14
- package/src/ai-vm.js +1 -1
- package/src/api/agent-placement.js +2 -2
- package/src/api/audit.js +1 -1
- package/src/api/file-paths.js +1 -1
- package/src/api/file-store.js +1 -1
- package/src/api/invite-email.js +4 -4
- package/src/api/join-text.js +5 -5
- package/src/api/notify.js +7 -7
- package/src/api/permissions.js +1 -1
- package/src/api/routes/agent-wake.js +1 -1
- package/src/api/routes/agents.js +2 -2
- package/src/api/routes/ai-vm.js +5 -5
- package/src/api/routes/connections.js +13 -13
- package/src/api/routes/grants.js +2 -2
- package/src/api/routes/mail.js +10 -10
- package/src/api/routes/relay.js +1 -1
- package/src/api/routes/secrets.js +11 -11
- package/src/api/routes/session-invites.js +5 -5
- package/src/api/routes/sessions.js +3 -3
- package/src/api/routes/workspace-agents.js +14 -14
- package/src/api/routes/workspace-files.js +12 -12
- package/src/api/routes/workspace-invites.js +5 -5
- package/src/api/routes/workspaces.js +11 -11
- package/src/api/secrets-access.js +1 -1
- package/src/api/server.js +3 -3
- package/src/api/team-access.js +1 -1
- package/src/api/workspace-access.js +1 -1
- package/src/api/workspace-reach.js +3 -3
- package/src/app-tools.js +10 -10
- package/src/autowork.js +4 -4
- package/src/branch-view.js +1 -1
- package/src/catchup.js +5 -5
- package/src/chat-links.js +18 -18
- package/src/connection.js +11 -11
- package/src/control.js +5 -5
- package/src/conversation.js +1 -1
- package/src/doctor.js +2 -2
- package/src/duties.js +1 -1
- package/src/fsutil.js +1 -1
- package/src/held.js +4 -4
- package/src/hooks.js +3 -3
- package/src/hosted-client.js +2 -2
- package/src/identity.js +1 -1
- package/src/inbox.js +1 -1
- package/src/key-cli.js +1 -1
- package/src/mail-tools.js +11 -11
- package/src/mcp-proxy.js +1 -1
- package/src/mcp.js +59 -59
- package/src/new-session.js +6 -6
- package/src/project-rules.js +2 -2
- package/src/relay-ask.js +2 -2
- package/src/relay-cluster.js +3 -3
- package/src/relay-live-write.js +3 -3
- package/src/relay-mcp.js +56 -56
- package/src/relay-prune.js +1 -1
- package/src/relay-turn-sync.js +1 -1
- package/src/secret-import.js +1 -1
- package/src/secret-names.js +6 -6
- package/src/secret-run.js +3 -3
- package/src/server.js +41 -41
- package/src/session-access.js +3 -3
- package/src/session-name.js +1 -1
- package/src/session.js +50 -50
- package/src/setup.js +7 -7
- package/src/status.js +2 -2
- package/src/tasks.js +1 -1
- package/src/turn-sync.js +4 -4
- package/src/ui/account-sessions.js +2 -2
- package/src/ui/agent-env-key.js +1 -1
- package/src/ui/agent-guide.js +35 -35
- package/src/ui/agent-kinds.js +8 -8
- package/src/ui/agent-place.js +16 -16
- package/src/ui/agents-table.js +6 -6
- package/src/ui/app.css +331 -0
- package/src/ui/app.js +28 -13
- package/src/ui/board.js +2 -2
- package/src/ui/catchup.js +5 -5
- package/src/ui/changes-seen.js +2 -2
- package/src/ui/changes.js +3 -3
- package/src/ui/cloud-ai.js +12 -12
- package/src/ui/common.js +1 -1
- package/src/ui/connections.js +1 -1
- package/src/ui/diffview.js +2 -2
- package/src/ui/feed.js +1 -1
- package/src/ui/feedback.js +4 -4
- package/src/ui/files.js +120 -14
- package/src/ui/fileview.js +3 -3
- package/src/ui/git-rule.js +3 -3
- package/src/ui/home.js +92 -47
- package/src/ui/index.html +1 -1
- package/src/ui/invite.js +8 -8
- package/src/ui/invites.js +3 -3
- package/src/ui/new-session.js +3 -3
- package/src/ui/prail-model.js +22 -0
- package/src/ui/prail.js +43 -0
- package/src/ui/project-board.js +359 -0
- package/src/ui/project-model.js +197 -0
- package/src/ui/project-pop.js +451 -0
- package/src/ui/projects.js +406 -0
- package/src/ui/sandbox-keys.js +3 -3
- package/src/ui/secrets-view.js +5 -5
- package/src/ui/session-words.js +2 -2
- package/src/ui/session.js +156 -43
- package/src/ui/tree.js +3 -3
- package/src/ui/voice.js +6 -6
- package/src/ui/workspaces.js +23 -23
- package/src/ui-server.js +78 -24
- package/src/update-check.js +2 -2
- package/src/voice.js +7 -7
- package/src/wake-tool.js +1 -1
- package/src/webhooks.js +1 -1
- package/src/workspace-cli.js +12 -12
- package/src/workspace-tools.js +33 -33
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// One task board for a project, across its codebases (the Tasks row of a project's sidebar). It is
|
|
2
|
+
// the board a codebase has (board.js draws both), with a row of chips to narrow it to one codebase
|
|
3
|
+
// and each card wearing its codebase's name. A task lives in its codebase's document, so the board
|
|
4
|
+
// shows the codebases open on this computer and says which are not; a change is saved to the
|
|
5
|
+
// codebase the task is in (the same routes a codebase's own board uses).
|
|
6
|
+
import { I, state, $, esc, api, toast, ago } from './common.js'
|
|
7
|
+
import { renderBoard, openTaskMenu, taskNotesModalHtml, matchesSearch, foldPlan, ticketHtml } from './board.js'
|
|
8
|
+
import { projectCodebases, projectBoard, splitBoardTaskId, boardAssignment, openTaskCount, tasksToKeep } from './project-model.js'
|
|
9
|
+
|
|
10
|
+
// What you picked on a project's board, kept while the app is open: the codebase, who, the search, folded columns.
|
|
11
|
+
const prefs = new Map()
|
|
12
|
+
const prefsOf = (id) => { if (!prefs.has(id)) prefs.set(id, { code: '', show: '', archived: false, query: '', opened: [], shut: [], into: '', draft: '', scroll: [], refocus: false }); return prefs.get(id) }
|
|
13
|
+
let live = null // the board on the page: { el, ro, later, leave }
|
|
14
|
+
|
|
15
|
+
// Each codebase's tasks as this computer last saw them ({ room: { at, tasks } }), so a codebase that
|
|
16
|
+
// is not open still shows on its project's board, to read.
|
|
17
|
+
const SEEN = 'quilt.boardSeen'
|
|
18
|
+
let seen = null
|
|
19
|
+
const seenNow = () => { if (!seen) { try { seen = JSON.parse(localStorage.getItem(SEEN) || '{}') || {} } catch { seen = {} } } return seen }
|
|
20
|
+
function remember (b) {
|
|
21
|
+
const all = seenNow(); let changed = false
|
|
22
|
+
for (const c of b.open) {
|
|
23
|
+
if (!c.room) continue
|
|
24
|
+
const tasks = tasksToKeep(state.sessions.get(c.id)?.status?.tasks || [])
|
|
25
|
+
if (all[c.room] && JSON.stringify(all[c.room].tasks) === JSON.stringify(tasks)) continue
|
|
26
|
+
all[c.room] = { at: Date.now(), tasks }; changed = true
|
|
27
|
+
}
|
|
28
|
+
if (changed) { try { localStorage.setItem(SEEN, JSON.stringify(all)) } catch { /* not kept: it is shown again when the codebase is open */ } }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The board of the open project, from what the app knows now. */
|
|
32
|
+
function boardOf (d) {
|
|
33
|
+
return projectBoard(projectCodebases(d, state.sessions, `person:${state.account?.id}`), state.sessions, seenNow())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** How many tasks are open across the project's codebases on this computer (the sidebar's count). */
|
|
37
|
+
export const projectOpenTasks = (d) => openTaskCount(boardOf(d).tasks)
|
|
38
|
+
|
|
39
|
+
/** Whether the board is being used right now (a card dragged, a name or a search typed, a menu or notes open). */
|
|
40
|
+
const busy = (el) => {
|
|
41
|
+
if (el.querySelector('.task.dragging, .task-title[contenteditable="true"], .board-filter-panel:not([hidden])') || document.querySelector('.task-menu, .task-notes-back')) return true
|
|
42
|
+
const at = document.activeElement
|
|
43
|
+
if (!at || !el.contains(at) || !/^(INPUT|SELECT|TEXTAREA)$/.test(at.tagName)) return false
|
|
44
|
+
return at.id !== 'task-add' || !!at.value.trim() // an empty "What needs doing?" is put back with its cursor
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Asked before a project's page is drawn again. True while the board on it is being used: the
|
|
49
|
+
* page is then left as it is, and `later()` is called once to try again. Otherwise the board
|
|
50
|
+
* remembers what the fresh drawing puts back (how far each column was scrolled, the cursor).
|
|
51
|
+
*/
|
|
52
|
+
export function holdProjectBoard (later) {
|
|
53
|
+
if (!live || !live.el.isConnected) return false
|
|
54
|
+
clearTimeout(live.later)
|
|
55
|
+
if (busy(live.el)) { live.later = setTimeout(later, 1200); return true }
|
|
56
|
+
live.leave()
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Draws the board into `el` for the project `d` and keeps it working. `changed()`: the open count
|
|
62
|
+
* may have changed (the sidebar shows it). `reload()`: the project is read again and its page drawn
|
|
63
|
+
* (a codebase was opened from the board).
|
|
64
|
+
*/
|
|
65
|
+
export function mountProjectBoard (el, { d, go, reload = () => {}, changed = () => {} }) {
|
|
66
|
+
const id = d.workspace.id
|
|
67
|
+
const st = prefsOf(id)
|
|
68
|
+
const data = () => (state.workspace && state.workspace.workspace.id === id ? state.workspace : d)
|
|
69
|
+
let b = boardOf(data())
|
|
70
|
+
const taskOf = (e) => b.tasks.find((t) => !t.stale && t.id === e.target.closest('.task, .task-archived, [data-task]')?.dataset.task)
|
|
71
|
+
const me = () => state.profile?.name || ''
|
|
72
|
+
const shows = (t) => !st.code || t.code === st.code
|
|
73
|
+
|
|
74
|
+
/** Saves a change to the codebase the task is in, and takes that codebase's tasks as it answers. */
|
|
75
|
+
const save = async (code, path, body) => {
|
|
76
|
+
const r = await api('POST', `/api/sessions/${code}/tasks${path}`, body)
|
|
77
|
+
const s = state.sessions.get(code)
|
|
78
|
+
if (s && r.tasks) s.status.tasks = r.tasks
|
|
79
|
+
draw()
|
|
80
|
+
return r
|
|
81
|
+
}
|
|
82
|
+
const change = (t, patch, path = '/update') => save(t.code, path, { id: splitBoardTaskId(t.id)[1], ...patch }).catch((err) => { toast(err.message); draw() })
|
|
83
|
+
|
|
84
|
+
// Which cards the codebase picked and the search leave on the board, and what each column then counts.
|
|
85
|
+
const apply = () => {
|
|
86
|
+
const board = $('.board', el)
|
|
87
|
+
if (!board) return
|
|
88
|
+
for (const c of board.querySelectorAll('.pj-chip')) { const on = (c.dataset.code || '') === st.code; c.classList.toggle('on', on); c.setAttribute('aria-pressed', String(on)) }
|
|
89
|
+
for (const col of board.querySelectorAll('.board-col')) {
|
|
90
|
+
let n = 0
|
|
91
|
+
for (const card of col.querySelectorAll('.task')) {
|
|
92
|
+
const t = b.tasks.find((x) => x.id === card.dataset.task)
|
|
93
|
+
const show = !!t && shows(t) && matchesSearch(card.dataset.search, st.query)
|
|
94
|
+
card.hidden = !show
|
|
95
|
+
if (show) n++
|
|
96
|
+
}
|
|
97
|
+
for (const x of col.querySelectorAll('.board-n, .board-strip-n')) x.textContent = String(n)
|
|
98
|
+
col.querySelector('.pj-empty')?.remove()
|
|
99
|
+
if (!n && !col.querySelector('.board-empty:not(.pj-empty)')) col.querySelector('.board-list').insertAdjacentHTML('beforeend', '<p class="board-empty pj-empty">Nothing here.</p>')
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// As many columns open as fit, work in flight first; the rest fold to strips (foldPlan, as a codebase's board).
|
|
103
|
+
const layout = ({ animate = false } = {}) => {
|
|
104
|
+
const board = $('.board', el)
|
|
105
|
+
const cols = board?.querySelector('.board-cols')
|
|
106
|
+
if (!cols) return
|
|
107
|
+
if (!animate) cols.classList.add('still')
|
|
108
|
+
const all = [...cols.querySelectorAll('.board-col')]
|
|
109
|
+
const counts = {}
|
|
110
|
+
for (const col of all) counts[col.dataset.column] = col.querySelectorAll('.task').length
|
|
111
|
+
const pad = parseFloat(getComputedStyle(cols).paddingLeft) || 0
|
|
112
|
+
const plan = foldPlan({ picked: st.opened, folded: st.shut, counts, room: cols.clientWidth - 2 * pad })
|
|
113
|
+
const open = new Set(plan.open)
|
|
114
|
+
board.dataset.layout = plan.layout
|
|
115
|
+
for (const col of all) {
|
|
116
|
+
const isOpen = open.has(col.dataset.column)
|
|
117
|
+
col.classList.toggle('folded', !isOpen)
|
|
118
|
+
col.querySelector('.board-strip').inert = isOpen
|
|
119
|
+
for (const part of col.querySelectorAll(':scope > h3, :scope > .board-list')) part.inert = !isOpen
|
|
120
|
+
const fold = col.querySelector('.board-fold')
|
|
121
|
+
if (fold) fold.hidden = isOpen && open.size === 1
|
|
122
|
+
}
|
|
123
|
+
if (!animate) { void cols.offsetWidth; cols.classList.remove('still') }
|
|
124
|
+
}
|
|
125
|
+
const openColumn = (id) => {
|
|
126
|
+
const { order, folded } = foldPlan({ picked: st.opened, folded: st.shut, room: 0 })
|
|
127
|
+
st.opened = [id, ...order.filter((x) => x !== id)]
|
|
128
|
+
st.shut = folded.filter((x) => x !== id)
|
|
129
|
+
layout({ animate: true })
|
|
130
|
+
}
|
|
131
|
+
const foldColumn = (id) => {
|
|
132
|
+
const { order, folded } = foldPlan({ picked: st.opened, folded: st.shut, room: 0 })
|
|
133
|
+
st.shut = [...new Set([...folded, id])]
|
|
134
|
+
st.opened = [...order.filter((x) => x !== id), id]
|
|
135
|
+
layout({ animate: true })
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function draw () {
|
|
139
|
+
b = boardOf(data())
|
|
140
|
+
remember(b)
|
|
141
|
+
const codes = [...b.open, ...b.stale]
|
|
142
|
+
if (st.code && !codes.some((c) => c.id === st.code)) st.code = ''
|
|
143
|
+
if (st.archived && !b.tasks.some((t) => t.archived)) st.archived = false
|
|
144
|
+
if (!b.open.some((c) => c.id === st.into)) st.into = (b.open.find((c) => c.id === st.code) || b.open[0] || {}).id || ''
|
|
145
|
+
const name = d.workspace.name
|
|
146
|
+
if (!codes.length) {
|
|
147
|
+
el.innerHTML = `<div class="board"><div class="board-head"><h2 class="board-title">Tasks</h2></div><p class="hint pj-board-none">${b.closed.length ? `A task lives in its codebase, and none of ${esc(name)}'s codebases is open on this computer. Open one from the sidebar and its tasks show here.` : `${esc(name)} has no codebases yet. Tasks belong to a codebase: start one and its board shows here.`}</p></div>`
|
|
148
|
+
return changed()
|
|
149
|
+
}
|
|
150
|
+
const lists = [...el.querySelectorAll('.board-list')]
|
|
151
|
+
const scroll = lists.length ? lists.map((l) => l.scrollTop) : st.scroll
|
|
152
|
+
const draft = $('#task-add', el)?.value ?? st.draft
|
|
153
|
+
el.innerHTML = renderBoard(st.archived ? b.tasks.filter(shows) : b.tasks, me(), b.people, '', { show: st.show, archived: st.archived })
|
|
154
|
+
const board = $('.board', el)
|
|
155
|
+
board.querySelector('.board-title')?.setAttribute('title', `One board for all of ${name}. Assign a task to a person or their AI.`)
|
|
156
|
+
for (const card of board.querySelectorAll('.task')) {
|
|
157
|
+
const t = b.tasks.find((x) => x.id === card.dataset.task)
|
|
158
|
+
if (!t) continue
|
|
159
|
+
if (t.stale) { // as last seen: to read, changed from inside its codebase
|
|
160
|
+
card.classList.add('pj-stale'); card.inert = true; card.draggable = false
|
|
161
|
+
card.querySelector('.task-main').insertAdjacentHTML('afterend', `<div class="pj-tags"><span class="tag pj-tag">${I.folder}${esc(t.codeName)}</span><span class="hint">as last seen</span></div>`)
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
// Its codebase, then its ticket's branch in that codebase's folder (each codebase is on a branch of its own).
|
|
165
|
+
card.querySelector('.task-main').insertAdjacentHTML('afterend', `<div class="pj-tags"><button type="button" class="tag pj-tag" data-code-open="${esc(t.code)}" title="Its codebase. Open ${esc(t.codeName)}.">${I.folder}${esc(t.codeName)}</button></div>${ticketHtml(t, b.open.find((c) => c.id === t.code)?.git)}`)
|
|
166
|
+
}
|
|
167
|
+
// A new task says which codebase it belongs to.
|
|
168
|
+
if (!b.open.length) board.querySelector('#task-add-form')?.remove() // nowhere to put a new task until a codebase is open
|
|
169
|
+
board.querySelector('.board-add-assign')?.insertAdjacentHTML('beforebegin', `<div class="board-add-assign pj-add-in"><label for="pj-add-in">In</label>
|
|
170
|
+
<select id="pj-add-in" class="task-add-assign" aria-label="The codebase the new task belongs to">${b.open.map((c) => `<option value="${esc(c.id)}"${c.id === st.into ? ' selected' : ''}>${esc(c.name)}</option>`).join('')}</select></div>`)
|
|
171
|
+
const all = b.tasks.filter((t) => !t.archived)
|
|
172
|
+
const chip = (code, label, n) => `<button type="button" class="pj-chip" data-code="${esc(code)}" aria-pressed="false">${code ? I.folder : ''}<span>${esc(label)}</span><span class="n">${n}</span></button>`
|
|
173
|
+
if (!st.archived) {
|
|
174
|
+
board.querySelector('.board-head').insertAdjacentHTML('afterend', `<div class="pj-tagbar" role="group" aria-label="Show the tasks of one codebase">
|
|
175
|
+
${chip('', 'All', all.length)}<span class="pj-tagbar-sep"></span>${codes.map((c) => chip(c.id, c.name, all.filter((t) => t.code === c.id).length)).join('')}
|
|
176
|
+
<span class="spacer"></span>
|
|
177
|
+
${b.stale.map((c) => `<span class="hint pj-seen" title="${esc(c.name)} is not open on this computer. Its tasks are as this computer last saw them, to read: open it to change them.">${esc(c.name)}: as of ${esc(ago(c.at))}</span>${c.dir ? `<button type="button" class="btn sm" data-open-here="${esc(c.dir)}">Open</button>` : ''}`).join('')}
|
|
178
|
+
${b.closed.length ? `<span class="hint" title="A task lives in its codebase: open it on this computer to see its tasks here.">Not open here: ${esc(b.closed.join(', '))}</span>` : ''}</div>`)
|
|
179
|
+
}
|
|
180
|
+
const search = board.querySelector('#board-search')
|
|
181
|
+
if (search) search.value = st.query
|
|
182
|
+
const add = $('#task-add', el)
|
|
183
|
+
if (add && draft) add.value = draft
|
|
184
|
+
layout()
|
|
185
|
+
apply()
|
|
186
|
+
board.querySelectorAll('.board-list').forEach((l, i) => { l.scrollTop = scroll[i] || 0 })
|
|
187
|
+
changed()
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const rename = (title, t) => {
|
|
191
|
+
if (!title || title.isContentEditable) return
|
|
192
|
+
title.contentEditable = 'true'
|
|
193
|
+
title.focus()
|
|
194
|
+
document.getSelection().selectAllChildren(title)
|
|
195
|
+
const done = (keep) => { title.onblur = null; const text = title.textContent.trim(); title.contentEditable = 'false'; if (keep && text && text !== t.title) change(t, { title: text }); else draw() }
|
|
196
|
+
title.onkeydown = (k) => { if (k.key === 'Enter') { k.preventDefault(); done(true) } else if (k.key === 'Escape') done(false) }
|
|
197
|
+
title.onblur = () => done(true)
|
|
198
|
+
}
|
|
199
|
+
const notes = (t, instant = false) => { // the same notes and comments pop-up a codebase's board has
|
|
200
|
+
document.querySelector('.task-notes-back')?.remove()
|
|
201
|
+
const back = document.createElement('div')
|
|
202
|
+
back.className = 'modal-back task-notes-back'
|
|
203
|
+
back.innerHTML = taskNotesModalHtml(t)
|
|
204
|
+
document.body.appendChild(back)
|
|
205
|
+
const close = () => { back.remove(); draw() }
|
|
206
|
+
back.addEventListener('mousedown', (e) => { if (e.target === back) close() })
|
|
207
|
+
back.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); close() } })
|
|
208
|
+
back.querySelector('[data-close-notes]').onclick = close
|
|
209
|
+
const form = back.querySelector('.task-comment-form')
|
|
210
|
+
const box = back.querySelector('.task-comment-text')
|
|
211
|
+
box.addEventListener('keydown', (e) => { if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); form.requestSubmit() } })
|
|
212
|
+
form.addEventListener('submit', async (e) => {
|
|
213
|
+
e.preventDefault()
|
|
214
|
+
const text = box.value.trim()
|
|
215
|
+
if (!text) return
|
|
216
|
+
try {
|
|
217
|
+
await save(t.code, '/comment', { id: splitBoardTaskId(t.id)[1], text })
|
|
218
|
+
const again = boardOf(data()).tasks.find((x) => x.id === t.id)
|
|
219
|
+
if (again) notes(again, true)
|
|
220
|
+
} catch (err) { toast(err.message) }
|
|
221
|
+
})
|
|
222
|
+
if (instant) { back.classList.add('is-open'); back.querySelector('.task-comment-text').focus() } else {
|
|
223
|
+
;(t.comments?.length || t.qaNotes || t.verified ? back.querySelector('[data-close-notes]') : box).focus()
|
|
224
|
+
requestAnimationFrame(() => requestAnimationFrame(() => back.classList.add('is-open')))
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Opening a ticket moves that codebase's folder onto the ticket's branch; leaving takes it back.
|
|
229
|
+
const ticket = async (btn, t) => {
|
|
230
|
+
if (btn.disabled) return
|
|
231
|
+
const opening = btn.matches('[data-task-open]')
|
|
232
|
+
btn.disabled = true
|
|
233
|
+
try {
|
|
234
|
+
const r = await api('POST', `/api/sessions/${t.code}/tasks/${opening ? 'open' : 'leave'}`, opening ? { id: splitBoardTaskId(t.id)[1] } : {})
|
|
235
|
+
const s = state.sessions.get(t.code)
|
|
236
|
+
if (s && r.tasks) s.status.tasks = r.tasks
|
|
237
|
+
const br = r.branch
|
|
238
|
+
if (!br) toast(opening ? `${t.codeName}'s folder is not a git clone, so tickets have no branch there.` : 'You are not on a ticket\'s branch.')
|
|
239
|
+
else if (br.stayed) toast(`Your ${t.codeName} folder stays on ${br.stayed}: ${br.why}`)
|
|
240
|
+
else if (opening) toast(`Your ${t.codeName} folder is on "${t.title}" now (${br.branch}).`)
|
|
241
|
+
else toast(`Your ${t.codeName} folder is back on ${br.branch}. What you had not committed stays on the ticket.`)
|
|
242
|
+
} catch (err) { toast(err.message) }
|
|
243
|
+
draw()
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// A codebase on this computer that is not open: opened in place, so its tasks can be changed from this board.
|
|
247
|
+
const openHere = async (btn) => {
|
|
248
|
+
btn.disabled = true
|
|
249
|
+
try {
|
|
250
|
+
const sum = await api('POST', '/api/sessions', { mode: 'rejoin', dir: btn.dataset.openHere })
|
|
251
|
+
state.sessions.set(sum.id, sum)
|
|
252
|
+
await reload()
|
|
253
|
+
} catch (err) { toast(err.message); btn.disabled = false }
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
el.onclick = (e) => {
|
|
257
|
+
const hit = (q) => e.target.closest(q)
|
|
258
|
+
const t = taskOf(e)
|
|
259
|
+
if (hit('.pj-chip')) { st.code = hit('.pj-chip').dataset.code || ''; if (st.code) st.into = st.code; return draw() }
|
|
260
|
+
if (hit('[data-code-open]')) return go(hit('[data-code-open]').dataset.codeOpen)
|
|
261
|
+
if (hit('[data-open-here]')) return openHere(hit('[data-open-here]'))
|
|
262
|
+
if (hit('[data-unfold]')) return openColumn(hit('[data-unfold]').dataset.unfold)
|
|
263
|
+
if (hit('[data-fold]')) return foldColumn(hit('[data-fold]').dataset.fold)
|
|
264
|
+
if (hit('[data-filter-toggle]')) { const panel = $('.board-filter-panel', el); panel.hidden = !panel.hidden; hit('[data-filter-toggle]').setAttribute('aria-expanded', String(!panel.hidden)); if (!panel.hidden) $('#board-search', el)?.focus(); return }
|
|
265
|
+
if (hit('[data-show-pick]')) { st.show = hit('[data-show-pick]').dataset.showPick; return draw() }
|
|
266
|
+
if (hit('[data-filter-clear]')) { st.show = ''; st.query = ''; return draw() }
|
|
267
|
+
if (hit('[data-archived-toggle]')) { st.archived = !st.archived; return draw() }
|
|
268
|
+
if (hit('[data-task-remove-ask]')) return hit('.task-archived').classList.add('confirming')
|
|
269
|
+
if (hit('[data-task-remove-cancel]')) return hit('.task-archived').classList.remove('confirming')
|
|
270
|
+
if (!t) return
|
|
271
|
+
if (hit('[data-move]')) return change(t, { column: hit('[data-move]').dataset.move })
|
|
272
|
+
if (hit('[data-task-open], [data-task-leave]')) return ticket(hit('[data-task-open], [data-task-leave]'), t)
|
|
273
|
+
if (hit('[data-task-more]')) {
|
|
274
|
+
return openTaskMenu(hit('[data-task-more]'), t, {
|
|
275
|
+
// The board may have been drawn again since the menu opened: find the card again.
|
|
276
|
+
edit: () => rename(el.querySelector(`.task[data-task="${CSS.escape(t.id)}"] .task-title`), t),
|
|
277
|
+
recur: () => change(t, { recurring: !t.recurring }),
|
|
278
|
+
pickup: () => change(t, { noPickup: !t.noPickup }),
|
|
279
|
+
archive: () => change(t, { archived: true }),
|
|
280
|
+
remove: () => change(t, {}, '/delete')
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
if (hit('[data-task-recur]')) return change(t, { recurring: !t.recurring })
|
|
284
|
+
if (hit('[data-task-notes]')) return notes(t)
|
|
285
|
+
if (hit('[data-task-nopickup]')) return change(t, { noPickup: false })
|
|
286
|
+
if (hit('[data-task-unarchive]')) return change(t, { archived: false })
|
|
287
|
+
if (hit('[data-task-delete]')) return change(t, {}, '/delete')
|
|
288
|
+
if (hit('[data-file-remove]')) return change(t, { files: (t.files || []).filter((f) => f !== hit('[data-file-remove]').dataset.fileRemove) })
|
|
289
|
+
if (hit('.task-title')) return rename(hit('.task-title'), t)
|
|
290
|
+
}
|
|
291
|
+
el.onsubmit = async (e) => {
|
|
292
|
+
e.preventDefault()
|
|
293
|
+
const t = taskOf(e)
|
|
294
|
+
if (e.target.id === 'task-add-form') {
|
|
295
|
+
const input = $('#task-add', el)
|
|
296
|
+
const title = input.value.trim()
|
|
297
|
+
const code = $('#pj-add-in', el)?.value || st.into
|
|
298
|
+
if (!title || !code || !b.open.some((c) => c.id === code)) return
|
|
299
|
+
const s = state.sessions.get(code)
|
|
300
|
+
input.value = ''
|
|
301
|
+
try { await save(code, '', { title, ...boardAssignment($('#task-add-assign', el)?.value || '', b.people, s?.status?.tasks || []) }); $('#task-add', el)?.focus() } catch (err) { toast(err.message); const again = $('#task-add', el); if (again) again.value = title }
|
|
302
|
+
} else if (t && e.target.matches('.task-file-form')) {
|
|
303
|
+
const f = e.target.querySelector('.task-file').value.trim()
|
|
304
|
+
if (f && !(t.files || []).includes(f)) change(t, { files: [...(t.files || []), f] })
|
|
305
|
+
} else if (t && e.target.matches('.task-cron-form')) change(t, { cron: e.target.querySelector('.task-cron').value.trim() })
|
|
306
|
+
}
|
|
307
|
+
el.onchange = (e) => {
|
|
308
|
+
if (e.target.id === 'pj-add-in') { st.into = e.target.value; return }
|
|
309
|
+
if (!e.target.matches('select.task-assign')) return
|
|
310
|
+
const t = taskOf(e)
|
|
311
|
+
if (t) change(t, boardAssignment(e.target.value, b.people, state.sessions.get(t.code)?.status?.tasks || []))
|
|
312
|
+
}
|
|
313
|
+
el.oninput = (e) => {
|
|
314
|
+
if (e.target.id === 'board-search') { st.query = e.target.value; return apply() }
|
|
315
|
+
if (e.target.id !== 'archive-filter') return
|
|
316
|
+
const q = e.target.value.trim().toLowerCase()
|
|
317
|
+
let any = false
|
|
318
|
+
for (const group of el.querySelectorAll('.archive-group')) {
|
|
319
|
+
let n = 0
|
|
320
|
+
for (const row of group.querySelectorAll('.task-archived')) { row.hidden = !!q && !row.dataset.title.includes(q); if (!row.hidden) n++ }
|
|
321
|
+
group.hidden = !n
|
|
322
|
+
group.querySelector('[data-group-count]').textContent = n
|
|
323
|
+
any = any || n > 0
|
|
324
|
+
}
|
|
325
|
+
const none = $('.board-archive-none', el)
|
|
326
|
+
if (none) none.hidden = any
|
|
327
|
+
}
|
|
328
|
+
// Drag a card to another column; dropped on a card, it goes before it.
|
|
329
|
+
el.ondragstart = (e) => { const card = e.target.closest?.('.task'); if (card) { e.dataTransfer.setData('text/plain', card.dataset.task); card.classList.add('dragging') } }
|
|
330
|
+
el.ondragover = (e) => { const col = e.target.closest('.board-col'); if (!col) return; e.preventDefault(); for (const c of el.querySelectorAll('.board-col.over')) if (c !== col) c.classList.remove('over'); col.classList.add('over') }
|
|
331
|
+
el.ondragend = () => { for (const n of el.querySelectorAll('.over, .dragging')) n.classList.remove('over', 'dragging') }
|
|
332
|
+
el.ondrop = (e) => {
|
|
333
|
+
const col = e.target.closest('.board-col')
|
|
334
|
+
const t = b.tasks.find((x) => x.id === e.dataTransfer.getData('text/plain'))
|
|
335
|
+
if (!col || !t) return
|
|
336
|
+
e.preventDefault()
|
|
337
|
+
for (const n of el.querySelectorAll('.over, .dragging')) n.classList.remove('over', 'dragging')
|
|
338
|
+
const before = b.tasks.find((x) => x.id === e.target.closest('.task')?.dataset.task)
|
|
339
|
+
change(t, { column: col.dataset.column, ...(before && before.code === t.code && before.id !== t.id ? { before: splitBoardTaskId(before.id)[1] } : {}) })
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (live) { clearTimeout(live.later); live.ro.disconnect() }
|
|
343
|
+
const ro = new ResizeObserver(() => layout())
|
|
344
|
+
live = {
|
|
345
|
+
el,
|
|
346
|
+
ro,
|
|
347
|
+
later: null,
|
|
348
|
+
leave: () => {
|
|
349
|
+
st.scroll = [...el.querySelectorAll('.board-list')].map((l) => l.scrollTop)
|
|
350
|
+
st.draft = $('#task-add', el)?.value || ''
|
|
351
|
+
st.refocus = document.activeElement?.id === 'task-add' && el.contains(document.activeElement)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
ro.observe(el)
|
|
355
|
+
draw()
|
|
356
|
+
if (st.refocus) $('#task-add', el)?.focus()
|
|
357
|
+
st.refocus = false
|
|
358
|
+
st.draft = ''
|
|
359
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// A project's page and Home, as plain logic (no DOM): the quilt block drawn for a codebase, the
|
|
2
|
+
// codebases a page lists, and which sidebar sections are folded. projects.js puts them on the page.
|
|
3
|
+
|
|
4
|
+
const hash = (s) => [...String(s)].reduce((n, c) => (Math.imul(n, 31) + c.codePointAt(0)) >>> 0, 5)
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A quilt block drawn from a name, as SVG: ink patches in three tones, some cut corner to corner,
|
|
8
|
+
* and one vermilion corner, as in Quilt's own mark. The same name always gives the same block.
|
|
9
|
+
*/
|
|
10
|
+
export function quiltBlock (name, cols = 2, rows = 2) {
|
|
11
|
+
let h = hash(name); let out = ''
|
|
12
|
+
const spark = h % (cols * rows)
|
|
13
|
+
for (let y = 0; y < rows; y++) {
|
|
14
|
+
for (let x = 0; x < cols; x++) {
|
|
15
|
+
h = (Math.imul(h, 1103515245) + 12345) >>> 0
|
|
16
|
+
const k = (h >>> 16) % 7; const X = x * 10; const Y = y * 10
|
|
17
|
+
out += y * cols + x === spark
|
|
18
|
+
? `<path class="q1" d="M${X} ${Y}h10L${X} ${Y + 10}z"/><path class="qs" d="M${X + 10} ${Y}v10h-10z"/>`
|
|
19
|
+
: k < 4
|
|
20
|
+
? `<rect class="q${k % 3 + 1}" x="${X}" y="${Y}" width="10" height="10"/>`
|
|
21
|
+
: k < 6
|
|
22
|
+
? `<path class="q1" d="M${X} ${Y}h10v10z"/><path class="q${k - 2}" d="M${X} ${Y}v10h10z"/>`
|
|
23
|
+
: `<path class="q2" d="M${X} ${Y}h10L${X} ${Y + 10}z"/><path class="q3" d="M${X + 10} ${Y}v10h-10z"/>`
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return `<svg class="pj-block" viewBox="0 0 ${cols * 10} ${rows * 10}" preserveAspectRatio="xMidYMid slice" aria-hidden="true">${out}</svg>`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const base = (dir) => String(dir || '').replace(/[\\/]+$/, '').split(/[\\/]/).pop() || ''
|
|
30
|
+
/** The people in a codebase open here, other than you, as faces: [{ name, color }]. */
|
|
31
|
+
const facesOf = (s) => ((s.status && s.status.peers) || []).filter((p) => p && !p.mine && p.name).map((p) => ({ name: p.name, color: p.color || '' }))
|
|
32
|
+
const nameOf = (s) => (s.status && s.status.sessionName) || base(s.dir)
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The codebases of the open project, as its page lists them. `d`: the project as the app's server
|
|
36
|
+
* gives it ({ running, recent, sessions }); `sessions`: the codebases open on this computer.
|
|
37
|
+
* Each is { key, name, dir, where, id?, room?, faces, lastUsed?, mine? } with `where` one of
|
|
38
|
+
* 'open' (running here), 'here' (on this computer, not open) or 'away' (not on this computer).
|
|
39
|
+
*/
|
|
40
|
+
export function projectCodebases (d, sessions = new Map(), me = '') {
|
|
41
|
+
if (!d) return []
|
|
42
|
+
const listed = d.sessions || []
|
|
43
|
+
const named = (room, fallback) => (listed.find((x) => x.room === room) || {}).name || fallback
|
|
44
|
+
const running = (d.running || []).map((id) => sessions.get(id)).filter(Boolean)
|
|
45
|
+
const open = running.map((s) => ({ key: `open:${s.id}`, where: 'open', id: s.id, room: s.status.room, dir: s.dir, name: named(s.status.room, nameOf(s)), faces: facesOf(s) }))
|
|
46
|
+
const openRooms = new Set(open.map((r) => r.room))
|
|
47
|
+
const here = (d.recent || []).filter((r) => !openRooms.has(r.room)).map((r) => ({ key: `here:${r.dir}`, where: 'here', room: r.room, dir: r.dir, name: named(r.room, base(r.dir)), faces: [], lastUsed: r.lastUsed }))
|
|
48
|
+
const known = new Set([...openRooms, ...here.map((r) => r.room)])
|
|
49
|
+
const away = listed.filter((s) => !known.has(s.room)).map((s) => ({ key: `away:${s.room}`, where: 'away', room: s.room, dir: '', name: s.name || s.room, faces: [], mine: !!me && s.ownerAccount === me }))
|
|
50
|
+
return [...open, ...here, ...away]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The codebases on this computer that are in no project (or in one this account no longer has): open ones first. */
|
|
54
|
+
export function looseCodebases ({ sessions = new Map(), recent = [], projects = [] } = {}) {
|
|
55
|
+
const known = new Set(projects.map((w) => w.id))
|
|
56
|
+
const loose = (ws) => !ws || !known.has(ws)
|
|
57
|
+
const open = [...sessions.values()].filter((s) => loose(s.workspace)).map((s) => ({ key: `open:${s.id}`, where: 'open', id: s.id, dir: s.dir, name: nameOf(s), faces: facesOf(s) }))
|
|
58
|
+
const here = recent.filter((r) => loose(r.workspace) && !r.unsupported).map((r) => ({ key: `here:${r.dir}`, where: 'here', dir: r.dir, name: base(r.dir), faces: [], lastUsed: r.lastUsed }))
|
|
59
|
+
return [...open, ...here]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Who is in a codebase, in a few words: "Brandon and Lin are here", "just you", "not on this computer yet". */
|
|
63
|
+
export function whoLine (c, ago = () => '') {
|
|
64
|
+
if (c.where === 'away') return 'not on this computer yet'
|
|
65
|
+
if (c.where === 'here') return c.lastUsed ? ago(c.lastUsed) : 'not open'
|
|
66
|
+
const names = c.faces.map((f) => f.name)
|
|
67
|
+
if (!names.length) return 'just you'
|
|
68
|
+
if (names.length === 1) return `${names[0]} is here`
|
|
69
|
+
if (names.length === 2) return `${names[0]} and ${names[1]} are here`
|
|
70
|
+
return `${names[0]}, ${names[1]} and ${names.length - 2} more are here`
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The sidebar sections folded shut, read from what was saved ('' or bad JSON: none). */
|
|
74
|
+
export function readFolded (saved) {
|
|
75
|
+
try { const list = JSON.parse(saved || '[]'); return new Set(Array.isArray(list) ? list.filter((k) => typeof k === 'string') : []) } catch { return new Set() }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ------------------------------------------------------------ the board --
|
|
79
|
+
// One task board for a project. Each task stays in its codebase's document; the board lists the
|
|
80
|
+
// tasks of every codebase of the project that is open on this computer, and saves each change to
|
|
81
|
+
// the codebase the task is in. A task's id on the board is `<codebase>:<its own id>`.
|
|
82
|
+
|
|
83
|
+
/** A task's id on a project's board, and back: [the codebase's id on this computer, the task's own id]. */
|
|
84
|
+
export const boardTaskId = (code, id) => `${code}:${id}`
|
|
85
|
+
export const splitBoardTaskId = (id) => { const i = String(id).indexOf(':'); return i < 0 ? ['', String(id)] : [String(id).slice(0, i), String(id).slice(i + 1)] }
|
|
86
|
+
|
|
87
|
+
/** Where a codebase's folder is in git, for its tickets: { branch, on: Map of a branch to the others on it }, or null with no git. */
|
|
88
|
+
export function boardGit (status) {
|
|
89
|
+
if (!status || !status.git || !status.git.branch) return null
|
|
90
|
+
const on = new Map()
|
|
91
|
+
const me = status.me && status.me.name
|
|
92
|
+
for (const p of status.peers || []) if (p && p.branch && p.name !== me) on.set(p.branch, [...new Set([...(on.get(p.branch) || []), p.name])])
|
|
93
|
+
return { branch: status.git.branch, on }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** What is kept of a codebase's tasks to show them while it is not open: the ones on the board, without their comments. */
|
|
97
|
+
export const tasksToKeep = (tasks = []) => tasks.filter((t) => t && t.id && !t.archived).slice(0, 300).map((t) => ({ ...t, comments: (t.comments || []).map(() => ({})) }))
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The board of a project. `codebases`: its codebases as projectCodebases gives them; `sessions`:
|
|
101
|
+
* the ones open here, with their tasks; `seen`: { room: { at, tasks } }, the tasks of each
|
|
102
|
+
* codebase as this computer last saw them. Answers { open: [{ id, name, room, git }] (the
|
|
103
|
+
* codebases whose tasks can be changed here), stale: [{ id, name, dir, at }] (not open here:
|
|
104
|
+
* shown as last seen, to read), closed: [names of the rest], tasks (each with its board id,
|
|
105
|
+
* `code`, `codeName` and `stale`), people (everyone in the open codebases, once each) }.
|
|
106
|
+
*/
|
|
107
|
+
export function projectBoard (codebases = [], sessions = new Map(), seen = {}) {
|
|
108
|
+
const open = []; const stale = []; const closed = []; const tasks = []; const people = new Map()
|
|
109
|
+
for (const c of codebases) {
|
|
110
|
+
const s = c.where === 'open' ? sessions.get(c.id) : null
|
|
111
|
+
if (!s || !s.status) {
|
|
112
|
+
const last = c.room && seen[c.room]
|
|
113
|
+
if (!last || !Array.isArray(last.tasks)) { closed.push(c.name); continue }
|
|
114
|
+
const id = `~${String(c.room).replace(/:/g, '')}`
|
|
115
|
+
stale.push({ id, name: c.name, dir: c.where === 'here' ? c.dir : '', at: last.at || 0 })
|
|
116
|
+
for (const t of last.tasks) if (t && t.id && !t.archived) tasks.push({ ...t, id: boardTaskId(id, t.id), code: id, codeName: c.name, stale: true })
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
open.push({ id: c.id, name: c.name, room: c.room || '', git: boardGit(s.status) })
|
|
120
|
+
for (const t of s.status.tasks || []) if (t && t.id) tasks.push({ ...t, id: boardTaskId(c.id, t.id), code: c.id, codeName: c.name })
|
|
121
|
+
for (const p of [s.status.me, ...(s.status.peers || [])]) {
|
|
122
|
+
if (!p || !p.name || p.persona || people.has(p.name)) continue
|
|
123
|
+
people.set(p.name, { name: p.name, color: p.color, tool: p.tool && p.tool !== 'unknown' ? p.tool : '', agent: p.kind === 'agent' })
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { open, stale, closed, tasks, people: [...people.values()] }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** How many of a board's tasks are open (to do or in progress, not archived). */
|
|
130
|
+
export const openTaskCount = (tasks = []) => tasks.filter((t) => !t.archived && (t.column === 'todo' || t.column === 'doing')).length
|
|
131
|
+
|
|
132
|
+
/** Who a task is for, from the board's choice (`p:name`, `a:name` for their AI, '' for nobody). `tasks`: the codebase's, for the AI tool it last had. */
|
|
133
|
+
export function boardAssignment (value, people = [], tasks = []) {
|
|
134
|
+
if (!value) return { assignee: '', forAi: false, tool: '' }
|
|
135
|
+
const forAi = value.startsWith('a:')
|
|
136
|
+
const assignee = value.slice(2)
|
|
137
|
+
const live = (people.find((p) => p.name === assignee) || {}).tool || ''
|
|
138
|
+
const saved = tasks.find((t) => t.assignee === assignee && !!t.forAi === forAi)
|
|
139
|
+
return { assignee, forAi, tool: forAi ? (live || (saved && saved.tool) || '') : '' }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// -------------------------------------------------------------- pop-ups --
|
|
143
|
+
// New project and a project's settings (project-pop.js), as plain logic.
|
|
144
|
+
|
|
145
|
+
/** Email addresses out of what was typed or pasted (spaces, commas, semicolons between them): { good (lowercased, once each), bad }. */
|
|
146
|
+
export function readEmails (text) {
|
|
147
|
+
const good = []; const bad = []
|
|
148
|
+
for (const raw of String(text || '').split(/[\s,;]+/)) {
|
|
149
|
+
const e = raw.trim().replace(/^<|>$/g, '')
|
|
150
|
+
if (!e) continue
|
|
151
|
+
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) { if (!good.includes(e.toLowerCase())) good.push(e.toLowerCase()) } else bad.push(e)
|
|
152
|
+
}
|
|
153
|
+
return { good, bad }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* What Create does for a new project, in order: the project, then for each agent you changed
|
|
158
|
+
* whether it works here, then the invites, then the codebases (the slow part, last). `v`: what
|
|
159
|
+
* the pop-up holds ({ name, about, color, code, emails, agents: { id: on }, agentList }). Each
|
|
160
|
+
* step is { kind, says (on the button while it runs), what (named if it fails), ... }.
|
|
161
|
+
*/
|
|
162
|
+
export function newProjectSteps (v) {
|
|
163
|
+
const name = String(v.name || '').trim()
|
|
164
|
+
const steps = [{ kind: 'project', says: `Creating ${name}…`, what: name, body: { name, description: String(v.about || '').trim(), color: v.color || '' } }]
|
|
165
|
+
for (const a of v.agentList || []) {
|
|
166
|
+
const everywhere = !!a.placement && a.placement.reach === 'all'
|
|
167
|
+
const on = (v.agents || {})[a.id]
|
|
168
|
+
if (on === undefined || on === everywhere) continue // as it would be anyway
|
|
169
|
+
steps.push({ kind: on ? 'agent-on' : 'agent-off', agent: a.id, says: `Setting up ${a.name}…`, what: a.name })
|
|
170
|
+
}
|
|
171
|
+
for (const to of v.emails || []) steps.push({ kind: 'invite', to, says: `Inviting ${to}…`, what: `the invite to ${to}` })
|
|
172
|
+
for (const c of v.code || []) {
|
|
173
|
+
const body = c.source === 'github' ? { source: 'github', repo: c.repo } : c.source === 'scratch' ? { source: 'scratch', name: c.name } : { source: 'folder', dir: c.dir }
|
|
174
|
+
steps.push({ kind: 'codebase', body, says: c.source === 'github' ? `Cloning ${c.name}…` : `Starting ${c.name}…`, what: c.name })
|
|
175
|
+
}
|
|
176
|
+
return steps
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** New project's "So far", under the list: [[what, how it stands]]. `agentsOn`: how many agents will work in it (null: not known yet). */
|
|
180
|
+
export function newProjectSummary (v) {
|
|
181
|
+
const n = (v.code || []).length; const p = (v.emails || []).length
|
|
182
|
+
return [
|
|
183
|
+
['Name', String(v.name || '').trim() || 'Not named yet'],
|
|
184
|
+
['Code', n ? `${n} ${n === 1 ? 'codebase' : 'codebases'}` : 'None yet'],
|
|
185
|
+
['People', p ? `You and ${p} ${p === 1 ? 'invite' : 'invites'}` : 'Just you'],
|
|
186
|
+
['Agents', v.agentsOn === null || v.agentsOn === undefined ? '…' : `${v.agentsOn} on`]
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The people of a project (not its agents), its owner first: [{ account, name, access, owner, you }]. `d`: the project as the app's server gives it. */
|
|
191
|
+
export function projectPeople (d, me = '') {
|
|
192
|
+
const agents = new Set((d.agents || []).map((a) => a.account))
|
|
193
|
+
const isAgent = (m) => m.kind === 'agent' || String(m.account || '').startsWith('agent:') || agents.has(m.account)
|
|
194
|
+
const owner = d.owner && d.owner.account && !String(d.owner.account).startsWith('org:') ? [{ account: d.owner.account, name: d.owner.name, access: 'edit', owner: true }] : []
|
|
195
|
+
return [...owner, ...(d.members || []).filter((m) => m && !isAgent(m) && !owner.some((o) => o.account === m.account)).map((m) => ({ account: m.account, name: m.name || m.account, access: m.access || 'edit', owner: false }))]
|
|
196
|
+
.map((m) => ({ ...m, you: !!me && m.account === me }))
|
|
197
|
+
}
|