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