heyquilt 0.3.152 → 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/src/ui/session.js CHANGED
@@ -2,8 +2,10 @@
2
2
  // AI conversations at once), one person's AI chat, a shared file or the task board;
3
3
  // the team chat on the right.
4
4
  import { mountSecrets } from './secrets.js'
5
- import { TOKEN, I, state, $, esc, basename, bytes, clock, ago, avatar, colorFor, toast, api, ask, remember, recall, toolsOf, NO_POSTING, ACCOUNT_KEY, loadAccessTypes, typeOptions, accessLine, loadingHtml, loadingNote } from './common.js'
5
+ import { mountConnections, approvalCardHtml, refreshApprovals, answerApproval } from './connections.js'
6
+ import { TOKEN, I, state, $, esc, basename, bytes, clock, ago, avatar, colorFor, toast, api, ask, remember, recall, toolsOf, NO_POSTING, ACCOUNT_KEY, loadAccessTypes, typeOptions, accessLine, loadingHtml, loadingNote, COLORS } from './common.js'
6
7
  import { openInvite, renderTabs, markRead, go } from './app.js'
8
+ import { NO_LINK_YET } from './invite.js'
7
9
  import { renderFeed } from './feed.js'
8
10
  import { renderLoom, resetLoom, focusFile, showsLoom } from './loom.js'
9
11
  import { buildLoom, foldAiLanes, aiWorking } from './loom-model.js'
@@ -11,23 +13,26 @@ import { railModel } from './rail-model.js'
11
13
  import { renderRail, openLocks, closeLocks } from './rail.js'
12
14
  import { feedbackDockHtml, bindFeedback } from './feedback.js'
13
15
  import { conversations } from './feed-convs.js'
14
- import { closeTreeMenu } from './tree.js'
16
+ import { closeTreeMenu, renderTree } from './tree.js'
15
17
  import { renderFileView, renderFileTabs } from './fileview.js'
16
18
  import { rolledOff, diffLines } from './diffview.js'
17
19
  import { searchMarkup, searchTabMarkup, liveByPerson, fileReadsNeeded, SEARCH_ICON } from './quiltview.js'
18
20
  import { changesMarkup, bindChanges, unbindChanges, changesChanged, fileChanges, loadChanges, changedCount, unseenChanges, markChangesSeen } from './changes.js'
19
21
  import { quiltMark } from './mark.js'
20
- import { openSettings } from './home.js'
22
+ import { openSettings, newSessionDialog, workspaceInviteDialog } from './home.js'
23
+ import { workspaceHomeHtml, bindWorkspaceHome, homeInsights } from './home-view.js'
24
+ import { peoplePageHtml, bindPeoplePage } from './people-view.js'
25
+ import { openPalette, paletteSource } from './palette.js'
21
26
  import { fileCardHref, renderable, textHtml, mentionAt, mentionCandidates, completeMention, ALL_AGENTS, RELAY_NAME, isRelay, relayPrompts, typingNames, typingHtml, TYPING_MS, foldPersonas, aiOwners, aiName, shownName, ownAiChatter } from './chat.js'
22
27
  import { toolLogo } from './tool-logo.js'
23
28
  import { renderBoard, taskNotesModalHtml, openTaskMenu, foldPlan, matchesSearch } from './board.js'
24
29
  import { accessFormValues, accessSaveBody, grantsLoading, grantsLoaded, grantsFailed } from './access-form.js'
25
- import { workspaceFilePicker } from './files.js'
30
+ import { allFilesHtml, bindAllFiles, attachMenu } from './files.js'
26
31
  import { sessionAgentsHtml } from './agent-place.js'
27
32
  import { renderCatchUp, bindCatchUp } from './catchup.js'
28
33
  import { boxSummary, boxesOf, unplaced, boxesSig, boxListHtml, boxFoldHtml } from './boxes.js'
29
34
  import { inSeam, makeQuiltWords, seamChip, squareCard, squarePanelHtml, seamSettingsHtml, openSquareButton, squaresSideHtml, SEAM_SIDE_HINT } from './seam-model.js'
30
- import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards } from './voice.js'
35
+ import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, inCallHere } from './voice.js'
31
36
 
32
37
  let current = null // session id being shown
33
38
  let timers = []
@@ -58,7 +63,7 @@ function ws (id) {
58
63
  expanded: {},
59
64
  boxesCollapsed: false, // the Boxes pane (who is working on what) starts open; folded, it is a rail of locks (rail.js)
60
65
  stale: {}, // file path -> changed while not visible
61
- loom: { chat: true, tasks: true, density: 'detailed', layout: 'lanes', hidden: [] },
66
+ loom: { chat: true, tasks: true, density: 'compact', layout: 'lanes', hidden: [] },
62
67
  ...(saved || {}),
63
68
  drawer: null
64
69
  })
@@ -121,15 +126,24 @@ export function mountSession (id) {
121
126
 
122
127
  $('#app').innerHTML = `
123
128
  <div class="ws" id="ws">
129
+ <nav class="ws-rail" id="ws-rail" aria-label="Workspaces">
130
+ <button class="rail-brand" data-go="home" aria-label="Home">${quiltMark({ word: false })}</button>
131
+ <div class="rail-tiles" id="rail-tiles"></div>
132
+ <span class="rail-line"></span>
133
+ <button type="button" class="rail-btn" data-pal title="Search (⌘K)" aria-label="Search">${SEARCH_ICON}</button>
134
+ <span class="rail-sp"></span>
135
+ <div class="rail-foot" id="rail-foot"></div>
136
+ </nav>
124
137
  <header class="ws-top">
125
138
  <button class="brand" data-go="home" aria-label="Home">${quiltMark({ sew: 'first' })}</button>
126
139
  <div class="overflow sess" id="sess">
127
- <button class="sess-btn" id="sess-btn" type="button" aria-haspopup="true" aria-expanded="false" aria-controls="sess-menu"><span class="sess-dot" id="sess-dot"></span><span class="sess-name" id="sess-name"></span><span class="badge" id="sess-badge" hidden></span>${I.chevDown}</button>
140
+ <button class="sess-btn" id="sess-btn" type="button" aria-haspopup="true" aria-expanded="false" aria-controls="sess-menu" aria-label="This session: rename, settings, invite, leave" title="This session"><span class="sess-dot" id="sess-dot"></span><span class="sess-name" id="sess-name"></span><span class="badge" id="sess-badge" hidden></span>${I.chevDown}</button>
128
141
  <div class="popover more-menu sess-menu" id="sess-menu" role="menu" aria-label="This session" hidden>
129
- <div id="tabs" class="sess-tabs"></div>
142
+ <div id="tabs" class="sess-tabs" hidden></div>
130
143
  <button class="pop-item" role="menuitem" id="rename-btn" hidden>Rename session…</button>
131
144
  <button class="pop-item" role="menuitem" id="move-ws-btn" hidden>Move to a workspace…</button>
132
145
  <button class="pop-item" role="menuitem" data-session-settings>Session settings…</button>
146
+ <button class="pop-item" role="menuitem" data-invite-people>Invite people…</button>
133
147
  <button class="pop-item" role="menuitem" data-gather-rules>One set of AI rules…</button>
134
148
  <div class="pop-sep"></div>
135
149
  <button class="pop-item" role="menuitem" id="leave-btn">Leave this session</button>
@@ -140,6 +154,7 @@ export function mountSession (id) {
140
154
  <span class="relay-problem" id="relay-problem" role="status" hidden></span>
141
155
  <span class="access-pill" id="access-pill" hidden></span>
142
156
  <button class="btn sm ghost icon narrow-only" id="toggle-tree" title="Boxes: who is working on what" aria-label="Show boxes">${I.box}</button>
157
+ <button class="btn sm ghost conn-btn" id="connections-btn" type="button" title="Apps agents in this session can use">${I.plug}<span class="wide-only">Connections</span></button>
143
158
  <div class="people" id="people">
144
159
  <div class="people-pill">
145
160
  <button class="people-btn" id="people-btn" aria-haspopup="true" aria-expanded="false" aria-controls="people-menu"></button>
@@ -170,6 +185,17 @@ export function mountSession (id) {
170
185
  </div>
171
186
  </div>
172
187
  </header>
188
+ <div class="ws-col">
189
+ <header class="wbar" id="wbar" aria-label="Workspace">
190
+ <div class="wb-name" id="wb-name"></div>
191
+ <button type="button" class="wb-btn icon" id="wb-home" title="Workspace home" aria-label="Workspace home">${I.home}</button>
192
+ <div class="wb-sess" id="wb-sess">
193
+ <button type="button" class="wb-btn wb-sessbtn" id="wb-sessbtn" aria-haspopup="true" aria-expanded="false" aria-controls="wb-sessmenu"></button>
194
+ <div class="popover wb-sessmenu" id="wb-sessmenu" role="menu" aria-label="Sessions" hidden></div>
195
+ </div>
196
+ <span class="spacer"></span>
197
+ <div class="wb-tools" id="wb-tools"></div>
198
+ </header>
173
199
  <div class="ws-body" id="ws-body">
174
200
  <aside class="ws-tree ws-boxes" aria-label="Boxes: who is working on what">
175
201
  <div class="pane-head">
@@ -177,10 +203,12 @@ export function mountSession (id) {
177
203
  <span class="pane-title">Boxes</span><span class="hint" id="box-count"></span>
178
204
  </div>
179
205
  <div class="tree-rail" id="tree-rail" role="toolbar" aria-orientation="vertical" aria-label="Locks"></div>
206
+ <div class="side-mini" id="side-mini" aria-label="Sessions and files"></div>
180
207
  <div class="tree-scroll boxes-side" id="boxes-side"></div>
181
208
  ${feedbackDockHtml('boxes')}
182
209
  </aside>
183
210
  <main class="ws-main">
211
+ <div class="sess-bar"><div class="sess-head" id="sess-head"></div><div class="sh-tools" id="sh-tools"></div></div>
184
212
  <div class="requests catchup" id="catchup" role="region" aria-label="While you were away" hidden></div>
185
213
  <div class="requests square" id="square-card" role="status" aria-label="Seam" hidden></div>
186
214
  <div class="requests" id="requests" hidden></div>
@@ -193,6 +221,7 @@ export function mountSession (id) {
193
221
  <aside class="ws-chat" id="chat-pane" aria-label="Chat">
194
222
  <div class="chat-resize" id="chat-resize" role="separator" aria-orientation="vertical" aria-label="Resize chat" title="Drag to resize · double-click to collapse" tabindex="0"></div>
195
223
  <button type="button" class="chat-rail" id="chat-rail" title="Open chat" aria-label="Open chat">${I.chat}<span class="chat-badge" id="chat-rail-badge" hidden></span></button>
224
+ <div class="work-strip" id="work-strip" aria-label="What people are working on"></div>
196
225
  <div class="chat-head"><h3>Chat</h3><span class="hint" id="chat-sub"></span>${callButtonMarkup()}<button type="button" class="tree-collapse chat-collapse" id="collapse-chat" title="Collapse chat" aria-label="Collapse chat" aria-controls="chat-pane">${I.arrowRight}</button></div>
197
226
  <div class="messages" id="messages"></div>
198
227
  <div class="typing" id="typing" role="status" aria-live="polite" hidden></div>
@@ -203,8 +232,8 @@ export function mountSession (id) {
203
232
  <div class="attachments" id="attachments"></div>
204
233
  <div class="mention-menu" id="mention-menu" role="listbox" aria-label="Mention someone" hidden></div>
205
234
  <div class="box">
206
- <button type="button" class="btn ghost icon" id="attach-btn" title="Send a file" aria-label="Send a file">${I.clip}</button>
207
- ${sum()?.workspace ? `<button type="button" class="btn ghost icon" data-attach-workspace title="Attach from workspace" aria-label="Attach from workspace">${I.folder}</button>` : ''}
235
+ <button type="button" class="btn ghost icon" id="attach-btn" title="Send a file" aria-label="Send a file">${I.plus}</button>
236
+ <button type="button" class="btn ghost icon" id="at-btn" title="Mention someone" aria-label="Mention someone"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"/></svg></button>
208
237
  <input type="file" id="file-input" multiple hidden>
209
238
  <textarea id="msg-input" rows="1" placeholder="Message everyone…"></textarea>
210
239
  <button type="submit" class="btn primary icon" id="send-btn" title="Send" aria-label="Send">${I.send}</button>
@@ -213,9 +242,36 @@ export function mountSession (id) {
213
242
  </aside>
214
243
  <div class="scrim" id="scrim"></div>
215
244
  </div>
245
+ </div>
216
246
  </div>${firstVisit ? `<div class="sv-loading" id="sv-loading">${loadingHtml({ label: 'Loading session', name: sum()?.status?.sessionName || basename(sum()?.dir || '') })}</div>` : ''}`
217
247
 
248
+ // Back in someone's view or your thread with them: the composer writes to them again.
249
+ { const w = ws(id); const who = w.mode === 'ai' ? (w.dmWith || w.aiSel) : null; if (who && who !== sum()?.status.me.name) state.to = who }
218
250
  bindTop()
251
+ $('#ws-rail [data-pal]').onclick = () => openPalette()
252
+ // ⌘K finds this session's people and pages, and the workspace's files (palette.js).
253
+ paletteSource('session', () => {
254
+ const s = sum()
255
+ if (!s || state.view !== current) return []
256
+ const st = s.status
257
+ const go2 = (mode) => () => { const w = ws(current); if (PAGES.includes(mode) && !PAGES.includes(w.mode)) w.pageBack = w.mode; w.mode = mode; if (mode === 'ai') { w.aiSel = null; w.dmWith = null } saveWs(current); renderMain(); renderMainBar(); renderSessHead(); renderWbar() }
258
+ const here = st.sessionName || basename(s.dir)
259
+ const out = [
260
+ ...[st.me, ...st.peers].filter(Boolean).map((p) => ({ group: 'People', title: p.name === st.me.name ? `${p.name} (you)` : p.name, sub: `${p.kind === 'agent' ? 'Agent' : p.agent?.tool || 'Person'} · ${p.agent?.status === 'working' ? (p.focus || 'Working') : 'Open their AI chats'}`, face: { name: p.name, color: p.color }, run: () => openPerson(p.name) })),
261
+ ...st.peers.filter(Boolean).map((p) => ({ group: 'Messages', title: `Messages with ${p.name}`, sub: 'Only the two of you see them', icon: I.chat, run: () => openDm(p.name) })),
262
+ { group: 'Go to', title: 'Chat', sub: here, icon: I.chat, run: go2('ai') },
263
+ { group: 'Go to', title: 'Tasks', sub: here, icon: I.board, run: go2('tasks') },
264
+ { group: 'Go to', title: 'Code', sub: here, icon: I.file, run: go2('files') },
265
+ ...(s.workspace ? [{ group: 'Go to', title: 'Workspace home', sub: 'Charts, sessions and previews', icon: I.home, run: go2('home') }, { group: 'Go to', title: 'Files', sub: 'Shared across the workspace', icon: I.folder, run: go2('wsfiles') }] : []),
266
+ { group: 'Go to', title: 'People', sub: 'Humans and AI', icon: I.users, run: go2('people') },
267
+ { group: 'Settings', title: 'Session settings', sub: here, icon: I.gear, run: () => openSessionSettings() },
268
+ ...(state.connectionsOn ? [{ group: 'Settings', title: 'Connections', sub: 'Apps agents here can use', icon: I.plug, run: () => { if (ws(current).mode !== 'connections') togglePage('connections') } }] : [])
269
+ ]
270
+ if (state.workspace && state.workspace.workspace?.id === s.workspace) {
271
+ for (const f of (state.workspace.files || []).slice(0, 200)) out.push({ group: 'Files', title: f.name || basename(f.path), sub: f.path, icon: f.kind === 'folder' ? I.folder : I.file, run: go2('wsfiles') })
272
+ }
273
+ return out
274
+ })
219
275
  mountCall(id, mounted.signal, () => {
220
276
  const st = sum().status
221
277
  const colors = new Map([...st.peers.map((p) => [p.name, p.color]), [st.me.name, st.me.color]])
@@ -225,7 +281,7 @@ export function mountSession (id) {
225
281
  bindChanges(id, mounted.signal, { onOpen: (path) => openFile(path, { tab: 'changes' }), close: () => setGitOpen(false), onCount: renderGitChip })
226
282
  bindCatchUp($('#catchup'), { sessionId: () => current, onOpen: openFile })
227
283
  // Report a bug / Suggest a feature at the bottom of the Boxes pane (feedback.js): onto this session's board.
228
- bindFeedback($('.ws-boxes'), { session: () => current, where: () => state.sessions.get(current)?.status?.sessionName || 'a session' })
284
+ bindFeedback($('#ws-rail'), { session: () => current, where: () => state.sessions.get(current)?.status?.sessionName || 'a session' })
229
285
  bindSquareCard()
230
286
  bindMain()
231
287
  bindTreeEvents()
@@ -431,16 +487,64 @@ function bindTop () {
431
487
  })
432
488
  }
433
489
  bindBranchMenu()
434
- bindMenu($('#sess-btn'), $('#sess-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings(); if (e.target.closest('[data-gather-rules]')) openGatherRules() })
490
+ bindMenu($('#sess-btn'), $('#sess-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings(); if (e.target.closest('[data-invite-people]')) openInvite(current); if (e.target.closest('[data-gather-rules]')) openGatherRules() })
491
+ // Your account chip and Settings live at the bottom of the sidebar, not in the header.
492
+ // The window has no top bar: workspaces, Settings and you live in the rail on the far left, and the
493
+ // session's Open button at the right of the session header. People and source control are in Session settings.
494
+ // The bug and idea buttons are for the team building Quilt, so they sit apart in a small dev row.
495
+ // With no second sidebar they sit at the bottom of the rail.
496
+ const dock = $('.ws-boxes .fb-dock')
497
+ if (dock) $('#ws-rail')?.appendChild(dock)
498
+ const tools = $('#sh-tools')
499
+ for (const sel of ['#relay-problem', '#access-pill', '.open-in']) { const n = $(`.ws-top ${sel}`); if (n && tools) tools.appendChild(n) }
500
+ bindWbar()
501
+ const wbTools = $('#wb-tools')
502
+ // Join requests wait behind a bell next to Settings instead of taking a band of the page; a new one pops a toast.
503
+ const req = $('#requests')
504
+ if (tools && req) {
505
+ const BELL = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>'
506
+ wbTools.insertAdjacentHTML('beforeend', `<div class="sh-notes"><button type="button" class="btn sm icon sh-bell" title="Notifications" aria-label="Notifications" aria-haspopup="true" aria-expanded="false">${BELL}<span class="sh-badge" hidden></span></button>
507
+ <div class="popover sh-notes-pop" role="dialog" aria-label="Notifications" hidden><div class="sh-notes-head">Notifications</div><p class="sh-notes-empty">Nothing waiting for you.</p></div></div>`)
508
+ const bell = wbTools.querySelector('.sh-bell')
509
+ const pop = wbTools.querySelector('.sh-notes-pop')
510
+ const badge = wbTools.querySelector('.sh-badge')
511
+ pop.appendChild(req)
512
+ const set = (open) => { pop.hidden = !open; bell.setAttribute('aria-expanded', String(open)) }
513
+ bell.onclick = () => set(pop.hidden)
514
+ pop.addEventListener('keydown', (e) => { if (e.key === 'Escape') { set(false); bell.focus() } })
515
+ // The access picker's list opens outside the panel: picking from it keeps the panel open.
516
+ document.addEventListener('mousedown', (e) => { if (!e.target.closest('.sh-notes, [role=listbox], .dd-list, .dd-menu')) set(false) }, { signal: mounted.signal })
517
+ let seen = new Set()
518
+ const sync = () => {
519
+ const forms = [...req.querySelectorAll('.request')]
520
+ badge.hidden = !forms.length
521
+ badge.textContent = String(forms.length)
522
+ pop.querySelector('.sh-notes-empty').hidden = !!forms.length
523
+ for (const f of forms) if (!seen.has(f.dataset.key) && pop.hidden) toast(`${f.querySelector('.rq-main b')?.textContent || 'Someone'} wants to join. See the bell.`)
524
+ seen = new Set(forms.map((f) => f.dataset.key))
525
+ }
526
+ new MutationObserver(sync).observe(req, { childList: true })
527
+ sync()
528
+ }
529
+ // Who is here, at the right of the bar. The session's own actions are in Session settings → General.
530
+ if (wbTools) wbTools.appendChild($('#people'))
531
+ const foot = $('#rail-foot')
532
+ if (foot) {
533
+ foot.innerHTML = `<button type="button" class="rail-btn" data-side-settings title="Settings" aria-label="Settings">${I.gear}</button>`
534
+ const you = $('.ws-top .overflow.you')
535
+ if (you) foot.appendChild(you)
536
+ foot.querySelector('[data-side-settings]').onclick = () => $('#settings-btn')?.click()
537
+ }
435
538
  bindMenu($('#you-btn'), $('#you-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings() })
436
539
  const wrap = $('#people')
437
540
  const btn = $('#people-btn')
438
541
  const menu = $('#people-menu')
439
542
  const open = () => { menu.hidden = false; btn.setAttribute('aria-expanded', 'true'); renderPeopleMenu() }
440
543
  const close = () => { menu.hidden = true; btn.setAttribute('aria-expanded', 'false') }
441
- btn.onclick = () => (menu.hidden ? open() : close())
544
+ // Everyone here, as a page of its own (dm06), a toggle like Files and Home; the member list is in Session settings.
545
+ btn.onclick = () => togglePage('people')
442
546
  wrap.addEventListener('keydown', (e) => { if (e.key === 'Escape') { close(); btn.focus() } })
443
- document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target)) close() }, { signal: mounted.signal })
547
+ document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target) && !menu.classList.contains('in-ss')) close() }, { signal: mounted.signal })
444
548
 
