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