heyquilt 0.3.164 → 0.3.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASES.md +14 -0
- package/package.json +1 -1
- package/src/api/audit.js +0 -1
- package/src/api/composio.js +1 -64
- package/src/api/memory-store.js +0 -7
- package/src/api/routes/connections.js +1 -78
- package/src/api/routes/workspaces.js +3 -43
- package/src/api/supabase-store.js +0 -11
- package/src/control.js +0 -21
- package/src/presence.js +1 -2
- package/src/server.js +1 -15
- package/src/ui/app.css +5 -743
- package/src/ui/app.js +22 -38
- package/src/ui/board.js +7 -17
- package/src/ui/connections.js +41 -235
- package/src/ui/feed.js +8 -23
- package/src/ui/files.js +22 -67
- package/src/ui/home.js +6 -95
- package/src/ui/loom-model.js +8 -11
- package/src/ui/loom.css +2 -183
- package/src/ui/loom.js +55 -132
- package/src/ui/session.js +75 -1065
- package/src/ui/signin.js +6 -4
- package/src/ui/workspaces.js +1 -2
- package/src/ui-server.js +4 -50
- package/src/dev-servers.js +0 -65
- package/src/ui/home-view.js +0 -170
- package/src/ui/palette.js +0 -75
- package/src/ui/people-view.js +0 -116
package/src/ui/session.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// the team chat on the right.
|
|
4
4
|
import { mountSecrets } from './secrets.js'
|
|
5
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
|
|
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 } from './common.js'
|
|
7
7
|
import { openInvite, renderTabs, markRead, go } from './app.js'
|
|
8
8
|
import { NO_LINK_YET } from './invite.js'
|
|
9
9
|
import { renderFeed } from './feed.js'
|
|
@@ -13,26 +13,23 @@ import { railModel } from './rail-model.js'
|
|
|
13
13
|
import { renderRail, openLocks, closeLocks } from './rail.js'
|
|
14
14
|
import { feedbackDockHtml, bindFeedback } from './feedback.js'
|
|
15
15
|
import { conversations } from './feed-convs.js'
|
|
16
|
-
import { closeTreeMenu
|
|
16
|
+
import { closeTreeMenu } from './tree.js'
|
|
17
17
|
import { renderFileView, renderFileTabs } from './fileview.js'
|
|
18
18
|
import { rolledOff, diffLines } from './diffview.js'
|
|
19
19
|
import { searchMarkup, searchTabMarkup, liveByPerson, fileReadsNeeded, SEARCH_ICON } from './quiltview.js'
|
|
20
20
|
import { changesMarkup, bindChanges, unbindChanges, changesChanged, fileChanges, loadChanges, changedCount, unseenChanges, markChangesSeen } from './changes.js'
|
|
21
21
|
import { quiltMark } from './mark.js'
|
|
22
|
-
import { openSettings
|
|
23
|
-
import { workspaceHomeHtml, bindWorkspaceHome, homeInsights } from './home-view.js'
|
|
24
|
-
import { peoplePageHtml, bindPeoplePage } from './people-view.js'
|
|
25
|
-
import { openPalette, paletteSource } from './palette.js'
|
|
22
|
+
import { openSettings } from './home.js'
|
|
26
23
|
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'
|
|
27
24
|
import { toolLogo } from './tool-logo.js'
|
|
28
25
|
import { renderBoard, taskNotesModalHtml, openTaskMenu, foldPlan, matchesSearch } from './board.js'
|
|
29
26
|
import { accessFormValues, accessSaveBody, grantsLoading, grantsLoaded, grantsFailed } from './access-form.js'
|
|
30
|
-
import {
|
|
27
|
+
import { workspaceFilePicker } from './files.js'
|
|
31
28
|
import { sessionAgentsHtml } from './agent-place.js'
|
|
32
29
|
import { renderCatchUp, bindCatchUp } from './catchup.js'
|
|
33
30
|
import { boxSummary, boxesOf, unplaced, boxesSig, boxListHtml, boxFoldHtml } from './boxes.js'
|
|
34
31
|
import { inSeam, makeQuiltWords, seamChip, squareCard, squarePanelHtml, seamSettingsHtml, openSquareButton, squaresSideHtml, SEAM_SIDE_HINT } from './seam-model.js'
|
|
35
|
-
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards
|
|
32
|
+
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards } from './voice.js'
|
|
36
33
|
|
|
37
34
|
let current = null // session id being shown
|
|
38
35
|
let timers = []
|
|
@@ -63,7 +60,7 @@ function ws (id) {
|
|
|
63
60
|
expanded: {},
|
|
64
61
|
boxesCollapsed: false, // the Boxes pane (who is working on what) starts open; folded, it is a rail of locks (rail.js)
|
|
65
62
|
stale: {}, // file path -> changed while not visible
|
|
66
|
-
loom: { chat: true, tasks: true, density: '
|
|
63
|
+
loom: { chat: true, tasks: true, density: 'detailed', layout: 'lanes', hidden: [] },
|
|
67
64
|
...(saved || {}),
|
|
68
65
|
drawer: null
|
|
69
66
|
})
|
|
@@ -126,24 +123,15 @@ export function mountSession (id) {
|
|
|
126
123
|
|
|
127
124
|
$('#app').innerHTML = `
|
|
128
125
|
<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>
|
|
137
126
|
<header class="ws-top">
|
|
138
127
|
<button class="brand" data-go="home" aria-label="Home">${quiltMark({ sew: 'first' })}</button>
|
|
139
128
|
<div class="overflow sess" id="sess">
|
|
140
|
-
<button class="sess-btn" id="sess-btn" type="button" aria-haspopup="true" aria-expanded="false" aria-controls="sess-menu"
|
|
129
|
+
<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>
|
|
141
130
|
<div class="popover more-menu sess-menu" id="sess-menu" role="menu" aria-label="This session" hidden>
|
|
142
|
-
<div id="tabs" class="sess-tabs"
|
|
131
|
+
<div id="tabs" class="sess-tabs"></div>
|
|
143
132
|
<button class="pop-item" role="menuitem" id="rename-btn" hidden>Rename session…</button>
|
|
144
133
|
<button class="pop-item" role="menuitem" id="move-ws-btn" hidden>Move to a workspace…</button>
|
|
145
134
|
<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>
|
|
147
135
|
<button class="pop-item" role="menuitem" data-gather-rules>One set of AI rules…</button>
|
|
148
136
|
<div class="pop-sep"></div>
|
|
149
137
|
<button class="pop-item" role="menuitem" id="leave-btn">Leave this session</button>
|
|
@@ -154,7 +142,7 @@ export function mountSession (id) {
|
|
|
154
142
|
<span class="relay-problem" id="relay-problem" role="status" hidden></span>
|
|
155
143
|
<span class="access-pill" id="access-pill" hidden></span>
|
|
156
144
|
<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>
|
|
145
|
+
<button class="btn sm ghost conn-btn" id="connections-btn" type="button" title="Apps agents in this session can use" ${state.connectionsOn ? '' : 'hidden'}>${I.plug}<span class="wide-only">Connections</span></button>
|
|
158
146
|
<div class="people" id="people">
|
|
159
147
|
<div class="people-pill">
|
|
160
148
|
<button class="people-btn" id="people-btn" aria-haspopup="true" aria-expanded="false" aria-controls="people-menu"></button>
|
|
@@ -185,17 +173,6 @@ export function mountSession (id) {
|
|
|
185
173
|
</div>
|
|
186
174
|
</div>
|
|
187
175
|
</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>
|
|
199
176
|
<div class="ws-body" id="ws-body">
|
|
200
177
|
<aside class="ws-tree ws-boxes" aria-label="Boxes: who is working on what">
|
|
201
178
|
<div class="pane-head">
|
|
@@ -203,12 +180,10 @@ export function mountSession (id) {
|
|
|
203
180
|
<span class="pane-title">Boxes</span><span class="hint" id="box-count"></span>
|
|
204
181
|
</div>
|
|
205
182
|
<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>
|
|
207
183
|
<div class="tree-scroll boxes-side" id="boxes-side"></div>
|
|
208
184
|
${feedbackDockHtml('boxes')}
|
|
209
185
|
</aside>
|
|
210
186
|
<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>
|
|
212
187
|
<div class="requests catchup" id="catchup" role="region" aria-label="While you were away" hidden></div>
|
|
213
188
|
<div class="requests square" id="square-card" role="status" aria-label="Seam" hidden></div>
|
|
214
189
|
<div class="requests" id="requests" hidden></div>
|
|
@@ -220,8 +195,7 @@ export function mountSession (id) {
|
|
|
220
195
|
</main>
|
|
221
196
|
<aside class="ws-chat" id="chat-pane" aria-label="Chat">
|
|
222
197
|
<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>
|
|
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
|
|
224
|
-
<div class="work-strip" id="work-strip" aria-label="What people are working on"></div>
|
|
198
|
+
<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>
|
|
225
199
|
<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>
|
|
226
200
|
<div class="messages" id="messages"></div>
|
|
227
201
|
<div class="typing" id="typing" role="status" aria-live="polite" hidden></div>
|
|
@@ -232,8 +206,8 @@ export function mountSession (id) {
|
|
|
232
206
|
<div class="attachments" id="attachments"></div>
|
|
233
207
|
<div class="mention-menu" id="mention-menu" role="listbox" aria-label="Mention someone" hidden></div>
|
|
234
208
|
<div class="box">
|
|
235
|
-
<button type="button" class="btn ghost icon" id="attach-btn" title="Send a file" aria-label="Send a file">${I.
|
|
236
|
-
|
|
209
|
+
<button type="button" class="btn ghost icon" id="attach-btn" title="Send a file" aria-label="Send a file">${I.clip}</button>
|
|
210
|
+
${sum()?.workspace ? `<button type="button" class="btn ghost icon" data-attach-workspace title="Attach from workspace" aria-label="Attach from workspace">${I.folder}</button>` : ''}
|
|
237
211
|
<input type="file" id="file-input" multiple hidden>
|
|
238
212
|
<textarea id="msg-input" rows="1" placeholder="Message everyone…"></textarea>
|
|
239
213
|
<button type="submit" class="btn primary icon" id="send-btn" title="Send" aria-label="Send">${I.send}</button>
|
|
@@ -242,36 +216,9 @@ export function mountSession (id) {
|
|
|
242
216
|
</aside>
|
|
243
217
|
<div class="scrim" id="scrim"></div>
|
|
244
218
|
</div>
|
|
245
|
-
</div>
|
|
246
219
|
</div>${firstVisit ? `<div class="sv-loading" id="sv-loading">${loadingHtml({ label: 'Loading session', name: sum()?.status?.sessionName || basename(sum()?.dir || '') })}</div>` : ''}`
|
|
247
220
|
|
|
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 }
|
|
250
221
|
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: () => openPage('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
|
-
})
|
|
275
222
|
mountCall(id, mounted.signal, () => {
|
|
276
223
|
const st = sum().status
|
|
277
224
|
const colors = new Map([...st.peers.map((p) => [p.name, p.color]), [st.me.name, st.me.color]])
|
|
@@ -281,7 +228,7 @@ export function mountSession (id) {
|
|
|
281
228
|
bindChanges(id, mounted.signal, { onOpen: (path) => openFile(path, { tab: 'changes' }), close: () => setGitOpen(false), onCount: renderGitChip })
|
|
282
229
|
bindCatchUp($('#catchup'), { sessionId: () => current, onOpen: openFile })
|
|
283
230
|
// Report a bug / Suggest a feature at the bottom of the Boxes pane (feedback.js): onto this session's board.
|
|
284
|
-
bindFeedback($('
|
|
231
|
+
bindFeedback($('.ws-boxes'), { session: () => current, where: () => state.sessions.get(current)?.status?.sessionName || 'a session' })
|
|
285
232
|
bindSquareCard()
|
|
286
233
|
bindMain()
|
|
287
234
|
bindTreeEvents()
|
|
@@ -487,65 +434,16 @@ function bindTop () {
|
|
|
487
434
|
})
|
|
488
435
|
}
|
|
489
436
|
bindBranchMenu()
|
|
490
|
-
bindMenu($('#sess-btn'), $('#sess-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings(); if (e.target.closest('[data-
|
|
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
|
-
// Escape closes it wherever the focus is, as a click elsewhere does.
|
|
515
|
-
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !pop.hidden) { set(false); bell.focus() } }, { signal: mounted.signal })
|
|
516
|
-
// The access picker's list opens outside the panel: picking from it keeps the panel open.
|
|
517
|
-
document.addEventListener('mousedown', (e) => { if (!e.target.closest('.sh-notes, [role=listbox], .dd-list, .dd-menu')) set(false) }, { signal: mounted.signal })
|
|
518
|
-
let seen = new Set()
|
|
519
|
-
const sync = () => {
|
|
520
|
-
const forms = [...req.querySelectorAll('.request')]
|
|
521
|
-
badge.hidden = !forms.length
|
|
522
|
-
badge.textContent = String(forms.length)
|
|
523
|
-
pop.querySelector('.sh-notes-empty').hidden = !!forms.length
|
|
524
|
-
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.`)
|
|
525
|
-
seen = new Set(forms.map((f) => f.dataset.key))
|
|
526
|
-
}
|
|
527
|
-
new MutationObserver(sync).observe(req, { childList: true })
|
|
528
|
-
sync()
|
|
529
|
-
}
|
|
530
|
-
// Who is here, at the right of the bar. The session's own actions are in Session settings → General.
|
|
531
|
-
if (wbTools) wbTools.appendChild($('#people'))
|
|
532
|
-
const foot = $('#rail-foot')
|
|
533
|
-
if (foot) {
|
|
534
|
-
foot.innerHTML = `<button type="button" class="rail-btn" data-side-settings title="Settings" aria-label="Settings">${I.gear}</button>`
|
|
535
|
-
const you = $('.ws-top .overflow.you')
|
|
536
|
-
if (you) foot.appendChild(you)
|
|
537
|
-
foot.querySelector('[data-side-settings]').onclick = () => $('#settings-btn')?.click()
|
|
538
|
-
}
|
|
437
|
+
bindMenu($('#sess-btn'), $('#sess-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings(); if (e.target.closest('[data-gather-rules]')) openGatherRules() })
|
|
539
438
|
bindMenu($('#you-btn'), $('#you-menu'), (e) => { if (e.target.closest('[data-session-settings]')) openSessionSettings() })
|
|
540
439
|
const wrap = $('#people')
|
|
541
440
|
const btn = $('#people-btn')
|
|
542
441
|
const menu = $('#people-menu')
|
|
543
442
|
const open = () => { menu.hidden = false; btn.setAttribute('aria-expanded', 'true'); renderPeopleMenu() }
|
|
544
443
|
const close = () => { menu.hidden = true; btn.setAttribute('aria-expanded', 'false') }
|
|
545
|
-
|
|
546
|
-
btn.onclick = () => openPage('people')
|
|
444
|
+
btn.onclick = () => (menu.hidden ? open() : close())
|
|
547
445
|
wrap.addEventListener('keydown', (e) => { if (e.key === 'Escape') { close(); btn.focus() } })
|
|
548
|
-
document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target)
|
|
446
|
+
document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target)) close() }, { signal: mounted.signal })
|
|
549
447
|
|
|
550
448
|
menu.addEventListener('click', async (e) => {
|
|
551
449
|
if (e.target.closest('[data-session-settings]')) { openSessionSettings(); return }
|
|
@@ -582,7 +480,7 @@ function bindTop () {
|
|
|
582
480
|
})
|
|
583
481
|
|
|
584
482
|
$('#toggle-tree').onclick = () => toggleDrawer('tree')
|
|
585
|
-
$('#connections-btn').onclick = () =>
|
|
483
|
+
$('#connections-btn').onclick = () => openSessionSettings('connections')
|
|
586
484
|
$('#toggle-chat').onclick = () => { toggleDrawer('chat'); $('#chat-badge').hidden = true }
|
|
587
485
|
$('#scrim').onclick = () => toggleDrawer(null)
|
|
588
486
|
}
|
|
@@ -807,13 +705,9 @@ function renderTop () {
|
|
|
807
705
|
label.innerHTML = ''
|
|
808
706
|
}
|
|
809
707
|
const people = [st.me, ...peopleHere(st)]
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
const others = people.filter((p) => p !== st.me)
|
|
814
|
-
const shown = [...busy.filter((p) => p !== st.me), ...others.filter((p) => !busy.includes(p))].slice(0, 4)
|
|
815
|
-
$('#people-btn').closest('.people-pill').hidden = !others.length && !busy.length
|
|
816
|
-
$('#people-btn').innerHTML = `${shown.length ? `<span class="stack">${shown.map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>` : ''}${others.length > shown.length ? `<span class="wb-more">+${others.length - shown.length}</span>` : ''}${busy.length ? `<i class="wb-working"><span class="pulse"></span>${busy.length} working</i>` : ''}`
|
|
708
|
+
const shown = people.slice(0, 4)
|
|
709
|
+
$('#people-btn').innerHTML = `<span class="stack">${shown.map((p, i) => `<span style="z-index:${10 - i}">${avatar(p.name, p.color)}</span>`).join('')}</span>
|
|
710
|
+
<span class="count">${people.length}</span>`
|
|
817
711
|
$('#people-btn').setAttribute('aria-label', `${people.length} ${people.length === 1 ? 'person' : 'people'} in this session${st.connected ? '' : ', reconnecting'}`)
|
|
818
712
|
// Why we're offline, when we know: otherwise "Reconnecting…" can go on silently forever.
|
|
819
713
|
const problem = $('#relay-problem')
|
|
@@ -828,7 +722,7 @@ function renderTop () {
|
|
|
828
722
|
renderCatchUp($('#catchup'), st.catchUp, { colors: new Map([st.me, ...st.peers].map((p) => [p.name, p.color])) })
|
|
829
723
|
renderSquareCard()
|
|
830
724
|
renderGitChip()
|
|
831
|
-
$('#sess-name').textContent =
|
|
725
|
+
$('#sess-name').textContent = st.sessionName || basename(sum().dir)
|
|
832
726
|
const me = state.account || {}
|
|
833
727
|
$('#you-btn').innerHTML = avatar(st.me.name, st.me.color)
|
|
834
728
|
$('#you-btn').setAttribute('aria-label', `${st.me.name}: settings`)
|
|
@@ -999,7 +893,7 @@ function renderAccess () {
|
|
|
999
893
|
${avatar(p.name, null)}
|
|
1000
894
|
<div class="rq-main"><b>${esc(p.name)}</b>${p.kind === 'agent' ? `<span class="tag bot">${I.bot}agent</span>` : ''}
|
|
1001
895
|
<span class="hint">wants to join · invited to ${p.invitedAs === 'viewer' ? 'view' : 'edit'}</span></div>
|
|
1002
|
-
|
|
896
|
+
${asType
|
|
1003
897
|
? `<select class="input" name="typeId" aria-label="Let ${esc(p.name)} in as" title="What they may do: an access type">${typeOptions()}</select>`
|
|
1004
898
|
: `<select class="input" name="role" aria-label="Role for ${esc(p.name)}">
|
|
1005
899
|
<option value="editor" ${p.invitedAs !== 'viewer' ? 'selected' : ''}>Can edit</option>
|
|
@@ -1007,7 +901,7 @@ function renderAccess () {
|
|
|
1007
901
|
</select>
|
|
1008
902
|
${p.kind === 'agent' ? `<input class="input" name="scopes" placeholder="All folders (or e.g. src, docs)" aria-label="Folders ${esc(p.name)} may change" title="Folders this agent may change, separated by commas">` : ''}`}
|
|
1009
903
|
<button type="button" class="btn sm ghost" data-deny>Deny</button>
|
|
1010
|
-
<button type="submit" class="btn sm primary">Let in</button
|
|
904
|
+
<button type="submit" class="btn sm primary">Let in</button>
|
|
1011
905
|
</form>`).join('')
|
|
1012
906
|
}
|
|
1013
907
|
|
|
@@ -1118,41 +1012,6 @@ function membersHtml (st, kind = 'people') {
|
|
|
1118
1012
|
<div class="pm-foot"><button type="button" class="btn sm ghost danger" data-end-session>End session for everyone</button></div>`
|
|
1119
1013
|
}
|
|
1120
1014
|
|
|
1121
|
-
/**
|
|
1122
|
-
* People in Session settings: everyone in the session and their access, and Invite. Settings only: messaging
|
|
1123
|
-
* people and what they are working on are in the chat and its cards, not here.
|
|
1124
|
-
*/
|
|
1125
|
-
function peopleSettingsHtml (st) {
|
|
1126
|
-
const acc = st.access || {}
|
|
1127
|
-
const members = new Map((st.members || []).filter((m) => !isAgentMember(m) && !m.chat).map((m) => [m.name, m]))
|
|
1128
|
-
const names = [...new Set([st.me.name, ...st.peers.filter((p) => p.kind !== 'agent').map((p) => p.name), ...members.keys()])]
|
|
1129
|
-
const rows = names.map((name) => {
|
|
1130
|
-
const m = members.get(name)
|
|
1131
|
-
const p = personInfo(name)
|
|
1132
|
-
const role = m ? m.role : name === st.me.name && acc.owner ? 'owner' : 'editor'
|
|
1133
|
-
const tools = toolsOf(p).map((t) => `<span class="tag">${esc(t)}</span>`).join('')
|
|
1134
|
-
const access = acc.owner && m && m.role !== 'owner'
|
|
1135
|
-
? `<form class="pm-member edit ps-access" data-key="${esc(m.key)}"><span class="nm" hidden>${esc(name)}</span>
|
|
1136
|
-
<select class="input" name="role" aria-label="Access for ${esc(name)}">
|
|
1137
|
-
<option value="editor" ${role === 'editor' ? 'selected' : ''}>Can edit</option>
|
|
1138
|
-
<option value="viewer" ${role === 'viewer' ? 'selected' : ''}>View only</option>
|
|
1139
|
-
</select>
|
|
1140
|
-
<button type="button" class="btn sm ghost icon" data-remove title="Remove ${esc(name)}" aria-label="Remove ${esc(name)}">${I.x}</button>
|
|
1141
|
-
</form>`
|
|
1142
|
-
: `<span class="ps-role">${roleLabel(role)}</span>`
|
|
1143
|
-
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>`
|
|
1144
|
-
}).join('')
|
|
1145
|
-
const admitBy = st.admitBy || acc.admitBy || 'owner'
|
|
1146
|
-
const admit = acc.owner && acc.controlled
|
|
1147
|
-
? `<label class="ps-setting"><span><b>Who can let people in</b><small>When someone opens an invite link, who approves them.</small></span>
|
|
1148
|
-
<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>`
|
|
1149
|
-
: !acc.controlled ? '<p class="ps-note">Anyone with the invite link can join this session.</p>' : ''
|
|
1150
|
-
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>
|
|
1151
|
-
<div class="ps-list">${rows}</div>
|
|
1152
|
-
${admit}
|
|
1153
|
-
${acc.owner ? '<div class="pm-foot"><button type="button" class="btn sm ghost danger" data-end-session>End session for everyone</button></div>' : ''}`
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
1015
|
/** With workspaces on, the agents this session's workspace invites (and the ones not invited), for its People. */
|
|
1157
1016
|
async function loadSessionAgents () {
|
|
1158
1017
|
const id = current
|
|
@@ -1377,278 +1236,26 @@ function renderPeopleMenu () {
|
|
|
1377
1236
|
* they are changing that aren't in everyone's folder yet. A dashed line divides people; each one's
|
|
1378
1237
|
* files stay folded until their boxes are clicked, and a click on a file shows its change in place.
|
|
1379
1238
|
*/
|
|
1380
|
-
// The left panel: the workspace's sessions, its shared files, the agents at work and the people here
|
|
1381
|
-
// (in place of the boxes). Sessions are the ones open on this computer; a click switches to one.
|
|
1382
|
-
const sideFiles = { id: null, list: null, loading: false }
|
|
1383
|
-
function loadSideFiles (wsId) {
|
|
1384
|
-
if (!wsId || sideFiles.loading || sideFiles.id === wsId) return
|
|
1385
|
-
sideFiles.loading = true
|
|
1386
|
-
api('GET', `/api/workspaces/${encodeURIComponent(wsId)}/files`)
|
|
1387
|
-
.then((r) => { sideFiles.list = r.files || [] })
|
|
1388
|
-
.catch(() => { sideFiles.list = [] })
|
|
1389
|
-
.finally(() => { sideFiles.id = wsId; sideFiles.loading = false; renderBoxesSide() })
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
// Above the chat, in the main area: a card for each person whose AI is working, with what it's on
|
|
1393
|
-
// and a stitching needle; everyone else folds into one card of avatars. A card opens that AI's chat.
|
|
1394
|
-
// The session's header, over the main area: its name, repo and branch, who is working, the
|
|
1395
|
-
// Chat / Tasks / Code / Calls tabs and who is in it.
|
|
1396
|
-
function renderSessHead () {
|
|
1397
|
-
const el = $('#sess-head')
|
|
1398
|
-
const s = current && sum()
|
|
1399
|
-
if (!el || !s) return
|
|
1400
|
-
const st = s.status
|
|
1401
|
-
const w = ws(current)
|
|
1402
|
-
// The workspace's pages (Home, Files, People, Connections) are the workspace's, not this session's: no session bar (dm06).
|
|
1403
|
-
el.closest('.sess-bar')?.classList.toggle('off', PAGES.includes(w.mode) && !!s.workspace)
|
|
1404
|
-
const working = [st.me, ...st.peers].filter((p) => p && p.agent && p.agent.status === 'working').length
|
|
1405
|
-
const repo = (st.quilt && (st.quilt.slug || st.quilt.name)) || basename(s.dir)
|
|
1406
|
-
// A folder without git has no branch (the session calls it ∅): then the chip is just the repo.
|
|
1407
|
-
const raw = (inSeam(st) && seamChip(st)?.label) || st.branch || ''
|
|
1408
|
-
const branch = /^[\w./@+-]+$/.test(raw) ? raw : ''
|
|
1409
|
-
// Home, Files and People are pages over the session: its tab stays lit (the one you came from).
|
|
1410
|
-
const shown = PAGES.includes(w.mode) ? w.pageBack : w.mode
|
|
1411
|
-
const on = shown === 'tasks' ? 'tasks' : shown === 'files' ? 'code' : shown === 'preview' ? 'preview' : shown === 'calls' ? 'calls' : 'chat'
|
|
1412
|
-
const tab = (k, label) => `<button type="button" class="sh-tab${on === k ? ' on' : ''}" data-sh-tab="${k}">${label}</button>`
|
|
1413
|
-
const nBranches = inSeam(st) ? Object.keys(st.squares || {}).length : 0
|
|
1414
|
-
// The session's name is in the bar above (renderWbar): here, its repo and branch.
|
|
1415
|
-
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>`
|
|
1416
|
-
const html = `${sc}
|
|
1417
|
-
${working ? `<span class="sh-live"><span class="pulse"></span>${working} working</span>` : ''}
|
|
1418
|
-
<span class="sh-sp"></span>
|
|
1419
|
-
<div class="sh-tabs" role="tablist">${tab('chat', 'Loom')}${tab('tasks', 'Tasks')}${tab('code', 'Code')}${tab('preview', 'Preview')}</div>
|
|
1420
|
-
<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>`
|
|
1421
|
-
if (el.dataset.html === html) return
|
|
1422
|
-
el.innerHTML = html
|
|
1423
|
-
el.dataset.html = html
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
const stripAsked = new Set()
|
|
1427
|
-
function renderWorkStrip () {
|
|
1428
|
-
const el = $('#work-strip')
|
|
1429
|
-
const s = current && sum()
|
|
1430
|
-
if (!el || !s) return
|
|
1431
|
-
const st = s.status
|
|
1432
|
-
const everyone = [{ ...st.me, isMe: true, online: st.connected }, ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true }))]
|
|
1433
|
-
const live = (p) => p.agent && p.agent.status === 'working'
|
|
1434
|
-
const working = everyone.filter(live)
|
|
1435
|
-
const quiet = everyone.filter((p) => !live(p))
|
|
1436
|
-
const what = (p) => p.focus || (p.editing && p.editing[0] ? `Editing ${basename(p.editing[0].path)}` : '') || 'Working'
|
|
1437
|
-
// A person's lanes are their AI's conversations: one needle each, sewing while that one is active.
|
|
1438
|
-
const feeds = state.feeds.get(current) || new Map()
|
|
1439
|
-
const who = owners(s)
|
|
1440
|
-
// Feeds load when someone's AI tab opens; the cards need everyone's, so ask for the missing ones.
|
|
1441
|
-
for (const p of everyone) {
|
|
1442
|
-
const key = `${current}|${p.name}`
|
|
1443
|
-
if (feeds.has(p.name) || stripAsked.has(key)) continue
|
|
1444
|
-
stripAsked.add(key) // once: a feed that can't load isn't asked for again on every redraw
|
|
1445
|
-
loadFeed(p.name).then(() => renderWorkStrip())
|
|
1446
|
-
}
|
|
1447
|
-
const lanesOf = (name) => {
|
|
1448
|
-
const entries = []
|
|
1449
|
-
for (const [k, list] of feeds) if (k === name || who.get(k) === name) entries.push(...(list || []))
|
|
1450
|
-
return conversations(entries)
|
|
1451
|
-
}
|
|
1452
|
-
const ACTIVE_MS = 3 * 60 * 1000
|
|
1453
|
-
const needles = (p) => {
|
|
1454
|
-
const lanes = lanesOf(p.name).slice(0, 8)
|
|
1455
|
-
const list = lanes.length ? lanes : [{ label: 'AI', ts: Date.now() }]
|
|
1456
|
-
const one = (c, i) => {
|
|
1457
|
-
const sewing = Date.now() - (c.ts || 0) < ACTIVE_MS || (i === 0 && live(p))
|
|
1458
|
-
return `<span class="ws-needle${sewing ? '' : ' still'}" title="${esc(c.label || 'Conversation')}${sewing ? ' · working' : ''}">${'<i></i>'.repeat(8)}<i class="v"></i></span>`
|
|
1459
|
-
}
|
|
1460
|
-
return `<span class="wk-lanes">${list.map(one).join('')}</span>`
|
|
1461
|
-
}
|
|
1462
|
-
const card = (p) => {
|
|
1463
|
-
const info = personInfo(p.name)
|
|
1464
|
-
const c = info.color || p.color || colorFor(p.name)
|
|
1465
|
-
const tool = (p.agent && p.agent.tool) || toolsOf(p)[0] || 'AI'
|
|
1466
|
-
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">
|
|
1467
|
-
<span class="wk-head">${avatar(p.name, c, p.online)}<b>${esc(p.isMe ? 'You' : p.name)}</b><small>${esc(tool)}</small></span>
|
|
1468
|
-
<span class="wk-what">${esc(what(p))}</span>${needles(p)}</button>`
|
|
1469
|
-
}
|
|
1470
|
-
const quietCard = quiet.length ? `<div class="wk-card quiet"><span class="wk-head"><b>${quiet.length} quiet</b></span>
|
|
1471
|
-
<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>
|
|
1472
|
-
<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>` : ''
|
|
1473
|
-
const html = working.map(card).join('') + quietCard
|
|
1474
|
-
if (el.dataset.html === html) return
|
|
1475
|
-
el.innerHTML = html
|
|
1476
|
-
el.dataset.html = html
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
// The skinny rail on the far left: one tile per workspace (project), the one this session is in lit.
|
|
1480
|
-
// A tile opens that workspace's page; + goes Home, where a new one is made.
|
|
1481
|
-
let railLoading = false
|
|
1482
|
-
document.addEventListener('click', (e) => {
|
|
1483
|
-
const t = e.target.closest('[data-rail-ws]')
|
|
1484
|
-
if (t) go(t.dataset.railWs ? `ws:${t.dataset.railWs}` : 'home')
|
|
1485
|
-
if (e.target.closest('[data-sh-sc]')) { openSessionSettings('vc'); return }
|
|
1486
|
-
const h = e.target.closest('[data-sh-tab]')
|
|
1487
|
-
if (h) {
|
|
1488
|
-
const k = h.dataset.shTab
|
|
1489
|
-
const m = ws(current)
|
|
1490
|
-
if (k === 'chat') { openLoom(); setTimeout(renderWbar, 0) }
|
|
1491
|
-
if (k === 'tasks' && m.mode !== 'tasks') { m.mode = 'tasks'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
|
|
1492
|
-
if (k === 'code') { m.mode = 'files'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
|
|
1493
|
-
if (k === 'preview') { m.mode = 'preview'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
|
|
1494
|
-
if (k === 'calls') { m.mode = 'calls'; saveWs(current); renderMainBar(); renderMain(); renderTop(); setTimeout(renderWbar, 0) }
|
|
1495
|
-
setTimeout(renderSessHead, 0)
|
|
1496
|
-
return
|
|
1497
|
-
}
|
|
1498
|
-
const w = e.target.closest('.work-strip [data-person]')
|
|
1499
|
-
if (w) openPerson(w.dataset.person)
|
|
1500
|
-
})
|
|
1501
|
-
function renderWorkspaceRail () {
|
|
1502
|
-
const el = $('#rail-tiles')
|
|
1503
|
-
const s = current && sum()
|
|
1504
|
-
if (!el || !s) return
|
|
1505
|
-
if (state.workspaces == null && !railLoading) {
|
|
1506
|
-
railLoading = true
|
|
1507
|
-
api('GET', '/api/workspaces').then((r) => { state.workspaces = r.workspaces || [] }).catch(() => { state.workspaces = [] }).finally(() => { railLoading = false; renderWorkspaceRail() })
|
|
1508
|
-
}
|
|
1509
|
-
const tiles = (state.workspaces || []).map((w) => {
|
|
1510
|
-
const on = w.id === s.workspace
|
|
1511
|
-
const c = COLORS[w.color] || COLORS.lilac
|
|
1512
|
-
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>`
|
|
1513
|
-
}).join('')
|
|
1514
|
-
const html = `${tiles}<button type="button" class="rail-ws add" data-rail-ws="" title="New workspace" aria-label="New workspace">${I.plus}</button>`
|
|
1515
|
-
if (el.dataset.html === html) return
|
|
1516
|
-
el.innerHTML = html
|
|
1517
|
-
el.dataset.html = html
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
// The bar across the top (the dm06 layout): the workspace, its home, the session menu, Connections, Files,
|
|
1521
|
-
// notifications, who is here and the session's "…" menu. It does what the second sidebar did.
|
|
1522
|
-
const working = (st) => (st.peers || []).filter((p) => p.agent && p.agent.status === 'working').length + (st.me?.agent?.status === 'working' ? 1 : 0)
|
|
1523
|
-
const workingFaces = (st) => [st.me, ...(st.peers || [])].filter((p) => p && p.agent && p.agent.status === 'working')
|
|
1524
|
-
function facesHtml (list, max = 3) {
|
|
1525
|
-
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>`
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
function bindWbar () {
|
|
1529
|
-
const bar = $('#wbar')
|
|
1530
|
-
if (!bar) return
|
|
1531
|
-
const tools = $('#wb-tools')
|
|
1532
|
-
tools.insertAdjacentHTML('beforeend', `<button type="button" class="wb-btn" id="wb-files" title="The workspace's shared files">${I.folder}<span>Files</span></button>`)
|
|
1533
|
-
const conn = $('#connections-btn')
|
|
1534
|
-
if (conn) { conn.className = 'wb-btn conn-btn'; tools.prepend(conn) }
|
|
1535
|
-
// Home is the workspace's home inside this window (dm06), a toggle like Files.
|
|
1536
|
-
$('#wb-home').onclick = () => { if (!sum()?.workspace) go('home'); else openPage('home') }
|
|
1537
|
-
// Files is a page of this session's window (dm06): a second click goes back to where you were.
|
|
1538
|
-
$('#wb-files').onclick = () => {
|
|
1539
|
-
if (!sum()?.workspace) { toast('Files are shared in a workspace. Move this session into one first.'); return }
|
|
1540
|
-
openPage('wsfiles')
|
|
1541
|
-
}
|
|
1542
|
-
const btn = $('#wb-sessbtn')
|
|
1543
|
-
const menu = $('#wb-sessmenu')
|
|
1544
|
-
const set = (open) => { menu.hidden = !open; btn.setAttribute('aria-expanded', String(open)); if (open) renderWbar() }
|
|
1545
|
-
btn.onclick = () => set(menu.hidden)
|
|
1546
|
-
menu.addEventListener('click', (e) => {
|
|
1547
|
-
if (e.target.closest('[data-wb-new]')) { set(false); go('home'); return }
|
|
1548
|
-
if (e.target.closest('[data-wb-settings]')) { set(false); openSessionSettings('general'); return }
|
|
1549
|
-
if (e.target.closest('[data-wb-invite]')) { set(false); openInvite(current); return }
|
|
1550
|
-
const r = e.target.closest('[data-wb-go]')
|
|
1551
|
-
if (r) { set(false); if (r.dataset.wbGo !== current) go(r.dataset.wbGo); else backToSession() }
|
|
1552
|
-
})
|
|
1553
|
-
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { set(false); btn.focus() } }, { signal: mounted.signal })
|
|
1554
|
-
document.addEventListener('mousedown', (e) => { if (!e.target.closest('#wb-sess')) set(false) }, { signal: mounted.signal })
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
function renderWbar () {
|
|
1558
|
-
const s = current && sum()
|
|
1559
|
-
if (!s || !$('#wbar')) return
|
|
1560
|
-
const st = s.status
|
|
1561
|
-
const wsInfo = (state.workspaces || []).find((w) => w.id === s.workspace)
|
|
1562
|
-
const kind = wsInfo ? (wsInfo.space?.kind === 'org' ? (wsInfo.space.name || 'Team') : 'Personal') : 'Not in a workspace'
|
|
1563
|
-
const nameHtml = `<b>${esc(wsInfo?.name || st.sessionName || basename(s.dir))}</b><small>${esc(kind)}</small>`
|
|
1564
|
-
const nm = $('#wb-name')
|
|
1565
|
-
if (nm.dataset.html !== nameHtml) { nm.innerHTML = nameHtml; nm.dataset.html = nameHtml }
|
|
1566
|
-
const n = working(st)
|
|
1567
|
-
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}`
|
|
1568
|
-
const btn = $('#wb-sessbtn')
|
|
1569
|
-
if (btn.dataset.html !== btnHtml) { btn.innerHTML = btnHtml; btn.dataset.html = btnHtml }
|
|
1570
|
-
const menu = $('#wb-sessmenu')
|
|
1571
|
-
if (!menu.hidden) {
|
|
1572
|
-
const rows = [...state.sessions.values()].map((x) => {
|
|
1573
|
-
const k = working(x.status)
|
|
1574
|
-
const unread = x.status.unread && x.id !== current ? `<span class="badge">${x.status.unread}</span>` : ''
|
|
1575
|
-
return `<button type="button" class="wb-srow${x.id === current ? ' on' : ''}${k ? '' : ' quiet'}" role="menuitem" data-wb-go="${esc(x.id)}" title="${esc(x.dir)}"><span class="wb-hico">${I.grid}</span><span class="wb-sname"><b>${esc(x.status.sessionName || basename(x.dir))}</b><small${k ? ' class="live"' : ''}>${k ? `<span class="pulse"></span>${k} working` : x.status.connected ? 'Quiet' : 'Not connected'}</small></span>${facesHtml(workingFaces(x.status))}${unread}</button>`
|
|
1576
|
-
}).join('')
|
|
1577
|
-
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>'}
|
|
1578
|
-
<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>`
|
|
1579
|
-
if (menu.dataset.html !== html) { menu.innerHTML = html; menu.dataset.html = html }
|
|
1580
|
-
}
|
|
1581
|
-
// Files is lit while its page is open.
|
|
1582
|
-
$('#wb-files')?.classList.toggle('on', ws(current).mode === 'wsfiles')
|
|
1583
|
-
$('#wb-home')?.classList.toggle('on', ws(current).mode === 'home')
|
|
1584
|
-
$('#connections-btn')?.classList.toggle('on', ws(current).mode === 'connections')
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
1239
|
function renderBoxesSide () {
|
|
1588
1240
|
const el = $('#boxes-side')
|
|
1589
1241
|
const s = current && sum()
|
|
1590
1242
|
if (!el || !s) return
|
|
1591
|
-
renderWorkStrip()
|
|
1592
|
-
renderSessHead()
|
|
1593
|
-
renderWorkspaceRail()
|
|
1594
|
-
renderWbar()
|
|
1595
1243
|
const st = s.status
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1600
|
-
|
|
1244
|
+
const { selfRow, myAiRow, otherRows, awayRows } = peopleRows(st, { fold: true })
|
|
1245
|
+
// In Seam there are no boxes (every edit is live in its square): the pane shows the squares and who is on each.
|
|
1246
|
+
const seam = inSeam(st)
|
|
1247
|
+
const title = el.closest('.ws-boxes')?.querySelector('.pane-title')
|
|
1248
|
+
if (title) title.textContent = seam ? 'Squares' : 'Boxes'
|
|
1249
|
+
el.closest('.ws-boxes')?.setAttribute('aria-label', seam ? 'Squares: who is on which, and what is not committed' : 'Boxes: who is working on what')
|
|
1250
|
+
const n = seam ? 0 : boxView.data.boxes.length
|
|
1601
1251
|
const count = $('#box-count')
|
|
1602
|
-
if (count) { count.textContent = ''; count.title = '' }
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
const meta = n ? `<span class="sp-live"><span class="pulse"></span>${n}</span>` : unread
|
|
1610
|
-
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>`
|
|
1611
|
-
}).join('')
|
|
1612
|
-
const files = sideFiles.list
|
|
1613
|
-
const filesHtml = !s.workspace ? '<p class="sp-empty">Files are shared in a workspace. This session isn\'t in one.</p>'
|
|
1614
|
-
: files == null ? '<p class="sp-empty">Loading…</p>'
|
|
1615
|
-
: 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('')
|
|
1616
|
-
: '<p class="sp-empty">No shared files yet.</p>'
|
|
1617
|
-
const everyone = [{ ...st.me, isMe: true, online: st.connected }, ...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true }))]
|
|
1618
|
-
const what = (p) => p.focus || (p.editing && p.editing[0] ? `Editing ${p.editing[0].path}` : '') || (p.agent && p.agent.status === 'working' ? 'Working' : '')
|
|
1619
|
-
const personRow = (p) => {
|
|
1620
|
-
const info = personInfo(p.name)
|
|
1621
|
-
const live = p.agent && p.agent.status === 'working'
|
|
1622
|
-
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>`
|
|
1623
|
-
}
|
|
1624
|
-
const agents = everyone.filter((p) => p.kind === 'agent')
|
|
1625
|
-
const people = everyone.filter((p) => p.kind !== 'agent')
|
|
1626
|
-
const section = (name, body, n) => `<div class="sp-head">${name}${n != null ? `<span class="sp-n">${n}</span>` : ''}</div>${body}`
|
|
1627
|
-
// The workspace's name and who is in it at the top; sessions and files; then People and Agents as one line
|
|
1628
|
-
// each (who's here and what they're on is in the cards over the chat).
|
|
1629
|
-
const kind = wsInfo?.space?.kind === 'org' ? (wsInfo.space.name || 'Org') : wsInfo ? 'Personal' : 'This computer'
|
|
1630
|
-
const plus = (attr, label) => `<button type="button" class="sp-plus" ${attr} title="${label}" aria-label="${label}">${I.plus}</button>`
|
|
1631
|
-
const head = (name, extra = '') => `<div class="sp-head">${name}${extra}</div>`
|
|
1632
|
-
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>`
|
|
1633
|
-
const html =
|
|
1634
|
-
head('Sessions', plus('data-side-new', 'New session')) + (sessions || '<p class="sp-empty">No sessions open.</p>') +
|
|
1635
|
-
head('Files', s.workspace ? plus('data-side-files', 'All files') : '') + filesHtml +
|
|
1636
|
-
`<div class="sp-sep"></div>
|
|
1637
|
-
<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>
|
|
1638
|
-
<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>`
|
|
1639
|
-
// Folded, the same pane is a column of icons: each session, then files, agents and people.
|
|
1640
|
-
const mini = $('#side-mini')
|
|
1641
|
-
if (mini) {
|
|
1642
|
-
const sess = [...state.sessions.values()].map((x) => {
|
|
1643
|
-
const name = x.status.sessionName || basename(x.dir)
|
|
1644
|
-
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>`
|
|
1645
|
-
}).join('')
|
|
1646
|
-
const miniHtml = sess + '<span class="mini-sep"></span>' +
|
|
1647
|
-
(s.workspace ? `<button type="button" class="mini-btn" data-side-files title="Files" aria-label="Files">${I.folder}</button>` : '') +
|
|
1648
|
-
`<button type="button" class="mini-btn" data-side-people="agents" title="Agents" aria-label="Agents">${I.bot}</button>` +
|
|
1649
|
-
`<button type="button" class="mini-btn" data-side-people="people" title="People" aria-label="People">${I.users}</button>`
|
|
1650
|
-
if (mini.dataset.html !== miniHtml) { mini.innerHTML = miniHtml; mini.dataset.html = miniHtml }
|
|
1651
|
-
}
|
|
1252
|
+
if (count) { count.textContent = n ? String(n) : ''; count.title = n ? `${n} file${n === 1 ? '' : 's'} boxed: changed, not in everyone's folder yet` : '' }
|
|
1253
|
+
const html = `${seam ? squaresSideHtml(st) : ''}<div class="pm-list bs-list">
|
|
1254
|
+
${selfRow}${myAiRow}
|
|
1255
|
+
${otherRows}
|
|
1256
|
+
${awayRows.length ? `<div class="pm-sep"></div><div class="bs-head">Away</div>${awayRows.join('')}` : ''}
|
|
1257
|
+
</div>
|
|
1258
|
+
<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>`
|
|
1652
1259
|
if (el.dataset.html === html) return
|
|
1653
1260
|
const top = el.scrollTop
|
|
1654
1261
|
el.innerHTML = html
|
|
@@ -1656,21 +1263,6 @@ function renderBoxesSide () {
|
|
|
1656
1263
|
el.scrollTop = top
|
|
1657
1264
|
}
|
|
1658
1265
|
|
|
1659
|
-
/** Session settings → General: the session's name, its workspace, inviting, one set of AI rules, and leaving it. */
|
|
1660
|
-
function generalSettingsHtml (st) {
|
|
1661
|
-
const owner = !!st.access?.owner
|
|
1662
|
-
const wsName = (state.workspaces || []).find((w) => w.id === sum().workspace)?.name || ''
|
|
1663
|
-
const canMove = owner && state.workspacesOn && (state.workspaces || []).some((w) => w.access === 'edit')
|
|
1664
|
-
const row = (title, sub, action) => `<div class="ss-row"><span><b>${title}</b><small>${sub}</small></span>${action}</div>`
|
|
1665
|
-
return `<div class="pm-section ss-general">
|
|
1666
|
-
${row('Name', esc(st.sessionName || basename(sum().dir)), owner ? '<button type="button" class="btn sm" data-ss-rename>Rename…</button>' : '')}
|
|
1667
|
-
${row('Workspace', esc(wsName || 'Not in a workspace'), canMove ? '<button type="button" class="btn sm" data-ss-move>Move…</button>' : '')}
|
|
1668
|
-
${row('Invite people', 'Send a link to someone, or to an agent', '<button type="button" class="btn sm" data-ss-invite-people>Invite…</button>')}
|
|
1669
|
-
${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>')}
|
|
1670
|
-
${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>')}
|
|
1671
|
-
</div>`
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
1266
|
/** Your AI chat's sharing in this session: two plain switches. */
|
|
1675
1267
|
function sharingHtml (st) {
|
|
1676
1268
|
const a = st.me.agent || {}
|
|
@@ -1731,8 +1323,6 @@ async function openGatherRules () {
|
|
|
1731
1323
|
|
|
1732
1324
|
// Session settings: one window, a section at a time, picked from the list on its left.
|
|
1733
1325
|
const SS_TABS = [
|
|
1734
|
-
// The session's own actions (what the bar's "…" menu held): its name, workspace, invite, AI rules, leaving.
|
|
1735
|
-
{ id: 'general', label: 'General', icon: 'gear' },
|
|
1736
1326
|
{ id: 'chat', label: 'Your AI chat', icon: 'chat' },
|
|
1737
1327
|
{ id: 'vc', label: 'Version control', icon: 'branch' },
|
|
1738
1328
|
{ id: 'agents', label: 'Agents', icon: 'bot' },
|
|
@@ -1740,97 +1330,15 @@ const SS_TABS = [
|
|
|
1740
1330
|
// Secrets (secrets.js): only once the accounts API has them switched on.
|
|
1741
1331
|
{ id: 'secrets', label: 'Secrets', icon: 'lock', on: () => state.secretsOn },
|
|
1742
1332
|
// Apps agents use (connections.js): only once the accounts API has Composio's key.
|
|
1743
|
-
{ id: 'connections', label: 'Connections', icon: 'plug' }
|
|
1333
|
+
{ id: 'connections', label: 'Connections', icon: 'plug', on: () => state.connectionsOn }
|
|
1744
1334
|
]
|
|
1745
1335
|
const ssTabs = () => SS_TABS.filter((x) => !x.on || x.on())
|
|
1746
1336
|
// The Secrets tab's card while it is drawn: kept across redraws of the window, so a typed name isn't lost.
|
|
1747
1337
|
let ssSecrets = null
|
|
1748
1338
|
let ssConnections = null // the Connections tab's card while it is drawn
|
|
1749
|
-
let ssTab = '
|
|
1750
|
-
|
|
1751
|
-
// GitHub: every session's history is in Seam, and Seam connects to GitHub (through the Seam app on GitHub),
|
|
1752
|
-
// never Quilt. The card reads Seam's GitHub through the session (GET/POST /api/sessions/<id>/github).
|
|
1753
|
-
const ssGh = { id: null, data: undefined, err: '', pick: '', busy: false, loading: false }
|
|
1754
|
-
async function loadGithub (body) {
|
|
1755
|
-
const id = current
|
|
1756
|
-
ssGh.id = id
|
|
1757
|
-
ssGh.busy = !!body
|
|
1758
|
-
ssGh.loading = true
|
|
1759
|
-
if (!body) ssGh.data = undefined
|
|
1760
|
-
ssGh.err = ''
|
|
1761
|
-
renderSessionSettings({ force: true })
|
|
1762
|
-
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 }
|
|
1763
|
-
ssGh.busy = false
|
|
1764
|
-
ssGh.loading = false
|
|
1765
|
-
if (id === current) renderSessionSettings({ force: true })
|
|
1766
|
-
}
|
|
1767
|
-
function githubCardHtml () {
|
|
1768
|
-
const d = ssGh.id === current ? ssGh.data : undefined
|
|
1769
|
-
const card = (pill, body) => `<div class="pm-section gh-section"><div class="pm-title">GitHub</div><div class="pm-card git-card gh-card">
|
|
1770
|
-
<div class="git-head"><h4>${I.github}GitHub</h4>${pill ? `<span class="pill">${pill}</span>` : ''}</div>${body}
|
|
1771
|
-
${ssGh.err ? `<p class="git-line warn">${esc(ssGh.err)}</p>` : ''}</div></div>`
|
|
1772
|
-
if (d === undefined) return card('', `<p class="hint">${loadingNote('Asking Seam…')}</p>`)
|
|
1773
|
-
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>')
|
|
1774
|
-
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>')
|
|
1775
|
-
const g = d.github || {}
|
|
1776
|
-
if (!g.configured) return card('Not connected', '<p class="git-line">GitHub isn\'t set up on this Seam server.</p>')
|
|
1777
|
-
const on = d.export && d.export.enabled && /github\.com\//.test(d.export.target)
|
|
1778
|
-
const repoOf = (t) => String(t).replace(/^https:\/\/github\.com\//, '').replace(/\.git$/, '')
|
|
1779
|
-
if (on) {
|
|
1780
|
-
const repo = repoOf(d.export.target)
|
|
1781
|
-
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>
|
|
1782
|
-
<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>`)
|
|
1783
|
-
}
|
|
1784
|
-
const install = g.app && g.app.install_url
|
|
1785
|
-
const insts = g.installations || []
|
|
1786
|
-
if (!insts.length) {
|
|
1787
|
-
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>
|
|
1788
|
-
${install ? `<a class="btn primary gh-connect" href="${esc(install)}" target="_blank" rel="noopener">${I.github}Install the Seam app on GitHub</a>` : ''}
|
|
1789
|
-
<button type="button" class="btn gh-connect" data-gh-refresh>I've installed it</button>`)
|
|
1790
|
-
}
|
|
1791
|
-
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('')
|
|
1792
|
-
const any = insts.some((i) => (i.repos || []).length)
|
|
1793
|
-
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>
|
|
1794
|
-
${any ? `<label class="gh-field"><span>Repository</span><select class="input" data-gh-pick><option value="">Choose a repository</option>${opts}</select></label>
|
|
1795
|
-
<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>'}
|
|
1796
|
-
${install ? `<a class="gh-more" href="${esc(install)}" target="_blank" rel="noopener">Choose other repositories on GitHub</a>` : ''}`)
|
|
1797
|
-
}
|
|
1798
|
-
function bindGithubCard (box) {
|
|
1799
|
-
const card = box.querySelector('.gh-card')
|
|
1800
|
-
if (!card) return
|
|
1801
|
-
card.addEventListener('change', (e) => { if (e.target.matches('[data-gh-pick]')) { ssGh.pick = e.target.value; renderSessionSettings({ force: true }) } })
|
|
1802
|
-
card.addEventListener('click', async (e) => {
|
|
1803
|
-
if (e.target.closest('[data-gh-refresh]')) { loadGithub(); return }
|
|
1804
|
-
if (e.target.closest('[data-gh-connect]') && ssGh.pick) {
|
|
1805
|
-
const [installation, repo] = ssGh.pick.split('|')
|
|
1806
|
-
loadGithub({ repo, installation })
|
|
1807
|
-
return
|
|
1808
|
-
}
|
|
1809
|
-
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 })
|
|
1810
|
-
})
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
// People (who is here, and Invite) and source control (GitHub, changes) are shown in Session settings: their
|
|
1814
|
-
// live panels, drawn by the same code as before, move into its People and Version control tabs while shown.
|
|
1815
|
-
const ssMoved = []
|
|
1816
|
-
function ssPark () {
|
|
1817
|
-
while (ssMoved.length) {
|
|
1818
|
-
const [node, home] = ssMoved.pop()
|
|
1819
|
-
node.hidden = true
|
|
1820
|
-
node.classList.remove('in-ss')
|
|
1821
|
-
home.appendChild(node)
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function ssMount (where, node) {
|
|
1825
|
-
if (!where || !node) return
|
|
1826
|
-
ssMoved.push([node, node.parentElement])
|
|
1827
|
-
node.classList.add('in-ss')
|
|
1828
|
-
node.hidden = false
|
|
1829
|
-
where.appendChild(node)
|
|
1830
|
-
}
|
|
1339
|
+
let ssTab = 'chat'
|
|
1831
1340
|
|
|
1832
1341
|
function openSessionSettings (tab) {
|
|
1833
|
-
ssPark()
|
|
1834
1342
|
document.querySelector('.session-settings-back')?.remove()
|
|
1835
1343
|
$('#people-menu').hidden = true
|
|
1836
1344
|
$('#people-btn').setAttribute('aria-expanded', 'false')
|
|
@@ -1849,7 +1357,7 @@ function openSessionSettings (tab) {
|
|
|
1849
1357
|
</div>
|
|
1850
1358
|
</div>`
|
|
1851
1359
|
document.body.appendChild(back)
|
|
1852
|
-
const close = () =>
|
|
1360
|
+
const close = () => back.remove()
|
|
1853
1361
|
back.addEventListener('mousedown', (e) => { if (e.target === back) close() })
|
|
1854
1362
|
back.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.preventDefault(); close() } })
|
|
1855
1363
|
back.querySelector('[data-close-ss]').onclick = close
|
|
@@ -1898,7 +1406,6 @@ function renderSessionSettings ({ force = false } = {}) {
|
|
|
1898
1406
|
}
|
|
1899
1407
|
box.dataset.tab = ssTab
|
|
1900
1408
|
back.querySelector('.ss-name').textContent = (ssTabs().find((t) => t.id === ssTab) || ssTabs()[0]).label
|
|
1901
|
-
ssPark()
|
|
1902
1409
|
if (ssTab === 'secrets') {
|
|
1903
1410
|
const room = st.room
|
|
1904
1411
|
const mounted = box.querySelector(`[data-secrets-room="${CSS.escape(String(room || ''))}"]`)
|
|
@@ -1924,22 +1431,10 @@ function renderSessionSettings ({ force = false } = {}) {
|
|
|
1924
1431
|
if (!force && active && box.querySelector('.pm-member.edit')) return
|
|
1925
1432
|
const refocus = active && active.name ? [active.closest('.pm-member').dataset.key, active.name] : null
|
|
1926
1433
|
// 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).
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
: ssTab === 'vc' ?
|
|
1930
|
-
:
|
|
1931
|
-
if (ssTab === 'vc') {
|
|
1932
|
-
bindGithubCard(box)
|
|
1933
|
-
if (!ssGh.loading && (ssGh.id !== current || ssGh.data === undefined)) loadGithub()
|
|
1934
|
-
}
|
|
1935
|
-
if (ssTab === 'people') box.querySelector('[data-ss-invite]').onclick = () => openInvite(current)
|
|
1936
|
-
if (ssTab === 'general') {
|
|
1937
|
-
box.querySelector('[data-ss-rename]')?.addEventListener('click', renameSession)
|
|
1938
|
-
box.querySelector('[data-ss-move]')?.addEventListener('click', moveToWorkspace)
|
|
1939
|
-
box.querySelector('[data-ss-invite-people]').onclick = () => openInvite(current)
|
|
1940
|
-
box.querySelector('[data-ss-rules]').onclick = () => openGatherRules()
|
|
1941
|
-
box.querySelector('[data-ss-leave]').onclick = () => $('#leave-btn').click()
|
|
1942
|
-
}
|
|
1434
|
+
const vc = inSeam(st) ? seamSettingsHtml(st) : makeQuiltHtml(st)
|
|
1435
|
+
box.innerHTML = ssTab === 'chat' ? sharingHtml(st)
|
|
1436
|
+
: ssTab === 'vc' ? (vc || '<div class="pm-empty">Only the session owner sees where this session\'s history is.</div>')
|
|
1437
|
+
: membersHtml(st, ssTab)
|
|
1943
1438
|
if (refocus) [...box.querySelectorAll('.pm-member')].find((f) => f.dataset.key === refocus[0])?.elements?.[refocus[1]]?.focus()
|
|
1944
1439
|
}
|
|
1945
1440
|
|
|
@@ -1980,13 +1475,6 @@ function bindMain () {
|
|
|
1980
1475
|
}
|
|
1981
1476
|
})
|
|
1982
1477
|
$('#main').addEventListener('click', async (e) => {
|
|
1983
|
-
// A person's view: back to the loom, or their direct messages.
|
|
1984
|
-
if (e.target.closest('[data-pv-back]')) { openLoom(); return }
|
|
1985
|
-
const dai = e.target.closest('[data-dm-ai]')
|
|
1986
|
-
if (dai) { openPerson(dai.dataset.dmAi); return }
|
|
1987
|
-
if (e.target.closest('[data-dm-back]')) { const from = ws(current).dmFrom; if (from) openPerson(from); else openLoom(); return }
|
|
1988
|
-
const pdm = e.target.closest('[data-pv-dm]')
|
|
1989
|
-
if (pdm) { openDm(pdm.dataset.pvDm); return }
|
|
1990
1478
|
const copy = e.target.closest('[data-copy-invite]')
|
|
1991
1479
|
if (copy) {
|
|
1992
1480
|
const view = copy.dataset.copyInvite === 'view'
|
|
@@ -2026,26 +1514,17 @@ function bindMain () {
|
|
|
2026
1514
|
|
|
2027
1515
|
function openLoom () {
|
|
2028
1516
|
const w = ws(current)
|
|
2029
|
-
const back = w.mode === 'ai' && !!w.aiSel && !w.dmWith
|
|
2030
|
-
if ((w.aiSel || w.dmWith) && state.to) { state.to = ''; renderRecipients() }
|
|
2031
1517
|
w.aiSel = null
|
|
2032
|
-
w.dmWith = null
|
|
2033
1518
|
w.mode = 'ai'
|
|
2034
1519
|
saveWs(current)
|
|
2035
1520
|
renderMainBar()
|
|
2036
1521
|
renderMain()
|
|
2037
|
-
// Back from a person: the cards rise back into place.
|
|
2038
|
-
if (back) $('#main .loom')?.classList.add('rising')
|
|
2039
1522
|
renderTreePane()
|
|
2040
1523
|
renderTop()
|
|
2041
1524
|
}
|
|
2042
1525
|
|
|
2043
1526
|
function openPerson (name) {
|
|
2044
1527
|
const w = ws(current)
|
|
2045
|
-
// Their view's composer writes to them (yours: to everyone).
|
|
2046
|
-
state.to = name === sum()?.status.me.name ? '' : name
|
|
2047
|
-
renderRecipients()
|
|
2048
|
-
w.dmWith = null
|
|
2049
1528
|
if (!w.aiTabs.includes(name)) w.aiTabs.push(name)
|
|
2050
1529
|
w.aiSel = name
|
|
2051
1530
|
w.mode = 'ai'
|
|
@@ -2115,18 +1594,13 @@ function renderMainBar () {
|
|
|
2115
1594
|
<button class="x" data-kind="file" data-close="${esc(path)}" aria-label="Close ${esc(basename(path))}">${I.x}</button></div>`).join('') +
|
|
2116
1595
|
((w.searchTabs || []).length && !w.fileTabs.length ? '<span class="ws-tab-sep"></span>' : '') +
|
|
2117
1596
|
(w.searchTabs || []).map((q) => searchTabMarkup(q, w.mode === 'search' && w.searchSel === q)).join('')
|
|
2118
|
-
// In Code and search the row holds only their own tabs: people are reached from the loom (dm06).
|
|
2119
|
-
for (const t of el.querySelectorAll('[data-kind="loom"], [data-kind="ai"]')) t.remove()
|
|
2120
|
-
el.querySelector(':scope > .ws-tab-sep:first-child')?.remove()
|
|
2121
1597
|
// On Everyone with nothing else open, the row would only name the view you are in: hide it until
|
|
2122
1598
|
// there is a tab to switch to (or, on the Tasks board, Everyone to go back to).
|
|
2123
|
-
|
|
2124
|
-
$('#mainbar').hidden = !((w.mode === 'files' && w.fileTabs.length) || w.mode === 'search')
|
|
1599
|
+
$('#mainbar').hidden = loomOn && !w.aiTabs.length && !w.fileTabs.length && !(w.searchTabs || []).length
|
|
2125
1600
|
}
|
|
2126
1601
|
|
|
2127
1602
|
// A card being renamed, or a drag in progress, must not be rebuilt under the pointer.
|
|
2128
1603
|
let draggingTask = false
|
|
2129
|
-
const openTasks = new Set() // board cards opened to their controls
|
|
2130
1604
|
let boardDirty = false
|
|
2131
1605
|
// Who the next task is for, chosen before Add: `p:name`, `a:name`, or '' for nobody.
|
|
2132
1606
|
// null until chosen: the add form then follows the board's Show choice.
|
|
@@ -2155,10 +1629,7 @@ function taskPeople (st) {
|
|
|
2155
1629
|
name: p.name,
|
|
2156
1630
|
color: p.color,
|
|
2157
1631
|
tool: p.tool && p.tool !== 'unknown' ? p.tool : '',
|
|
2158
|
-
agent: p.kind === 'agent'
|
|
2159
|
-
// Working now, and since when: a card in progress says "Cursor working · 14m" (dm06).
|
|
2160
|
-
working: !!(p.agent && p.agent.status === 'working'),
|
|
2161
|
-
since: p.focusAt || 0
|
|
1632
|
+
agent: p.kind === 'agent'
|
|
2162
1633
|
}))
|
|
2163
1634
|
}
|
|
2164
1635
|
|
|
@@ -2676,14 +2147,8 @@ function bindBoard () {
|
|
|
2676
2147
|
catch (err) { toast(err.message) }
|
|
2677
2148
|
return
|
|
2678
2149
|
}
|
|
2679
|
-
// 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.
|
|
2680
|
-
const card = e.target.closest('.task')
|
|
2681
|
-
if (!card || e.target.closest('button, select, input, textarea, a, form')) return
|
|
2682
2150
|
const title = e.target.closest('.task-title')
|
|
2683
|
-
if (title
|
|
2684
|
-
if (openTasks.has(card.dataset.task)) openTasks.delete(card.dataset.task)
|
|
2685
|
-
else openTasks.add(card.dataset.task)
|
|
2686
|
-
card.classList.toggle('open', openTasks.has(card.dataset.task))
|
|
2151
|
+
if (title) beginEdit(title)
|
|
2687
2152
|
})
|
|
2688
2153
|
el.addEventListener('dragstart', (e) => {
|
|
2689
2154
|
const card = e.target.closest?.('.task')
|
|
@@ -2727,58 +2192,11 @@ function bindBoard () {
|
|
|
2727
2192
|
})
|
|
2728
2193
|
}
|
|
2729
2194
|
|
|
2730
|
-
// The session's chat sits in the main area where the Loom was, on the Everyone tab; any other tab
|
|
2731
|
-
// (an AI chat, a file, tasks, search) puts it back on the right. The pane is moved, not redrawn, so
|
|
2732
|
-
// what's typed and the scroll position stay.
|
|
2733
|
-
// The chat is a panel on the right of every session tab (Daniel, 2026-11-12), so the loom shows only the AIs' work;
|
|
2734
|
-
// it folds to a slim rail. The workspace's pages (Home, Files, People, Connections) have none.
|
|
2735
|
-
function placeChat () {
|
|
2736
|
-
const pane = $('#chat-pane')
|
|
2737
|
-
const body = $('#ws-body')
|
|
2738
|
-
if (!pane || !body || !current) return
|
|
2739
|
-
body.classList.remove('chat-in-main')
|
|
2740
|
-
body.classList.add('loom-chat')
|
|
2741
|
-
body.classList.toggle('chat-off', PAGES.includes(ws(current).mode))
|
|
2742
|
-
if (pane.parentElement !== body) body.insertBefore(pane, $('#scrim'))
|
|
2743
|
-
}
|
|
2744
|
-
|
|
2745
|
-
// The Code tab: the session's repo (a session is one repo) as a file tree, beside the file that's open.
|
|
2746
|
-
function codeShell (el) {
|
|
2747
|
-
let shell = el.querySelector(':scope > .code-view')
|
|
2748
|
-
if (!shell) {
|
|
2749
|
-
el.innerHTML = '<div class="code-view"><nav class="code-tree" aria-label="Files"></nav><div class="code-file"></div></div>'
|
|
2750
|
-
shell = el.firstElementChild
|
|
2751
|
-
}
|
|
2752
|
-
const w = ws(current)
|
|
2753
|
-
renderTree(shell.querySelector('.code-tree'), state.trees.get(current), { me: me(), expanded: w.codeOpen || {}, selected: w.fileSel })
|
|
2754
|
-
return shell.querySelector('.code-file')
|
|
2755
|
-
}
|
|
2756
|
-
document.addEventListener('click', (e) => {
|
|
2757
|
-
const tree = e.target.closest('.code-tree')
|
|
2758
|
-
if (!tree || !current) return
|
|
2759
|
-
const changes = e.target.closest('[data-changes]')
|
|
2760
|
-
if (changes) { openFile(changes.dataset.changes, { tab: 'changes' }); return }
|
|
2761
|
-
if (e.target.closest('[data-more]')) return
|
|
2762
|
-
const dir = e.target.closest('[data-dir]')
|
|
2763
|
-
if (dir) {
|
|
2764
|
-
const w = ws(current)
|
|
2765
|
-
w.codeOpen = { ...(w.codeOpen || {}), [dir.dataset.dir]: dir.getAttribute('aria-expanded') !== 'true' }
|
|
2766
|
-
saveWs(current)
|
|
2767
|
-
codeShell($('#main'))
|
|
2768
|
-
return
|
|
2769
|
-
}
|
|
2770
|
-
const file = e.target.closest('[data-file]')
|
|
2771
|
-
if (file) openFile(file.dataset.file, { tab: 'file' })
|
|
2772
|
-
})
|
|
2773
|
-
|
|
2774
2195
|
function renderMain () {
|
|
2775
2196
|
const el = $('#main')
|
|
2776
2197
|
if (!current || !el) return
|
|
2777
2198
|
const w = ws(current)
|
|
2778
2199
|
const st = sum().status
|
|
2779
|
-
document.querySelector('.sess-bar')?.classList.toggle('off', PAGES.includes(w.mode) && !!sum().workspace)
|
|
2780
|
-
// The loom and a person's view keep the composer under them; the other tabs have none.
|
|
2781
|
-
placeChat()
|
|
2782
2200
|
if (w.mode === 'tasks') {
|
|
2783
2201
|
// Restoring the last archived task goes back to the board, and stays there.
|
|
2784
2202
|
if (w.archived && !(st.tasks || []).some((t) => t.archived)) w.archived = false
|
|
@@ -2788,7 +2206,7 @@ function renderMain () {
|
|
|
2788
2206
|
// A task an older app gave to one of someone's AI sessions ("Dana · login") is that person's.
|
|
2789
2207
|
const who = owners(sum())
|
|
2790
2208
|
const tasks = (st.tasks || []).map((t) => (t && who.has(t.assignee) ? { ...t, assignee: who.get(t.assignee) } : t))
|
|
2791
|
-
const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || []
|
|
2209
|
+
const html = renderBoard(tasks, me(), taskPeople(st), assignTo, { archived: !!w.archived, show, closedGroups: w.archiveClosed || [] })
|
|
2792
2210
|
// Status ticks arrive every few seconds. Re-rendering an unchanged board
|
|
2793
2211
|
// would throw away hover, selection and scroll for nothing.
|
|
2794
2212
|
if (html === lastBoard.html && lastBoard.el && el.firstElementChild === lastBoard.el) return
|
|
@@ -2831,99 +2249,6 @@ function renderMain () {
|
|
|
2831
2249
|
return
|
|
2832
2250
|
}
|
|
2833
2251
|
delete el.dataset.qtSearch
|
|
2834
|
-
if (w.mode === 'people' && !sum().workspace) {
|
|
2835
|
-
// Not in a workspace: the session's own people.
|
|
2836
|
-
state.workspace = null
|
|
2837
|
-
} else if (w.mode === 'wsfiles' || w.mode === 'home' || w.mode === 'people' || ((w.mode === 'preview' || w.mode === 'connections') && sum().workspace)) {
|
|
2838
|
-
const id = sum().workspace
|
|
2839
|
-
if (!id) { w.mode = 'ai'; return renderMain() }
|
|
2840
|
-
if (!state.workspace || state.workspace.workspace?.id !== id) {
|
|
2841
|
-
if (!filesLoading) {
|
|
2842
|
-
filesLoading = true
|
|
2843
|
-
api('GET', `/api/workspaces/${encodeURIComponent(id)}`).then((d) => { state.workspace = d }).catch((err) => toast(err.message)).finally(() => { filesLoading = false; renderMain() })
|
|
2844
|
-
}
|
|
2845
|
-
el.innerHTML = `<div class="main-empty"><p class="hint">${loadingNote()}</p></div>`
|
|
2846
|
-
return
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
if (pageConnections && w.mode !== 'connections') { pageConnections.destroy(); pageConnections = null }
|
|
2850
|
-
if (w.mode === 'home') {
|
|
2851
|
-
const id = sum().workspace
|
|
2852
|
-
const html = workspaceHomeHtml(state.workspace, homeInsights(id, () => renderMain()), { adding: !!w.homeAdding })
|
|
2853
|
-
if (el.dataset.home !== html) {
|
|
2854
|
-
el.innerHTML = html
|
|
2855
|
-
el.dataset.home = html
|
|
2856
|
-
const reload = async () => { state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`).catch(() => state.workspace); delete el.dataset.home; renderMain() }
|
|
2857
|
-
bindWorkspaceHome(el, { id, go, reload, newSession: () => newSessionDialog(id), invite: () => workspaceInviteDialog(id), setAdding: (on) => { w.homeAdding = on; delete el.dataset.home; renderMain() } })
|
|
2858
|
-
}
|
|
2859
|
-
return
|
|
2860
|
-
}
|
|
2861
|
-
delete el.dataset.home
|
|
2862
|
-
if (w.mode === 'people') {
|
|
2863
|
-
const st = sum().status
|
|
2864
|
-
const d = state.workspace && state.workspace.workspace?.id === sum().workspace ? state.workspace : { workspace: { name: st.sessionName || basename(sum().dir) }, members: [], agents: [] }
|
|
2865
|
-
const html = peoplePageHtml(d, { me: st.me.name, here: new Set([st.me.name, ...st.peers.map((p) => p.name)]) })
|
|
2866
|
-
if (el.dataset.people !== html) {
|
|
2867
|
-
el.innerHTML = html
|
|
2868
|
-
el.dataset.people = html
|
|
2869
|
-
bindPeoplePage(el.firstElementChild, { message: (n) => openDm(n), person: (n) => openPerson(n), settings: (tab) => openSessionSettings(tab), invite: () => sum().workspace ? workspaceInviteDialog(sum().workspace) : openInvite(current) })
|
|
2870
|
-
}
|
|
2871
|
-
return
|
|
2872
|
-
}
|
|
2873
|
-
delete el.dataset.people
|
|
2874
|
-
if (w.mode === 'calls') {
|
|
2875
|
-
const html = callsTabHtml()
|
|
2876
|
-
if (el.dataset.calls !== html) { el.innerHTML = html; el.dataset.calls = html; bindCallsTab(el) }
|
|
2877
|
-
return
|
|
2878
|
-
}
|
|
2879
|
-
delete el.dataset.calls
|
|
2880
|
-
if (w.mode === 'preview') {
|
|
2881
|
-
const html = previewTabHtml(w)
|
|
2882
|
-
if (el.dataset.preview !== html) { el.innerHTML = html; el.dataset.preview = html; bindPreviewTab(el) }
|
|
2883
|
-
return
|
|
2884
|
-
}
|
|
2885
|
-
delete el.dataset.preview
|
|
2886
|
-
if (w.mode === 'wsfiles') {
|
|
2887
|
-
const id = sum().workspace
|
|
2888
|
-
const html = `<div class="fv-page">${allFilesHtml(state.workspace, { id, embedded: true })}</div>`
|
|
2889
|
-
if (el.dataset.files !== html) {
|
|
2890
|
-
el.innerHTML = html
|
|
2891
|
-
el.dataset.files = html
|
|
2892
|
-
const rerender = () => { delete el.dataset.files; renderMain() }
|
|
2893
|
-
bindAllFiles(el, { id, go, rerender, reload: async () => { state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`).catch(() => state.workspace); rerender() } })
|
|
2894
|
-
}
|
|
2895
|
-
return
|
|
2896
|
-
}
|
|
2897
|
-
delete el.dataset.files
|
|
2898
|
-
// Connections (dm06): the apps the workspace's sessions can use, or this session's when it is in none.
|
|
2899
|
-
if (w.mode === 'connections') {
|
|
2900
|
-
const wsId = sum().workspace
|
|
2901
|
-
const scope = wsId ? { type: 'workspace', id: wsId } : { type: 'session', id: sum().status.room }
|
|
2902
|
-
const key = `${scope.type}:${scope.id}`
|
|
2903
|
-
if (!pageConnections || el.dataset.connections !== key || !el.querySelector('.cn-page')) {
|
|
2904
|
-
pageConnections?.destroy()
|
|
2905
|
-
el.innerHTML = '<div class="cn-page-wrap"></div>'
|
|
2906
|
-
el.dataset.connections = key
|
|
2907
|
-
const sessions = wsId ? (state.workspace?.sessions || []).map((x) => x.name || x.room) : [sum().status.sessionName || basename(sum().dir)]
|
|
2908
|
-
pageConnections = mountConnections(el.firstElementChild, { ...scope, page: true, sessions, callsRoom: sum().status.room, me: sum().status.me.name })
|
|
2909
|
-
}
|
|
2910
|
-
return
|
|
2911
|
-
}
|
|
2912
|
-
delete el.dataset.connections
|
|
2913
|
-
if (w.mode === 'ai' && w.dmWith) {
|
|
2914
|
-
placeChat()
|
|
2915
|
-
const html = dmThreadHtml(w.dmWith)
|
|
2916
|
-
if (el.dataset.dm !== html) {
|
|
2917
|
-
const sc = el.querySelector('.dm-scroll')
|
|
2918
|
-
const atEnd = !sc || sc.scrollHeight - sc.scrollTop - sc.clientHeight < 60
|
|
2919
|
-
el.innerHTML = html
|
|
2920
|
-
el.dataset.dm = html
|
|
2921
|
-
const n = el.querySelector('.dm-scroll')
|
|
2922
|
-
if (atEnd || !sc) n.scrollTop = n.scrollHeight
|
|
2923
|
-
}
|
|
2924
|
-
return
|
|
2925
|
-
}
|
|
2926
|
-
delete el.dataset.dm
|
|
2927
2252
|
if (w.mode === 'ai') {
|
|
2928
2253
|
if (!w.aiSel) {
|
|
2929
2254
|
const people = st.peers
|
|
@@ -2942,11 +2267,8 @@ function renderMain () {
|
|
|
2942
2267
|
<button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy invite link</span></button>` : `<p class="hint">${esc(NO_LINK_YET)}</p>`}
|
|
2943
2268
|
<p class="hint small">Once they join, you'll see their AI chat here as it happens.</p>
|
|
2944
2269
|
</div>`
|
|
2945
|
-
placeChat()
|
|
2946
2270
|
return
|
|
2947
2271
|
}
|
|
2948
|
-
// The loom: everyone's lanes and what their AIs did; the chat is in its panel on the right.
|
|
2949
|
-
placeChat()
|
|
2950
2272
|
renderLoomView(el)
|
|
2951
2273
|
return
|
|
2952
2274
|
}
|
|
@@ -2955,13 +2277,11 @@ function renderMain () {
|
|
|
2955
2277
|
if (!entries) { el.innerHTML = `<div class="main-empty"><p class="hint">${loadingNote()}</p></div>`; return }
|
|
2956
2278
|
const p = personInfo(w.aiSel)
|
|
2957
2279
|
const convSel = w.convSel && w.convSel[w.aiSel]
|
|
2958
|
-
|
|
2959
|
-
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 || '' })
|
|
2280
|
+
renderFeed(el, { entries, person: w.aiSel, isMe: !!p.isMe, color: p.color, agent: p.agent, online: p.online, convSel })
|
|
2960
2281
|
} else {
|
|
2961
|
-
const host = codeShell(el)
|
|
2962
2282
|
if (!w.fileSel) {
|
|
2963
|
-
|
|
2964
|
-
<p class="hint"
|
|
2283
|
+
el.innerHTML = `<div class="main-empty"><div class="ill">${I.file}</div><h3>Open a file</h3>
|
|
2284
|
+
<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>`
|
|
2965
2285
|
return
|
|
2966
2286
|
}
|
|
2967
2287
|
const cached = state.files.get(fileKey(w.fileSel))
|
|
@@ -2972,7 +2292,7 @@ function renderMain () {
|
|
|
2972
2292
|
if (need === 'history') loadHistory(w.fileSel)
|
|
2973
2293
|
else loadBlame(w.fileSel)
|
|
2974
2294
|
}
|
|
2975
|
-
renderFileView(
|
|
2295
|
+
renderFileView(el, {
|
|
2976
2296
|
path: w.fileSel,
|
|
2977
2297
|
file: cached ? cached.file : null,
|
|
2978
2298
|
meta: treeMeta(w.fileSel),
|
|
@@ -3210,9 +2530,7 @@ function loomPrefs (w) {
|
|
|
3210
2530
|
w.loom = {
|
|
3211
2531
|
chat: p.chat !== false,
|
|
3212
2532
|
tasks: p.tasks !== false,
|
|
3213
|
-
|
|
3214
|
-
density: p.densityPicked && p.density === 'detailed' ? 'detailed' : 'compact',
|
|
3215
|
-
densityPicked: !!p.densityPicked,
|
|
2533
|
+
density: p.density === 'compact' ? 'compact' : 'detailed',
|
|
3216
2534
|
layout: p.layout === 'merged' ? 'merged' : 'lanes',
|
|
3217
2535
|
hidden: names(p.hidden),
|
|
3218
2536
|
pinned: names(p.pinned), // lanes kept open when they don't all fit
|
|
@@ -3233,14 +2551,13 @@ function renderLoomView (el) {
|
|
|
3233
2551
|
const st = s.status
|
|
3234
2552
|
// One lane per person: the AI sessions on someone's computer are them, as in chat.
|
|
3235
2553
|
const { personOf, ...data } = foldAiLanes({
|
|
3236
|
-
// Everyone else first, your own lane last (dm06).
|
|
3237
2554
|
people: [
|
|
3238
|
-
...st.
|
|
3239
|
-
{ ...
|
|
2555
|
+
{ ...st.me, isMe: true, online: st.connected },
|
|
2556
|
+
...st.peers.map((p) => ({ ...p, online: p.hosted ? 'http' : true, optional: !!p.persona }))
|
|
3240
2557
|
],
|
|
3241
2558
|
owners: owners(s),
|
|
3242
2559
|
feeds: state.feeds.get(current) || new Map(),
|
|
3243
|
-
messages:
|
|
2560
|
+
messages: renderable(state.messages.get(current)),
|
|
3244
2561
|
tasks: st.tasks || [],
|
|
3245
2562
|
claims: st.claims || []
|
|
3246
2563
|
})
|
|
@@ -3252,288 +2569,16 @@ function renderLoomView (el) {
|
|
|
3252
2569
|
me: st.me.name,
|
|
3253
2570
|
names: mentionNames(s),
|
|
3254
2571
|
meAgent: st.me.kind === 'agent',
|
|
3255
|
-
onAction: loomAction
|
|
3256
|
-
extra: {
|
|
3257
|
-
// A band that asks for an app action's approval carries the card (connections.js).
|
|
3258
|
-
approval: (it) => state.connectionsOn ? approvalCardHtml({ approval: it.approval }, st.room) : '',
|
|
3259
|
-
unreadFrom: (name) => dmUnread(name),
|
|
3260
|
-
seenAt: (name) => (ws(current).dmSeen || {})[name] || 0
|
|
3261
|
-
}
|
|
2572
|
+
onAction: loomAction
|
|
3262
2573
|
})
|
|
3263
|
-
if (state.connectionsOn && renderable(state.messages.get(current)).some((m) => m.approval)) refreshApprovals(st.room, () => renderMain())
|
|
3264
|
-
}
|
|
3265
|
-
|
|
3266
|
-
/** The open session's workspace's name, for "From <workspace>'s files". */
|
|
3267
|
-
const wsName = () => (state.workspaces || []).find((x) => x.id === sum()?.workspace)?.name || ''
|
|
3268
|
-
|
|
3269
|
-
/** A message (and files) straight to `to`, from a band's quick reply: as the composer sends them. Throws on failure. */
|
|
3270
|
-
async function sendTo ({ to, text, files = [] }) {
|
|
3271
|
-
const id = current
|
|
3272
|
-
try {
|
|
3273
|
-
if (files.length) {
|
|
3274
|
-
for (let i = 0; i < files.length; i++) {
|
|
3275
|
-
const words = i === 0 ? text : ''
|
|
3276
|
-
if (files[i].wsFile) await api('POST', `/api/sessions/${id}/attach-from-workspace`, { fileId: files[i].wsFile, to, text: words })
|
|
3277
|
-
else await api('POST', `/api/sessions/${id}/send`, files[i], { 'x-filename': encodeURIComponent(files[i].name), 'x-to': encodeURIComponent(to), 'x-text': encodeURIComponent(words) })
|
|
3278
|
-
}
|
|
3279
|
-
} else await api('POST', `/api/sessions/${id}/say`, { text, to })
|
|
3280
|
-
const w = ws(current)
|
|
3281
|
-
w.dmSeen = { ...(w.dmSeen || {}), [to]: Date.now() }
|
|
3282
|
-
saveWs(current)
|
|
3283
|
-
} catch (err) { toast(err.message); throw err }
|
|
3284
|
-
}
|
|
3285
|
-
|
|
3286
|
-
/** Direct messages to you from `name` you haven't opened yet (their thread marks them seen). */
|
|
3287
|
-
function dmUnread (name) {
|
|
3288
|
-
const st = sum().status
|
|
3289
|
-
const seen = (ws(current).dmSeen || {})[name] || 0
|
|
3290
|
-
return renderable(state.messages.get(current)).filter((m) => m.by === name && m.to === st.me.name && (m.ts || 0) > seen).length
|
|
3291
|
-
}
|
|
3292
|
-
|
|
3293
|
-
/** Your direct messages with one person (dm06): a thread of their own, theirs on the left and yours on the right. */
|
|
3294
|
-
function openDm (name) {
|
|
3295
|
-
const w = ws(current)
|
|
3296
|
-
w.dmFrom = w.aiSel || null
|
|
3297
|
-
w.dmWith = name
|
|
3298
|
-
w.mode = 'ai'
|
|
3299
|
-
w.dmSeen = { ...(w.dmSeen || {}), [name]: Date.now() }
|
|
3300
|
-
saveWs(current)
|
|
3301
|
-
state.to = name
|
|
3302
|
-
renderRecipients()
|
|
3303
|
-
renderMain()
|
|
3304
|
-
renderSessHead()
|
|
3305
|
-
$('#msg-input')?.focus()
|
|
3306
2574
|
}
|
|
3307
2575
|
|
|
3308
|
-
/** The thread with `name`: every direct message between you, oldest first. */
|
|
3309
|
-
function dmThreadHtml (name) {
|
|
3310
|
-
const s = sum()
|
|
3311
|
-
const st = s.status
|
|
3312
|
-
const me = st.me.name
|
|
3313
|
-
const p = personInfo(name)
|
|
3314
|
-
const list = renderable(state.messages.get(current)).filter((m) => (m.by === name && m.to === me) || (m.by === me && m.to === name))
|
|
3315
|
-
let day = ''
|
|
3316
|
-
const rows = list.map((m) => {
|
|
3317
|
-
const mine = m.by === me
|
|
3318
|
-
const d = new Date(m.ts || 0).toDateString()
|
|
3319
|
-
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>` : ''
|
|
3320
|
-
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>` : ''
|
|
3321
|
-
// As in the mockup: the face at the top, beside a line with who and when, the bubble under it.
|
|
3322
|
-
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>`
|
|
3323
|
-
}).join('')
|
|
3324
|
-
return `<div class="dm-view" style="--c:${esc(p.color || '')}">
|
|
3325
|
-
<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>
|
|
3326
|
-
<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>
|
|
3327
|
-
</div>`
|
|
3328
|
-
}
|
|
3329
|
-
|
|
3330
|
-
/**
|
|
3331
|
-
* A lane card turns into the person's view (dm06): the other cards fall away while the card grows into
|
|
3332
|
-
* the view's header, then the view fades in under it. Without motion (reduced motion), it just opens.
|
|
3333
|
-
*/
|
|
3334
|
-
async function morphToPerson (name, card) {
|
|
3335
|
-
const main = $('#main')
|
|
3336
|
-
const loom = main && main.querySelector('.loom')
|
|
3337
|
-
if (!loom || !card || matchMedia('(prefers-reduced-motion: reduce)').matches) return openPerson(name)
|
|
3338
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
|
|
3339
|
-
const r = card.getBoundingClientRect()
|
|
3340
|
-
const clone = card.cloneNode(true)
|
|
3341
|
-
clone.classList.add('pv-morph')
|
|
3342
|
-
// The view's back arrow rides in the card from the start, so nothing pops in after it lands.
|
|
3343
|
-
clone.insertAdjacentHTML('afterbegin', `<span class="pv-back pv-mbk" aria-hidden="true">${I.arrowLeft}</span>`)
|
|
3344
|
-
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 })
|
|
3345
|
-
document.body.appendChild(clone)
|
|
3346
|
-
card.style.visibility = 'hidden'
|
|
3347
|
-
for (const x of loom.querySelectorAll('.loom-head, .lc, .loom-band, .loom-needle')) {
|
|
3348
|
-
if (x === card) continue
|
|
3349
|
-
x.style.setProperty('--d', `${(Math.random() * 0.06).toFixed(2)}s`)
|
|
3350
|
-
x.style.setProperty('--r', `${(Math.random() * 10 - 5).toFixed(1)}deg`)
|
|
3351
|
-
}
|
|
3352
|
-
loom.classList.add('falling')
|
|
3353
|
-
await sleep(230)
|
|
3354
|
-
openPerson(name)
|
|
3355
|
-
const head = main.querySelector('.pv-head')
|
|
3356
|
-
if (!head) { clone.remove(); return }
|
|
3357
|
-
head.style.visibility = 'hidden'
|
|
3358
|
-
main.querySelector('.feed-scroll')?.classList.add('pv-in')
|
|
3359
|
-
const t = head.getBoundingClientRect()
|
|
3360
|
-
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))
|
|
3361
|
-
clone.classList.add('grow')
|
|
3362
|
-
Object.assign(clone.style, { left: `${t.left}px`, top: `${t.top}px`, width: `${t.width}px`, height: `${t.height}px` })
|
|
3363
|
-
await sleep(470)
|
|
3364
|
-
// The card now has the header's own layout: show the header under it and let the card fade off it.
|
|
3365
|
-
head.style.visibility = ''
|
|
3366
|
-
clone.style.transition = 'opacity .14s'
|
|
3367
|
-
clone.style.opacity = '0'
|
|
3368
|
-
setTimeout(() => clone.remove(), 160)
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3371
|
-
/**
|
|
3372
|
-
* The Preview tab (dm06): the session's links (its own, then the workspace's) on the left, the one picked
|
|
3373
|
-
* in a frame with its address, a phone or desktop width, and Open in browser. Links are added here or on
|
|
3374
|
-
* the workspace's home (Previews).
|
|
3375
|
-
*/
|
|
3376
|
-
// ------------------------------------------------------------------ Calls tab --
|
|
3377
|
-
// The session's calls (dm06), from their transcripts: who was in each, its first words, when and how long.
|
|
3378
|
-
// A row opens its transcript; the button at the top starts a call, or joins the one going on.
|
|
3379
|
-
let callsView = { id: null, calls: null, open: null, lines: null, at: 0 }
|
|
3380
|
-
function loadCalls (force = false) {
|
|
3381
|
-
const id = current
|
|
3382
|
-
if (!force && callsView.id === id && Date.now() - callsView.at < 15000) return
|
|
3383
|
-
callsView = { ...callsView, id, at: Date.now(), ...(callsView.id === id ? {} : { calls: null, open: null, lines: null }) }
|
|
3384
|
-
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 = [] })
|
|
3385
|
-
}
|
|
3386
|
-
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` }
|
|
3387
|
-
function callDay (ts) {
|
|
3388
|
-
const d = new Date(ts)
|
|
3389
|
-
const days = Math.round((new Date().setHours(0, 0, 0, 0) - new Date(ts).setHours(0, 0, 0, 0)) / 86400000)
|
|
3390
|
-
const at = d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })
|
|
3391
|
-
return days === 0 ? `Today ${at}` : days === 1 ? `Yesterday ${at}` : days < 7 ? d.toLocaleDateString([], { weekday: 'short' }) : d.toLocaleDateString([], { month: 'short', day: 'numeric' })
|
|
3392
|
-
}
|
|
3393
|
-
function callsTabHtml () {
|
|
3394
|
-
loadCalls()
|
|
3395
|
-
const st = sum().status
|
|
3396
|
-
const live = $('#chat-call') && !$('#chat-call').hidden
|
|
3397
|
-
const inCall = inCallHere(current)
|
|
3398
|
-
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>`
|
|
3399
|
-
if (callsView.calls === null) return `<div class="cl-page">${top}<p class="hint">${loadingNote()}</p></div>`
|
|
3400
|
-
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>`
|
|
3401
|
-
const color = (n) => personInfo(n).color
|
|
3402
|
-
const rows = callsView.calls.map((c) => {
|
|
3403
|
-
const open = callsView.open === c.call
|
|
3404
|
-
const names = c.people.slice(0, 3)
|
|
3405
|
-
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` : ''}`
|
|
3406
|
-
const said = c.opening.map((l) => `${l.by}: ${l.text}`).join(' · ')
|
|
3407
|
-
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>`) : ''
|
|
3408
|
-
return `<div class="cl-call${open ? ' open' : ''}"><button type="button" class="cl-row" data-cl-open="${esc(c.call)}" aria-expanded="${open}">
|
|
3409
|
-
<span class="cl-play">${I.play}</span><span class="cl-t"><b>${esc(title)}</b><small>${esc(said)}</small></span>
|
|
3410
|
-
<span class="cl-faces">${c.people.slice(0, 4).map((n) => avatar(n, color(n))).join('')}</span>
|
|
3411
|
-
<span class="cl-when"><b>${esc(callDay(c.start))}</b><small>${esc(minutes(c.end - c.start))}</small></span></button>
|
|
3412
|
-
${open ? `<ol class="cl-lines">${lines}</ol>` : ''}</div>`
|
|
3413
|
-
}).join('')
|
|
3414
|
-
return `<div class="cl-page">${top}<div class="cl-list">${rows}</div></div>`
|
|
3415
|
-
}
|
|
3416
|
-
function bindCallsTab (el) {
|
|
3417
|
-
el.onclick = async (e) => {
|
|
3418
|
-
if (e.target.closest('[data-cl-start]')) { $('#chat-call')?.click(); return }
|
|
3419
|
-
const r = e.target.closest('[data-cl-open]')
|
|
3420
|
-
if (!r) return
|
|
3421
|
-
const call = r.dataset.clOpen
|
|
3422
|
-
if (callsView.open === call) { callsView.open = null; renderMain(); return }
|
|
3423
|
-
callsView.open = call
|
|
3424
|
-
callsView.lines = null
|
|
3425
|
-
renderMain()
|
|
3426
|
-
const id = current
|
|
3427
|
-
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) }
|
|
3428
|
-
}
|
|
3429
|
-
}
|
|
3430
|
-
|
|
3431
|
-
// Dev servers running from this session's folder on this computer, found by the app (dev-servers.js): they show in
|
|
3432
|
-
// Preview by themselves, before the links people saved.
|
|
3433
|
-
let devView = { id: null, servers: [], at: 0 }
|
|
3434
|
-
function loadDevServers () {
|
|
3435
|
-
const id = current
|
|
3436
|
-
if (devView.id === id && Date.now() - devView.at < 10000) return
|
|
3437
|
-
devView = { id, servers: devView.id === id ? devView.servers : [], at: Date.now() }
|
|
3438
|
-
api('GET', `/api/sessions/${id}/dev-servers`).then((r) => {
|
|
3439
|
-
if (devView.id !== id || JSON.stringify(r.servers) === JSON.stringify(devView.servers)) return
|
|
3440
|
-
devView.servers = r.servers
|
|
3441
|
-
if (ws(current).mode === 'preview') renderMain()
|
|
3442
|
-
}).catch(() => {})
|
|
3443
|
-
}
|
|
3444
|
-
|
|
3445
|
-
function previewTabHtml (w) {
|
|
3446
|
-
const s = sum()
|
|
3447
|
-
const room = s.status.room
|
|
3448
|
-
loadDevServers()
|
|
3449
|
-
const d = state.workspace && state.workspace.workspace?.id === s.workspace ? state.workspace : null
|
|
3450
|
-
const here = s.status.sessionName || basename(s.dir)
|
|
3451
|
-
const found = devView.servers.map((x) => ({ id: `dev:${x.port}`, name: `Your localhost:${x.port}`, url: x.url, note: `${x.command} · running in ${here} on this computer`, dev: true }))
|
|
3452
|
-
const links = [...found, ...(d ? (d.links || []).filter((l) => !l.room || l.room === room).sort((a, b) => (a.room === room ? 0 : 1) - (b.room === room ? 0 : 1)) : [])]
|
|
3453
|
-
const pick = links.find((l) => l.id === w.previewSel) || links[0] || null
|
|
3454
|
-
const host = (u) => { try { return new URL(u).host } catch { return u } }
|
|
3455
|
-
const local = (u) => /^(localhost|127\.|0\.0\.0\.0)/.test(host(u))
|
|
3456
|
-
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(l.dev ? l.note : [host(l.url), l.note].filter(Boolean).join(' · '))}</small></span></button>`).join('')
|
|
3457
|
-
// Adding a link (staging, production, a preview someone shares) is a button; its two fields open in place.
|
|
3458
|
-
const form = !s.workspace
|
|
3459
|
-
? '<p class="pt-note">Dev servers you run in this folder show up here by themselves. Saved links are kept in a workspace: move this session into one to add them.</p>'
|
|
3460
|
-
: w.ptAdding
|
|
3461
|
-
? `<form class="pt-add" data-pt-add><input class="input" name="name" placeholder="Name (Staging, Production…)" maxlength="80" required><input class="input" name="url" placeholder="https://…" maxlength="500" required><div class="pt-add-row"><button class="btn ghost" type="button" data-pt-cancel>Cancel</button><button class="btn primary" type="submit">Add</button></div></form>`
|
|
3462
|
-
: `<div class="pt-foot"><button type="button" class="btn pt-addbtn" data-pt-adding>${I.plus}<span>Add a link</span></button><p class="pt-note">Dev servers you run in ${esc(here)} show up here by themselves.</p></div>`
|
|
3463
|
-
const frame = pick
|
|
3464
|
-
? `<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>${pick.dev ? '<span class="pt-live"><span class="pulse"></span>Running on this computer</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>
|
|
3465
|
-
<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>
|
|
3466
|
-
<a class="btn sm" href="${esc(pick.url)}" target="_blank" rel="noopener">${I.external}<span>Open in browser</span></a></div>
|
|
3467
|
-
<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>`
|
|
3468
|
-
: `<div class="main-empty"><div class="ill">${I.globe}</div><h3>Nothing to preview yet</h3><p class="hint">Start the project's dev server in ${esc(here)} and it shows up here. Staging and production are a link away: Add a link.</p></div>`
|
|
3469
|
-
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>`
|
|
3470
|
-
}
|
|
3471
|
-
|
|
3472
|
-
function bindPreviewTab (el) {
|
|
3473
|
-
const w = ws(current)
|
|
3474
|
-
const redraw = () => { delete $('#main').dataset.preview; renderMain() }
|
|
3475
|
-
el.onclick = (e) => {
|
|
3476
|
-
const p = e.target.closest('[data-pt-pick]')
|
|
3477
|
-
if (p) { w.previewSel = p.dataset.ptPick; saveWs(current); return redraw() }
|
|
3478
|
-
const sz = e.target.closest('[data-pt-size]')
|
|
3479
|
-
if (sz) { w.previewPhone = sz.dataset.ptSize === 'phone'; saveWs(current); return redraw() }
|
|
3480
|
-
if (e.target.closest('[data-pt-reload]')) { const f = el.querySelector('.pt-frame'); if (f) f.src = f.src }
|
|
3481
|
-
if (e.target.closest('[data-pt-adding]')) { w.ptAdding = true; redraw(); el.querySelector('[data-pt-add] input')?.focus(); return }
|
|
3482
|
-
if (e.target.closest('[data-pt-cancel]')) { w.ptAdding = false; redraw() }
|
|
3483
|
-
}
|
|
3484
|
-
const form = el.querySelector('[data-pt-add]')
|
|
3485
|
-
if (form && form.elements.name) {
|
|
3486
|
-
form.onsubmit = async (e) => {
|
|
3487
|
-
e.preventDefault()
|
|
3488
|
-
const id = sum().workspace
|
|
3489
|
-
try {
|
|
3490
|
-
const l = await api('POST', `/api/workspaces/${encodeURIComponent(id)}/links`, { name: form.elements.name.value, url: form.elements.url.value, room: sum().status.room })
|
|
3491
|
-
state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`)
|
|
3492
|
-
w.previewSel = l.id
|
|
3493
|
-
w.ptAdding = false
|
|
3494
|
-
saveWs(current)
|
|
3495
|
-
redraw()
|
|
3496
|
-
} catch (err) { toast(err.message) }
|
|
3497
|
-
}
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
|
|
3501
|
-
let filesLoading = false // the workspace's files, fetched for the Files page
|
|
3502
|
-
let pageConnections = null // the Connections page's manager while it is drawn
|
|
3503
|
-
// Pages of the workspace (dm06): Home, Files, People and Connections. Their button opens the page (and stays lit
|
|
3504
|
-
// on it); the session menu brings you back to the session, to the view you left it on.
|
|
3505
|
-
const PAGES = ['home', 'wsfiles', 'people', 'connections']
|
|
3506
|
-
function openPage (mode) {
|
|
3507
|
-
const w = ws(current)
|
|
3508
|
-
if (w.mode === mode) return
|
|
3509
|
-
if (!PAGES.includes(w.mode)) w.pageBack = w.mode
|
|
3510
|
-
w.mode = mode
|
|
3511
|
-
saveWs(current)
|
|
3512
|
-
renderMain()
|
|
3513
|
-
renderSessHead()
|
|
3514
|
-
renderWbar()
|
|
3515
|
-
}
|
|
3516
|
-
/** Back from a workspace page to the session's own view (the one you left it on). */
|
|
3517
|
-
function backToSession () {
|
|
3518
|
-
const w = ws(current)
|
|
3519
|
-
if (!PAGES.includes(w.mode)) return
|
|
3520
|
-
w.mode = PAGES.includes(w.pageBack) || !w.pageBack ? 'ai' : w.pageBack
|
|
3521
|
-
saveWs(current)
|
|
3522
|
-
renderMainBar()
|
|
3523
|
-
renderMain()
|
|
3524
|
-
renderSessHead()
|
|
3525
|
-
renderWbar()
|
|
3526
|
-
}
|
|
3527
2576
|
let loomPersonOf = new Map() // a "<person>'s AI" lane -> the person whose AI chat it opens
|
|
3528
2577
|
|
|
3529
|
-
function loomAction (kind, value
|
|
2578
|
+
function loomAction (kind, value) {
|
|
3530
2579
|
const w = ws(current)
|
|
3531
2580
|
const prefs = loomPrefs(w)
|
|
3532
|
-
if (kind === 'person') return
|
|
3533
|
-
// 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.
|
|
3534
|
-
if (kind === 'dm') return openDm(value)
|
|
3535
|
-
if (kind === 'reply') return sendTo(value)
|
|
3536
|
-
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 }) })
|
|
2581
|
+
if (kind === 'person') return openPerson(loomPersonOf.get(value) || value)
|
|
3537
2582
|
if (kind === 'conv') { openPerson(loomPersonOf.get(value.name) || value.name); pickConv(value.conv); return }
|
|
3538
2583
|
if (kind === 'file') return openFile(value)
|
|
3539
2584
|
if (kind === 'holds') return openLocks(value.anchor, { who: value.name }) // the same lock list as the Files rail
|
|
@@ -3545,7 +2590,7 @@ function loomAction (kind, value, from) {
|
|
|
3545
2590
|
if (kind === 'hide') prefs.hidden = [...new Set([...prefs.hidden, value])]
|
|
3546
2591
|
else if (kind === 'unhide') prefs.hidden = prefs.hidden.filter((n) => n !== value)
|
|
3547
2592
|
else if (kind === 'toggle') prefs[value] = prefs[value] === false
|
|
3548
|
-
else if (kind === 'density')
|
|
2593
|
+
else if (kind === 'density') prefs.density = value
|
|
3549
2594
|
else if (kind === 'layout') prefs.layout = value
|
|
3550
2595
|
else if (kind === 'pin') prefs.pinned = prefs.pinned.includes(value) ? prefs.pinned.filter((n) => n !== value) : [...prefs.pinned, value]
|
|
3551
2596
|
else if (kind === 'open-lane') { prefs.opened = [value, ...prefs.opened.filter((n) => n !== value)].slice(0, 20); prefs.layout = 'lanes' }
|
|
@@ -3601,8 +2646,7 @@ async function loadTree () {
|
|
|
3601
2646
|
// Keep the banner (editor, claim) fresh without re-highlighting.
|
|
3602
2647
|
const cached = state.files.get(fileKey(w.fileSel))
|
|
3603
2648
|
const meta = treeMeta(w.fileSel)
|
|
3604
|
-
if ($('#main .
|
|
3605
|
-
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) })
|
|
2649
|
+
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) })
|
|
3606
2650
|
}
|
|
3607
2651
|
} catch {}
|
|
3608
2652
|
}
|
|
@@ -3677,7 +2721,7 @@ function applyTreeCollapsed () {
|
|
|
3677
2721
|
const body = $('#ws-body')
|
|
3678
2722
|
const btn = $('#collapse-tree')
|
|
3679
2723
|
if (!body || !current) return
|
|
3680
|
-
const collapsed =
|
|
2724
|
+
const collapsed = ws(current).boxesCollapsed === true
|
|
3681
2725
|
body.classList.toggle('tree-collapsed', collapsed)
|
|
3682
2726
|
const rail = $('#tree-rail')
|
|
3683
2727
|
if (rail) rail.toggleAttribute('inert', !collapsed)
|
|
@@ -3696,7 +2740,9 @@ function applyTreeCollapsed () {
|
|
|
3696
2740
|
|
|
3697
2741
|
function toggleTreeCollapsed () {
|
|
3698
2742
|
if (!current) return
|
|
3699
|
-
|
|
2743
|
+
const w = ws(current)
|
|
2744
|
+
w.boxesCollapsed = !w.boxesCollapsed
|
|
2745
|
+
saveWs(current)
|
|
3700
2746
|
applyTreeCollapsed()
|
|
3701
2747
|
}
|
|
3702
2748
|
|
|
@@ -3741,13 +2787,6 @@ function renderChatBadge () {
|
|
|
3741
2787
|
badge.hidden = !n
|
|
3742
2788
|
badge.textContent = n > 99 ? '99+' : String(n)
|
|
3743
2789
|
rail.title = n ? `Open chat · ${n} new message${n === 1 ? '' : 's'}` : 'Open chat'
|
|
3744
|
-
// Folded, the rail also shows who wrote to you directly, with what is unread: a click opens your thread with them.
|
|
3745
|
-
const faces = $('#chat-rail-faces')
|
|
3746
|
-
if (faces) {
|
|
3747
|
-
const from = s && chatCollapsed() ? (s.status.peers || []).map((p) => ({ p, n: dmUnread(p.name) })).filter((x) => x.n) : []
|
|
3748
|
-
const html = from.map(({ p, n }) => `<span class="crf" data-rail-dm="${esc(p.name)}" title="${esc(`${n} direct message${n === 1 ? '' : 's'} from ${p.name}`)}">${avatar(p.name, personInfo(p.name).color || p.color)}<i>${n > 9 ? '9+' : n}</i></span>`).join('')
|
|
3749
|
-
if (faces.dataset.html !== html) { faces.innerHTML = html; faces.dataset.html = html }
|
|
3750
|
-
}
|
|
3751
2790
|
}
|
|
3752
2791
|
|
|
3753
2792
|
function bindChatPane () {
|
|
@@ -3755,11 +2794,7 @@ function bindChatPane () {
|
|
|
3755
2794
|
const handle = $('#chat-resize')
|
|
3756
2795
|
if (!body || !handle) return
|
|
3757
2796
|
$('#collapse-chat').onclick = () => setChatCollapsed(true)
|
|
3758
|
-
$('#chat-rail').onclick = (
|
|
3759
|
-
const dm = e.target.closest('[data-rail-dm]')
|
|
3760
|
-
if (dm) { openDm(dm.dataset.railDm); setChatCollapsed(false); return } // the thread, and the chat open to answer them
|
|
3761
|
-
setChatCollapsed(false)
|
|
3762
|
-
}
|
|
2797
|
+
$('#chat-rail').onclick = () => setChatCollapsed(false)
|
|
3763
2798
|
handle.ondblclick = () => setChatCollapsed(!chatCollapsed())
|
|
3764
2799
|
handle.onkeydown = (e) => {
|
|
3765
2800
|
if (e.key === 'Enter') { e.preventDefault(); return setChatCollapsed(!chatCollapsed()) }
|
|
@@ -3801,12 +2836,6 @@ function bindChatPane () {
|
|
|
3801
2836
|
function bindTreeEvents () {
|
|
3802
2837
|
const collapse = $('#collapse-tree')
|
|
3803
2838
|
if (collapse) collapse.onclick = () => toggleTreeCollapsed()
|
|
3804
|
-
$('#side-mini')?.addEventListener('click', (e) => {
|
|
3805
|
-
if (e.target.closest('[data-side-people]')) { openSessionSettings(e.target.closest('[data-side-people]').dataset.sidePeople); return }
|
|
3806
|
-
if (e.target.closest('[data-side-files]')) { go(`wsfiles:${sum().workspace}`); return }
|
|
3807
|
-
const g = e.target.closest('[data-side-go]')
|
|
3808
|
-
if (g && g.dataset.sideGo !== current) go(g.dataset.sideGo)
|
|
3809
|
-
})
|
|
3810
2839
|
const el = $('#boxes-side')
|
|
3811
2840
|
el.addEventListener('click', (e) => {
|
|
3812
2841
|
// A person's boxes: folded until clicked, and folded again by another click.
|
|
@@ -3820,12 +2849,6 @@ function bindTreeEvents () {
|
|
|
3820
2849
|
}
|
|
3821
2850
|
const bx = e.target.closest('[data-box-toggle],[data-unpack],[data-ask]')
|
|
3822
2851
|
if (bx) { boxAction(bx); return }
|
|
3823
|
-
if (e.target.closest('[data-side-people]')) { openSessionSettings(e.target.closest('[data-side-people]').dataset.sidePeople); return }
|
|
3824
|
-
if (e.target.closest('[data-side-ws]')) { go(`ws:${sum().workspace}`); return }
|
|
3825
|
-
if (e.target.closest('[data-side-files]')) { go(`wsfiles:${sum().workspace}`); return }
|
|
3826
|
-
if (e.target.closest('[data-side-new]')) { go('home'); return }
|
|
3827
|
-
const g = e.target.closest('[data-side-go]')
|
|
3828
|
-
if (g) { if (g.dataset.sideGo !== current) go(g.dataset.sideGo); return }
|
|
3829
2852
|
const t = e.target.closest('[data-person],[data-dm]')
|
|
3830
2853
|
if (!t) return
|
|
3831
2854
|
if (t.dataset.dm) {
|
|
@@ -3879,22 +2902,13 @@ function bindChat () {
|
|
|
3879
2902
|
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && !e.defaultPrevented) { e.preventDefault(); $('#composer').requestSubmit() }
|
|
3880
2903
|
})
|
|
3881
2904
|
$('#to-select').onchange = (e) => { state.to = e.target.value; updatePlaceholder() }
|
|
3882
|
-
|
|
3883
|
-
$('#attach-btn').onclick = () => attachMenu($('#attach-btn'), { workspace: sum()?.workspace, name: wsName(), onUpload: () => $('#file-input').click(), onPick: (f) => attachFromWorkspace(f) })
|
|
3884
|
-
// @: starts a mention where the cursor is, and the mention list opens as when typing it.
|
|
3885
|
-
$('#at-btn').onclick = () => {
|
|
3886
|
-
const ta = $('#msg-input')
|
|
3887
|
-
const at = ta.selectionStart ?? ta.value.length
|
|
3888
|
-
const before = ta.value.slice(0, at)
|
|
3889
|
-
ta.value = `${before}${before && !/\s$/.test(before) ? ' ' : ''}@${ta.value.slice(at)}`
|
|
3890
|
-
ta.focus()
|
|
3891
|
-
const pos = ta.value.indexOf('@', at) + 1
|
|
3892
|
-
ta.setSelectionRange(pos, pos)
|
|
3893
|
-
ta.dispatchEvent(new Event('input', { bubbles: true }))
|
|
3894
|
-
}
|
|
2905
|
+
$('#attach-btn').onclick = () => $('#file-input').click()
|
|
3895
2906
|
$('#file-input').onchange = (e) => { addFiles(e.target.files); e.target.value = '' }
|
|
3896
|
-
|
|
2907
|
+
$('[data-attach-workspace]')?.addEventListener('click', async () => {
|
|
3897
2908
|
if (mayNotPost()) return toast(NO_POSTING)
|
|
2909
|
+
const workspace = sum()?.workspace
|
|
2910
|
+
const pick = await workspaceFilePicker(workspace)
|
|
2911
|
+
if (!pick) return
|
|
3898
2912
|
try {
|
|
3899
2913
|
await api('POST', `/api/sessions/${id}/attach-from-workspace`, { fileId: pick.id, to: state.to || null, text: input.value.trim() })
|
|
3900
2914
|
input.value = ''
|
|
@@ -3904,7 +2918,7 @@ function bindChat () {
|
|
|
3904
2918
|
} finally {
|
|
3905
2919
|
input.focus()
|
|
3906
2920
|
}
|
|
3907
|
-
}
|
|
2921
|
+
})
|
|
3908
2922
|
// A file in the chat opens in the file view, where it's shown as what it is (preview.js).
|
|
3909
2923
|
$('#messages').addEventListener('click', (e) => {
|
|
3910
2924
|
const yes = e.target.closest('[data-approve],[data-decline]')
|
|
@@ -4013,11 +3027,7 @@ function updatePlaceholder () {
|
|
|
4013
3027
|
if (!input) return
|
|
4014
3028
|
if (mayNotPost()) { input.placeholder = NO_POSTING; return }
|
|
4015
3029
|
const who = state.to ? (state.to === `${me()}'s AI` ? 'your AI' : state.to) : 'everyone'
|
|
4016
|
-
|
|
4017
|
-
input.placeholder = state.pending.length ? `Add a note for ${who} (optional)…` : state.to ? `Message ${who} directly…` : `Message everyone in ${where}…`
|
|
4018
|
-
// The To chip takes the person's color for a direct message (dm06).
|
|
4019
|
-
const to = input.closest('.composer')?.querySelector('.to')
|
|
4020
|
-
if (to) to.style.setProperty('--to-c', state.to ? (personInfo(state.to).color || colorFor(state.to)) : '')
|
|
3030
|
+
input.placeholder = state.pending.length ? `Add a note for ${who} (optional)…` : `Message ${who}…`
|
|
4021
3031
|
}
|
|
4022
3032
|
|
|
4023
3033
|
function renderRecipients () {
|
|
@@ -4033,8 +3043,8 @@ function renderRecipients () {
|
|
|
4033
3043
|
if (state.to) names.add(state.to)
|
|
4034
3044
|
const online = new Set(peopleHere(s.status).map((p) => p.name))
|
|
4035
3045
|
const away = new Set((s.status.away || []).map((a) => a.name))
|
|
4036
|
-
sel.innerHTML =
|
|
4037
|
-
`<option value="${esc(n)}" ${n === state.to ? 'selected' : ''}>${esc(n === `${s.status.me.name}'s AI` ? 'Your AI' : n)}
|
|
3046
|
+
sel.innerHTML = '<option value="">Everyone</option>' + [...names].sort().map((n) =>
|
|
3047
|
+
`<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('')
|
|
4038
3048
|
sel.value = state.to
|
|
4039
3049
|
sel.closest('.to').hidden = names.size === 0
|
|
4040
3050
|
updatePlaceholder()
|