445
549
  menu.addEventListener('click', async (e) => {
446
550
  if (e.target.closest('[data-session-settings]')) { openSessionSettings(); return }
@@ -477,6 +581,7 @@ function bindTop () {
477
581
  })
478
582
 
479
583
  $('#toggle-tree').onclick = () => toggleDrawer('tree')
584
+ $('#connections-btn').onclick = () => togglePage('connections')
480
585
  $('#toggle-chat').onclick = () => { toggleDrawer('chat'); $('#chat-badge').hidden = true }
481
586
  $('#scrim').onclick = () => toggleDrawer(null)
482
587
  }
@@ -701,9 +806,10 @@ function renderTop () {
701
806
  label.innerHTML = ''
702
807
  }
703
808
  const people = [st.me, ...peopleHere(st)]
704
- const shown = people.slice(0, 4)
705
- $('#people-btn').innerHTML = `<span class="stack">${shown.map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>
706
- <span class="count">${people.length}</span>`
809
+ // Who is working first (dm06: their faces, "+N" for everyone else here, and "N working").
810
+ const busy = people.filter((p) => p.agent && p.agent.status === 'working')
811
+ const shown = [...busy, ...people.filter((p) => !busy.includes(p))].slice(0, 4)
812
+ $('#people-btn').innerHTML = `<span class="stack">${shown.map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>${people.length > shown.length ? `<span class="wb-more">+${people.length - shown.length}</span>` : ''}${busy.length ? `<i class="wb-working"><span class="pulse"></span>${busy.length} working</i>` : ''}`
707
813
  $('#people-btn').setAttribute('aria-label', `${people.length} ${people.length === 1 ? 'person' : 'people'} in this session${st.connected ? '' : ', reconnecting'}`)
708
814
  // Why we're offline, when we know: otherwise "Reconnecting…" can go on silently forever.
709
815
  const problem = $('#relay-problem')
