heyquilt 0.3.154 → 0.3.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASES.md +13 -0
- package/bin/quilt.js +4 -0
- package/package.json +1 -1
- package/src/api/audit.js +13 -2
- package/src/api/composio.js +139 -0
- package/src/api/memory-store.js +47 -0
- package/src/api/routes/connections.js +311 -0
- package/src/api/routes/sessions.js +9 -1
- package/src/api/routes/workspaces.js +43 -3
- package/src/api/server.js +14 -3
- package/src/api/supabase-store.js +43 -0
- package/src/app-tools.js +107 -0
- package/src/control.js +28 -0
- package/src/mcp.js +7 -0
- package/src/presence.js +2 -1
- package/src/relay-mcp.js +14 -0
- package/src/server.js +37 -2
- package/src/ui/agent-guide.js +4 -0
- package/src/ui/app.css +572 -2
- package/src/ui/app.js +42 -23
- package/src/ui/board.js +17 -7
- package/src/ui/common.js +2 -0
- package/src/ui/connections.js +215 -0
- package/src/ui/feed.js +23 -8
- package/src/ui/files.js +65 -20
- package/src/ui/home-view.js +170 -0
- package/src/ui/home.js +95 -6
- package/src/ui/loom-model.js +11 -8
- package/src/ui/loom.css +182 -2
- package/src/ui/loom.js +132 -55
- package/src/ui/palette.js +75 -0
- package/src/ui/people-view.js +116 -0
- package/src/ui/session.js +1026 -69
- package/src/ui/signin.js +1 -0
- package/src/ui/workspaces.js +7 -1
- package/src/ui-server.js +76 -4
package/src/ui/files.js
CHANGED
|
@@ -157,9 +157,10 @@ const folderActsHtml = (f) => `<span class="folder-acts"><button type="button" c
|
|
|
157
157
|
function folderTileHtml (d, f, { acts = false } = {}) {
|
|
158
158
|
const s = folderStats(d, f.path)
|
|
159
159
|
const tile = `
|
|
160
|
-
<button type="button" class="tile folder" data-folder="${esc(f.path)}" title="${esc(f.path)}">
|
|
161
|
-
<span class="
|
|
162
|
-
<span class="
|
|
160
|
+
<button type="button" class="tile folder fv-card" data-folder="${esc(f.path)}" title="${esc(f.path)}">
|
|
161
|
+
<span class="fv-ico">${I.folder}</span>
|
|
162
|
+
<span class="fv-meta"><b>${esc(f.name)}</b>${f.note ? `<small>${esc(f.note)}</small>` : ''}</span>
|
|
163
|
+
<span class="fv-foot"><span>${esc(plural(s.count, 'file', 'files'))}${s.count ? ` · ${esc(bytes(s.size))}` : ''}</span></span>
|
|
163
164
|
</button>`
|
|
164
165
|
return acts ? `<div class="tile-wrap">${tile}${folderActsHtml(f)}</div>` : tile
|
|
165
166
|
}
|
|
@@ -404,8 +405,7 @@ function previewHtml (d, f) {
|
|
|
404
405
|
</aside>`
|
|
405
406
|
}
|
|
406
407
|
|
|
407
|
-
export function allFilesHtml (d) {
|
|
408
|
-
const id = String(state.view).slice('wsfiles:'.length)
|
|
408
|
+
export function allFilesHtml (d, { id = String(state.view).slice('wsfiles:'.length), embedded = false } = {}) {
|
|
409
409
|
if (!d || d.workspace.id !== id) return `<p class="hint">${loadingNote()}</p>`
|
|
410
410
|
const fv = state.filesView
|
|
411
411
|
// A folder someone removed (or a stale saved view) falls back to the top.
|
|
@@ -417,28 +417,28 @@ export function allFilesHtml (d) {
|
|
|
417
417
|
const here = filesOf(d).filter((f) => inside(fv.folder, f.path))
|
|
418
418
|
const usage = usageText(d)
|
|
419
419
|
const edit = canEdit(d)
|
|
420
|
+
// The dm06 Files page: folder cards and file tiles, an upload tile only where a folder is empty.
|
|
420
421
|
const grid = !folders.length && !files.length && !edit ? ''
|
|
421
|
-
:
|
|
422
|
-
: `<div class="tiles">
|
|
422
|
+
: `<div class="tiles fv-grid">
|
|
423
423
|
${folders.map((f) => folderTileHtml(d, f, { acts: edit })).join('')}
|
|
424
424
|
${files.map((f) => fileTileHtml(d, f, { on: f.id === fv.picked, meta: [bytes(f.size || 0), whoOf(d, f.uploadedBy)].filter(Boolean).join(' · ') })).join('')}
|
|
425
|
-
${edit ? uploadTileHtml(id, fv.folder ? `Upload to ${fv.folder.split('/').pop()}` : 'Upload or drop files') : ''}
|
|
425
|
+
${edit && !folders.length && !files.length ? uploadTileHtml(id, fv.folder ? `Upload to ${fv.folder.split('/').pop()}` : 'Upload or drop files') : ''}
|
|
426
426
|
</div>`
|
|
427
|
+
const title = fv.folder ? crumbsHtml(d, fv.folder) : '<h1>Files</h1>'
|
|
428
|
+
const sub = fv.folder
|
|
429
|
+
? `${plural(here.length, 'file', 'files')} · ${bytes(here.reduce((n, f) => n + (f.size || 0), 0))}`
|
|
430
|
+
: `Shared across ${d.workspace.name}: every session and everyone's AI can use them${usage ? ` · ${usage}` : ''}`
|
|
427
431
|
return `
|
|
428
|
-
|
|
429
|
-
<header class="files-head">
|
|
430
|
-
<div class="t">${
|
|
432
|
+
${embedded ? '' : `<a class="ws-back" href="#" data-ws-open="${esc(id)}">${I.caret} ${esc(d.workspace.name)}</a>`}
|
|
433
|
+
<header class="files-head fv-head">
|
|
434
|
+
<div class="t">${title}<p class="hint">${esc(sub)}</p></div>
|
|
431
435
|
<span class="spacer"></span>
|
|
432
|
-
|
|
433
|
-
<button type="button" role="tab" data-files-mode="tiles" class="${fv.mode !== 'list' ? 'on' : ''}" aria-selected="${fv.mode !== 'list'}">Tiles</button>
|
|
434
|
-
<button type="button" role="tab" data-files-mode="list" class="${fv.mode === 'list' ? 'on' : ''}" aria-selected="${fv.mode === 'list'}">List</button>
|
|
435
|
-
</div>
|
|
436
|
-
${edit ? `<button class="btn sm" data-new-folder>${I.plus}<span>New folder</span></button><button class="btn sm primary" data-upload>${I.upload}<span>Upload</span></button>` : ''}
|
|
436
|
+
${edit ? `<button class="btn" data-new-folder>${I.plus}<span>New folder</span></button><button class="btn primary" data-upload>${I.upload}<span>Upload</span></button>` : ''}
|
|
437
437
|
</header>
|
|
438
|
-
${
|
|
439
|
-
<div class="files-body" data-files-drop>
|
|
438
|
+
${edit ? `<p class="hint files-progress" data-progress>${uploadingTo(id) ? esc(progressLabel()) : ''}</p><input type="file" multiple hidden data-upload-input>` : ''}
|
|
439
|
+
<div class="files-body${picked ? '' : ' no-preview'}" data-files-drop>
|
|
440
440
|
<div class="files-main">${grid || '<p class="hint">Nothing in this folder yet.</p>'}</div>
|
|
441
|
-
${picked ? previewHtml(d, picked) : '
|
|
441
|
+
${picked ? previewHtml(d, picked) : ''}
|
|
442
442
|
</div>`
|
|
443
443
|
}
|
|
444
444
|
|
|
@@ -447,7 +447,8 @@ export function bindAllFiles (root, { id, reload, go, rerender = () => go(`wsfil
|
|
|
447
447
|
const d = state.workspace
|
|
448
448
|
if (!d || d.workspace.id !== id) return
|
|
449
449
|
const fv = state.filesView
|
|
450
|
-
root.querySelector('[data-ws-open]')
|
|
450
|
+
const back = root.querySelector('[data-ws-open]')
|
|
451
|
+
if (back) back.onclick = (e) => { e.preventDefault(); go(`ws:${id}`) }
|
|
451
452
|
root.querySelectorAll('[data-folder]').forEach((el) => {
|
|
452
453
|
const open = (e) => { e?.preventDefault(); fv.folder = el.dataset.folder; fv.picked = null; rerender() }
|
|
453
454
|
el.onclick = open
|
|
@@ -562,6 +563,50 @@ export function previewBusy () {
|
|
|
562
563
|
return [...document.querySelectorAll('.file-preview video, .file-preview audio')].some((m) => !m.paused)
|
|
563
564
|
}
|
|
564
565
|
|
|
566
|
+
// ---------------------------------------------------------------- attach menu --
|
|
567
|
+
/**
|
|
568
|
+
* The menu an attach button opens (dm06): "Upload from your computer…", then the workspace's latest files to
|
|
569
|
+
* attach as they are. `onPick` gets { id, name, size }; "All files…" opens the picker for the rest.
|
|
570
|
+
*/
|
|
571
|
+
export async function attachMenu (anchor, { workspace = null, name = '', onUpload, onPick }) {
|
|
572
|
+
document.querySelector('.att-pop')?.remove()
|
|
573
|
+
const pop = document.createElement('div')
|
|
574
|
+
pop.className = 'att-pop'
|
|
575
|
+
pop.setAttribute('role', 'menu')
|
|
576
|
+
const place = () => {
|
|
577
|
+
const r = anchor.getBoundingClientRect()
|
|
578
|
+
pop.style.left = `${Math.max(8, Math.min(r.left, innerWidth - 308))}px`
|
|
579
|
+
if (r.top > innerHeight / 2) { pop.style.bottom = `${innerHeight - r.top + 6}px`; pop.style.top = '' } else { pop.style.top = `${r.bottom + 6}px`; pop.style.bottom = '' }
|
|
580
|
+
}
|
|
581
|
+
const draw = (files) => {
|
|
582
|
+
const shown = (files || []).slice(0, 6)
|
|
583
|
+
pop.innerHTML = `<div class="att-h">Attach</div><button type="button" class="att-i" role="menuitem" data-att-up>${I.upload}Upload from your computer…</button>
|
|
584
|
+
${workspace ? `<div class="att-h">From ${esc(name || 'the workspace')}’s files</div>${files === null ? '<p class="att-none">Loading…</p>' : shown.length ? shown.map((f) => `<button type="button" class="att-i" role="menuitem" data-att-pick="${esc(f.id)}">${I.file}<span>${esc(f.name)}</span></button>`).join('') : '<p class="att-none">No files yet.</p>'}${files && files.length > shown.length ? `<button type="button" class="att-i more" role="menuitem" data-att-all>All files…</button>` : ''}` : ''}`
|
|
585
|
+
place()
|
|
586
|
+
}
|
|
587
|
+
let files = workspace ? null : []
|
|
588
|
+
draw(files)
|
|
589
|
+
document.body.appendChild(pop)
|
|
590
|
+
place()
|
|
591
|
+
const close = () => { pop.remove(); document.removeEventListener('mousedown', out, true); document.removeEventListener('keydown', esc_, true) }
|
|
592
|
+
const out = (e) => { if (!pop.contains(e.target) && !anchor.contains(e.target)) close() }
|
|
593
|
+
const esc_ = (e) => { if (e.key === 'Escape') { e.stopPropagation(); close(); anchor.focus() } }
|
|
594
|
+
document.addEventListener('mousedown', out, true)
|
|
595
|
+
document.addEventListener('keydown', esc_, true)
|
|
596
|
+
pop.onclick = async (e) => {
|
|
597
|
+
if (e.target.closest('[data-att-up]')) { close(); onUpload(); return }
|
|
598
|
+
const b = e.target.closest('[data-att-pick]')
|
|
599
|
+
const f = b && files.find((x) => x.id === b.dataset.attPick)
|
|
600
|
+
if (f) { close(); onPick({ id: f.id, name: f.name, size: f.size || 0 }); return }
|
|
601
|
+
if (e.target.closest('[data-att-all]')) { close(); const p = await workspaceFilePicker(workspace); if (p) onPick({ ...p, size: (files.find((x) => x.id === p.id) || {}).size || 0 }) }
|
|
602
|
+
}
|
|
603
|
+
if (workspace) {
|
|
604
|
+
try { files = (await api('GET', wsUrl(workspace, '/files'))).files.filter((f) => f.kind !== 'folder').sort((a, b) => (b.updatedAt || b.createdAt || 0) - (a.updatedAt || a.createdAt || 0)) } catch { files = [] }
|
|
605
|
+
if (pop.isConnected) draw(files)
|
|
606
|
+
}
|
|
607
|
+
return close
|
|
608
|
+
}
|
|
609
|
+
|
|
565
610
|
// ---------------------------------------------------------------- picker --
|
|
566
611
|
/** A dialog to choose one of the workspace's files. Resolves { id, name }, or null. */
|
|
567
612
|
export async function workspaceFilePicker (id) {
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// A workspace's home (plans/app-redesign.md, the dm06 mockup): charts of AI time and merges, its sessions as
|
|
2
|
+
// cards with who is working in each, and its previews (the links that matter). Drawn inside a session (its
|
|
3
|
+
// header's Home button) and as the workspace's own page. Data: the workspace (GET /api/workspaces/:id), its
|
|
4
|
+
// insights (AI minutes from the accounts API, merges from Seam) and this computer's open sessions.
|
|
5
|
+
import { esc, avatar, ago, I, api, toast, state, basename } from './common.js'
|
|
6
|
+
|
|
7
|
+
const SERIES = 'var(--chart, #2a78d6)' // one hue for every single-series chart
|
|
8
|
+
const DAY_MS = 24 * 60 * 60 * 1000
|
|
9
|
+
const dayStart = (t) => { const d = new Date(t); d.setHours(0, 0, 0, 0); return d.getTime() }
|
|
10
|
+
const hm = (min) => `${Math.floor(min / 60)}h ${String(Math.round(min % 60)).padStart(2, '0')}m`
|
|
11
|
+
|
|
12
|
+
/** The last `n` days (oldest first) with what fell on each: [{ start, label, value }]. */
|
|
13
|
+
function byDay (items, n, value = () => 1) {
|
|
14
|
+
const today = dayStart(Date.now())
|
|
15
|
+
const days = Array.from({ length: n }, (_, i) => ({ start: today - (n - 1 - i) * DAY_MS, value: 0 }))
|
|
16
|
+
for (const it of items) {
|
|
17
|
+
const i = days.findIndex((d) => it.at >= d.start && it.at < d.start + DAY_MS)
|
|
18
|
+
if (i >= 0) days[i].value += value(it)
|
|
19
|
+
}
|
|
20
|
+
return days.map((d, i) => ({ ...d, today: i === n - 1, label: new Date(d.start).toLocaleDateString([], { weekday: 'short' }) }))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function aiChart (ins) {
|
|
24
|
+
const days = byDay(ins.aiHours || [], 7, (h) => h.minutes)
|
|
25
|
+
const total = days.reduce((a, d) => a + d.value, 0)
|
|
26
|
+
const prev = (ins.aiHours || []).filter((h) => h.at < days[0].start && h.at >= days[0].start - 7 * DAY_MS).reduce((a, h) => a + h.minutes, 0)
|
|
27
|
+
const max = Math.max(1, ...days.map((d) => d.value))
|
|
28
|
+
const change = prev ? Math.round(((total - prev) / prev) * 100) : null
|
|
29
|
+
return `<div class="hm-chart"><div class="hm-ch"><small>AI time · last 7 days</small><b>${hm(total)}</b>${change == null ? '<em>Counted from when Quilt started keeping it</em>' : `<em class="${change >= 0 ? 'up' : 'down'}">${change >= 0 ? '+' : ''}${change}% on the week before</em>`}</div>
|
|
30
|
+
<div class="hm-bars">${days.map((d) => `<div class="hm-bar${d.today ? ' today' : ''}" data-tip="${esc(`${d.today ? 'Today' : d.label} · ${hm(d.value)} of AI time`)}"><i style="height:${Math.max(2, (d.value / max) * 100).toFixed(1)}%"></i><span>${esc(d.label.slice(0, 3))}</span></div>`).join('')}</div></div>`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function mergesChart (ins) {
|
|
34
|
+
const days = byDay(ins.merges || [], 14)
|
|
35
|
+
const week = days.slice(7).reduce((a, d) => a + d.value, 0)
|
|
36
|
+
const last = days.slice(0, 7).reduce((a, d) => a + d.value, 0)
|
|
37
|
+
const W = 280; const H = 90
|
|
38
|
+
const max = Math.max(1, ...days.map((d) => d.value))
|
|
39
|
+
const pts = days.map((d, i) => [i * W / (days.length - 1), H - 6 - (d.value / max) * (H - 16)])
|
|
40
|
+
const line = 'M' + pts.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(' L')
|
|
41
|
+
const dots = pts.map(([x, y], i) => `<span class="hm-dot" style="left:${(x / W * 100).toFixed(2)}%;top:${(y / H * 100).toFixed(2)}%" data-tip="${esc(`${i === days.length - 1 ? 'Today' : new Date(days[i].start).toLocaleDateString([], { month: 'short', day: 'numeric' })} · ${days[i].value} merge${days[i].value === 1 ? '' : 's'} onto main`)}"></span>`).join('')
|
|
42
|
+
const none = !(ins.merges || []).length
|
|
43
|
+
return `<div class="hm-chart"><div class="hm-ch"><small>Merged onto main · 14 days</small><b>${week} this week</b><em class="${none ? '' : week >= last ? 'up' : 'down'}">${none ? 'From its sessions in Seam open on this computer' : `${week >= last ? '+' : ''}${week - last} on last week`}</em></div>
|
|
44
|
+
<div class="hm-line"><svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" aria-hidden="true"><path d="${line} L${W},${H} L0,${H} Z" fill="${SERIES}" fill-opacity=".10"/><path d="${line}" fill="none" stroke="${SERIES}" stroke-width="2" vector-effect="non-scaling-stroke" stroke-linejoin="round"/></svg>${dots}</div>
|
|
45
|
+
<div class="hm-ax"><span>2 weeks ago</span><span>Today</span></div></div>`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function bySessionChart (ins, names) {
|
|
49
|
+
const since = dayStart(Date.now()) - 6 * DAY_MS
|
|
50
|
+
const per = new Map()
|
|
51
|
+
for (const h of ins.aiHours || []) if (h.at >= since) per.set(h.room, (per.get(h.room) || 0) + h.minutes)
|
|
52
|
+
const rows = [...per].sort((a, b) => b[1] - a[1]).slice(0, 5)
|
|
53
|
+
const max = Math.max(1, ...rows.map(([, v]) => v))
|
|
54
|
+
const top = rows.length ? Math.round(rows[0][1] / rows.reduce((a, [, v]) => a + v, 0) * 100) : 0
|
|
55
|
+
return `<div class="hm-chart"><div class="hm-ch"><small>AI time by session · 7 days</small><b>${rows.length} session${rows.length === 1 ? '' : 's'}</b><em>${rows.length ? `${esc(names.get(rows[0][0]) || rows[0][0])} is ${top}% of it` : 'No AI time yet this week'}</em></div>
|
|
56
|
+
<div class="hm-rows">${rows.map(([room, v]) => `<div class="hm-row" data-tip="${esc(`${names.get(room) || room} · ${hm(v)} of AI time this week`)}"><span class="hm-rn">${esc(names.get(room) || room)}</span><span class="hm-rt"><i style="width:${(v / max * 100).toFixed(1)}%"></i></span><span class="hm-rv">${hm(v)}</span></div>`).join('')}</div></div>`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Who is working in each of the workspace's sessions open on this computer: room -> { working, faces, id }. */
|
|
60
|
+
function liveByRoom () {
|
|
61
|
+
const out = new Map()
|
|
62
|
+
for (const x of state.sessions.values()) {
|
|
63
|
+
const st = x.status
|
|
64
|
+
if (!st || !st.room) continue
|
|
65
|
+
const faces = [st.me, ...(st.peers || [])].filter((p) => p && p.agent && p.agent.status === 'working')
|
|
66
|
+
out.set(st.room, { id: x.id, working: faces.length, faces, people: [st.me, ...(st.peers || [])].filter(Boolean), name: st.sessionName || basename(x.dir) })
|
|
67
|
+
}
|
|
68
|
+
return out
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const facesHtml = (list, max = 4) => `<span class="hm-faces">${list.slice(0, max).map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>`
|
|
72
|
+
|
|
73
|
+
function sessionCard (s, live) {
|
|
74
|
+
const l = live.get(s.room)
|
|
75
|
+
const name = s.name || l?.name || s.room
|
|
76
|
+
const state = l ? (l.working ? `<span class="hm-cs lv"><span class="pulse"></span>${l.working} working</span>` : '<span class="hm-cs">Open here</span>') : `<span class="hm-cs">${s.lastActiveAt ? `Quiet · ${esc(ago(s.lastActiveAt))}` : 'Quiet'}</span>`
|
|
77
|
+
const doing = l ? (l.faces.map((p) => p.focus).find(Boolean) || '') : ''
|
|
78
|
+
return `<div class="hm-card${l && l.working ? '' : ' quiet'}" ${l ? `data-hm-open="${esc(l.id)}"` : `data-hm-join="${esc(s.room)}"`} title="${l ? 'Open this session' : 'Open it from the list below the cards'}">
|
|
79
|
+
<div class="hm-ct"><span class="hm-ico">${I.grid}</span><b>${esc(name)}</b>${state}</div>
|
|
80
|
+
<small class="hm-cl">${esc(doing || (l ? `${l.people.length} here` : 'Not open on this computer'))}</small>
|
|
81
|
+
<div class="hm-cf">${l ? facesHtml(l.working ? l.faces : l.people) : '<span></span>'}<span class="hm-room">${esc(name)}</span></div></div>`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function previewsHtml (d, edit, names, adding) {
|
|
85
|
+
const links = d.links || []
|
|
86
|
+
const rows = links.map((l) => {
|
|
87
|
+
const host = (() => { try { return new URL(l.url).host } catch { return l.url } })()
|
|
88
|
+
const local = /^(localhost|127\.|0\.0\.0\.0)/.test(host)
|
|
89
|
+
return `<div class="hm-pv"><span class="hm-pvdot${local ? ' live' : ''}"></span><div class="hm-pvx"><b>${esc(l.name)}</b><code>${esc(host)}</code><small>${esc([l.room ? names.get(l.room) || '' : '', l.note].filter(Boolean).join(' · ') || 'For the whole workspace')}</small></div>
|
|
90
|
+
<a class="hm-pvo" href="${esc(l.url)}" target="_blank" rel="noopener" title="Open ${esc(l.url)}" aria-label="Open ${esc(l.name)}">${I.external}</a>${edit ? `<button type="button" class="hm-pvx-rm" data-hm-rmlink="${esc(l.id)}" title="Remove ${esc(l.name)}" aria-label="Remove ${esc(l.name)}">${I.x}</button>` : ''}</div>`
|
|
91
|
+
}).join('')
|
|
92
|
+
const form = adding
|
|
93
|
+
? `<form class="hm-pv hm-pvform" data-hm-linkform><input class="input" name="name" placeholder="Name (Production, Staging…)" required maxlength="80"><input class="input" name="url" placeholder="https://…" required maxlength="500"><select class="input" name="room"><option value="">Whole workspace</option>${(d.sessions || []).map((s) => `<option value="${esc(s.room)}">${esc(s.name || s.room)}</option>`).join('')}</select><button class="btn primary" type="submit">Add</button><button class="btn ghost" type="button" data-hm-cancel>Cancel</button></form>`
|
|
94
|
+
: edit ? `<button type="button" class="hm-pv hm-pvadd" data-hm-addlink>${I.plus}Add a link</button>` : ''
|
|
95
|
+
return `<section class="hm-sec"><h3>Previews</h3><div class="hm-pvg">${rows}${form}</div>${!links.length && !edit ? '<p class="hint">No links yet.</p>' : ''}</section>`
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The home's markup: `ins` may still be loading (null). */
|
|
99
|
+
export function workspaceHomeHtml (d, ins, { adding = false } = {}) {
|
|
100
|
+
const live = liveByRoom()
|
|
101
|
+
const names = new Map((d.sessions || []).map((s) => [s.room, s.name || live.get(s.room)?.name || s.room]))
|
|
102
|
+
const working = (d.sessions || []).reduce((a, s) => a + (live.get(s.room)?.working || 0), 0)
|
|
103
|
+
const busy = (d.sessions || []).filter((s) => live.get(s.room)?.working).length
|
|
104
|
+
const edit = d.access && (d.access.access === 'edit' || d.access.admin)
|
|
105
|
+
const charts = ins ? `<div class="hm-charts">${aiChart(ins)}${mergesChart(ins)}${bySessionChart(ins, names)}</div>` : '<div class="hm-charts loading"><div class="hm-chart"></div><div class="hm-chart"></div><div class="hm-chart"></div></div>'
|
|
106
|
+
return `<div class="hm-page">
|
|
107
|
+
<div class="hm-head"><div><h2>${esc(d.workspace.name)}</h2><small>${working ? `${working} working across ${busy} session${busy === 1 ? '' : 's'} right now` : `${(d.sessions || []).length} session${(d.sessions || []).length === 1 ? '' : 's'} · nobody working right now`}</small></div><span class="hm-sp"></span>
|
|
108
|
+
<button type="button" class="btn" data-hm-invite>${I.users}<span>Invite</span></button><button type="button" class="btn primary" data-hm-new>${I.plus}<span>New session</span></button></div>
|
|
109
|
+
${charts}
|
|
110
|
+
<section class="hm-sec"><h3>Sessions</h3><div class="hm-grid">${(d.sessions || []).map((s) => sessionCard(s, live)).join('') || '<p class="hint">No sessions yet: New session starts one.</p>'}</div></section>
|
|
111
|
+
${previewsHtml(d, edit, names, adding)}
|
|
112
|
+
</div>`
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const insights = new Map() // workspace id -> { at, data }
|
|
116
|
+
let loading = null
|
|
117
|
+
|
|
118
|
+
/** The workspace's insights, cached a minute: calls `then` when fresh ones arrive. */
|
|
119
|
+
export function homeInsights (id, then) {
|
|
120
|
+
const c = insights.get(id)
|
|
121
|
+
if (c && Date.now() - c.at < 60_000) return c.data
|
|
122
|
+
if (loading !== id) {
|
|
123
|
+
loading = id
|
|
124
|
+
api('GET', `/api/workspaces/${encodeURIComponent(id)}/insights`).then((data) => { insights.set(id, { at: Date.now(), data }); then() })
|
|
125
|
+
.catch(() => { insights.set(id, { at: Date.now(), data: { aiHours: [], merges: [] } }); then() })
|
|
126
|
+
.finally(() => { loading = null })
|
|
127
|
+
}
|
|
128
|
+
return c ? c.data : null
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let tip = null
|
|
132
|
+
/** Clicks, the Add a link form and the charts' tooltips. `reload()` fetches the workspace again. */
|
|
133
|
+
export function bindWorkspaceHome (root, { id, go, reload, newSession, invite, setAdding }) {
|
|
134
|
+
if (!tip) { tip = document.createElement('div'); tip.className = 'hm-tip'; tip.hidden = true; document.body.appendChild(tip) }
|
|
135
|
+
root.onmousemove = (e) => {
|
|
136
|
+
const t = e.target.closest('[data-tip]')
|
|
137
|
+
if (!t || !root.contains(t)) { tip.hidden = true; return }
|
|
138
|
+
tip.textContent = t.dataset.tip
|
|
139
|
+
tip.hidden = false
|
|
140
|
+
tip.style.left = `${Math.min(e.clientX + 14, innerWidth - tip.offsetWidth - 8)}px`
|
|
141
|
+
tip.style.top = `${e.clientY - 34}px`
|
|
142
|
+
}
|
|
143
|
+
root.onmouseleave = () => { tip.hidden = true }
|
|
144
|
+
root.onclick = async (e) => {
|
|
145
|
+
const o = e.target.closest('[data-hm-open]')
|
|
146
|
+
if (o) { tip.hidden = true; go(o.dataset.hmOpen); return }
|
|
147
|
+
if (e.target.closest('[data-hm-join]')) { go(`ws:${id}`); return }
|
|
148
|
+
if (e.target.closest('[data-hm-new]')) return newSession()
|
|
149
|
+
if (e.target.closest('[data-hm-invite]')) return invite()
|
|
150
|
+
if (e.target.closest('[data-hm-addlink]')) { setAdding(true); return }
|
|
151
|
+
if (e.target.closest('[data-hm-cancel]')) { setAdding(false); return }
|
|
152
|
+
const rm = e.target.closest('[data-hm-rmlink]')
|
|
153
|
+
if (rm) {
|
|
154
|
+
try { await api('POST', `/api/workspaces/${encodeURIComponent(id)}/links/${encodeURIComponent(rm.dataset.hmRmlink)}/remove`) } catch (err) { toast(err.message) }
|
|
155
|
+
reload()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const form = root.querySelector('[data-hm-linkform]')
|
|
159
|
+
if (form) {
|
|
160
|
+
form.elements.name.focus()
|
|
161
|
+
form.onsubmit = async (e) => {
|
|
162
|
+
e.preventDefault()
|
|
163
|
+
try {
|
|
164
|
+
await api('POST', `/api/workspaces/${encodeURIComponent(id)}/links`, { name: form.elements.name.value, url: form.elements.url.value, room: form.elements.room.value || null })
|
|
165
|
+
setAdding(false)
|
|
166
|
+
reload()
|
|
167
|
+
} catch (err) { toast(err.message) }
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/ui/home.js
CHANGED
|
@@ -17,6 +17,8 @@ import { SOUND_EVENTS, playSound } from './sounds.js'
|
|
|
17
17
|
import { thisSessionGitHtml } from './git-rule.js'
|
|
18
18
|
import { cloudAiCardHtml, bindCloudAi, cloudSetupOn, cloudSetupHtml, cloudSetupStep } from './cloud-ai.js'
|
|
19
19
|
import { feedbackDockHtml, bindFeedback } from './feedback.js'
|
|
20
|
+
import { workspaceHomeHtml, bindWorkspaceHome, homeInsights } from './home-view.js'
|
|
21
|
+
import { openPalette } from './palette.js'
|
|
20
22
|
|
|
21
23
|
export const tildify = (p) => state.defaults.home && String(p).startsWith(state.defaults.home) ? `~${String(p).slice(state.defaults.home.length)}` : p
|
|
22
24
|
const hostOf = (url) => { try { return new URL(String(url).replace(/^ws/, 'http')).host } catch { return url } }
|
|
@@ -38,11 +40,14 @@ export function renderShell (view) {
|
|
|
38
40
|
const page = $('#page')
|
|
39
41
|
const scroll = page ? page.scrollTop : 0
|
|
40
42
|
$('#app').innerHTML = `
|
|
41
|
-
<div class="app-shell
|
|
43
|
+
<div class="app-shell rail-shell">
|
|
42
44
|
${mobileBarHtml(view)}
|
|
43
45
|
<div class="side-scrim" data-side-close></div>
|
|
44
|
-
${
|
|
45
|
-
<
|
|
46
|
+
${railHtml(view)}
|
|
47
|
+
<div class="shell-main">
|
|
48
|
+
${wbarHtml(view)}
|
|
49
|
+
<main class="page" id="page">${view === 'settings' ? settingsPageHtml() : view === 'agents' ? agentsPageHtml() : view.startsWith('wsfiles:') ? allFilesHtml(state.workspace) : view.startsWith('ws:') ? wsHomeHtml(view.slice(3)) : homeHtml()}</main>
|
|
50
|
+
</div>
|
|
46
51
|
</div>`
|
|
47
52
|
if (page && view === state.shellView) $('#page').scrollTop = scroll
|
|
48
53
|
state.shellView = view
|
|
@@ -54,11 +59,31 @@ export function renderShell (view) {
|
|
|
54
59
|
const rerender = () => { if (state.view === view) renderShell(view) }
|
|
55
60
|
bindAllFiles($('#page'), { id, go, rerender, reload: async () => { await openWorkspace(id).catch((err) => toast(err.message)); rerender() } })
|
|
56
61
|
} else if (view.startsWith('ws:')) {
|
|
57
|
-
|
|
62
|
+
const id = view.slice(3)
|
|
63
|
+
const rerender = () => { if (state.view === view) renderShell(view) }
|
|
64
|
+
if (state.workspace && state.workspace.workspace.id === id) {
|
|
65
|
+
bindWorkspaceHome($('#page .hm-page'), { id, go, reload: async () => { await openWorkspace(id).catch((err) => toast(err.message)); rerender() }, newSession: () => newSessionDialog(id), invite: () => workspaceInviteDialog(id), setAdding: (on) => { state.homeAdding = on; rerender() } })
|
|
66
|
+
}
|
|
67
|
+
bindWorkspacePage($('#page'), { go, rerender, newSessionDialog, inviteDialog: workspaceInviteDialog, dialog })
|
|
58
68
|
bindSessionActions($('#page'))
|
|
59
69
|
} else bindHome()
|
|
60
70
|
}
|
|
61
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A workspace's page: its home (home-view.js, the same as a session's Home), then what is set up for the
|
|
74
|
+
* whole workspace: its team and settings, its secrets and the apps its agents use.
|
|
75
|
+
*/
|
|
76
|
+
function wsHomeHtml (id) {
|
|
77
|
+
const d = state.workspace
|
|
78
|
+
if (!d || d.workspace.id !== id) return workspacePageHtml() // its loading state
|
|
79
|
+
return `${workspaceHomeHtml(d, homeInsights(id, () => { if (state.view === `ws:${id}`) renderShell(`ws:${id}`) }), { adding: !!state.homeAdding })}
|
|
80
|
+
<div class="hm-page hm-setup">
|
|
81
|
+
<section class="hm-sec"><h3>Workspace</h3><div class="hm-morerow"><button type="button" class="btn" data-team>${I.users}<span>Team</span></button><button type="button" class="btn" data-ws-settings>${I.gear}<span>Settings</span></button></div></section>
|
|
82
|
+
${state.secretsOn ? '<section class="sec ws-secrets" data-ws-secrets></section>' : ''}
|
|
83
|
+
${state.connectionsOn ? '<section class="sec ws-connections"><h3>Connections</h3><div data-ws-connections></div></section>' : ''}
|
|
84
|
+
</div>`
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
/** Narrow windows: a slim bar with the logo, where you are, your avatar and a menu
|
|
63
88
|
* button; the full sidebar slides in from the left as a drawer. Hidden on wide windows. */
|
|
64
89
|
function placeName (view) {
|
|
@@ -81,6 +106,58 @@ function mobileBarHtml (view) {
|
|
|
81
106
|
</header>`
|
|
82
107
|
}
|
|
83
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The rail on the far left (the dm06 layout, as in a session): the mark (Home), a tile per workspace, + (a new
|
|
111
|
+
* workspace, on Home), then Join a session, Agents, Settings, you and the dev buttons at the bottom.
|
|
112
|
+
*/
|
|
113
|
+
function railHtml (view) {
|
|
114
|
+
const p = state.profile
|
|
115
|
+
const on = String(view).replace(/^wsfiles:/, 'ws:')
|
|
116
|
+
const tiles = (state.workspacesOn ? (state.workspaces || []) : []).map((w) => {
|
|
117
|
+
const here = on === `ws:${w.id}`
|
|
118
|
+
const c = COLORS[w.color] || COLORS.lilac
|
|
119
|
+
return `<button type="button" class="rail-ws${here ? ' on' : ''}" data-view="ws:${esc(w.id)}" title="${esc(w.name)}" aria-label="${esc(w.name)}"${here ? ' aria-current="true"' : ''} style="--wc:${esc(c)}">${esc([...String(w.name || '?')][0].toUpperCase())}</button>`
|
|
120
|
+
}).join('')
|
|
121
|
+
return `
|
|
122
|
+
<nav class="side ws-rail" aria-label="Workspaces">
|
|
123
|
+
<button type="button" class="rail-brand" data-view="home" aria-label="Home" title="Home">${quiltMark({ word: false })}</button>
|
|
124
|
+
<div class="rail-tiles">${tiles}${state.workspacesOn ? `<button type="button" class="rail-ws add" data-view="home" title="New workspace" aria-label="New workspace">${I.plus}</button>` : ''}</div>
|
|
125
|
+
<span class="rail-line"></span>
|
|
126
|
+
<button type="button" class="rail-btn" data-pal title="Search (⌘K)" aria-label="Search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button>
|
|
127
|
+
<span class="rail-sp"></span>
|
|
128
|
+
<div class="rail-foot">
|
|
129
|
+
<button type="button" class="rail-btn" data-join-session title="Join a session" aria-label="Join a session">${I.link}</button>
|
|
130
|
+
<button type="button" class="rail-btn${view === 'agents' ? ' on' : ''}" data-view="agents" title="Agents" aria-label="Agents">${I.bot}</button>
|
|
131
|
+
${window.quiltDesktop?.dev ? `<button type="button" class="rail-btn" data-dev-restart title="Quit and start Quilt again (running from source)" aria-label="Restart (dev)">${I.refresh}</button>` : ''}
|
|
132
|
+
<button type="button" class="rail-btn${view === 'settings' ? ' on' : ''}" data-view="settings" title="Account settings: your defaults for new sessions" aria-label="Settings">${I.gear}</button>
|
|
133
|
+
<button type="button" class="rail-me" data-view="settings" title="${esc(p.name)} · your profile and account settings" aria-label="Your profile">${avatar(p.name, p.color)}</button>
|
|
134
|
+
</div>
|
|
135
|
+
${feedbackDockHtml('side')}
|
|
136
|
+
</nav>`
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The bar across the top of a workspace's pages (its home and its files): as in a session, without one open. */
|
|
140
|
+
function wbarHtml (view) {
|
|
141
|
+
const id = view.startsWith('wsfiles:') ? view.slice(8) : view.startsWith('ws:') ? view.slice(3) : ''
|
|
142
|
+
if (!id) return ''
|
|
143
|
+
const w = (state.workspaces || []).find((x) => x.id === id)
|
|
144
|
+
const name = w?.name || state.workspace?.workspace?.name || 'Workspace'
|
|
145
|
+
const kind = w?.space?.kind === 'org' ? (w.space.name || 'Team') : 'Personal'
|
|
146
|
+
const running = [...state.sessions.values()].filter((x) => x.workspace === id)
|
|
147
|
+
const rows = running.map((x) => `<button type="button" class="wb-srow" role="menuitem" data-go="${esc(x.id)}">${I.grid}<span class="wb-sname"><b>${esc(x.status.sessionName || basename(x.dir))}</b><small>${x.status.connected ? 'Open here' : 'Not connected'}</small></span></button>`).join('')
|
|
148
|
+
return `
|
|
149
|
+
<header class="wbar" aria-label="Workspace">
|
|
150
|
+
<div class="wb-name"><b>${esc(name)}</b><small>${esc(kind)}</small></div>
|
|
151
|
+
<button type="button" class="wb-btn icon${view.startsWith('ws:') ? ' on' : ''}" data-view="ws:${esc(id)}" title="Workspace home" aria-label="Workspace home">${I.home}</button>
|
|
152
|
+
<div class="wb-sess">
|
|
153
|
+
<button type="button" class="wb-btn wb-sessbtn" data-wb-sess aria-haspopup="true" aria-expanded="false">${I.grid}<b>${running.length ? `${running.length} open here` : 'Sessions'}</b>${I.chevDown}</button>
|
|
154
|
+
<div class="popover wb-sessmenu" role="menu" aria-label="Sessions" hidden><div class="wb-mhead">Sessions<button type="button" class="wb-mplus" data-new-session title="New session" aria-label="New session">${I.plus}</button></div>${rows || '<p class="wb-mempty">None open on this computer: the workspace home lists them all.</p>'}</div>
|
|
155
|
+
</div>
|
|
156
|
+
<span class="spacer"></span>
|
|
157
|
+
<div class="wb-tools"><button type="button" class="wb-btn${view.startsWith('wsfiles:') ? ' on' : ''}" data-view="${view.startsWith('wsfiles:') ? (state.sessions.has(state.filesFrom) ? esc(state.filesFrom) : `ws:${esc(id)}`) : `wsfiles:${esc(id)}`}" title="${view.startsWith('wsfiles:') ? 'Back' : 'The workspace\'s shared files'}">${I.folder}<span>Files</span></button></div>
|
|
158
|
+
</header>`
|
|
159
|
+
}
|
|
160
|
+
|
|
84
161
|
function sidebarHtml (view) {
|
|
85
162
|
const p = state.profile
|
|
86
163
|
const running = [...state.sessions.values()]
|
|
@@ -177,7 +254,19 @@ function bindSidebar () {
|
|
|
177
254
|
if (wrap && !wrap.contains(e.target)) { $('#sessions-menu').hidden = true; $('#sessions-btn').setAttribute('aria-expanded', 'false') }
|
|
178
255
|
})
|
|
179
256
|
}
|
|
180
|
-
document.querySelectorAll('.side [data-go]').forEach((b) => { b.onclick = () => go(b.dataset.go) })
|
|
257
|
+
document.querySelectorAll('.side [data-go], .wbar [data-go]').forEach((b) => { b.onclick = () => go(b.dataset.go) })
|
|
258
|
+
$('.rail-shell [data-pal]')?.addEventListener('click', () => openPalette())
|
|
259
|
+
const sb = $('.wbar [data-wb-sess]')
|
|
260
|
+
if (sb) {
|
|
261
|
+
const pop = sb.nextElementSibling
|
|
262
|
+
const set = (open) => { pop.hidden = !open; sb.setAttribute('aria-expanded', String(open)) }
|
|
263
|
+
sb.onclick = () => set(pop.hidden)
|
|
264
|
+
if (!bindSidebar.wbListening) {
|
|
265
|
+
bindSidebar.wbListening = true
|
|
266
|
+
document.addEventListener('mousedown', (e) => { if (!e.target.closest('.wb-sess')) document.querySelectorAll('.app-shell .wb-sessmenu').forEach((m) => { m.hidden = true }) })
|
|
267
|
+
}
|
|
268
|
+
bindSessionActions(pop)
|
|
269
|
+
}
|
|
181
270
|
bindSessionActions(document.querySelector('.side'))
|
|
182
271
|
// Report a bug / Suggest a feature, at the bottom of the sidebar (feedback.js): filed into a session running here.
|
|
183
272
|
bindFeedback(document.querySelector('.side'), { where: () => placeName(state.shellView || 'home') })
|
|
@@ -350,7 +439,7 @@ export function newSessionDialog (workspace = '') {
|
|
|
350
439
|
* workspace, the org's in an org's) are added at once. Agents can also join every session here
|
|
351
440
|
* as it starts, and Invite a new agent makes a link for an agent that joins once it registers.
|
|
352
441
|
*/
|
|
353
|
-
function workspaceInviteDialog (id) {
|
|
442
|
+
export function workspaceInviteDialog (id) {
|
|
354
443
|
const d = state.workspace
|
|
355
444
|
// An org's workspace offers the org's agents only (never your own: they can't join it).
|
|
356
445
|
const isOrg = !!d?.workspace?.orgId
|
package/src/ui/loom-model.js
CHANGED
|
@@ -391,12 +391,16 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
|
|
|
391
391
|
|
|
392
392
|
if (show.chat !== false) {
|
|
393
393
|
for (const m of messages || []) {
|
|
394
|
-
|
|
394
|
+
// Someone without a lane (the relay's own lines, an approval card) still gets a band.
|
|
395
395
|
const text = String(m.text || '')
|
|
396
396
|
items.push({
|
|
397
397
|
type: 'chat',
|
|
398
398
|
key: `chat|${m.id}`,
|
|
399
|
-
lane: m.by,
|
|
399
|
+
lane: index.has(m.by) ? m.by : null,
|
|
400
|
+
by: m.by,
|
|
401
|
+
msgId: m.id,
|
|
402
|
+
approval: m.approval || '',
|
|
403
|
+
relay: !index.has(m.by),
|
|
400
404
|
ts: Number(m.ts) || 0,
|
|
401
405
|
text: text.slice(0, PREVIEW),
|
|
402
406
|
to: m.to || '',
|
|
@@ -457,8 +461,10 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
|
|
|
457
461
|
items.forEach((it, i) => {
|
|
458
462
|
it.id = `k${i}`
|
|
459
463
|
const l = it.lane == null ? null : laneOf(it.lane)
|
|
460
|
-
|
|
461
|
-
|
|
464
|
+
// Chat is a band across every lane (the dm06 loom), at its time, whoever wrote it.
|
|
465
|
+
const band = it.type === 'chat'
|
|
466
|
+
it.col = l && !band ? l.col : null
|
|
467
|
+
it.folded = !!l && !band && l.fold !== 'open'
|
|
462
468
|
})
|
|
463
469
|
let rows = packRows(items.filter((it) => !it.folded), columns.length)
|
|
464
470
|
|
|
@@ -515,11 +521,8 @@ export function buildLoom ({ people = [], feeds = new Map(), messages = [], task
|
|
|
515
521
|
stitches.sort((x, y) => Number(y.collide) - Number(x.collide))
|
|
516
522
|
if (stitches.length > MAX_STITCHES) stitches.length = MAX_STITCHES
|
|
517
523
|
|
|
524
|
+
// Chat is a band across every lane now: it names who it's for itself, so no thread is drawn to them.
|
|
518
525
|
const mentions = []
|
|
519
|
-
for (const it of items) {
|
|
520
|
-
if (it.type !== 'chat') continue
|
|
521
|
-
for (const n of it.mentions) if (index.has(n)) mentions.push({ from: it.id, lane: n, col: laneOf(n).col })
|
|
522
|
-
}
|
|
523
526
|
|
|
524
527
|
return { lanes, columns, items, knots, rows, stitches, mentions, files }
|
|
525
528
|
}
|