@@ -718,7 +824,7 @@ function renderTop () {
718
824
  renderCatchUp($('#catchup'), st.catchUp, { colors: new Map([st.me, ...st.peers].map((p) => [p.name, p.color])) })
719
825
  renderSquareCard()
720
826
  renderGitChip()
721
- $('#sess-name').textContent = st.sessionName || basename(sum().dir)
827
+ $('#sess-name').textContent = (state.workspaces || []).find((w) => w.id === sum().workspace)?.name || st.sessionName || basename(sum().dir)
722
828
  const me = state.account || {}
723
829
  $('#you-btn').innerHTML = avatar(st.me.name, st.me.color)
724
830
  $('#you-btn').setAttribute('aria-label', `${st.me.name}: settings`)
@@ -1008,6 +1114,41 @@ function membersHtml (st, kind = 'people') {
1008
1114
  <div class="pm-foot"><button type="button" class="btn sm ghost danger" data-end-session>End session for everyone</button></div>`
1009
1115
  }
1010
1116
 
1117
+ /**
1118
+ * People in Session settings: everyone in the session and their access, and Invite. Settings only: messaging
1119
+ * people and what they are working on are in the chat and its cards, not here.
1120
+ */
1121
+ function peopleSettingsHtml (st) {
1122
+ const acc = st.access || {}
1123
+ const members = new Map((st.members || []).filter((m) => !isAgentMember(m) && !m.chat).map((m) => [m.name, m]))
1124
+ const names = [...new Set([st.me.name, ...st.peers.filter((p) => p.kind !== 'agent').map((p) => p.name), ...members.keys()])]
1125
+ const rows = names.map((name) => {
1126
+ const m = members.get(name)
1127
+ const p = personInfo(name)
1128
+ const role = m ? m.role : name === st.me.name && acc.owner ? 'owner' : 'editor'
1129
+ const tools = toolsOf(p).map((t) => `<span class="tag">${esc(t)}</span>`).join('')
1130
+ const access = acc.owner && m && m.role !== 'owner'
1131
+ ? `<form class="pm-member edit ps-access" data-key="${esc(m.key)}"><span class="nm" hidden>${esc(name)}</span>
1132
+ <select class="input" name="role" aria-label="Access for ${esc(name)}">
1133
+ <option value="editor" ${role === 'editor' ? 'selected' : ''}>Can edit</option>
1134
+ <option value="viewer" ${role === 'viewer' ? 'selected' : ''}>View only</option>
1135
+ </select>
1136
+ <button type="button" class="btn sm ghost icon" data-remove title="Remove ${esc(name)}" aria-label="Remove ${esc(name)}">${I.x}</button>
1137
+ </form>`
1138
+ : `<span class="ps-role">${roleLabel(role)}</span>`
1139
+ return `<div class="ps-row">${avatar(name, p.color, p.online)}<span class="ps-name"><b>${esc(name)}</b>${name === st.me.name ? '<span class="ps-you">you</span>' : ''}${tools}</span>${access}</div>`
1140
+ }).join('')
1141
+ const admitBy = st.admitBy || acc.admitBy || 'owner'
1142
+ const admit = acc.owner && acc.controlled
1143
+ ? `<label class="ps-setting"><span><b>Who can let people in</b><small>When someone opens an invite link, who approves them.</small></span>
1144
+ <select class="input" data-admit-by aria-label="Who can let people into this session">${[['owner', 'Only the owner'], ['editors', 'Anyone who can edit'], ['members', 'Anyone in the session']].map(([v, l]) => `<option value="${v}" ${admitBy === v ? 'selected' : ''}>${l}</option>`).join('')}</select></label>`
1145
+ : !acc.controlled ? '<p class="ps-note">Anyone with the invite link can join this session.</p>' : ''
1146
+ return `<div class="ps-head"><span>${names.length} ${names.length === 1 ? 'person' : 'people'}</span><button type="button" class="btn sm primary" data-ss-invite>${I.plus}Invite people</button></div>
1147
+ <div class="ps-list">${rows}</div>
1148
+ ${admit}
1149
+ ${acc.owner ? '<div class="pm-foot"><button type="button" class="btn sm ghost danger" data-end-session>End session for everyone</button></div>' : ''}`
1150
+ }
1151
+
1011
1152
  /** With workspaces on, the agents this session's workspace invites (and the ones not invited), for its People. */
1012
1153
  async function loadSessionAgents () {
1013
1154
  const id = current
@@ -1232,26 +1373,278 @@ function renderPeopleMenu () {
1232
1373
  * they are changing that aren't in everyone's folder yet. A dashed line divides people; each one's
1233
1374
  * files stay folded until their boxes are clicked, and a click on a file shows its change in place.
1234
1375
  */
1376
+ // The left panel: the workspace's sessions, its shared files, the agents at work and the people here
1377
+ // (in place of the boxes). Sessions are the ones open on this computer; a click switches to one.
1378
+ const sideFiles = { id: null, list: null, loading: false }
1379
+ function loadSideFiles (wsId) {
1380
+ if (!wsId || sideFiles.loading || sideFiles.id === wsId) return
1381
+ sideFiles.loading = true
1382
+ api('GET', `/api/workspaces/${encodeURIComponent(wsId)}/files`)
1383
+ .then((r) => { sideFiles.list = r.files || [] })
1384
+ .catch(() => { sideFiles.list = [] })
1385
+ .finally(() => { sideFiles.id = wsId; sideFiles.loading = false; renderBoxesSide() })
1386
+ }
1387
+
1388
+ // Above the chat, in the main area: a card for each person whose AI is working, with what it's on
1389
+ // and a stitching needle; everyone else folds into one card of avatars. A card opens that AI's chat.
1390
+ // The session's header, over the main area: its name, repo and branch, who is working, the
1391
+ // Chat / Tasks / Code / Calls tabs and who is in it.
1392
+ function renderSessHead () {
1393
+ const el = $('#sess-head')
1394
+ const s = current && sum()
1395
+ if (!el || !s) return
1396
+ const st = s.status
1397
+ const w = ws(current)
1398
+ // The workspace's pages (Home, Files, People, Connections) are the workspace's, not this session's: no session bar (dm06).
1399
+ el.closest('.sess-bar')?.classList.toggle('off', PAGES.includes(w.mode) && !!s.workspace)
1400
+ const working = [st.me, ...st.peers].filter((p) => p && p.agent && p.agent.status === 'working').length
1401
+ const repo = (st.quilt && (st.quilt.slug || st.quilt.name)) || basename(s.dir)
1402
+ // A folder without git has no branch (the session calls it ∅): then the chip is just the repo.
1403
+ const raw = (inSeam(st) && seamChip(st)?.label) || st.branch || ''
1404
+ const branch = /^[\w./@+-]+$/.test(raw) ? raw : ''
1405
+ // Home, Files and People are pages over the session: its tab stays lit (the one you came from).
1406
+ const shown = PAGES.includes(w.mode) ? w.pageBack : w.mode
1407
+ const on = shown === 'tasks' ? 'tasks' : shown === 'files' ? 'code' : shown === 'preview' ? 'preview' : shown === 'calls' ? 'calls' : 'chat'
1408
+ const tab = (k, label) => `<button type="button" class="sh-tab${on === k ? ' on' : ''}" data-sh-tab="${k}">${label}</button>`
1409
+ const nBranches = inSeam(st) ? Object.keys(st.squares || {}).length : 0
1410
+ // The session's name is in the bar above (renderWbar): here, its repo and branch.
1411
+ const sc = `<button type="button" class="sh-repo" data-sh-sc title="Source control: open Version control">${I.branch}${esc(repo)}${branch ? `<i>·</i>${esc(branch)}` : ''}${nBranches > 1 ? `<i>·</i>${nBranches} branches` : ''}</button>`
1412
+ const html = `${sc}
1413
+ ${working ? `<span class="sh-live"><span class="pulse"></span>${working} working</span>` : ''}
1414
+ <span class="sh-sp"></span>
1415
+ <div class="sh-tabs" role="tablist">${tab('chat', 'Chat')}${tab('tasks', 'Tasks')}${tab('code', 'Code')}${tab('preview', 'Preview')}${tab('calls', 'Calls')}</div>
1416
+ <span class="sh-faces" title="${esc([st.me, ...st.peers].map((p) => p.name).join(', '))}">${[st.me, ...st.peers].slice(0, 4).map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, personInfo(p.name).color || p.color)}</span>`).join('')}</span>`
1417
+ if (el.dataset.html === html) return
1418
+ el.innerHTML = html
1419
+ el.dataset.html = html
1420
+ }
1421
+
1422
+ const stripAsked = new Set()
1423
+ function renderWorkStrip () {
1424
+ const el = $('#work-strip')
1425
+ const s = current && sum()
1426
+ if (!el || !s) return
1427
+ const st = s.status
1428
+ const everyone = [{ ...st.me, isMe: true, online: st.connected }, ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true }))]
1429
+ const live = (p) => p.agent && p.agent.status === 'working'
1430
+ const working = everyone.filter(live)
1431
+ const quiet = everyone.filter((p) => !live(p))
1432
+ const what = (p) => p.focus || (p.editing && p.editing[0] ? `Editing ${basename(p.editing[0].path)}` : '') || 'Working'
1433
+ // A person's lanes are their AI's conversations: one needle each, sewing while that one is active.
1434
+ const feeds = state.feeds.get(current) || new Map()
1435
+ const who = owners(s)
1436
+ // Feeds load when someone's AI tab opens; the cards need everyone's, so ask for the missing ones.
1437
+ for (const p of everyone) {
1438
+ const key = `${current}|${p.name}`
1439
+ if (feeds.has(p.name) || stripAsked.has(key)) continue
1440
+ stripAsked.add(key) // once: a feed that can't load isn't asked for again on every redraw
1441
+ loadFeed(p.name).then(() => renderWorkStrip())
1442
+ }
1443
+ const lanesOf = (name) => {
1444
+ const entries = []
1445
+ for (const [k, list] of feeds) if (k === name || who.get(k) === name) entries.push(...(list || []))
1446
+ return conversations(entries)
1447
+ }
1448
+ const ACTIVE_MS = 3 * 60 * 1000
1449
+ const needles = (p) => {
1450
+ const lanes = lanesOf(p.name).slice(0, 8)
1451
+ const list = lanes.length ? lanes : [{ label: 'AI', ts: Date.now() }]
1452
+ const one = (c, i) => {
1453
+ const sewing = Date.now() - (c.ts || 0) < ACTIVE_MS || (i === 0 && live(p))
1454
+ return `<span class="ws-needle${sewing ? '' : ' still'}" title="${esc(c.label || 'Conversation')}${sewing ? ' · working' : ''}">${'<i></i>'.repeat(8)}<i class="v"></i></span>`
1455
+ }
1456
+ return `<span class="wk-lanes">${list.map(one).join('')}</span>`
1457
+ }
1458
+ const card = (p) => {
1459
+ const info = personInfo(p.name)
1460
+ const c = info.color || p.color || colorFor(p.name)
1461
+ const tool = (p.agent && p.agent.tool) || toolsOf(p)[0] || 'AI'
1462
+ return `<button type="button" class="wk-card live" data-person="${esc(p.name)}" style="--pc:${esc(c)}" title="Open ${p.isMe ? 'your' : `${esc(p.name)}'s`} AI chat">
1463
+ <span class="wk-head">${avatar(p.name, c, p.online)}<b>${esc(p.isMe ? 'You' : p.name)}</b><small>${esc(tool)}</small></span>
1464
+ <span class="wk-what">${esc(what(p))}</span>${needles(p)}</button>`
1465
+ }
1466
+ const quietCard = quiet.length ? `<div class="wk-card quiet"><span class="wk-head"><b>${quiet.length} quiet</b></span>
1467
+ <span class="wk-avs">${quiet.slice(0, 6).map((p) => avatar(p.name, personInfo(p.name).color || p.color, p.online)).join('')}${quiet.length > 6 ? `<span class="wk-more">+${quiet.length - 6}</span>` : ''}</span>
1468
+ <span class="wk-names">${esc(quiet.slice(0, 3).map((p) => (p.isMe ? 'You' : p.name)).join(', '))}${quiet.length > 3 ? ` and ${quiet.length - 3} more` : ''}</span></div>` : ''
1469
+ const html = working.map(card).join('') + quietCard
1470
+ if (el.dataset.html === html) return
1471
+ el.innerHTML = html
1472
+ el.dataset.html = html
1473
+ }
1474
+
1475
+ // The skinny rail on the far left: one tile per workspace (project), the one this session is in lit.
1476
+ // A tile opens that workspace's page; + goes Home, where a new one is made.
1477
+ let railLoading = false
1478
+ document.addEventListener('click', (e) => {
1479
+ const t = e.target.closest('[data-rail-ws]')
1480
+ if (t) go(t.dataset.railWs ? `ws:${t.dataset.railWs}` : 'home')
1481
+ if (e.target.closest('[data-sh-sc]')) { openSessionSettings('vc'); return }
1482
+ const h = e.target.closest('[data-sh-tab]')
1483
+ if (h) {
1484
+ const k = h.dataset.shTab
1485
+ const m = ws(current)
1486
+ if (k === 'chat') { openLoom(); setTimeout(renderWbar, 0) }
1487
+ if (k === 'tasks' && m.mode !== 'tasks') { m.mode = 'tasks'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
1488
+ if (k === 'code') { m.mode = 'files'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
1489
+ if (k === 'preview') { m.mode = 'preview'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
1490
+ if (k === 'calls') { m.mode = 'calls'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
1491
+ setTimeout(renderSessHead, 0)
1492
+ return
1493
+ }
1494
+ const w = e.target.closest('.work-strip [data-person]')
1495
+ if (w) openPerson(w.dataset.person)
1496
+ })
1497
+ function renderWorkspaceRail () {
1498
+ const el = $('#rail-tiles')
1499
+ const s = current && sum()
1500
+ if (!el || !s) return
1501
+ if (state.workspaces == null && !railLoading) {
1502
+ railLoading = true
1503
+ api('GET', '/api/workspaces').then((r) => { state.workspaces = r.workspaces || [] }).catch(() => { state.workspaces = [] }).finally(() => { railLoading = false; renderWorkspaceRail() })
1504
+ }
1505
+ const tiles = (state.workspaces || []).map((w) => {
1506
+ const on = w.id === s.workspace
1507
+ const c = COLORS[w.color] || COLORS.lilac
1508
+ return `<button type="button" class="rail-ws${on ? ' on' : ''}" data-rail-ws="${esc(w.id)}" title="${esc(w.name)}" aria-label="${esc(w.name)}"${on ? ' aria-current="true"' : ''} style="--wc:${esc(c)}">${esc([...String(w.name || '?')][0].toUpperCase())}</button>`
1509
+ }).join('')
1510
+ const html = `${tiles}<button type="button" class="rail-ws add" data-rail-ws="" title="New workspace" aria-label="New workspace">${I.plus}</button>`
1511
+ if (el.dataset.html === html) return
1512
+ el.innerHTML = html
1513
+ el.dataset.html = html
1514
+ }
1515
+
1516
+ // The bar across the top (the dm06 layout): the workspace, its home, the session menu, Connections, Files,
1517
+ // notifications, who is here and the session's "…" menu. It does what the second sidebar did.
1518
+ const working = (st) => (st.peers || []).filter((p) => p.agent && p.agent.status === 'working').length + (st.me?.agent?.status === 'working' ? 1 : 0)
1519
+ const workingFaces = (st) => [st.me, ...(st.peers || [])].filter((p) => p && p.agent && p.agent.status === 'working')
1520
+ function facesHtml (list, max = 3) {
1521
+ return `<span class="wb-faces">${list.slice(0, max).map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, personInfo(p.name).color || p.color)}</span>`).join('')}</span>`
1522
+ }
1523
+
1524
+ function bindWbar () {
1525
+ const bar = $('#wbar')
1526
+ if (!bar) return
1527
+ const tools = $('#wb-tools')
1528
+ tools.insertAdjacentHTML('beforeend', `<button type="button" class="wb-btn" id="wb-files" title="The workspace's shared files">${I.folder}<span>Files</span></button>`)
1529
+ const conn = $('#connections-btn')
1530
+ if (conn) { conn.className = 'wb-btn conn-btn'; tools.prepend(conn) }
1531
+ // Home is the workspace's home inside this window (dm06), a toggle like Files.
1532
+ $('#wb-home').onclick = () => { if (!sum()?.workspace) go('home'); else togglePage('home') }
1533
+ // Files is a page of this session's window (dm06): a second click goes back to where you were.
1534
+ $('#wb-files').onclick = () => {
1535
+ if (!sum()?.workspace) { toast('Files are shared in a workspace. Move this session into one first.'); return }
1536
+ togglePage('wsfiles')
1537
+ }
1538
+ const btn = $('#wb-sessbtn')
1539
+ const menu = $('#wb-sessmenu')
1540
+ const set = (open) => { menu.hidden = !open; btn.setAttribute('aria-expanded', String(open)); if (open) renderWbar() }
1541
+ btn.onclick = () => set(menu.hidden)
1542
+ menu.addEventListener('click', (e) => {
1543
+ if (e.target.closest('[data-wb-new]')) { set(false); go('home'); return }
1544
+ if (e.target.closest('[data-wb-settings]')) { set(false); openSessionSettings('general'); return }
1545
+ if (e.target.closest('[data-wb-invite]')) { set(false); openInvite(current); return }
1546
+ const r = e.target.closest('[data-wb-go]')
1547
+ if (r) { set(false); if (r.dataset.wbGo !== current) go(r.dataset.wbGo) }
1548
+ })
1549
+ $('#wb-sess').addEventListener('keydown', (e) => { if (e.key === 'Escape') { set(false); btn.focus() } })
1550
+ document.addEventListener('mousedown', (e) => { if (!e.target.closest('#wb-sess')) set(false) }, { signal: mounted.signal })
1551
+ }
1552
+
1553
+ function renderWbar () {
1554
+ const s = current && sum()
1555
+ if (!s || !$('#wbar')) return
1556
+ const st = s.status
1557
+ const wsInfo = (state.workspaces || []).find((w) => w.id === s.workspace)
1558
+ const kind = wsInfo ? (wsInfo.space?.kind === 'org' ? (wsInfo.space.name || 'Team') : 'Personal') : 'Not in a workspace'
1559
+ const nameHtml = `<b>${esc(wsInfo?.name || st.sessionName || basename(s.dir))}</b><small>${esc(kind)}</small>`
1560
+ const nm = $('#wb-name')
1561
+ if (nm.dataset.html !== nameHtml) { nm.innerHTML = nameHtml; nm.dataset.html = nameHtml }
1562
+ const n = working(st)
1563
+ const btnHtml = `${I.grid}<b>${esc(st.sessionName || basename(s.dir))}</b>${n ? `<i class="wb-live"><span class="pulse"></span>${n}</i>` : ''}${facesHtml(workingFaces(st))}${I.chevDown}`
1564
+ const btn = $('#wb-sessbtn')
1565
+ if (btn.dataset.html !== btnHtml) { btn.innerHTML = btnHtml; btn.dataset.html = btnHtml }
1566
+ const menu = $('#wb-sessmenu')
1567
+ if (!menu.hidden) {
1568
+ const rows = [...state.sessions.values()].map((x) => {
1569
+ const k = working(x.status)
1570
+ const unread = x.status.unread && x.id !== current ? `<span class="badge">${x.status.unread}</span>` : ''
1571
+ return `<button type="button" class="wb-srow${x.id === current ? ' on' : ''}" role="menuitem" data-wb-go="${esc(x.id)}" title="${esc(x.dir)}">${I.grid}<span class="wb-sname"><b>${esc(x.status.sessionName || basename(x.dir))}</b><small>${k ? `${k} working` : x.status.connected ? 'Quiet' : 'Not connected'}</small></span>${facesHtml(workingFaces(x.status))}${unread}</button>`
1572
+ }).join('')
1573
+ const html = `<div class="wb-mhead">Sessions<button type="button" class="wb-mplus" data-wb-new title="New session" aria-label="New session">${I.plus}</button></div>${rows || '<p class="wb-mempty">No sessions open.</p>'}
1574
+ <div class="pop-sep"></div><button type="button" class="pop-item" role="menuitem" data-wb-settings>${I.gear}Session settings…</button><button type="button" class="pop-item" role="menuitem" data-wb-invite>${I.users}Invite people…</button>`
1575
+ if (menu.dataset.html !== html) { menu.innerHTML = html; menu.dataset.html = html }
1576
+ }
1577
+ // Files is lit while its page is open.
1578
+ $('#wb-files')?.classList.toggle('on', ws(current).mode === 'wsfiles')
1579
+ $('#wb-home')?.classList.toggle('on', ws(current).mode === 'home')
1580
+ $('#connections-btn')?.classList.toggle('on', ws(current).mode === 'connections')
1581
+ }
1582
+
1235
1583
  function renderBoxesSide () {
1236
1584
  const el = $('#boxes-side')
1237
1585
  const s = current && sum()
1238
1586
  if (!el || !s) return
1587
+ renderWorkStrip()
1588
+ renderSessHead()
1589
+ renderWorkspaceRail()
1590
+ renderWbar()
1239
1591
  const st = s.status
1240
- const { selfRow, myAiRow, otherRows, awayRows } = peopleRows(st, { fold: true })
1241
- // In Seam there are no boxes (every edit is live in its square): the pane shows the squares and who is on each.
1242
- const seam = inSeam(st)
1243
- const title = el.closest('.ws-boxes')?.querySelector('.pane-title')
1244
- if (title) title.textContent = seam ? 'Squares' : 'Boxes'
1245
- el.closest('.ws-boxes')?.setAttribute('aria-label', seam ? 'Squares: who is on which, and what is not committed' : 'Boxes: who is working on what')
1246
- const n = seam ? 0 : boxView.data.boxes.length
1592
+ const wsInfo = (state.workspaces || []).find((w) => w.id === s.workspace)
1593
+ const pane = el.closest('.ws-boxes')
1594
+ const title = pane?.querySelector('.pane-title')
1595
+ if (title) title.textContent = ''
1596
+ pane?.setAttribute('aria-label', 'Sessions and files')
1247
1597
  const count = $('#box-count')
1248
- if (count) { count.textContent = n ? String(n) : ''; count.title = n ? `${n} file${n === 1 ? '' : 's'} boxed: changed, not in everyone's folder yet` : '' }
1249
- const html = `${seam ? squaresSideHtml(st) : ''}<div class="pm-list bs-list">
1250
- ${selfRow}${myAiRow}
1251
- ${otherRows}
1252
- ${awayRows.length ? `<div class="pm-sep"></div><div class="bs-head">Away</div>${awayRows.join('')}` : ''}
1253
- </div>
1254
- <p class="bs-hint">${seam ? SEAM_SIDE_HINT : boxView.data.on ? 'A box is a file someone is changing that isn\'t in everyone\'s folder yet. Click someone\'s boxes to see the files, and a file to see its change.' : 'What everyone is working on. Their unfinished files show here as boxes.'}</p>`
1598
+ if (count) { count.textContent = ''; count.title = '' }
1599
+ if (s.workspace) loadSideFiles(s.workspace)
1600
+ const working = (x) => (x.peers || []).filter((p) => p.agent && p.agent.status === 'working').length + (x.me?.agent?.status === 'working' ? 1 : 0)
1601
+ const sessions = [...state.sessions.values()].map((x) => {
1602
+ const on = x.id === current
1603
+ const n = working(x.status)
1604
+ const unread = x.status.unread && !on ? `<span class="badge">${x.status.unread}</span>` : ''
1605
+ const meta = n ? `<span class="sp-live"><span class="pulse"></span>${n}</span>` : unread
1606
+ return `<button type="button" class="sp-row${on ? ' on' : ''}" data-side-go="${esc(x.id)}" title="${esc(x.dir)}">${I.grid}<span class="sp-name">${esc(x.status.sessionName || basename(x.dir))}</span>${meta}</button>`
1607
+ }).join('')
1608
+ const files = sideFiles.list
1609
+ const filesHtml = !s.workspace ? '<p class="sp-empty">Files are shared in a workspace. This session isn\'t in one.</p>'
1610
+ : files == null ? '<p class="sp-empty">Loading…</p>'
1611
+ : files.length ? files.slice(0, 12).map((f) => `<div class="sp-row file" title="${esc(f.path)}">${f.kind === 'folder' ? I.folder : I.file || I.folder}<span class="sp-name">${esc(f.name || basename(f.path))}</span><span class="hint">${f.kind === 'folder' ? '' : esc(bytes(f.size || 0))}</span></div>`).join('')
1612
+ : '<p class="sp-empty">No shared files yet.</p>'
1613
+ const everyone = [{ ...st.me, isMe: true, online: st.connected }, ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true }))]
1614
+ const what = (p) => p.focus || (p.editing && p.editing[0] ? `Editing ${p.editing[0].path}` : '') || (p.agent && p.agent.status === 'working' ? 'Working' : '')
1615
+ const personRow = (p) => {
1616
+ const info = personInfo(p.name)
1617
+ const live = p.agent && p.agent.status === 'working'
1618
+ return `<div class="sp-person"><button type="button" class="sp-row" data-person="${esc(p.name)}" title="Open ${p.isMe ? 'your' : `${esc(p.name)}'s`} AI chat">${avatar(p.name, info.color || p.color, p.online)}<span class="sp-main"><span class="sp-name">${esc(p.isMe ? `${p.name} (you)` : p.name)}</span>${what(p) ? `<span class="sp-sub${live ? ' live' : ''}">${live ? '<span class="pulse"></span>' : ''}${esc(what(p))}</span>` : ''}</span></button>${p.isMe ? '' : `<button class="btn sm ghost icon pm-dm" data-dm="${esc(p.name)}" title="Message ${esc(p.name)}" aria-label="Message ${esc(p.name)}">${I.chat}</button>`}</div>`
1619
+ }
1620
+ const agents = everyone.filter((p) => p.kind === 'agent')
1621
+ const people = everyone.filter((p) => p.kind !== 'agent')
1622
+ const section = (name, body, n) => `<div class="sp-head">${name}${n != null ? `<span class="sp-n">${n}</span>` : ''}</div>${body}`
1623
+ // The workspace's name and who is in it at the top; sessions and files; then People and Agents as one line
1624
+ // each (who's here and what they're on is in the cards over the chat).
1625
+ const kind = wsInfo?.space?.kind === 'org' ? (wsInfo.space.name || 'Org') : wsInfo ? 'Personal' : 'This computer'
1626
+ const plus = (attr, label) => `<button type="button" class="sp-plus" ${attr} title="${label}" aria-label="${label}">${I.plus}</button>`
1627
+ const head = (name, extra = '') => `<div class="sp-head">${name}${extra}</div>`
1628
+ const topHtml = `<div class="sp-top"><div><h2>${esc(wsInfo?.name || st.sessionName || basename(s.dir))}</h2><small>${esc(kind)} · ${people.length} ${people.length === 1 ? 'person' : 'people'} · ${agents.length} ${agents.length === 1 ? 'agent' : 'agents'}</small></div>${s.workspace ? `<button type="button" class="sp-plus" data-side-ws title="Workspace page" aria-label="Workspace page">${I.more || '⋯'}</button>` : ''}</div>`
1629
+ const html =
1630
+ head('Sessions', plus('data-side-new', 'New session')) + (sessions || '<p class="sp-empty">No sessions open.</p>') +
1631
+ head('Files', s.workspace ? plus('data-side-files', 'All files') : '') + filesHtml +
1632
+ `<div class="sp-sep"></div>
1633
+ <button type="button" class="sp-row" data-side-people="agents">${I.bot}<span class="sp-name">Agents</span><span class="sp-n">${agents.length}</span></button>
1634
+ <button type="button" class="sp-row" data-side-people="people">${I.users}<span class="sp-name">People</span><span class="sp-n">${people.length}</span></button>`
1635
+ // Folded, the same pane is a column of icons: each session, then files, agents and people.
1636
+ const mini = $('#side-mini')
1637
+ if (mini) {
1638
+ const sess = [...state.sessions.values()].map((x) => {
1639
+ const name = x.status.sessionName || basename(x.dir)
1640
+ return `<button type="button" class="mini-btn${x.id === current ? ' on' : ''}" data-side-go="${esc(x.id)}" title="${esc(name)}" aria-label="${esc(name)}">${I.grid}${working(x.status) ? '<span class="mini-live"></span>' : ''}</button>`
1641
+ }).join('')
1642
+ const miniHtml = sess + '<span class="mini-sep"></span>' +
1643
+ (s.workspace ? `<button type="button" class="mini-btn" data-side-files title="Files" aria-label="Files">${I.folder}</button>` : '') +
1644
+ `<button type="button" class="mini-btn" data-side-people="agents" title="Agents" aria-label="Agents">${I.bot}</button>` +
1645
+ `<button type="button" class="mini-btn" data-side-people="people" title="People" aria-label="People">${I.users}</button>`
1646
+ if (mini.dataset.html !== miniHtml) { mini.innerHTML = miniHtml; mini.dataset.html = miniHtml }
1647
+ }
1255
1648
  if (el.dataset.html === html) return
1256
1649
  const top = el.scrollTop
1257
1650
  el.innerHTML = html
@@ -1259,6 +1652,21 @@ function renderBoxesSide () {
1259
1652
  el.scrollTop = top
1260
1653
  }
1261
1654
 
1655
+ /** Session settings → General: the session's name, its workspace, inviting, one set of AI rules, and leaving it. */
1656
+ function generalSettingsHtml (st) {
1657
+ const owner = !!st.access?.owner
1658
+ const wsName = (state.workspaces || []).find((w) => w.id === sum().workspace)?.name || ''
1659
+ const canMove = owner && state.workspacesOn && (state.workspaces || []).some((w) => w.access === 'edit')
1660
+ const row = (title, sub, action) => `<div class="ss-row"><span><b>${title}</b><small>${sub}</small></span>${action}</div>`
1661
+ return `<div class="pm-section ss-general">
1662
+ ${row('Name', esc(st.sessionName || basename(sum().dir)), owner ? '<button type="button" class="btn sm" data-ss-rename>Rename…</button>' : '')}
1663
+ ${row('Workspace', esc(wsName || 'Not in a workspace'), canMove ? '<button type="button" class="btn sm" data-ss-move>Move…</button>' : '')}
1664
+ ${row('Invite people', 'Send a link to someone, or to an agent', '<button type="button" class="btn sm" data-ss-invite-people>Invite…</button>')}
1665
+ ${row('One set of AI rules', 'Gather everyone\'s AI rules for this session into one', '<button type="button" class="btn sm" data-ss-rules>Open…</button>')}
1666
+ ${row('Leave this session', 'Quilt stops syncing this folder; your files stay where they are', '<button type="button" class="btn sm danger" data-ss-leave>Leave</button>')}
1667
+ </div>`
1668
+ }
1669
+
1262
1670
  /** Your AI chat's sharing in this session: two plain switches. */
1263
1671
  function sharingHtml (st) {
1264
1672
  const a = st.me.agent || {}
@@ -1319,19 +1727,106 @@ async function openGatherRules () {
1319
1727
 
1320
1728
  // Session settings: one window, a section at a time, picked from the list on its left.
1321
1729
  const SS_TABS = [
1730
+ // The session's own actions (what the bar's "…" menu held): its name, workspace, invite, AI rules, leaving.
1731
+ { id: 'general', label: 'General', icon: 'gear' },
1322
1732
  { id: 'chat', label: 'Your AI chat', icon: 'chat' },
1323
1733
  { id: 'vc', label: 'Version control', icon: 'branch' },
1324
1734
  { id: 'agents', label: 'Agents', icon: 'bot' },
1325
1735
  { id: 'people', label: 'People', icon: 'users' },
1326
1736
  // Secrets (secrets.js): only once the accounts API has them switched on.
1327
- { id: 'secrets', label: 'Secrets', icon: 'lock', on: () => state.secretsOn }
1737
+ { id: 'secrets', label: 'Secrets', icon: 'lock', on: () => state.secretsOn },
1738
+ // Apps agents use (connections.js): only once the accounts API has Composio's key.
1739
+ { id: 'connections', label: 'Connections', icon: 'plug' }
1328
1740
  ]
1329
1741
  const ssTabs = () => SS_TABS.filter((x) => !x.on || x.on())
1330
1742
  // The Secrets tab's card while it is drawn: kept across redraws of the window, so a typed name isn't lost.
1331
1743
  let ssSecrets = null
1332
- let ssTab = 'chat'
1744
+ let ssConnections = null // the Connections tab's card while it is drawn
1745
+ let ssTab = 'general'
1746
+
1747
+ // GitHub: every session's history is in Seam, and Seam connects to GitHub (through the Seam app on GitHub),
1748
+ // never Quilt. The card reads Seam's GitHub through the session (GET/POST /api/sessions/<id>/github).
1749
+ const ssGh = { id: null, data: undefined, err: '', pick: '', busy: false, loading: false }
1750
+ async function loadGithub (body) {
1751
+ const id = current
1752
+ ssGh.id = id
1753
+ ssGh.busy = !!body
1754
+ ssGh.loading = true
1755
+ if (!body) ssGh.data = undefined
1756
+ ssGh.err = ''
1757
+ renderSessionSettings({ force: true })
1758
+ try { ssGh.data = await api(body ? 'POST' : 'GET', `/api/sessions/${id}/github`, body) } catch (err) { ssGh.err = err.message; if (ssGh.data === undefined) ssGh.data = null }
1759
+ ssGh.busy = false
1760
+ ssGh.loading = false
1761
+ if (id === current) renderSessionSettings({ force: true })
1762
+ }
1763
+ function githubCardHtml () {
1764
+ const d = ssGh.id === current ? ssGh.data : undefined
1765
+ const card = (pill, body) => `<div class="pm-section gh-section"><div class="pm-title">GitHub</div><div class="pm-card git-card gh-card">
1766
+ <div class="git-head"><h4>${I.github}GitHub</h4>${pill ? `<span class="pill">${pill}</span>` : ''}</div>${body}
1767
+ ${ssGh.err ? `<p class="git-line warn">${esc(ssGh.err)}</p>` : ''}</div></div>`
1768
+ if (d === undefined) return card('', `<p class="hint">${loadingNote('Asking Seam…')}</p>`)
1769
+ if (!d) return card('', '<p class="git-line">Seam couldn\'t be reached.</p><button type="button" class="btn gh-connect" data-gh-refresh>Try again</button>')
1770
+ if (!d.quilt) return card('Not connected', '<p class="git-line">GitHub connects through Seam, where this session\'s history is kept. This session\'s code isn\'t in Seam yet, so there is nothing to connect.</p>')
1771
+ const g = d.github || {}
1772
+ if (!g.configured) return card('Not connected', '<p class="git-line">GitHub isn\'t set up on this Seam server.</p>')
1773
+ const on = d.export && d.export.enabled && /github\.com\//.test(d.export.target)
1774
+ const repoOf = (t) => String(t).replace(/^https:\/\/github\.com\//, '').replace(/\.git$/, '')
1775
+ if (on) {
1776
+ const repo = repoOf(d.export.target)
1777
+ return card('Connected', `<p class="git-line ok">Seam sends main to <b>${esc(repo)}</b> after every merge.${d.export.status && d.export.status.state ? ` Last push: ${esc(d.export.status.state)}.` : ''}</p>
1778
+ <div class="gh-row"><a class="btn" href="https://github.com/${esc(repo)}" target="_blank" rel="noopener">Open on GitHub</a><button type="button" class="btn ghost danger" data-gh-disconnect ${ssGh.busy ? 'disabled' : ''}>Disconnect</button></div>`)
1779
+ }
1780
+ const install = g.app && g.app.install_url
1781
+ const insts = g.installations || []
1782
+ if (!insts.length) {
1783
+ return card('Not connected', `<p class="git-line">Seam reaches GitHub through the Seam app. Install it on your GitHub account or organisation and choose the repositories it may use. If you already have a repository for this code, choose that one.</p>
1784
+ ${install ? `<a class="btn primary gh-connect" href="${esc(install)}" target="_blank" rel="noopener">${I.github}Install the Seam app on GitHub</a>` : ''}
1785
+ <button type="button" class="btn gh-connect" data-gh-refresh>I've installed it</button>`)
1786
+ }
1787
+ const opts = insts.map((i) => `<optgroup label="${esc(i.login)}">${(i.repos || []).map((r) => { const v = `${i.id}|${r.full_name}`; return `<option value="${esc(v)}" ${ssGh.pick === v ? 'selected' : ''}>${esc(r.full_name)}</option>` }).join('')}</optgroup>`).join('')
1788
+ const any = insts.some((i) => (i.repos || []).length)
1789
+ return card('Not connected', `<p class="git-line">Pick the repository for this session. Seam keeps its main up to date: main goes there after every merge.</p>
1790
+ ${any ? `<label class="gh-field"><span>Repository</span><select class="input" data-gh-pick><option value="">Choose a repository</option>${opts}</select></label>
1791
+ <button type="button" class="btn primary gh-connect" data-gh-connect ${ssGh.pick && !ssGh.busy ? '' : 'disabled'}>${I.github}${ssGh.busy ? 'Connecting…' : 'Connect'}</button>` : '<p class="hint">The Seam app doesn\'t reach any repository yet.</p>'}
1792
+ ${install ? `<a class="gh-more" href="${esc(install)}" target="_blank" rel="noopener">Choose other repositories on GitHub</a>` : ''}`)
1793
+ }
1794
+ function bindGithubCard (box) {
1795
+ const card = box.querySelector('.gh-card')
1796
+ if (!card) return
1797
+ card.addEventListener('change', (e) => { if (e.target.matches('[data-gh-pick]')) { ssGh.pick = e.target.value; renderSessionSettings({ force: true }) } })
1798
+ card.addEventListener('click', async (e) => {
1799
+ if (e.target.closest('[data-gh-refresh]')) { loadGithub(); return }
1800
+ if (e.target.closest('[data-gh-connect]') && ssGh.pick) {
1801
+ const [installation, repo] = ssGh.pick.split('|')
1802
+ loadGithub({ repo, installation })
1803
+ return
1804
+ }
1805
+ if (e.target.closest('[data-gh-disconnect]') && await ask({ title: 'Disconnect GitHub?', message: 'Seam stops sending main to that repository. What is there stays.', ok: 'Disconnect', danger: true })) loadGithub({ disconnect: true })
1806
+ })
1807
+ }
1808
+
1809
+ // People (who is here, and Invite) and source control (GitHub, changes) are shown in Session settings: their
1810
+ // live panels, drawn by the same code as before, move into its People and Version control tabs while shown.
1811
+ const ssMoved = []
1812
+ function ssPark () {
1813
+ while (ssMoved.length) {
1814
+ const [node, home] = ssMoved.pop()
1815
+ node.hidden = true
1816
+ node.classList.remove('in-ss')
1817
+ home.appendChild(node)
1818
+ }
1819
+ }
1820
+ function ssMount (where, node) {
1821
+ if (!where || !node) return
1822
+ ssMoved.push([node, node.parentElement])
1823
+ node.classList.add('in-ss')
1824
+ node.hidden = false
1825
+ where.appendChild(node)
1826
+ }
1333
1827
 
1334
1828
  function openSessionSettings (tab) {
1829
+ ssPark()
1335
1830
  document.querySelector('.session-settings-back')?.remove()
1336
1831
  $('#people-menu').hidden = true
1337
1832
  $('#people-btn').setAttribute('aria-expanded', 'false')
@@ -1350,7 +1845,7 @@ function openSessionSettings (tab) {
1350
1845
  </div>
1351
1846
  </div>`
1352
1847
  document.body.appendChild(back)
1353
- const close = () => back.remove()
1848
+ const close = () => { ssPark(); back.remove() }
1354
1849
  back.addEventListener('mousedown', (e) => { if (e.target === back) close() })
1355
1850
  back.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); close() } })
1356
1851
  back.querySelector('[data-close-ss]').onclick = close
@@ -1399,6 +1894,7 @@ function renderSessionSettings ({ force = false } = {}) {
1399
1894
  }
1400
1895
  box.dataset.tab = ssTab
1401
1896
  back.querySelector('.ss-name').textContent = (ssTabs().find((t) => t.id === ssTab) || ssTabs()[0]).label
1897
+ ssPark()
1402
1898
  if (ssTab === 'secrets') {
1403
1899
  const room = st.room
1404
1900
  const mounted = box.querySelector(`[data-secrets-room="${CSS.escape(String(room || ''))}"]`)
@@ -1409,16 +1905,37 @@ function renderSessionSettings ({ force = false } = {}) {
1409
1905
  return
1410
1906
  }
1411
1907
  if (ssSecrets) { ssSecrets.destroy(); ssSecrets = null }
1908
+ if (ssTab === 'connections') {
1909
+ const room = st.room
1910
+ if (box.querySelector(`[data-connections-room="${CSS.escape(String(room || ''))}"]`) && !force) return
1911
+ ssConnections?.destroy()
1912
+ box.innerHTML = `<div class="ss-connections" data-connections-room="${esc(room || '')}"></div>`
1913
+ ssConnections = mountConnections(box.firstElementChild, { type: 'session', id: room })
1914
+ return
1915
+ }
1916
+ if (ssConnections) { ssConnections.destroy(); ssConnections = null }
1412
1917
  // Don't redraw under the owner while they change someone's access (unless fresh grants
1413
1918
  // arrived: then the form is redrawn from them, and keeps its focus).
1414
1919
  const active = box.contains(document.activeElement) && document.activeElement.closest('.pm-member') ? document.activeElement : null
1415
1920
  if (!force && active && box.querySelector('.pm-member.edit')) return
1416
1921
  const refocus = active && active.name ? [active.closest('.pm-member').dataset.key, active.name] : null
1417
1922
  // Source control is Seam's: where the history is (or, for the owner of a session not in Seam yet, the button that moves it there).
1418
- const vc = inSeam(st) ? seamSettingsHtml(st) : makeQuiltHtml(st)
1419
- box.innerHTML = ssTab === 'chat' ? sharingHtml(st)
1420
- : ssTab === 'vc' ? (vc || '<div class="pm-empty">Only the session owner sees where this session\'s history is.</div>')
1421
- : membersHtml(st, ssTab)
1923
+ box.innerHTML = ssTab === 'general' ? generalSettingsHtml(st)
1924
+ : ssTab === 'chat' ? sharingHtml(st)
1925
+ : ssTab === 'vc' ? githubCardHtml()
1926
+ : ssTab === 'people' ? peopleSettingsHtml(st) : membersHtml(st, ssTab)
1927
+ if (ssTab === 'vc') {
1928
+ bindGithubCard(box)
1929
+ if (!ssGh.loading && (ssGh.id !== current || ssGh.data === undefined)) loadGithub()
1930
+ }
1931
+ if (ssTab === 'people') box.querySelector('[data-ss-invite]').onclick = () => openInvite(current)
1932
+ if (ssTab === 'general') {
1933
+ box.querySelector('[data-ss-rename]')?.addEventListener('click', renameSession)
1934
+ box.querySelector('[data-ss-move]')?.addEventListener('click', moveToWorkspace)
1935
+ box.querySelector('[data-ss-invite-people]').onclick = () => openInvite(current)
1936
+ box.querySelector('[data-ss-rules]').onclick = () => openGatherRules()
1937
+ box.querySelector('[data-ss-leave]').onclick = () => $('#leave-btn').click()
1938
+ }
1422
1939
  if (refocus) [...box.querySelectorAll('.pm-member')].find((f) => f.dataset.key === refocus[0])?.elements?.[refocus[1]]?.focus()
1423
1940
  }
1424
1941
 
@@ -1459,10 +1976,19 @@ function bindMain () {
1459
1976
  }
1460
1977
  })
1461
1978
  $('#main').addEventListener('click', async (e) => {
1979
+ // A person's view: back to the loom, or their direct messages.
1980
+ if (e.target.closest('[data-pv-back]')) { openLoom(); return }
1981
+ const dai = e.target.closest('[data-dm-ai]')
1982
+ if (dai) { openPerson(dai.dataset.dmAi); return }
1983
+ if (e.target.closest('[data-dm-back]')) { const from = ws(current).dmFrom; if (from) openPerson(from); else openLoom(); return }
1984
+ const pdm = e.target.closest('[data-pv-dm]')
1985
+ if (pdm) { openDm(pdm.dataset.pvDm); return }
1462
1986
  const copy = e.target.closest('[data-copy-invite]')
1463
1987
  if (copy) {
1464
1988
  const view = copy.dataset.copyInvite === 'view'
1465
- try { await navigator.clipboard.writeText(view ? sum().viewInvite : sum().invite); toast(view ? 'View-only link copied' : 'Invite link copied') } catch { openInvite(current) }
1989
+ const link = view ? sum().viewInvite : sum().invite
1990
+ if (!link) return toast(NO_LINK_YET)
1991
+ try { await navigator.clipboard.writeText(link); toast(view ? 'View-only link copied' : 'Invite link copied') } catch { openInvite(current) }
1466
1992
  return
1467
1993
  }
1468
1994
  const b = e.target.closest('[data-person]')
@@ -1496,17 +2022,26 @@ function bindMain () {
1496
2022
 
1497
2023
  function openLoom () {
1498
2024
  const w = ws(current)
2025
+ const back = w.mode === 'ai' && !!w.aiSel && !w.dmWith
2026
+ if ((w.aiSel || w.dmWith) && state.to) { state.to = ''; renderRecipients() }
1499
2027
  w.aiSel = null
2028
+ w.dmWith = null
1500
2029
  w.mode = 'ai'
1501
2030
  saveWs(current)
1502
2031
  renderMainBar()
1503
2032
  renderMain()
2033
+ // Back from a person: the cards rise back into place.
2034
+ if (back) $('#main .loom')?.classList.add('rising')
1504
2035
  renderTreePane()
1505
2036
  renderTop()
1506
2037
  }
1507
2038
 
1508
2039
  function openPerson (name) {
1509
2040
  const w = ws(current)
2041
+ // Their view's composer writes to them (yours: to everyone).
2042
+ state.to = name === sum()?.status.me.name ? '' : name
2043
+ renderRecipients()
2044
+ w.dmWith = null
1510
2045
  if (!w.aiTabs.includes(name)) w.aiTabs.push(name)
1511
2046
  w.aiSel = name
1512
2047
  w.mode = 'ai'
@@ -1576,13 +2111,18 @@ function renderMainBar () {
1576
2111
  <button class="x" data-kind="file" data-close="${esc(path)}" aria-label="Close ${esc(basename(path))}">${I.x}</button></div>`).join('') +
1577
2112
  ((w.searchTabs || []).length && !w.fileTabs.length ? '<span class="ws-tab-sep"></span>' : '') +
1578
2113
  (w.searchTabs || []).map((q) => searchTabMarkup(q, w.mode === 'search' && w.searchSel === q)).join('')
2114
+ // In Code and search the row holds only their own tabs: people are reached from the loom (dm06).
2115
+ for (const t of el.querySelectorAll('[data-kind="loom"], [data-kind="ai"]')) t.remove()
2116
+ el.querySelector(':scope > .ws-tab-sep:first-child')?.remove()
1579
2117
  // On Everyone with nothing else open, the row would only name the view you are in: hide it until
1580
2118
  // there is a tab to switch to (or, on the Tasks board, Everyone to go back to).
1581
- $('#mainbar').hidden = loomOn && !w.aiTabs.length && !w.fileTabs.length && !(w.searchTabs || []).length
2119
+ // Only the Code tab (open files) and search keep a row of tabs: the loom, people and DMs have back arrows (dm06).
2120
+ $('#mainbar').hidden = !((w.mode === 'files' && w.fileTabs.length) || w.mode === 'search')
1582
2121
  }
1583
2122
 
1584
2123
  // A card being renamed, or a drag in progress, must not be rebuilt under the pointer.
1585
2124
  let draggingTask = false
2125
+ const openTasks = new Set() // board cards opened to their controls
1586
2126
  let boardDirty = false
1587
2127
  // Who the next task is for, chosen before Add: `p:name`, `a:name`, or '' for nobody.
1588
2128
  // null until chosen: the add form then follows the board's Show choice.
@@ -1611,7 +2151,10 @@ function taskPeople (st) {
1611
2151
  name: p.name,
1612
2152
  color: p.color,
1613
2153
  tool: p.tool && p.tool !== 'unknown' ? p.tool : '',
1614
- agent: p.kind === 'agent'
2154
+ agent: p.kind === 'agent',
2155
+ // Working now, and since when: a card in progress says "Cursor working · 14m" (dm06).
2156
+ working: !!(p.agent && p.agent.status === 'working'),
2157
+ since: p.focusAt || 0
1615
2158
  }))
1616
2159
  }
1617
2160
 
@@ -2129,8 +2672,14 @@ function bindBoard () {
2129
2672
  catch (err) { toast(err.message) }
2130
2673
  return
2131
2674
  }
2675
+ // A card shows its title, who has it and whether their AI is on it (dm06); a click opens its controls, and the title of an open one renames it.
2676
+ const card = e.target.closest('.task')
2677
+ if (!card || e.target.closest('button, select, input, textarea, a, form')) return
2132
2678
  const title = e.target.closest('.task-title')
2133
- if (title) beginEdit(title)
2679
+ if (title && card.classList.contains('open')) { beginEdit(title); return }
2680
+ if (openTasks.has(card.dataset.task)) openTasks.delete(card.dataset.task)
2681
+ else openTasks.add(card.dataset.task)
2682
+ card.classList.toggle('open', openTasks.has(card.dataset.task))
2134
2683
  })
2135
2684
  el.addEventListener('dragstart', (e) => {
2136
2685
  const card = e.target.closest?.('.task')
@@ -2174,11 +2723,58 @@ function bindBoard () {
2174
2723
  })
2175
2724
  }
2176
2725
 
2726
+ // The session's chat sits in the main area where the Loom was, on the Everyone tab; any other tab
2727
+ // (an AI chat, a file, tasks, search) puts it back on the right. The pane is moved, not redrawn, so
2728
+ // what's typed and the scroll position stay.
2729
+ function placeChat (inMain) {
2730
+ const pane = $('#chat-pane')
2731
+ const body = $('#ws-body')
2732
+ const main = $('#main')
2733
+ if (!pane || !body || !main) return
2734
+ body.classList.toggle('chat-in-main', inMain)
2735
+ body.classList.toggle('loom-chat', inMain)
2736
+ body.classList.toggle('chat-off', !inMain) // chat is its own tab now, so the other tabs have no chat column
2737
+ if (inMain && pane.parentElement !== main.parentElement) main.after(pane)
2738
+ if (!inMain && pane.parentElement !== body) body.insertBefore(pane, $('#scrim'))
2739
+ }
2740
+
2741
+ // The Code tab: the session's repo (a session is one repo) as a file tree, beside the file that's open.
2742
+ function codeShell (el) {
2743
+ let shell = el.querySelector(':scope > .code-view')
2744
+ if (!shell) {
2745
+ el.innerHTML = '<div class="code-view"><nav class="code-tree" aria-label="Files"></nav><div class="code-file"></div></div>'
2746
+ shell = el.firstElementChild
2747
+ }
2748
+ const w = ws(current)
2749
+ renderTree(shell.querySelector('.code-tree'), state.trees.get(current), { me: me(), expanded: w.codeOpen || {}, selected: w.fileSel })
2750
+ return shell.querySelector('.code-file')
2751
+ }
2752
+ document.addEventListener('click', (e) => {
2753
+ const tree = e.target.closest('.code-tree')
2754
+ if (!tree || !current) return
2755
+ const changes = e.target.closest('[data-changes]')
2756
+ if (changes) { openFile(changes.dataset.changes, { tab: 'changes' }); return }
2757
+ if (e.target.closest('[data-more]')) return
2758
+ const dir = e.target.closest('[data-dir]')
2759
+ if (dir) {
2760
+ const w = ws(current)
2761
+ w.codeOpen = { ...(w.codeOpen || {}), [dir.dataset.dir]: dir.getAttribute('aria-expanded') !== 'true' }
2762
+ saveWs(current)
2763
+ codeShell($('#main'))
2764
+ return
2765
+ }
2766
+ const file = e.target.closest('[data-file]')
2767
+ if (file) openFile(file.dataset.file, { tab: 'file' })
2768
+ })
2769
+
2177
2770
  function renderMain () {
2178
2771
  const el = $('#main')
2179
2772
  if (!current || !el) return
2180
2773
  const w = ws(current)
2181
2774
  const st = sum().status
2775
+ document.querySelector('.sess-bar')?.classList.toggle('off', PAGES.includes(w.mode) && !!sum().workspace)
2776
+ // The loom and a person's view keep the composer under them; the other tabs have none.
2777
+ if (w.mode !== 'ai') placeChat(false)
2182
2778
  if (w.mode === 'tasks') {
2183
2779
  // Restoring the last archived task goes back to the board, and stays there.
2184
2780
  if (w.archived && !(st.tasks || []).some((t) => t.archived)) w.archived = false
@@ -2188,7 +2784,7 @@ function renderMain () {
2188
2784
  // A task an older app gave to one of someone's AI sessions ("Dana · login") is that person's.
2189
2785
  const who = owners(sum())
2190
2786
  const tasks = (st.tasks || []).map((t) => (t && who.has(t.assignee) ? { ...t, assignee: who.get(t.assignee) } : t))
2191
- const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || [] })
2787
+ const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || [], open: openTasks })
2192
2788
  // Status ticks arrive every few seconds. Re-rendering an unchanged board
2193
2789
  // would throw away hover, selection and scroll for nothing.
2194
2790
  if (html === lastBoard.html && lastBoard.el && el.firstElementChild === lastBoard.el) return
@@ -2231,6 +2827,99 @@ function renderMain () {
2231
2827
  return
2232
2828
  }
2233
2829
  delete el.dataset.qtSearch
2830
+ if (w.mode === 'people' && !sum().workspace) {
2831
+ // Not in a workspace: the session's own people.
2832
+ state.workspace = null
2833
+ } else if (w.mode === 'wsfiles' || w.mode === 'home' || w.mode === 'people' || ((w.mode === 'preview' || w.mode === 'connections') && sum().workspace)) {
2834
+ const id = sum().workspace
2835
+ if (!id) { w.mode = 'ai'; return renderMain() }
2836
+ if (!state.workspace || state.workspace.workspace?.id !== id) {
2837
+ if (!filesLoading) {
2838
+ filesLoading = true
2839
+ api('GET', `/api/workspaces/${encodeURIComponent(id)}`).then((d) => { state.workspace = d }).catch((err) => toast(err.message)).finally(() => { filesLoading = false; renderMain() })
2840
+ }
2841
+ el.innerHTML = `<div class="main-empty"><p class="hint">${loadingNote()}</p></div>`
2842
+ return
2843
+ }
2844
+ }
2845
+ if (pageConnections && w.mode !== 'connections') { pageConnections.destroy(); pageConnections = null }
2846
+ if (w.mode === 'home') {
2847
+ const id = sum().workspace
2848
+ const html = workspaceHomeHtml(state.workspace, homeInsights(id, () => renderMain()), { adding: !!w.homeAdding })
2849
+ if (el.dataset.home !== html) {
2850
+ el.innerHTML = html
2851
+ el.dataset.home = html
2852
+ const reload = async () => { state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`).catch(() => state.workspace); delete el.dataset.home; renderMain() }
2853
+ bindWorkspaceHome(el, { id, go, reload, newSession: () => newSessionDialog(id), invite: () => workspaceInviteDialog(id), setAdding: (on) => { w.homeAdding = on; delete el.dataset.home; renderMain() } })
2854
+ }
2855
+ return
2856
+ }
2857
+ delete el.dataset.home
2858
+ if (w.mode === 'people') {
2859
+ const st = sum().status
2860
+ const d = state.workspace && state.workspace.workspace?.id === sum().workspace ? state.workspace : { workspace: { name: st.sessionName || basename(sum().dir) }, members: [], agents: [] }
2861
+ const html = peoplePageHtml(d, { me: st.me.name, here: new Set([st.me.name, ...st.peers.map((p) => p.name)]) })
2862
+ if (el.dataset.people !== html) {
2863
+ el.innerHTML = html
2864
+ el.dataset.people = html
2865
+ bindPeoplePage(el.firstElementChild, { message: (n) => openDm(n), person: (n) => openPerson(n), settings: (tab) => openSessionSettings(tab), invite: () => sum().workspace ? workspaceInviteDialog(sum().workspace) : openInvite(current) })
2866
+ }
2867
+ return
2868
+ }
2869
+ delete el.dataset.people
2870
+ if (w.mode === 'calls') {
2871
+ const html = callsTabHtml()
2872
+ if (el.dataset.calls !== html) { el.innerHTML = html; el.dataset.calls = html; bindCallsTab(el) }
2873
+ return
2874
+ }
2875
+ delete el.dataset.calls
2876
+ if (w.mode === 'preview') {
2877
+ const html = previewTabHtml(w)
2878
+ if (el.dataset.preview !== html) { el.innerHTML = html; el.dataset.preview = html; bindPreviewTab(el) }
2879
+ return
2880
+ }
2881
+ delete el.dataset.preview
2882
+ if (w.mode === 'wsfiles') {
2883
+ const id = sum().workspace
2884
+ const html = `<div class="fv-page">${allFilesHtml(state.workspace, { id, embedded: true })}</div>`
2885
+ if (el.dataset.files !== html) {
2886
+ el.innerHTML = html
2887
+ el.dataset.files = html
2888
+ const rerender = () => { delete el.dataset.files; renderMain() }
2889
+ bindAllFiles(el, { id, go, rerender, reload: async () => { state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`).catch(() => state.workspace); rerender() } })
2890
+ }
2891
+ return
2892
+ }
2893
+ delete el.dataset.files
2894
+ // Connections (dm06): the apps the workspace's sessions can use, or this session's when it is in none.
2895
+ if (w.mode === 'connections') {
2896
+ const wsId = sum().workspace
2897
+ const scope = wsId ? { type: 'workspace', id: wsId } : { type: 'session', id: sum().status.room }
2898
+ const key = `${scope.type}:${scope.id}`
2899
+ if (!pageConnections || el.dataset.connections !== key || !el.querySelector('.cn-page')) {
2900
+ pageConnections?.destroy()
2901
+ el.innerHTML = '<div class="cn-page-wrap"></div>'
2902
+ el.dataset.connections = key
2903
+ const sessions = wsId ? (state.workspace?.sessions || []).map((x) => x.name || x.room) : [sum().status.sessionName || basename(sum().dir)]
2904
+ pageConnections = mountConnections(el.firstElementChild, { ...scope, page: true, sessions, callsRoom: sum().status.room, me: sum().status.me.name })
2905
+ }
2906
+ return
2907
+ }
2908
+ delete el.dataset.connections
2909
+ if (w.mode === 'ai' && w.dmWith) {
2910
+ placeChat(true)
2911
+ const html = dmThreadHtml(w.dmWith)
2912
+ if (el.dataset.dm !== html) {
2913
+ const sc = el.querySelector('.dm-scroll')
2914
+ const atEnd = !sc || sc.scrollHeight - sc.scrollTop - sc.clientHeight < 60
2915
+ el.innerHTML = html
2916
+ el.dataset.dm = html
2917
+ const n = el.querySelector('.dm-scroll')
2918
+ if (atEnd || !sc) n.scrollTop = n.scrollHeight
2919
+ }
2920
+ return
2921
+ }
2922
+ delete el.dataset.dm
2234
2923
  if (w.mode === 'ai') {
2235
2924
  if (!w.aiSel) {
2236
2925
  const people = st.peers
@@ -2244,13 +2933,16 @@ function renderMain () {
2244
2933
  <div class="invite-pair">
2245
2934
  <div><div class="label">Can edit</div><div class="codebox"><code>${esc(invite)}</code></div><button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy edit link</span></button></div>
2246
2935
  <div><div class="label">View only</div><div class="codebox"><code>${esc(viewInvite)}</code></div><button class="btn" data-copy-invite="view">${I.copy}<span>Copy view link</span></button></div>
2247
- </div>` : `
2936
+ </div>` : invite ? `
2248
2937
  <div class="codebox"><code id="empty-invite">${esc(invite)}</code></div>
2249
- <button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy invite link</span></button>`}
2938
+ <button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy invite link</span></button>` : `<p class="hint">${esc(NO_LINK_YET)}</p>`}
2250
2939
  <p class="hint small">Once they join, you'll see their AI chat here as it happens.</p>
2251
2940
  </div>`
2941
+ placeChat(false)
2252
2942
  return
2253
2943
  }
2944
+ // Chat is the loom (the dm06 layout): everyone's lanes, chat as bands across them, the composer below.
2945
+ placeChat(true)
2254
2946
  renderLoomView(el)
2255
2947
  return
2256
2948
  }
@@ -2259,11 +2951,13 @@ function renderMain () {
2259
2951
  if (!entries) { el.innerHTML = `<div class="main-empty"><p class="hint">${loadingNote()}</p></div>`; return }
2260
2952
  const p = personInfo(w.aiSel)
2261
2953
  const convSel = w.convSel && w.convSel[w.aiSel]
2262
- renderFeed(el, { entries, person: w.aiSel, isMe: !!p.isMe, color: p.color, agent: p.agent, online: p.online, convSel })
2954
+ placeChat(true)
2955
+ renderFeed(el, { entries, person: w.aiSel, isMe: !!p.isMe, color: p.color, agent: p.agent, online: p.online, convSel, head: true, tool: p.kind === 'agent' ? 'agent' : p.tool || '' })
2263
2956
  } else {
2957
+ const host = codeShell(el)
2264
2958
  if (!w.fileSel) {
2265
- el.innerHTML = `<div class="main-empty"><div class="ill">${I.file}</div><h3>Open a file</h3>
2266
- <p class="hint">${inSeam(sum().status) ? 'Search the code at the top and open a file from there, or open one from the Boxes list.' : 'Open one from the git panel\'s changes, or a box\'s change from the Boxes list. Lines your partners change light up as they happen.'}</p></div>`
2959
+ host.innerHTML = `<div class="main-empty"><div class="ill">${I.file}</div><h3>Open a file</h3>
2960
+ <p class="hint">Pick one from the files on the left. Lines your partners change light up as they happen.</p></div>`
2267
2961
  return
2268
2962
  }
2269
2963
  const cached = state.files.get(fileKey(w.fileSel))
@@ -2274,7 +2968,7 @@ function renderMain () {
2274
2968
  if (need === 'history') loadHistory(w.fileSel)
2275
2969
  else loadBlame(w.fileSel)
2276
2970
  }
2277
- renderFileView(el, {
2971
+ renderFileView(host, {
2278
2972
  path: w.fileSel,
2279
2973
  file: cached ? cached.file : null,
2280
2974
  meta: treeMeta(w.fileSel),
@@ -2512,7 +3206,9 @@ function loomPrefs (w) {
2512
3206
  w.loom = {
2513
3207
  chat: p.chat !== false,
2514
3208
  tasks: p.tasks !== false,
2515
- density: p.density === 'compact' ? 'compact' : 'detailed',
3209
+ // Compact cards are the dm06 card (what was asked, what it did, its files); Detailed adds the reply, when picked.
3210
+ density: p.densityPicked && p.density === 'detailed' ? 'detailed' : 'compact',
3211
+ densityPicked: !!p.densityPicked,
2516
3212
  layout: p.layout === 'merged' ? 'merged' : 'lanes',
2517
3213
  hidden: names(p.hidden),
2518
3214
  pinned: names(p.pinned), // lanes kept open when they don't all fit
@@ -2533,9 +3229,10 @@ function renderLoomView (el) {
2533
3229
  const st = s.status
2534
3230
  // One lane per person: the AI sessions on someone's computer are them, as in chat.
2535
3231
  const { personOf, ...data } = foldAiLanes({
3232
+ // Everyone else first, your own lane last (dm06).
2536
3233
  people: [
2537
- { ...st.me, isMe: true, online: st.connected },
2538
- ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true, optional: !!p.persona }))
3234
+ ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true, optional: !!p.persona })),
3235
+ { ...st.me, isMe: true, online: st.connected }
2539
3236
  ],
2540
3237
  owners: owners(s),
2541
3238
  feeds: state.feeds.get(current) || new Map(),
@@ -2551,16 +3248,251 @@ function renderLoomView (el) {
2551
3248
  me: st.me.name,
2552
3249
  names: mentionNames(s),
2553
3250
  meAgent: st.me.kind === 'agent',
2554
- onAction: loomAction
3251
+ onAction: loomAction,
3252
+ extra: {
3253
+ // A band that asks for an app action's approval carries the card (connections.js).
3254
+ approval: (it) => state.connectionsOn ? approvalCardHtml({ approval: it.approval }, st.room) : '',
3255
+ unreadFrom: (name) => dmUnread(name),
3256
+ seenAt: (name) => (ws(current).dmSeen || {})[name] || 0
3257
+ }
2555
3258
  })
3259
+ if (state.connectionsOn && renderable(state.messages.get(current)).some((m) => m.approval)) refreshApprovals(st.room, () => renderMain())
3260
+ }
3261
+
3262
+ /** The open session's workspace's name, for "From <workspace>'s files". */
3263
+ const wsName = () => (state.workspaces || []).find((x) => x.id === sum()?.workspace)?.name || ''
3264
+
3265
+ /** A message (and files) straight to `to`, from a band's quick reply: as the composer sends them. Throws on failure. */
3266
+ async function sendTo ({ to, text, files = [] }) {
3267
+ const id = current
3268
+ try {
3269
+ if (files.length) {
3270
+ for (let i = 0; i < files.length; i++) {
3271
+ const words = i === 0 ? text : ''
3272
+ if (files[i].wsFile) await api('POST', `/api/sessions/${id}/attach-from-workspace`, { fileId: files[i].wsFile, to, text: words })
3273
+ else await api('POST', `/api/sessions/${id}/send`, files[i], { 'x-filename': encodeURIComponent(files[i].name), 'x-to': encodeURIComponent(to), 'x-text': encodeURIComponent(words) })
3274
+ }
3275
+ } else await api('POST', `/api/sessions/${id}/say`, { text, to })
3276
+ const w = ws(current)
3277
+ w.dmSeen = { ...(w.dmSeen || {}), [to]: Date.now() }
3278
+ saveWs(current)
3279
+ } catch (err) { toast(err.message); throw err }
3280
+ }
3281
+
3282
+ /** Direct messages to you from `name` you haven't opened yet (their thread marks them seen). */
3283
+ function dmUnread (name) {
3284
+ const st = sum().status
3285
+ const seen = (ws(current).dmSeen || {})[name] || 0
3286
+ return renderable(state.messages.get(current)).filter((m) => m.by === name && m.to === st.me.name && (m.ts || 0) > seen).length
3287
+ }
3288
+
3289
+ /** Your direct messages with one person (dm06): a thread of their own, theirs on the left and yours on the right. */
3290
+ function openDm (name) {
3291
+ const w = ws(current)
3292
+ w.dmFrom = w.aiSel || null
3293
+ w.dmWith = name
3294
+ w.mode = 'ai'
3295
+ w.dmSeen = { ...(w.dmSeen || {}), [name]: Date.now() }
3296
+ saveWs(current)
3297
+ state.to = name
3298
+ renderRecipients()
3299
+ renderMain()
3300
+ renderSessHead()
3301
+ $('#msg-input')?.focus()
3302
+ }
3303
+
3304
+ /** The thread with `name`: every direct message between you, oldest first. */
3305
+ function dmThreadHtml (name) {
3306
+ const s = sum()
3307
+ const st = s.status
3308
+ const me = st.me.name
3309
+ const p = personInfo(name)
3310
+ const list = renderable(state.messages.get(current)).filter((m) => (m.by === name && m.to === me) || (m.by === me && m.to === name))
3311
+ let day = ''
3312
+ const rows = list.map((m) => {
3313
+ const mine = m.by === me
3314
+ const d = new Date(m.ts || 0).toDateString()
3315
+ const divider = d !== day ? `<div class="dm-day"><span>${esc((day = d) === new Date().toDateString() ? 'Today' : new Date(m.ts).toLocaleDateString([], { weekday: 'long', month: 'short', day: 'numeric' }))}</span></div>` : ''
3316
+ const file = m.file ? `<a class="file-card" href="${fileCardHref(current, m.id, TOKEN)}" download="${esc(m.file.name)}" data-chat-file="${esc(m.id)}" title="Open ${esc(m.file.name)}"><span class="fi">${I.file}</span><span style="min-width:0"><div class="fn">${esc(m.file.name)}</div><div class="fs">${bytes(m.file.size)} · ${mine ? 'sent' : 'received'}</div></span></a>` : ''
3317
+ // As in the mockup: the face at the top, beside a line with who and when, the bubble under it.
3318
+ return `${divider}<div class="dm-msg${mine ? ' mine' : ''}">${avatar(mine ? me : name, mine ? st.me.color : p.color)}<div class="dm-body"><div class="dm-who"><b>${esc(mine ? 'You' : name)}</b><time>${esc(clock(m.ts))}</time></div><div class="dm-bubble">${m.text ? `<div class="text">${textHtml(m.text, mentionNames(s), me, { meAgent: st.me.kind === 'agent' })}</div>` : ''}${file}</div></div></div>`
3319
+ }).join('')
3320
+ return `<div class="dm-view" style="--c:${esc(p.color || '')}">
3321
+ <div class="pv-head"><button type="button" class="pv-back" data-dm-back title="Back" aria-label="Back">${I.arrowLeft}</button>${avatar(name, p.color, p.online)}<div class="pv-who"><b>${esc(name)}</b><small>Direct messages · only you and ${esc(name)}</small></div><span class="pv-sp"></span><button type="button" class="btn sm pv-dm" data-dm-ai="${esc(name)}">${esc(name)}'s AI chats</button></div>
3322
+ <div class="dm-scroll"><div class="dm-list">${rows || `<div class="dm-empty"><b>No messages with ${esc(name)} yet</b><span class="hint">Write below: only ${esc(name)} sees it.</span></div>`}</div></div>
3323
+ </div>`
3324
+ }
3325
+
3326
+ /**
3327
+ * A lane card turns into the person's view (dm06): the other cards fall away while the card grows into
3328
+ * the view's header, then the view fades in under it. Without motion (reduced motion), it just opens.
3329
+ */
3330
+ async function morphToPerson (name, card) {
3331
+ const main = $('#main')
3332
+ const loom = main && main.querySelector('.loom')
3333
+ if (!loom || !card || matchMedia('(prefers-reduced-motion: reduce)').matches) return openPerson(name)
3334
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
3335
+ const r = card.getBoundingClientRect()
3336
+ const clone = card.cloneNode(true)
3337
+ clone.classList.add('pv-morph')
3338
+ // The view's back arrow rides in the card from the start, so nothing pops in after it lands.
3339
+ clone.insertAdjacentHTML('afterbegin', `<span class="pv-back pv-mbk" aria-hidden="true">${I.arrowLeft}</span>`)
3340
+ Object.assign(clone.style, { position: 'fixed', left: `${r.left}px`, top: `${r.top}px`, width: `${r.width}px`, height: `${r.height}px`, margin: 0, zIndex: 50 })
3341
+ document.body.appendChild(clone)
3342
+ card.style.visibility = 'hidden'
3343
+ for (const x of loom.querySelectorAll('.loom-head, .lc, .loom-band, .loom-needle')) {
3344
+ if (x === card) continue
3345
+ x.style.setProperty('--d', `${(Math.random() * 0.06).toFixed(2)}s`)
3346
+ x.style.setProperty('--r', `${(Math.random() * 10 - 5).toFixed(1)}deg`)
3347
+ }
3348
+ loom.classList.add('falling')
3349
+ await sleep(230)
3350
+ openPerson(name)
3351
+ const head = main.querySelector('.pv-head')
3352
+ if (!head) { clone.remove(); return }
3353
+ head.style.visibility = 'hidden'
3354
+ main.querySelector('.feed-scroll')?.classList.add('pv-in')
3355
+ const t = head.getBoundingClientRect()
3356
+ await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))
3357
+ clone.classList.add('grow')
3358
+ Object.assign(clone.style, { left: `${t.left}px`, top: `${t.top}px`, width: `${t.width}px`, height: `${t.height}px` })
3359
+ await sleep(470)
3360
+ // The card now has the header's own layout: show the header under it and let the card fade off it.
3361
+ head.style.visibility = ''
3362
+ clone.style.transition = 'opacity .14s'
3363
+ clone.style.opacity = '0'
3364
+ setTimeout(() => clone.remove(), 160)
3365
+ }
3366
+
3367
+ /**
3368
+ * The Preview tab (dm06): the session's links (its own, then the workspace's) on the left, the one picked
3369
+ * in a frame with its address, a phone or desktop width, and Open in browser. Links are added here or on
3370
+ * the workspace's home (Previews).
3371
+ */
3372
+ // ------------------------------------------------------------------ Calls tab --
3373
+ // The session's calls (dm06), from their transcripts: who was in each, its first words, when and how long.
3374
+ // A row opens its transcript; the button at the top starts a call, or joins the one going on.
3375
+ let callsView = { id: null, calls: null, open: null, lines: null, at: 0 }
3376
+ function loadCalls (force = false) {
3377
+ const id = current
3378
+ if (!force && callsView.id === id && Date.now() - callsView.at < 15000) return
3379
+ callsView = { ...callsView, id, at: Date.now(), ...(callsView.id === id ? {} : { calls: null, open: null, lines: null }) }
3380
+ api('GET', `/api/sessions/${id}/calls`).then((r) => { if (callsView.id === id) { callsView.calls = r.calls; if (ws(current).mode === 'calls') renderMain() } }).catch(() => { callsView.calls = [] })
3381
+ }
3382
+ const minutes = (ms) => { const m = Math.max(1, Math.round(ms / 60000)); return m < 60 ? `${m} min` : `${Math.floor(m / 60)} h ${m % 60} min` }
3383
+ function callDay (ts) {
3384
+ const d = new Date(ts)
3385
+ const days = Math.round((new Date().setHours(0, 0, 0, 0) - new Date(ts).setHours(0, 0, 0, 0)) / 86400000)
3386
+ const at = d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })
3387
+ return days === 0 ? `Today ${at}` : days === 1 ? `Yesterday ${at}` : days < 7 ? d.toLocaleDateString([], { weekday: 'short' }) : d.toLocaleDateString([], { month: 'short', day: 'numeric' })
3388
+ }
3389
+ function callsTabHtml () {
3390
+ loadCalls()
3391
+ const st = sum().status
3392
+ const live = $('#chat-call') && !$('#chat-call').hidden
3393
+ const inCall = inCallHere(current)
3394
+ const top = `<div class="cl-top"><span>Calls in ${esc(st.sessionName || basename(sum().dir))}${callsView.calls?.length ? ` · ${callsView.calls.length}` : ''}</span><button type="button" class="btn ${live ? 'primary' : ''}" data-cl-start${live ? '' : ' disabled title="Calls are not turned on for this session"'}>${I.mic}<span>${inCall ? 'Open the call' : 'Start a call'}</span></button></div>`
3395
+ if (callsView.calls === null) return `<div class="cl-page">${top}<p class="hint">${loadingNote()}</p></div>`
3396
+ if (!callsView.calls.length) return `<div class="cl-page">${top}<div class="cl-none"><b>No calls yet</b><p>When people here talk in a call with transcripts on, it shows up here with what was said.</p></div></div>`
3397
+ const color = (n) => personInfo(n).color
3398
+ const rows = callsView.calls.map((c) => {
3399
+ const open = callsView.open === c.call
3400
+ const names = c.people.slice(0, 3)
3401
+ const title = `Call with ${names.length > 1 ? `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}` : names[0] || 'no one'}${c.people.length > 3 ? ` and ${c.people.length - 3} more` : ''}`
3402
+ const said = c.opening.map((l) => `${l.by}: ${l.text}`).join(' · ')
3403
+ const lines = open ? (callsView.lines ? callsView.lines.map((l) => `<li><b>${esc(l.by)}</b><time>${esc(clock(l.ts))}</time><span>${esc(l.text)}</span></li>`).join('') : `<li class="hint">${loadingNote()}</li>`) : ''
3404
+ return `<div class="cl-call${open ? ' open' : ''}"><button type="button" class="cl-row" data-cl-open="${esc(c.call)}" aria-expanded="${open}">
3405
+ <span class="cl-play">${I.play}</span><span class="cl-t"><b>${esc(title)}</b><small>${esc(said)}</small></span>
3406
+ <span class="cl-faces">${c.people.slice(0, 4).map((n) => avatar(n, color(n))).join('')}</span>
3407
+ <span class="cl-when"><b>${esc(callDay(c.start))}</b><small>${esc(minutes(c.end - c.start))}</small></span></button>
3408
+ ${open ? `<ol class="cl-lines">${lines}</ol>` : ''}</div>`
3409
+ }).join('')
3410
+ return `<div class="cl-page">${top}<div class="cl-list">${rows}</div></div>`
3411
+ }
3412
+ function bindCallsTab (el) {
3413
+ el.onclick = async (e) => {
3414
+ if (e.target.closest('[data-cl-start]')) { $('#chat-call')?.click(); return }
3415
+ const r = e.target.closest('[data-cl-open]')
3416
+ if (!r) return
3417
+ const call = r.dataset.clOpen
3418
+ if (callsView.open === call) { callsView.open = null; renderMain(); return }
3419
+ callsView.open = call
3420
+ callsView.lines = null
3421
+ renderMain()
3422
+ const id = current
3423
+ try { const { lines } = await api('GET', `/api/sessions/${id}/calls/${encodeURIComponent(call)}`); if (callsView.open === call) { callsView.lines = lines; renderMain() } } catch (err) { toast(err.message) }
3424
+ }
2556
3425
  }
2557
3426
 
3427
+ function previewTabHtml (w) {
3428
+ const s = sum()
3429
+ const room = s.status.room
3430
+ const d = state.workspace && state.workspace.workspace?.id === s.workspace ? state.workspace : null
3431
+ const links = d ? (d.links || []).filter((l) => !l.room || l.room === room).sort((a, b) => (a.room === room ? 0 : 1) - (b.room === room ? 0 : 1)) : []
3432
+ const pick = links.find((l) => l.id === w.previewSel) || links[0] || null
3433
+ const host = (u) => { try { return new URL(u).host } catch { return u } }
3434
+ const local = (u) => /^(localhost|127\.|0\.0\.0\.0)/.test(host(u))
3435
+ const list = links.map((l) => `<button type="button" class="pt-link${pick && l.id === pick.id ? ' on' : ''}" data-pt-pick="${esc(l.id)}"><span class="pt-ico${local(l.url) ? ' live' : ''}">${local(l.url) ? I.play : I.globe}</span><span class="pt-x"><b>${esc(l.name)}</b><small>${esc([host(l.url), l.note].filter(Boolean).join(' · '))}</small></span></button>`).join('')
3436
+ const form = `<form class="pt-add" data-pt-add>${s.workspace ? `<input class="input" name="name" placeholder="Name (Staging, Bob's localhost…)" maxlength="80" required><input class="input" name="url" placeholder="https://… or http://localhost:3000" maxlength="500" required><button class="btn" type="submit">${I.plus}<span>Add a link</span></button>` : '<p class="hint">Links are kept in a workspace: move this session into one to add them.</p>'}</form>`
3437
+ const frame = pick
3438
+ ? `<div class="pt-bar"><button type="button" class="pt-btn" data-pt-reload title="Reload" aria-label="Reload">${I.refresh}</button><span class="pt-url">${I.lock}<code>${esc(pick.url.replace(/^https?:\/\//, ''))}</code></span>${local(pick.url) ? '<span class="pt-live"><span class="pulse"></span>Live from a computer in this session</span>' : ''}<span class="pt-sp"></span>
3439
+ <span class="pt-size" role="group" aria-label="Width"><button type="button" class="pt-btn${w.previewPhone ? '' : ' on'}" data-pt-size="desktop" title="Desktop" aria-label="Desktop width"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg></button><button type="button" class="pt-btn${w.previewPhone ? ' on' : ''}" data-pt-size="phone" title="Phone" aria-label="Phone width"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="2" width="10" height="20" rx="2"/><path d="M11 18h2"/></svg></button></span>
3440
+ <a class="btn sm" href="${esc(pick.url)}" target="_blank" rel="noopener">${I.external}<span>Open in browser</span></a></div>
3441
+ <div class="pt-stage${w.previewPhone ? ' phone' : ''}"><iframe class="pt-frame" src="${esc(pick.url)}" title="${esc(pick.name)}" sandbox="allow-scripts allow-forms allow-same-origin allow-popups" referrerpolicy="no-referrer"></iframe></div>`
3442
+ : `<div class="main-empty"><div class="ill">${I.globe}</div><h3>Nothing to preview yet</h3><p class="hint">Add the links that matter for this session: its dev server, a square's preview, staging, production.</p></div>`
3443
+ return `<div class="pt-view"><aside class="pt-side"><div class="pt-h">Running</div>${list || '<p class="hint pt-none">No links yet.</p>'}${form}</aside><section class="pt-main">${frame}</section></div>`
3444
+ }
3445
+
3446
+ function bindPreviewTab (el) {
3447
+ const w = ws(current)
3448
+ const redraw = () => { delete $('#main').dataset.preview; renderMain() }
3449
+ el.onclick = (e) => {
3450
+ const p = e.target.closest('[data-pt-pick]')
3451
+ if (p) { w.previewSel = p.dataset.ptPick; saveWs(current); return redraw() }
3452
+ const sz = e.target.closest('[data-pt-size]')
3453
+ if (sz) { w.previewPhone = sz.dataset.ptSize === 'phone'; saveWs(current); return redraw() }
3454
+ if (e.target.closest('[data-pt-reload]')) { const f = el.querySelector('.pt-frame'); if (f) f.src = f.src }
3455
+ }
3456
+ const form = el.querySelector('[data-pt-add]')
3457
+ if (form && form.elements.name) {
3458
+ form.onsubmit = async (e) => {
3459
+ e.preventDefault()
3460
+ const id = sum().workspace
3461
+ try {
3462
+ const l = await api('POST', `/api/workspaces/${encodeURIComponent(id)}/links`, { name: form.elements.name.value, url: form.elements.url.value, room: sum().status.room })
3463
+ state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`)
3464
+ w.previewSel = l.id
3465
+ saveWs(current)
3466
+ redraw()
3467
+ } catch (err) { toast(err.message) }
3468
+ }
3469
+ }
3470
+ }
3471
+
3472
+ let filesLoading = false // the workspace's files, fetched for the Files page
3473
+ let pageConnections = null // the Connections page's manager while it is drawn
3474
+ // Pages over the session (dm06): Home, Files, People and Connections. Each is a toggle: a second click goes back to
3475
+ // the session's view you came from, whose tab stays lit meanwhile.
3476
+ const PAGES = ['home', 'wsfiles', 'people', 'connections']
3477
+ function togglePage (mode) {
3478
+ const w = ws(current)
3479
+ if (w.mode === mode) w.mode = PAGES.includes(w.pageBack) ? 'ai' : (w.pageBack || 'ai')
3480
+ else { if (!PAGES.includes(w.mode)) w.pageBack = w.mode; w.mode = mode }
3481
+ saveWs(current)
3482
+ renderMain()
3483
+ renderSessHead()
3484
+ renderWbar()
3485
+ }
2558
3486
  let loomPersonOf = new Map() // a "<person>'s AI" lane -> the person whose AI chat it opens
2559
3487
 
2560
- function loomAction (kind, value) {
3488
+ function loomAction (kind, value, from) {
2561
3489
  const w = ws(current)
2562
3490
  const prefs = loomPrefs(w)
2563
- if (kind === 'person') return openPerson(loomPersonOf.get(value) || value)
3491
+ if (kind === 'person') return from && from.classList.contains('lh-card') ? morphToPerson(loomPersonOf.get(value) || value, from) : openPerson(loomPersonOf.get(value) || value)
3492
+ // A lane card's message button or a band to you: your thread with them. A quick reply in a band: sent to them from there.
3493
+ if (kind === 'dm') return openDm(value)
3494
+ if (kind === 'reply') return sendTo(value)
3495
+ if (kind === 'attach') return attachMenu(value.anchor, { workspace: sum().workspace, name: wsName(), onUpload: value.upload, onPick: (f) => value.add({ wsFile: f.id, name: f.name, size: f.size }) })
2564
3496
  if (kind === 'conv') { openPerson(loomPersonOf.get(value.name) || value.name); pickConv(value.conv); return }
2565
3497
  if (kind === 'file') return openFile(value)
2566
3498
  if (kind === 'holds') return openLocks(value.anchor, { who: value.name }) // the same lock list as the Files rail
@@ -2572,7 +3504,7 @@ function loomAction (kind, value) {
2572
3504
  if (kind === 'hide') prefs.hidden = [...new Set([...prefs.hidden, value])]
2573
3505
  else if (kind === 'unhide') prefs.hidden = prefs.hidden.filter((n) => n !== value)
2574
3506
  else if (kind === 'toggle') prefs[value] = prefs[value] === false
2575
- else if (kind === 'density') prefs.density = value
3507
+ else if (kind === 'density') { prefs.density = value; prefs.densityPicked = true }
2576
3508
  else if (kind === 'layout') prefs.layout = value
2577
3509
  else if (kind === 'pin') prefs.pinned = prefs.pinned.includes(value) ? prefs.pinned.filter((n) => n !== value) : [...prefs.pinned, value]
2578
3510
  else if (kind === 'open-lane') { prefs.opened = [value, ...prefs.opened.filter((n) => n !== value)].slice(0, 20); prefs.layout = 'lanes' }
@@ -2628,7 +3560,8 @@ async function loadTree () {
2628
3560
  // Keep the banner (editor, claim) fresh without re-highlighting.
2629
3561
  const cached = state.files.get(fileKey(w.fileSel))
2630
3562
  const meta = treeMeta(w.fileSel)
2631
- if (cached) renderFileView($('#main'), { path: w.fileSel, file: cached.file, meta, me: me(), bannerOnly: true, chatHref: meta?.chat ? fileCardHref(id, meta.chat.id, TOKEN) : null, rawHref: rawHrefFor(id) })
3563
+ if ($('#main .code-view')) codeShell($('#main'))
3564
+ if (cached) renderFileView($('#main .code-file') || $('#main'), { path: w.fileSel, file: cached.file, meta, me: me(), bannerOnly: true, chatHref: meta?.chat ? fileCardHref(id, meta.chat.id, TOKEN) : null, rawHref: rawHrefFor(id) })
2632
3565
  }
2633
3566
  } catch {}
2634
3567
  }
@@ -2703,7 +3636,7 @@ function applyTreeCollapsed () {
2703
3636
  const body = $('#ws-body')
2704
3637
  const btn = $('#collapse-tree')
2705
3638
  if (!body || !current) return
2706
- const collapsed = ws(current).boxesCollapsed === true
3639
+ const collapsed = recall('side-collapsed', '0') === '1' // one setting for the window, not per session
2707
3640
  body.classList.toggle('tree-collapsed', collapsed)
2708
3641
  const rail = $('#tree-rail')
2709
3642
  if (rail) rail.toggleAttribute('inert', !collapsed)
@@ -2722,9 +3655,7 @@ function applyTreeCollapsed () {
2722
3655
 
2723
3656
  function toggleTreeCollapsed () {
2724
3657
  if (!current) return
2725
- const w = ws(current)
2726
- w.boxesCollapsed = !w.boxesCollapsed
2727
- saveWs(current)
3658
+ remember('side-collapsed', recall('side-collapsed', '0') === '1' ? '0' : '1')
2728
3659
  applyTreeCollapsed()
2729
3660
  }
2730
3661
 
@@ -2818,6 +3749,12 @@ function bindChatPane () {
2818
3749
  function bindTreeEvents () {
2819
3750
  const collapse = $('#collapse-tree')
2820
3751
  if (collapse) collapse.onclick = () => toggleTreeCollapsed()
3752
+ $('#side-mini')?.addEventListener('click', (e) => {
3753
+ if (e.target.closest('[data-side-people]')) { openSessionSettings(e.target.closest('[data-side-people]').dataset.sidePeople); return }
3754
+ if (e.target.closest('[data-side-files]')) { go(`wsfiles:${sum().workspace}`); return }
3755
+ const g = e.target.closest('[data-side-go]')
3756
+ if (g && g.dataset.sideGo !== current) go(g.dataset.sideGo)
3757
+ })
2821
3758
  const el = $('#boxes-side')
2822
3759
  el.addEventListener('click', (e) => {
2823
3760
  // A person's boxes: folded until clicked, and folded again by another click.
@@ -2831,6 +3768,12 @@ function bindTreeEvents () {
2831
3768
  }
2832
3769
  const bx = e.target.closest('[data-box-toggle],[data-unpack],[data-ask]')
2833
3770
  if (bx) { boxAction(bx); return }
3771
+ if (e.target.closest('[data-side-people]')) { openSessionSettings(e.target.closest('[data-side-people]').dataset.sidePeople); return }
3772
+ if (e.target.closest('[data-side-ws]')) { go(`ws:${sum().workspace}`); return }
3773
+ if (e.target.closest('[data-side-files]')) { go(`wsfiles:${sum().workspace}`); return }
3774
+ if (e.target.closest('[data-side-new]')) { go('home'); return }
3775
+ const g = e.target.closest('[data-side-go]')
3776
+ if (g) { if (g.dataset.sideGo !== current) go(g.dataset.sideGo); return }
2834
3777
  const t = e.target.closest('[data-person],[data-dm]')
2835
3778
  if (!t) return
2836
3779
  if (t.dataset.dm) {
@@ -2884,13 +3827,22 @@ function bindChat () {
2884
3827
  if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && !e.defaultPrevented) { e.preventDefault(); $('#composer').requestSubmit() }
2885
3828
  })
2886
3829
  $('#to-select').onchange = (e) => { state.to = e.target.value; updatePlaceholder() }
2887
- $('#attach-btn').onclick = () => $('#file-input').click()
3830
+ // +: upload from this computer, or one of the workspace's files (dm06's attach menu).
3831
+ $('#attach-btn').onclick = () => attachMenu($('#attach-btn'), { workspace: sum()?.workspace, name: wsName(), onUpload: () => $('#file-input').click(), onPick: (f) => attachFromWorkspace(f) })
3832
+ // @: starts a mention where the cursor is, and the mention list opens as when typing it.
3833
+ $('#at-btn').onclick = () => {
3834
+ const ta = $('#msg-input')
3835
+ const at = ta.selectionStart ?? ta.value.length
3836
+ const before = ta.value.slice(0, at)
3837
+ ta.value = `${before}${before && !/\s$/.test(before) ? ' ' : ''}@${ta.value.slice(at)}`
3838
+ ta.focus()
3839
+ const pos = ta.value.indexOf('@', at) + 1
3840
+ ta.setSelectionRange(pos, pos)
3841
+ ta.dispatchEvent(new Event('input', { bubbles: true }))
3842
+ }
2888
3843
  $('#file-input').onchange = (e) => { addFiles(e.target.files); e.target.value = '' }
2889
- $('[data-attach-workspace]')?.addEventListener('click', async () => {
3844
+ const attachFromWorkspace = async (pick) => {
2890
3845
  if (mayNotPost()) return toast(NO_POSTING)
2891
- const workspace = sum()?.workspace
2892
- const pick = await workspaceFilePicker(workspace)
2893
- if (!pick) return
2894
3846
  try {
2895
3847
  await api('POST', `/api/sessions/${id}/attach-from-workspace`, { fileId: pick.id, to: state.to || null, text: input.value.trim() })
2896
3848
  input.value = ''
@@ -2900,9 +3852,11 @@ function bindChat () {
2900
3852
  } finally {
2901
3853
  input.focus()
2902
3854
  }
2903
- })
3855
+ }
2904
3856
  // A file in the chat opens in the file view, where it's shown as what it is (preview.js).
2905
3857
  $('#messages').addEventListener('click', (e) => {
3858
+ const yes = e.target.closest('[data-approve],[data-decline]')
3859
+ if (yes) { const room = sum()?.status.room; if (room) answerApproval(room, yes.dataset.approve || yes.dataset.decline, !!yes.dataset.approve, () => renderMessages(false, false)); return }
2906
3860
  const card = e.target.closest('[data-chat-file]')
2907
3861
  if (!card || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button) return
2908
3862
  const entry = state.trees.get(current)?.files.find((f) => f.chat && f.chat.id === card.dataset.chatFile)
@@ -3007,7 +3961,11 @@ function updatePlaceholder () {
3007
3961
  if (!input) return
3008
3962
  if (mayNotPost()) { input.placeholder = NO_POSTING; return }
3009
3963
  const who = state.to ? (state.to === `${me()}'s AI` ? 'your AI' : state.to) : 'everyone'
3010
- input.placeholder = state.pending.length ? `Add a note for ${who} (optional)…` : `Message ${who}…`
3964
+ const where = sum()?.status.sessionName || basename(sum()?.dir || '')
3965
+ input.placeholder = state.pending.length ? `Add a note for ${who} (optional)…` : state.to ? `Message ${who} directly…` : `Message everyone in ${where}…`
3966
+ // The To chip takes the person's color for a direct message (dm06).
3967
+ const to = input.closest('.composer')?.querySelector('.to')
3968
+ if (to) to.style.setProperty('--to-c', state.to ? (personInfo(state.to).color || colorFor(state.to)) : '')
3011
3969
  }
3012
3970
 
3013
3971
  function renderRecipients () {
@@ -3023,8 +3981,8 @@ function renderRecipients () {
3023
3981
  if (state.to) names.add(state.to)
3024
3982
  const online = new Set(peopleHere(s.status).map((p) => p.name))
3025
3983
  const away = new Set((s.status.away || []).map((a) => a.name))
3026
- sel.innerHTML = '<option value="">Everyone</option>' + [...names].sort().map((n) =>
3027
- `<option value="${esc(n)}" ${n === state.to ? 'selected' : ''}>${esc(n === `${s.status.me.name}'s AI` ? 'Your AI' : n)} (direct${online.has(n) ? '' : away.has(n) ? ', away' : ', offline'})</option>`).join('')
3984
+ sel.innerHTML = `<option value="">Everyone in ${esc(s.status.sessionName || basename(s.dir))}</option>` + [...names].sort().map((n) =>
3985
+ `<option value="${esc(n)}" ${n === state.to ? 'selected' : ''}>${esc(n === `${s.status.me.name}'s AI` ? 'Your AI' : n)} · direct message${online.has(n) ? '' : away.has(n) ? ' (away)' : ' (offline)'}</option>`).join('')
3028
3986
  sel.value = state.to
3029
3987
  sel.closest('.to').hidden = names.size === 0
3030
3988
  updatePlaceholder()
@@ -3169,9 +4127,11 @@ function renderMessages (incoming = false, force = false) {
3169
4127
  const face = mine ? '' : relay ? `<span class="relay-q avatar">${I.globe}</span>` : avatar(by, colors.get(by) || colors.get(m.by))
3170
4128
  return `<div class="msg${mine ? ' mine' : ''}">
3171
4129
  <div style="min-width:0"><div class="head">${face}<b${by !== m.by ? ` title="${esc(m.by)}"` : ''}>${mine ? 'You' : esc(by === `${name}'s AI` ? 'Your AI' : by)}</b>${aiTag(by, name)}${dm}<span>${esc(clock(m.ts))}</span></div>
3172
- <div class="bubble">${m.text ? `<div class="text">${textHtml(m.text, names, name, { meAgent: s.status.me.kind === 'agent' })}</div>` : ''}${file}</div></div></div>`
4130
+ <div class="bubble">${m.text ? `<div class="text">${textHtml(m.text, names, name, { meAgent: s.status.me.kind === 'agent' })}</div>` : ''}${file}${relay && m.approval ? approvalCardHtml(m, s.status.room) : ''}</div></div></div>`
3173
4131
  })() })), ...calls].sort((a, b) => a.ts - b.ts).map((x) => x.html).join('')
3174
4132
  : '<div class="day-empty"><div><b>Say hi.</b></div><div class="hint">Messages, direct messages and files you share appear here. Drop a file on this panel to send it.</div></div>'
3175
4133
  if (force || nearBottom || (incoming && list[list.length - 1]?.by === name)) el.scrollTop = el.scrollHeight
4134
+ // An app action waiting for a person (connections.js): which cards still wait.
4135
+ if (state.connectionsOn && list.some((m) => m.approval && isRelay(m.by))) refreshApprovals(s.status.room, () => renderMessages(false, false))
3176
4136
  renderChatBadge()
3177
4137
  }