heyquilt 0.3.184 → 0.3.186
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 +8 -0
- package/package.json +1 -1
- package/src/api/routes/workspaces.js +2 -0
- package/src/app-workspaces.js +21 -0
- package/src/session.js +43 -4
- package/src/ui/app.css +12 -6
- package/src/ui/loom.css +3 -2
- package/src/ui/loom.js +8 -26
- package/src/ui/projects.js +5 -5
- package/src/ui/session.js +27 -15
- package/src/ui/voice.js +118 -44
- package/src/ui-server.js +28 -4
- package/src/voice.js +63 -0
package/RELEASES.md
CHANGED
|
@@ -11,6 +11,14 @@ Format: `## <version> — <YYYY-MM-DD>`, an optional one-line summary, then bull
|
|
|
11
11
|
Lead each bullet with a short bold phrase. Inline `code` and **bold** are rendered;
|
|
12
12
|
nothing else is.
|
|
13
13
|
|
|
14
|
+
## 0.3.186 — 2026-11-23
|
|
15
|
+
|
|
16
|
+
- **Nothing above the Loom.** The bar over the Loom ("Everyone" and its counts) is gone, so the lanes start at the top. A lane you hid leaves its chip in a row under the lane heads, there only while a lane is hidden: click it to bring the lane back.
|
|
17
|
+
|
|
18
|
+
## 0.3.185 — 2026-11-23
|
|
19
|
+
|
|
20
|
+
- **A simpler Loom.** The three switches above the Loom are gone: Chat and Tasks, Detailed and Compact, Lanes and One column. The Loom always shows chat and tasks, every card in full, and a lane for each person (one column when the window is narrow).
|
|
21
|
+
|
|
14
22
|
## 0.3.184 — 2026-11-22
|
|
15
23
|
|
|
16
24
|
Connections for the agents you choose.
|
package/package.json
CHANGED
|
@@ -83,6 +83,8 @@ export function workspaceRoutes (ctx) {
|
|
|
83
83
|
access: access.access,
|
|
84
84
|
admin: access.admin,
|
|
85
85
|
via: access.via,
|
|
86
|
+
// The codebases in it, so an app knows which of the folders on its computer belong here.
|
|
87
|
+
rooms: sessions.map((s) => s.room),
|
|
86
88
|
// files: the row's count, kept by every upload, delete and sweep (setWorkspaceUsage).
|
|
87
89
|
counts: { sessions: sessions.length, members: members.length, open: sessions.filter((s) => isOpen(s, t)).length, files: ws.fileCount ?? 0 }
|
|
88
90
|
}
|
package/src/app-workspaces.js
CHANGED
|
@@ -2,3 +2,24 @@
|
|
|
2
2
|
// app, its agents' workspace tools and `quilt workspace` act as if the accounts API had them off,
|
|
3
3
|
// whatever the API says. QUILT_APP_WORKSPACES=1 brings them back (tests, and when they return).
|
|
4
4
|
export const appWorkspaces = (env = process.env) => /^(1|true)$/i.test(env.QUILT_APP_WORKSPACES || '')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The folders on this computer whose codebase is in a project the folder doesn't know about:
|
|
8
|
+
* someone who joined a project's codebase with an invite, or whose partner moved it into a
|
|
9
|
+
* project, has no project in the folder's own settings. `workspaces`: the account's projects as
|
|
10
|
+
* the API lists them (each with its `rooms`); `folders`: [{ dir, room, workspace }]. Returns
|
|
11
|
+
* [{ dir, workspace }] to save. A folder whose room no listed project has is left as it is.
|
|
12
|
+
*/
|
|
13
|
+
export function projectsToLearn (workspaces = [], folders = []) {
|
|
14
|
+
const of = new Map()
|
|
15
|
+
for (const w of workspaces) for (const room of (w && w.rooms) || []) if (!of.has(room)) of.set(room, w.id)
|
|
16
|
+
const out = []
|
|
17
|
+
const seen = new Set()
|
|
18
|
+
for (const f of folders) {
|
|
19
|
+
const id = f && f.room ? of.get(f.room) : ''
|
|
20
|
+
if (!id || f.workspace === id || seen.has(f.dir)) continue
|
|
21
|
+
seen.add(f.dir)
|
|
22
|
+
out.push({ dir: f.dir, workspace: id })
|
|
23
|
+
}
|
|
24
|
+
return out
|
|
25
|
+
}
|
package/src/session.js
CHANGED
|
@@ -55,7 +55,7 @@ import { cleanTyping, TYPING_MS, AGENT_TYPING_MS } from './ui/chat.js'
|
|
|
55
55
|
import { DEFAULT_KEY, validBranchKey } from './branchdocs.js'
|
|
56
56
|
import { headKey, headName, branchTip, busy as gitBusy, leftoverLock, indexStamp, filesAt, blobAt, treeState, watchGit, SETTLE_MS as GIT_SETTLE_MS, STALE_LOCK_MS, upstreamOf, fetchUpstream, aheadBehind, changesBetween, fastForward, stage, hasBranch, switchBranch, defaultRemote, remoteBranch, follow, adoptRepo, originUrl } from './gitstate.js'
|
|
57
57
|
import { shareableRemote, repoLabel } from './repo-ref.js'
|
|
58
|
-
import { cleanVoice, newCallId, voiceView, inVoice, transcribeSetting, setTranscribe, addLine, readLines, MAX_IN_CALL, CALL_FULL, callAgents, setAgentLeft, notInCall, agentSays, markCallForAgents, namedAgents, callPing, spokenReply, AGENT_REPLY_MS } from './voice.js'
|
|
58
|
+
import { cleanVoice, cleanDmVoice, dmVoiceView, dmCallers, newCallId, voiceView, inVoice, transcribeSetting, setTranscribe, addLine, readLines, MAX_IN_CALL, CALL_FULL, callAgents, setAgentLeft, notInCall, agentSays, markCallForAgents, namedAgents, callPing, spokenReply, AGENT_REPLY_MS } from './voice.js'
|
|
59
59
|
import { toolInUse } from './agents/common.js'
|
|
60
60
|
|
|
61
61
|
export { applyTextDiff }
|
|
@@ -4181,9 +4181,11 @@ export class Session extends EventEmitter {
|
|
|
4181
4181
|
/**
|
|
4182
4182
|
* Joins, updates or leaves the session's voice call (src/voice.js): `v` is null to leave, or
|
|
4183
4183
|
* { muted, sig, transcribing, sharing } from the app window, which does the audio. Only people talk.
|
|
4184
|
+
* `dm`: a person's name, for the call with them alone (a direct message's call) instead.
|
|
4184
4185
|
*/
|
|
4185
|
-
setVoice (v) {
|
|
4186
|
+
setVoice (v, { dm = '' } = {}) {
|
|
4186
4187
|
if (!this.conn || !this.conn.awareness) throw new Error('Not connected to the codebase yet.')
|
|
4188
|
+
if (dm) return this.setDmVoice(v, String(dm).trim())
|
|
4187
4189
|
if (v && v.in !== false) {
|
|
4188
4190
|
if (this.kind === 'agent') throw new Error('Voice is for people: agents read the transcript instead.')
|
|
4189
4191
|
if (!this.mayTalk()) throw new Error(TALK_REFUSED)
|
|
@@ -4199,6 +4201,8 @@ export class Session extends EventEmitter {
|
|
|
4199
4201
|
// Speech goes to the transcript only while the owner has it on.
|
|
4200
4202
|
transcribing: v.transcribing === true && view.transcribe
|
|
4201
4203
|
})
|
|
4204
|
+
// One call at a time: joining the codebase's leaves a call with one person.
|
|
4205
|
+
if (this.conn.awareness.getLocalState()?.voiceDm) this.conn.awareness.setLocalStateField('voiceDm', null)
|
|
4202
4206
|
this.conn.awareness.setLocalStateField('voice', next)
|
|
4203
4207
|
if (v.agents === true) markCallForAgents(this.doc, next.call)
|
|
4204
4208
|
} else if (this.conn.awareness.getLocalState()?.voice) {
|
|
@@ -4208,9 +4212,44 @@ export class Session extends EventEmitter {
|
|
|
4208
4212
|
return this.voice()
|
|
4209
4213
|
}
|
|
4210
4214
|
|
|
4211
|
-
/**
|
|
4212
|
-
|
|
4215
|
+
/** Joins, updates or leaves the call with `partner` alone (voice.js dmVoiceView): never transcribed, and nobody else is in it. */
|
|
4216
|
+
setDmVoice (v, partner) {
|
|
4217
|
+
const aw = this.conn.awareness
|
|
4218
|
+
const was = cleanDmVoice(aw.getLocalState()?.voiceDm)
|
|
4219
|
+
if (v && v.in !== false) {
|
|
4220
|
+
if (this.kind === 'agent') throw new Error('Voice is for people: agents read the transcript instead.')
|
|
4221
|
+
if (!this.mayTalk()) throw new Error(TALK_REFUSED)
|
|
4222
|
+
const who = [...this.members, ...[...aw.getStates().values()].filter((s) => s && s.name)].find((m) => m.name === partner)
|
|
4223
|
+
if (!who || who.kind === 'agent' || partner === this.name) throw new Error(`${partner || 'That'} is not a person in this codebase you can call.`)
|
|
4224
|
+
const same = was && was.with === partner ? was : null
|
|
4225
|
+
const view = this.voice({ dm: partner })
|
|
4226
|
+
const next = cleanDmVoice({
|
|
4227
|
+
...v,
|
|
4228
|
+
in: true,
|
|
4229
|
+
with: partner,
|
|
4230
|
+
since: same ? same.since : Date.now(),
|
|
4231
|
+
call: same ? same.call : (view.peers[0] && view.peers[0].call) || newCallId()
|
|
4232
|
+
})
|
|
4233
|
+
// One call at a time: a call with one person leaves the codebase's.
|
|
4234
|
+
if (aw.getLocalState()?.voice) aw.setLocalStateField('voice', null)
|
|
4235
|
+
aw.setLocalStateField('voiceDm', next)
|
|
4236
|
+
} else if (was && was.with === partner) {
|
|
4237
|
+
aw.setLocalStateField('voiceDm', null)
|
|
4238
|
+
}
|
|
4239
|
+
this.scheduleStatusWrite()
|
|
4240
|
+
return this.voice({ dm: partner })
|
|
4241
|
+
}
|
|
4242
|
+
|
|
4243
|
+
/** The calls with one person that are going on for us: { name: its view }, ours and anyone's who is calling us. */
|
|
4244
|
+
voiceDms () {
|
|
4245
|
+
if (!this.conn || !this.conn.awareness) return {}
|
|
4246
|
+
return Object.fromEntries(dmCallers({ awareness: this.conn.awareness, clientID: this.doc.clientID, name: this.name }).map((n) => [n, this.voice({ dm: n })]))
|
|
4247
|
+
}
|
|
4248
|
+
|
|
4249
|
+
/** The call as this app sees it (voiceView): who is in, and the signals left for us. `dm`: the call with that person alone. */
|
|
4250
|
+
voice ({ dm = '' } = {}) {
|
|
4213
4251
|
if (!this.conn || !this.conn.awareness) return { me: 0, in: false, muted: false, call: '', transcribe: false, peers: [] }
|
|
4252
|
+
if (dm) return dmVoiceView({ awareness: this.conn.awareness, clientID: this.doc.clientID, name: this.name, partner: dm })
|
|
4214
4253
|
return voiceView({ awareness: this.conn.awareness, clientID: this.doc.clientID, members: this.members, doc: this.doc })
|
|
4215
4254
|
}
|
|
4216
4255
|
|
package/src/ui/app.css
CHANGED
|
@@ -1765,14 +1765,20 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1765
1765
|
.ws.pj-cb[data-side-page="chat"] .ws-chat { display: flex; }
|
|
1766
1766
|
.ws.pj-cb:is([data-side-page="connections"], [data-side-page="artifacts"]) :is(#main, #mainbar) { display: none; }
|
|
1767
1767
|
.ws.pj-cb .ws-main > .pj-pmain { flex: 1; }
|
|
1768
|
-
/* a call
|
|
1769
|
-
.ws.pj-cb
|
|
1770
|
-
.ws.pj-cb[data-side
|
|
1771
|
-
.ws.pj-cb
|
|
1768
|
+
/* a call is in the channel: a screen someone shares there sits in the middle, the channel beside it */
|
|
1769
|
+
.ws.pj-cb[data-side-page="chat"]:has(#screen-stage:not([hidden])) .ws-main { display: flex; }
|
|
1770
|
+
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: 244px minmax(0, 1fr) 380px; }
|
|
1771
|
+
.ws.pj-cb[data-side="shut"][data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: minmax(0, 1fr) 380px; }
|
|
1772
|
+
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) .ws-chat { border-left: 1px solid var(--border); }
|
|
1773
|
+
/* a call going on shows on its channel's row */
|
|
1774
|
+
.pj-side .pj-call { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--ok); }
|
|
1775
|
+
.pj-side .pj-call svg { width: 13px; height: 13px; color: inherit; }
|
|
1772
1776
|
@media (max-width: 900px) {
|
|
1773
|
-
.ws.pj-cb .ws-body
|
|
1777
|
+
.ws.pj-cb .ws-body { grid-template-columns: minmax(0, 1fr); }
|
|
1774
1778
|
.ws.pj-cb .pj-side { position: absolute; top: 0; bottom: 0; left: 0; z-index: 5; width: min(244px, 80vw); max-height: none; border-right: 1px solid var(--border); border-bottom: 0; box-shadow: var(--shadow-pop); }
|
|
1775
|
-
|
|
1779
|
+
/* too narrow for both: the screen takes the page, and Hide puts the channel back */
|
|
1780
|
+
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
|
|
1781
|
+
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) .ws-chat { display: none; }
|
|
1776
1782
|
}
|
|
1777
1783
|
|
|
1778
1784
|
/* ---- Artifacts (files.js artifactsHtml): tiles across the page; an open artifact takes the page
|
package/src/ui/loom.css
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
.loom-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
|
|
13
13
|
.loom-title b { font-weight: 600; font-size: 14px; }
|
|
14
14
|
.loom-title .hint { font-size: 12px; color: var(--muted); white-space: nowrap; }
|
|
15
|
-
.loom-live { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 600; }
|
|
16
|
-
.loom-live .pulse { width: 7px; height: 7px; }
|
|
17
15
|
.loom-bar .spacer { flex: 1; }
|
|
18
16
|
.loom-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
|
|
19
17
|
.loom-seg .loom-chip { border: 0; border-radius: 0; }
|
|
@@ -23,6 +21,9 @@
|
|
|
23
21
|
.loom-chip:hover { color: var(--text); }
|
|
24
22
|
.loom-chip.on { background: var(--panel-2); color: var(--text); }
|
|
25
23
|
.loom-chip.off { border-style: dashed; }
|
|
24
|
+
/* lanes you hid: a row of chips under the lane heads, there only while a lane is hidden */
|
|
25
|
+
.loom-hidden { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 18px; border-bottom: 1px solid var(--border); }
|
|
26
|
+
.loom-hidden .hint { font-size: 12px; color: var(--muted); }
|
|
26
27
|
|
|
27
28
|
/* ---------- lanes ---------- */
|
|
28
29
|
.loom-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative; scrollbar-width: thin; } /* lanes fold to fit, so never sideways */
|
package/src/ui/loom.js
CHANGED
|
@@ -60,7 +60,7 @@ export function renderLoom (el, { build, prefs, me, names, meAgent, onAction })
|
|
|
60
60
|
if (typing && typing === document.activeElement) return
|
|
61
61
|
if (!ticker) ticker = setInterval(tickClocks, 30000)
|
|
62
62
|
const wasLoom = showsLoom(el)
|
|
63
|
-
const merged =
|
|
63
|
+
const merged = el.clientWidth > 0 && el.clientWidth < MERGE_BELOW
|
|
64
64
|
lastWidth = el.clientWidth
|
|
65
65
|
model = build(merged, Math.max(0, el.clientWidth - 14)) // less a scrollbar
|
|
66
66
|
const html = loomHtml(model, { prefs, me, names, meAgent, merged })
|
|
@@ -114,29 +114,14 @@ function loomHtml (m, { prefs, me, names, meAgent, merged }) {
|
|
|
114
114
|
const WIDTH = { open: 'minmax(250px, 1fr)', strip: '46px', crowd: '58px', merged: 'minmax(0, 1fr)' }
|
|
115
115
|
const cols = m.columns.length ? m.columns.map((c) => WIDTH[c.kind]).join(' ') : 'minmax(0, 1fr)'
|
|
116
116
|
const colorOf = new Map(lanes.map((l) => [l.name, colorFor(l.name, l.color)]))
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const working = lanes.filter((l) => l.working).length
|
|
120
|
-
const dens = prefs.density === 'compact' ? 'compact' : 'detailed'
|
|
117
|
+
// One way to look at it: chat and tasks shown, every card in full, a lane per person (one column when narrow).
|
|
118
|
+
const dens = 'detailed'
|
|
121
119
|
const hidden = (prefs.hidden || []).filter(Boolean)
|
|
122
120
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<div class="loom-seg" role="group" aria-label="Show">
|
|
128
|
-
<button class="loom-chip${prefs.chat !== false ? ' on' : ''}" data-loom-pref="chat" aria-pressed="${prefs.chat !== false}">${I.chat}<span>Chat</span></button>
|
|
129
|
-
<button class="loom-chip${prefs.tasks !== false ? ' on' : ''}" data-loom-pref="tasks" aria-pressed="${prefs.tasks !== false}">${I.board}<span>Tasks</span></button>
|
|
130
|
-
</div>
|
|
131
|
-
<div class="loom-seg" role="group" aria-label="Detail">
|
|
132
|
-
<button class="loom-chip${dens === 'detailed' ? ' on' : ''}" data-loom-density="detailed" aria-pressed="${dens === 'detailed'}">Detailed</button>
|
|
133
|
-
<button class="loom-chip${dens === 'compact' ? ' on' : ''}" data-loom-density="compact" aria-pressed="${dens === 'compact'}">Compact</button>
|
|
134
|
-
</div>
|
|
135
|
-
<div class="loom-seg wide-only" role="group" aria-label="Layout">
|
|
136
|
-
<button class="loom-chip${prefs.layout !== 'merged' ? ' on' : ''}" data-loom-layout="lanes" aria-pressed="${prefs.layout !== 'merged'}" title="A lane per person">Lanes</button>
|
|
137
|
-
<button class="loom-chip${prefs.layout === 'merged' ? ' on' : ''}" data-loom-layout="merged" aria-pressed="${prefs.layout === 'merged'}" title="One column, in time order">One column</button>
|
|
138
|
-
</div>
|
|
139
|
-
</div>`
|
|
121
|
+
// Nothing sits above the lanes. A lane you hid leaves a chip beside the lane heads, to bring it back.
|
|
122
|
+
const back = hidden.length
|
|
123
|
+
? `<div class="loom-hidden" role="group" aria-label="Hidden lanes"><span class="hint">Hidden</span>${hidden.map((n) => `<button class="loom-chip off" data-loom-unhide="${esc(n)}" title="Show ${esc(n)}'s lane">${I.eye}<span>${esc(n)}</span></button>`).join('')}</div>`
|
|
124
|
+
: ''
|
|
140
125
|
|
|
141
126
|
const heads = merged
|
|
142
127
|
? ''
|
|
@@ -183,9 +168,9 @@ function loomHtml (m, { prefs, me, names, meAgent, merged }) {
|
|
|
183
168
|
})
|
|
184
169
|
|
|
185
170
|
return `<div class="loom${merged ? ' merged' : ''}${convFocus ? ' following' : ''}" data-density="${dens}">
|
|
186
|
-
${bar}
|
|
187
171
|
<div class="loom-scroll">
|
|
188
172
|
${heads}
|
|
173
|
+
${back}
|
|
189
174
|
<div class="loom-grid" role="feed" aria-label="Everyone's AI conversations, chat and task notes" style="grid-template-columns:${cols}">
|
|
190
175
|
${parts.join('')}
|
|
191
176
|
<svg class="loom-stitches" aria-hidden="true"></svg>
|
|
@@ -714,9 +699,6 @@ function bind (el) {
|
|
|
714
699
|
if ((b = pick('[data-file]'))) return act('file', b.dataset.file)
|
|
715
700
|
if ((b = pick('[data-loom-hide]'))) return act('hide', b.dataset.loomHide)
|
|
716
701
|
if ((b = pick('[data-loom-unhide]'))) return act('unhide', b.dataset.loomUnhide)
|
|
717
|
-
if ((b = pick('[data-loom-pref]'))) return act('toggle', b.dataset.loomPref)
|
|
718
|
-
if ((b = pick('[data-loom-density]'))) return act('density', b.dataset.loomDensity)
|
|
719
|
-
if ((b = pick('[data-loom-layout]'))) return act('layout', b.dataset.loomLayout)
|
|
720
702
|
if (t.closest('a, button')) return
|
|
721
703
|
if (String(window.getSelection?.() || '')) return // selecting text in a card, not opening it
|
|
722
704
|
const c = pick('.lc-turn')
|
package/src/ui/projects.js
CHANGED
|
@@ -230,19 +230,19 @@ export function codeCrumbHtml (project) {
|
|
|
230
230
|
* `tasks`: its open tasks; `artifacts`: how many the project has, once known; `chatNew`: messages in its channel since it was last looked at;
|
|
231
231
|
* `people`: who is in it, you first ({ name, color }).
|
|
232
232
|
*/
|
|
233
|
-
export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, chatNew = 0, people = [], connections = false, canInvite = true, dms = [], dmOn = '' }) {
|
|
233
|
+
export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, chatNew = 0, people = [], connections = false, canInvite = true, dms = [], dmOn = '', call = 0 }) {
|
|
234
234
|
const nav = (v, icon, label, n, attr = `data-code-page="${v}"`) => `<button type="button" class="${page === v ? 'on' : ''}" ${attr}${page === v ? ' aria-current="page"' : ''}>${icon}<span class="nm">${label}</span>${n ? `<span class="ct">${n}</span>` : ''}</button>`
|
|
235
235
|
const isFolded = (k) => foldedNow().has(k)
|
|
236
236
|
const label = (k, text, n) => `<div class="side-label pj-side-label"><button type="button" class="pj-fold" data-fold="${k}" aria-expanded="${!isFolded(k)}" title="${isFolded(k) ? 'Show' : 'Hide'} ${text.toLowerCase()}"><span>${text}</span>${I.chevDown}</button>${isFolded(k) && n ? `<span class="ct new">${n}</span>` : ''}</div>`
|
|
237
|
-
// A folded section keeps the row you are on
|
|
238
|
-
const channel = !isFolded('channels') || page === 'chat' || chatNew
|
|
237
|
+
// A folded section keeps the row you are on, what is new, and a call going on.
|
|
238
|
+
const channel = !isFolded('channels') || page === 'chat' || chatNew || call
|
|
239
239
|
const inDm = page === 'chat' ? dmOn : ''
|
|
240
240
|
return `
|
|
241
241
|
<nav class="side-nav" aria-label="Pages">${nav('loom', I.users, 'Loom')}${nav('tasks', I.board, 'Tasks', tasks)}${project ? nav('artifacts', I.folder, 'Artifacts', artifacts) : ''}${connections ? nav('connections', I.link, 'Connections') : ''}</nav>
|
|
242
242
|
${label('channels', 'Channels', chatNew)}
|
|
243
|
-
<div class="side-sessions pj-rooms">${channel ? `<button type="button" class="${page === 'chat' && !inDm ? 'on' : ''}" data-code-page="chat" data-dm="" title="Everyone working in ${esc(name)}"${page === 'chat' && !inDm ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${chatNew ? `<span class="ct new">${chatNew > 99 ? '99+' : chatNew}</span>` : ''}</button>` : ''}</div>
|
|
243
|
+
<div class="side-sessions pj-rooms">${channel ? `<button type="button" class="${page === 'chat' && !inDm ? 'on' : ''}" data-code-page="chat" data-dm="" title="Everyone working in ${esc(name)}"${page === 'chat' && !inDm ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${call ? `<span class="pj-call" title="${call === 1 ? '1 person is' : `${call} people are`} in a call here">${I.headset}${call}</span>` : ''}${chatNew ? `<span class="ct new">${chatNew > 99 ? '99+' : chatNew}</span>` : ''}</button>` : ''}</div>
|
|
244
244
|
${dms.length ? `${label('dms', 'Direct messages')}
|
|
245
|
-
<div class="side-sessions pj-rooms">${isFolded('dms') && !inDm && !dms.some((t) => t.n) ? '' : dms.filter((t) => !isFolded('dms') || t.name === inDm || t.n).map((t) => `<button type="button" class="${t.name === inDm ? 'on' : ''}" data-dm="${esc(t.name)}" title="You and ${esc(t.name)}"${t.name === inDm ? ' aria-current="page"' : ''}>${avatar(t.name)}<span class="nm">${esc(t.name)}</span>${t.n ? `<span class="ct new">${t.n > 99 ? '99+' : t.n}</span>` : ''}</button>`).join('')}</div>` : ''}
|
|
245
|
+
<div class="side-sessions pj-rooms">${isFolded('dms') && !inDm && !dms.some((t) => t.n || t.call) ? '' : dms.filter((t) => !isFolded('dms') || t.name === inDm || t.n || t.call).map((t) => `<button type="button" class="${t.name === inDm ? 'on' : ''}" data-dm="${esc(t.name)}" title="You and ${esc(t.name)}"${t.name === inDm ? ' aria-current="page"' : ''}>${avatar(t.name)}<span class="nm">${esc(t.name)}</span>${t.call ? `<span class="pj-call" title="${t.call === 1 ? `${esc(t.name)} is calling you` : `You and ${esc(t.name)} are in a call`}">${I.headset}${t.call}</span>` : ''}${t.n ? `<span class="ct new">${t.n > 99 ? '99+' : t.n}</span>` : ''}</button>`).join('')}</div>` : ''}
|
|
246
246
|
<div class="side-foot side-nav">
|
|
247
247
|
<button type="button" data-code-team title="People in this codebase"><span class="pj-faces sm">${people.slice(0, 3).map((m) => avatar(m.name, m.color)).join('')}</span><span class="nm">Team</span><span class="ct">${people.length}</span></button>
|
|
248
248
|
${canInvite ? `<button type="button" data-code-invite>${I.link}<span class="nm">Invite</span></button>` : ''}
|
package/src/ui/session.js
CHANGED
|
@@ -26,7 +26,7 @@ import { workspaceFilePicker, artifactsHtml, bindAllFiles } from './files.js'
|
|
|
26
26
|
import { sessionAgentsHtml } from './agent-place.js'
|
|
27
27
|
import { renderCatchUp, bindCatchUp } from './catchup.js'
|
|
28
28
|
import { heldCard } from './session-words.js'
|
|
29
|
-
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards,
|
|
29
|
+
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, callCounts, callScope } from './voice.js'
|
|
30
30
|
import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, toggleFolded } from './projects.js'
|
|
31
31
|
import { dmThreads } from './project-model.js'
|
|
32
32
|
|
|
@@ -219,8 +219,10 @@ export function mountSession (id) {
|
|
|
219
219
|
mountCall(id, mounted.signal, () => {
|
|
220
220
|
const st = sum().status
|
|
221
221
|
const colors = new Map([...st.peers.map((p) => [p.name, p.color]), [st.me.name, st.me.color]])
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
// Who can be called alone: a person in the codebase, never an agent or someone's AI.
|
|
223
|
+
const canCall = (n) => n !== st.me.name && [...st.peers, ...(st.members || [])].some((p) => p.name === n && p.kind !== 'agent' && !p.persona)
|
|
224
|
+
return { owner: !!st.access?.owner, me: st.me, colorOf: (n) => colors.get(n), canCall }
|
|
225
|
+
}, () => renderMessages(), () => renderCodeSide())
|
|
224
226
|
bindAccess()
|
|
225
227
|
bindChanges(id, mounted.signal, { onOpen: (path) => openFile(path, { tab: 'changes' }), close: () => setGitOpen(false), onCount: renderGitChip })
|
|
226
228
|
bindCatchUp($('#catchup'), { sessionId: () => current, onOpen: openFile })
|
|
@@ -393,6 +395,12 @@ const pj = () => !!state.workspacesOn
|
|
|
393
395
|
const projectHere = () => { const id = sum()?.workspace; return (id && (state.workspaces || []).find((w) => w.id === id)) || null }
|
|
394
396
|
let codeConns = null // the Connections card while its page shows
|
|
395
397
|
|
|
398
|
+
/** Under "Chat": who is in the conversation on screen. With the sidebar, a direct message is the two of you. */
|
|
399
|
+
function chatSub (st) {
|
|
400
|
+
if (pj() && state.to) return `only you and ${state.to}`
|
|
401
|
+
return st.peers.length ? `with ${peopleHere(st).map((p) => p.sessions && p.mine ? 'your AI' : p.name).join(', ')}` : 'just you so far'
|
|
402
|
+
}
|
|
403
|
+
|
|
396
404
|
function renderCodeSide () {
|
|
397
405
|
const el = $('#code-side')
|
|
398
406
|
if (!el || !current || !sum()) return
|
|
@@ -402,7 +410,16 @@ function renderCodeSide () {
|
|
|
402
410
|
const page = side || (w.mode === 'tasks' ? 'tasks' : 'loom')
|
|
403
411
|
const open = (st.tasks || []).filter((t) => !t.archived && (t.column === 'todo' || t.column === 'doing')).length
|
|
404
412
|
const people = [st.me, ...peopleHere(st)]
|
|
405
|
-
|
|
413
|
+
// A call is in its conversation: the codebase's in the channel, one with a person in your messages with them.
|
|
414
|
+
if (side === 'chat') callScope(state.to || '')
|
|
415
|
+
const calls = callCounts()
|
|
416
|
+
const dms = dmThreads(renderable(state.messages.get(current)), st.me?.name || '').map((t) => ({ ...t, n: dmNew.get(t.name) || 0, call: calls.dms[t.name] || 0 }))
|
|
417
|
+
// Someone calling you has a row, whether or not you have written to each other.
|
|
418
|
+
for (const name of Object.keys(calls.dms)) if (!dms.some((t) => t.name === name)) dms.unshift({ name, ts: Date.now(), n: 0, call: calls.dms[name] })
|
|
419
|
+
// So does the conversation on screen, before anything is written in it.
|
|
420
|
+
if (side === 'chat' && state.to && !dms.some((t) => t.name === state.to)) dms.unshift({ name: state.to, ts: Date.now(), n: 0, call: 0 })
|
|
421
|
+
if ($('#chat-sub')) $('#chat-sub').textContent = chatSub(st)
|
|
422
|
+
el.innerHTML = codeSideHtml({ page, name: st.sessionName || basename(sum().dir), project: projectHere(), tasks: open, artifacts: (projectData()?.files || []).filter((f) => f.kind !== 'folder').length, chatNew, people, dms, dmOn: state.to || '', connections: !!state.connectionsOn, canInvite: !!st.access?.owner || st.access?.role !== 'viewer', call: calls.channel })
|
|
406
423
|
const root = $('#ws')
|
|
407
424
|
root.dataset.sidePage = side
|
|
408
425
|
$('#code-crumb').innerHTML = codeCrumbHtml(projectHere())
|
|
@@ -733,7 +750,7 @@ function renderTop () {
|
|
|
733
750
|
$('#rename-btn').hidden = !st.access?.owner
|
|
734
751
|
$('#move-ws-btn').hidden = !(st.access?.owner && state.workspacesOn && (state.workspaces || []).some((w) => w.access === 'edit'))
|
|
735
752
|
renderTaskButton()
|
|
736
|
-
$('#chat-sub').textContent =
|
|
753
|
+
$('#chat-sub').textContent = chatSub(st)
|
|
737
754
|
}
|
|
738
755
|
|
|
739
756
|
// --------------------------------------------------------------- source control --
|
|
@@ -2225,11 +2242,8 @@ async function refreshFile (path, highlight) {
|
|
|
2225
2242
|
function loomPrefs (w) {
|
|
2226
2243
|
const p = w.loom && typeof w.loom === 'object' ? w.loom : {}
|
|
2227
2244
|
const names = (list) => Array.isArray(list) ? list.filter((n) => typeof n === 'string') : []
|
|
2245
|
+
// The Loom is shown one way (chat and tasks in it, cards in full, a lane each): choices saved by an older app are dropped.
|
|
2228
2246
|
w.loom = {
|
|
2229
|
-
chat: p.chat !== false,
|
|
2230
|
-
tasks: p.tasks !== false,
|
|
2231
|
-
density: p.density === 'compact' ? 'compact' : 'detailed',
|
|
2232
|
-
layout: p.layout === 'merged' ? 'merged' : 'lanes',
|
|
2233
2247
|
hidden: names(p.hidden),
|
|
2234
2248
|
pinned: names(p.pinned), // lanes kept open when they don't all fit
|
|
2235
2249
|
opened: names(p.opened).slice(0, 20), // lanes opened from a strip, latest first
|
|
@@ -2287,11 +2301,8 @@ function loomAction (kind, value) {
|
|
|
2287
2301
|
}
|
|
2288
2302
|
if (kind === 'hide') prefs.hidden = [...new Set([...prefs.hidden, value])]
|
|
2289
2303
|
else if (kind === 'unhide') prefs.hidden = prefs.hidden.filter((n) => n !== value)
|
|
2290
|
-
else if (kind === 'toggle') prefs[value] = prefs[value] === false
|
|
2291
|
-
else if (kind === 'density') prefs.density = value
|
|
2292
|
-
else if (kind === 'layout') prefs.layout = value
|
|
2293
2304
|
else if (kind === 'pin') prefs.pinned = prefs.pinned.includes(value) ? prefs.pinned.filter((n) => n !== value) : [...prefs.pinned, value]
|
|
2294
|
-
else if (kind === 'open-lane')
|
|
2305
|
+
else if (kind === 'open-lane') prefs.opened = [value, ...prefs.opened.filter((n) => n !== value)].slice(0, 20)
|
|
2295
2306
|
else if (kind === 'conv-name') {
|
|
2296
2307
|
// Empty: back to the conversation's own name (its tool's title, or its first prompt).
|
|
2297
2308
|
const rest = Object.fromEntries(Object.entries(prefs.convNames).filter(([k]) => k !== value.conv))
|
|
@@ -2451,7 +2462,7 @@ let dmNew = new Map() // and for each direct message's row: who wrote -> how man
|
|
|
2451
2462
|
|
|
2452
2463
|
// With the sidebar (projects on), chat is a page from the sidebar, not a column: it counts as folded
|
|
2453
2464
|
// whenever it is not the page showing (a call keeps it beside the page).
|
|
2454
|
-
const chatCollapsed = () => pj() && current ?
|
|
2465
|
+
const chatCollapsed = () => pj() && current ? ws(current).side !== 'chat' : recall('chat-collapsed', '') === '1'
|
|
2455
2466
|
const chatWidthFor = (body, w) => Math.round(Math.min(Math.max(w, CHAT_MIN), Math.max(CHAT_MIN, Math.min(CHAT_MAX, body.clientWidth - 560))))
|
|
2456
2467
|
|
|
2457
2468
|
function applyChatLayout () {
|
|
@@ -2579,7 +2590,8 @@ function bindChat () {
|
|
|
2579
2590
|
input.addEventListener('keydown', (e) => {
|
|
2580
2591
|
if (e.key === 'Enter' && !e.shiftKey && !e.isComposing && !e.defaultPrevented) { e.preventDefault(); $('#composer').requestSubmit() }
|
|
2581
2592
|
})
|
|
2582
|
-
|
|
2593
|
+
// With the sidebar, who you write to is the conversation on screen: its row, its messages, its call.
|
|
2594
|
+
$('#to-select').onchange = (e) => { state.to = e.target.value; updatePlaceholder(); if (pj()) { renderCodeSide(); renderMessages() } }
|
|
2583
2595
|
$('#attach-btn').onclick = () => $('#file-input').click()
|
|
2584
2596
|
$('#file-input').onchange = (e) => { addFiles(e.target.files); e.target.value = '' }
|
|
2585
2597
|
$('[data-attach-workspace]')?.addEventListener('click', async () => {
|
package/src/ui/voice.js
CHANGED
|
@@ -10,11 +10,18 @@ import { VoiceCall } from './voice-call.js'
|
|
|
10
10
|
import { screenShown, shareRefused } from './voice-model.js'
|
|
11
11
|
import { playSound } from './sounds.js'
|
|
12
12
|
|
|
13
|
-
const views = new Map() //
|
|
13
|
+
const views = new Map() // a call's key -> the call as its session's server sees it
|
|
14
|
+
// A call's key: the codebase's own call is its session id; a call with one person (a direct
|
|
15
|
+
// message's) is the session id, a line break, and that person's name.
|
|
16
|
+
const keyOf = (id, to) => to ? `${id}\n${to}` : id
|
|
17
|
+
const sidOf = (key) => key.split('\n')[0]
|
|
18
|
+
const toOf = (key) => key.split('\n')[1] || ''
|
|
19
|
+
const voiceUrl = (key) => `/api/sessions/${sidOf(key)}/voice${toOf(key) ? `?to=${encodeURIComponent(toOf(key))}` : ''}`
|
|
14
20
|
const EMPTY = { peers: [], transcribe: false, recent: [], calls: [], since: 0, call: '', agents: [] }
|
|
15
21
|
const FULL = 6 // voice.js MAX_IN_CALL: everyone connects to everyone, so a call holds six
|
|
16
|
-
let live = null // { sid, call }: the call this window is in (one at a time)
|
|
17
|
-
let shown = null // { id, who, chatChanged }: the session on screen
|
|
22
|
+
let live = null // { sid, call }: the call this window is in (one at a time); `sid` is the call's key
|
|
23
|
+
let shown = null // { id, to, key, who, chatChanged, callChanged }: the session on screen, and whose conversation ('' the channel's)
|
|
24
|
+
const rung = new Set() // calls with one person we were told about, so each says so once
|
|
18
25
|
let joining = false
|
|
19
26
|
let asking = false // a transcribed call: what joining means, shown before the microphone opens
|
|
20
27
|
let options = false // the transcript choices, open in the pinned call
|
|
@@ -50,7 +57,7 @@ window.quiltDesktop?.onPickScreen?.((ask) => pickScreen(ask))
|
|
|
50
57
|
/** Shows what can be shared (`sources`, or `blocked` when the system doesn't let Quilt see the screen); resolves to the id picked, or null. */
|
|
51
58
|
export function pickScreen ({ sources = [], blocked = false } = {}) {
|
|
52
59
|
endPicking(null)
|
|
53
|
-
if (!shown || !live || live.sid !== shown.id) return Promise.resolve(null)
|
|
60
|
+
if (!shown || !live || sidOf(live.sid) !== shown.id) return Promise.resolve(null)
|
|
54
61
|
return new Promise((resolve) => { picking = { sources, blocked, resolve }; renderCall() })
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -65,8 +72,8 @@ function endPicking (id) {
|
|
|
65
72
|
* A session is on screen: wire the call into its chat. `who()`: { owner, me, colorOf(name) } now;
|
|
66
73
|
* `chatChanged()`: the chat's calls changed, draw its messages again.
|
|
67
74
|
*/
|
|
68
|
-
export function mountCall (id, signal, who, chatChanged = () => {}) {
|
|
69
|
-
shown = { id, who, chatChanged }
|
|
75
|
+
export function mountCall (id, signal, who, chatChanged = () => {}, callChanged = () => {}) {
|
|
76
|
+
shown = { id, to: '', key: id, who, chatChanged, callChanged, counts: '' }
|
|
70
77
|
asking = false
|
|
71
78
|
options = false
|
|
72
79
|
drawn = ''
|
|
@@ -77,30 +84,89 @@ export function mountCall (id, signal, who, chatChanged = () => {}) {
|
|
|
77
84
|
$('#self-share')?.addEventListener('click', onClick, { signal })
|
|
78
85
|
const tick = setInterval(renderCall, 20000) // the call's minutes
|
|
79
86
|
signal.addEventListener('abort', () => clearInterval(tick))
|
|
80
|
-
api('GET',
|
|
87
|
+
api('GET', voiceUrl(id)).then((v) => voiceEvent(id, v), () => {})
|
|
81
88
|
renderCall()
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
export function unmountCall () { endPicking(null); shown = null; asking = false; options = false }
|
|
85
92
|
|
|
86
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* The conversation on screen changed: `to` is a person's name for the call with them alone (a
|
|
95
|
+
* direct message's), '' for the codebase's own. The call button and the pinned call follow it.
|
|
96
|
+
*/
|
|
97
|
+
export function callScope (to = '') {
|
|
98
|
+
if (!shown || shown.to === to) return
|
|
99
|
+
shown.to = to
|
|
100
|
+
shown.key = keyOf(shown.id, to)
|
|
101
|
+
asking = false
|
|
102
|
+
options = false
|
|
103
|
+
drawn = ''
|
|
104
|
+
renderCall()
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** How many people are in each call of the codebase on screen: { channel, dms: { name: n } } (0 and left out: no call). */
|
|
108
|
+
export function callCounts () {
|
|
109
|
+
const out = { channel: 0, dms: {} }
|
|
110
|
+
if (!shown) return out
|
|
111
|
+
const n = (v) => v ? v.peers.length + (v.in ? 1 : 0) : 0
|
|
112
|
+
out.channel = n(views.get(shown.id))
|
|
113
|
+
for (const [k, v] of views) if (toOf(k) && sidOf(k) === shown.id && n(v)) out.dms[toOf(k)] = n(v)
|
|
114
|
+
return out
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Keeps an answer about one call: the codebase's comes with the calls with one person going on beside it (`dms`). */
|
|
118
|
+
function keep (key, view) {
|
|
119
|
+
if (toOf(key)) { views.set(key, view); return view }
|
|
120
|
+
const { dms, ...own } = view
|
|
121
|
+
views.set(key, own)
|
|
122
|
+
if (dms) {
|
|
123
|
+
for (const k of views.keys()) if (toOf(k) && sidOf(k) === key && !dms[toOf(k)]) views.delete(k)
|
|
124
|
+
for (const [name, v] of Object.entries(dms)) views.set(keyOf(key, name), v)
|
|
125
|
+
}
|
|
126
|
+
return view
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The call as the app's server sees it now (a `voice` event, or an answer): the codebase's, with its `dms`. */
|
|
87
130
|
export function voiceEvent (id, view) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (
|
|
131
|
+
keep(id, view)
|
|
132
|
+
for (const key of [id, ...Object.keys(view.dms || {}).map((n) => keyOf(id, n))]) {
|
|
133
|
+
const v = views.get(key)
|
|
134
|
+
// Left in the call by a window that closed or reloaded without leaving: out now.
|
|
135
|
+
if (!checked.has(key)) {
|
|
136
|
+
checked.add(key)
|
|
137
|
+
if (v.in && !(live && live.sid === key)) { api('POST', voiceUrl(key), { in: false }).then((r) => answered(key, r), () => {}); continue }
|
|
138
|
+
}
|
|
139
|
+
// Someone started a call with us alone: say so once, where it can be answered.
|
|
140
|
+
if (toOf(key) && !v.in && v.peers.length && v.call && !rung.has(v.call)) {
|
|
141
|
+
rung.add(v.call)
|
|
142
|
+
if (shown && shown.id === id && shown.key !== key) toast(`${toOf(key)} is calling you: open your messages with ${toOf(key)} to join.`)
|
|
143
|
+
}
|
|
93
144
|
}
|
|
145
|
+
changed(id)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** An answer about one call (`key`), from joining, leaving or a setting. */
|
|
149
|
+
function answered (key, view) {
|
|
150
|
+
if (toOf(key)) { keep(key, view); changed(sidOf(key)) } else voiceEvent(key, view)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** What we know of session `id`'s calls changed: the call we're in hears it, and the page draws it. */
|
|
154
|
+
function changed (id) {
|
|
94
155
|
// The call we're in: it plays the join and leave sounds itself (onPeople), so a relay blip plays neither.
|
|
95
|
-
if (live && live.sid === id) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// A call ended: its card joins the chat. The call going on now changes every few seconds and
|
|
99
|
-
// has no card, so it never redraws the chat.
|
|
100
|
-
const now = going(view)
|
|
101
|
-
const calls = JSON.stringify(view.calls.filter((c) => c.call !== now))
|
|
102
|
-
if (calls !== callsDrawn) { callsDrawn = calls; shown.chatChanged() }
|
|
156
|
+
if (live && sidOf(live.sid) === id) {
|
|
157
|
+
const v = views.get(live.sid)
|
|
158
|
+
if (v) { live.call.update(v); if (!toOf(live.sid)) speakAgents(id, v) }
|
|
103
159
|
}
|
|
160
|
+
if (!shown || shown.id !== id) return
|
|
161
|
+
renderCall()
|
|
162
|
+
const counts = JSON.stringify(callCounts())
|
|
163
|
+
if (counts !== shown.counts) { shown.counts = counts; shown.callChanged() }
|
|
164
|
+
// A call ended: its card joins the chat. The call going on now changes every few seconds and
|
|
165
|
+
// has no card, so it never redraws the chat.
|
|
166
|
+
const view = views.get(id) || EMPTY
|
|
167
|
+
const now = going(view)
|
|
168
|
+
const calls = JSON.stringify(view.calls.filter((c) => c.call !== now))
|
|
169
|
+
if (calls !== callsDrawn) { callsDrawn = calls; shown.chatChanged() }
|
|
104
170
|
}
|
|
105
171
|
|
|
106
172
|
/** The call going on now, if anyone is in one: its id. */
|
|
@@ -114,9 +180,9 @@ async function join (id, transcribing) {
|
|
|
114
180
|
try {
|
|
115
181
|
if (live) await leave()
|
|
116
182
|
const call = new VoiceCall({
|
|
117
|
-
post: (b) => api('POST',
|
|
183
|
+
post: (b) => api('POST', voiceUrl(id), b).then((v) => keep(id, v)),
|
|
118
184
|
ice: () => api('GET', '/api/voice/ice'),
|
|
119
|
-
clip: (b) => api('POST', `/api/sessions/${id}/voice/clip`, b).catch((err) => {
|
|
185
|
+
clip: (b) => api('POST', `/api/sessions/${sidOf(id)}/voice/clip`, b).catch((err) => {
|
|
120
186
|
// Over the month's minutes, transcripts not set up, or a Quilt server without them yet:
|
|
121
187
|
// stop sending, and say why once.
|
|
122
188
|
if (err.status === 429 || err.status === 503 || err.status === 404) {
|
|
@@ -129,7 +195,7 @@ async function join (id, transcribing) {
|
|
|
129
195
|
}
|
|
130
196
|
throw err
|
|
131
197
|
}),
|
|
132
|
-
onChange: () => { if (shown && shown.id === id) renderCall() },
|
|
198
|
+
onChange: () => { if (shown && shown.id === sidOf(id)) renderCall() },
|
|
133
199
|
onPeople: (sound) => playSound(sound, { force: true })
|
|
134
200
|
})
|
|
135
201
|
live = { sid: id, call }
|
|
@@ -158,7 +224,7 @@ async function leave () {
|
|
|
158
224
|
selfClosed = false
|
|
159
225
|
if (selfVideo) selfVideo.srcObject = null
|
|
160
226
|
const v = await call.leave().catch(() => null)
|
|
161
|
-
if (v)
|
|
227
|
+
if (v) answered(sid, v)
|
|
162
228
|
playSound('callOut', { force: true })
|
|
163
229
|
renderCall()
|
|
164
230
|
}
|
|
@@ -166,13 +232,13 @@ async function leave () {
|
|
|
166
232
|
// Closing or reloading the window leaves the call (the page can't wait for an answer).
|
|
167
233
|
window.addEventListener('pagehide', () => {
|
|
168
234
|
if (!live) return
|
|
169
|
-
navigator.sendBeacon(
|
|
235
|
+
navigator.sendBeacon(`${voiceUrl(live.sid)}${toOf(live.sid) ? '&' : '?'}t=${encodeURIComponent(TOKEN || '')}`, new Blob([JSON.stringify({ in: false })], { type: 'application/json' }))
|
|
170
236
|
})
|
|
171
237
|
|
|
172
238
|
async function onClick (e) {
|
|
173
239
|
const t = e.target.closest('button')
|
|
174
240
|
if (!t || !shown || !t.closest('#chat-call, #call-pin, #screen-stage, #self-share, .call-card')) return
|
|
175
|
-
const id = shown.
|
|
241
|
+
const id = shown.key
|
|
176
242
|
const view = views.get(id) || EMPTY
|
|
177
243
|
const d = t.dataset
|
|
178
244
|
if (d.callJoin === 'ask') {
|
|
@@ -196,7 +262,7 @@ async function onClick (e) {
|
|
|
196
262
|
renderCall()
|
|
197
263
|
} else if (d.screenHide !== undefined) {
|
|
198
264
|
// Hidden until they stop sharing: everyone sharing now, so another screen doesn't take its place.
|
|
199
|
-
for (const p of view.peers) if (p.sharing) hiddenScreens.add(p.id)
|
|
265
|
+
for (const p of ((live && views.get(live.sid)) || view).peers) if (p.sharing) hiddenScreens.add(p.id)
|
|
200
266
|
renderCall()
|
|
201
267
|
} else if (d.selfShare) {
|
|
202
268
|
selfClosed = d.selfShare === 'close'
|
|
@@ -221,7 +287,7 @@ async function onClick (e) {
|
|
|
221
287
|
renderCall()
|
|
222
288
|
} else if (d.callOwner) {
|
|
223
289
|
try {
|
|
224
|
-
voiceEvent(id, await api('POST', `/api/sessions/${id}/voice/transcribe`, { on: d.callOwner === 'on' }))
|
|
290
|
+
voiceEvent(shown.id, await api('POST', `/api/sessions/${shown.id}/voice/transcribe`, { on: d.callOwner === 'on' }))
|
|
225
291
|
} catch (err) { toast(err.message) }
|
|
226
292
|
} else if (d.callRead) {
|
|
227
293
|
const c = d.callRead
|
|
@@ -229,7 +295,7 @@ async function onClick (e) {
|
|
|
229
295
|
else {
|
|
230
296
|
opened.add(c)
|
|
231
297
|
if (!full.has(c)) {
|
|
232
|
-
try { full.set(c, (await api('GET', `/api/sessions/${id}/voice/transcript?call=${encodeURIComponent(c)}`)).lines) } catch (err) { toast(err.message); opened.delete(c) }
|
|
298
|
+
try { full.set(c, (await api('GET', `/api/sessions/${shown.id}/voice/transcript?call=${encodeURIComponent(c)}`)).lines) } catch (err) { toast(err.message); opened.delete(c) }
|
|
233
299
|
}
|
|
234
300
|
}
|
|
235
301
|
shown.chatChanged()
|
|
@@ -290,7 +356,7 @@ function lineHtml (l, colorOf) {
|
|
|
290
356
|
|
|
291
357
|
/** Rings on whoever speaks now, without redrawing (it changes many times a second). */
|
|
292
358
|
function paintTalk () {
|
|
293
|
-
if (!live || !shown || live.sid !== shown.
|
|
359
|
+
if (!live || !shown || live.sid !== shown.key) return
|
|
294
360
|
for (const el of document.querySelectorAll('#call-pin [data-face]')) {
|
|
295
361
|
const k = el.dataset.face
|
|
296
362
|
el.classList.toggle('talk', k.startsWith('agent:') ? live.call.agentTalking === k.slice(6) : live.call.speaking(k === 'me' ? 'me' : Number(k)))
|
|
@@ -302,27 +368,37 @@ export function renderCall () {
|
|
|
302
368
|
const btn = $('#chat-call')
|
|
303
369
|
const pin = $('#call-pin')
|
|
304
370
|
if (!btn || !pin || !shown) return
|
|
305
|
-
const id = shown.
|
|
371
|
+
const id = shown.key
|
|
372
|
+
const to = shown.to
|
|
306
373
|
const view = views.get(id) || EMPTY
|
|
307
|
-
const
|
|
374
|
+
const who = shown.who()
|
|
375
|
+
const { me, colorOf } = who
|
|
376
|
+
// Transcripts are the codebase's call's: a call with one person is never written down.
|
|
377
|
+
const owner = who.owner && !to
|
|
308
378
|
// In the call once the microphone is open and the server has us.
|
|
309
379
|
const here = !!(live && live.sid === id && live.call.in)
|
|
310
380
|
const elsewhere = !!(live && live.sid !== id)
|
|
311
381
|
const others = view.peers
|
|
312
382
|
const c = here ? live.call : null
|
|
313
|
-
|
|
383
|
+
// A person can be called; an agent, or someone who is not in the codebase, can't.
|
|
384
|
+
btn.hidden = here || joining || asking || others.length > 0 || !!(to && !(who.canCall && who.canCall(to)))
|
|
314
385
|
btn.disabled = elsewhere
|
|
386
|
+
btn.title = elsewhere ? 'Leave your other call first' : to ? `Call ${to}` : 'Start a voice call in this codebase'
|
|
315
387
|
pin.hidden = !(here || joining || asking || others.length)
|
|
316
388
|
// The latest lines change every few seconds: they're drawn on their own, so the controls above
|
|
317
389
|
// them (Join, mute, leave) are never redrawn under a click.
|
|
318
390
|
const lines = here && view.recent.length ? view.recent.map((l) => lineHtml(l, colorOf)).join('') : ''
|
|
319
391
|
// A screen hidden stays hidden until its person stops sharing; the next time they share, it shows.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
392
|
+
// The screens are the call's we are in, whichever conversation is on screen: in the channel while
|
|
393
|
+
// in a call with one person, their screen still fills the middle.
|
|
394
|
+
const mine = live && sidOf(live.sid) === shown.id && live.call.in ? live : null
|
|
395
|
+
const sharers = mine ? (views.get(mine.sid) || EMPTY).peers : []
|
|
396
|
+
for (const pid of [...hiddenScreens]) if (!sharers.some((p) => p.id === pid && p.sharing)) hiddenScreens.delete(pid)
|
|
397
|
+
const showing = mine ? screenShown({ peers: sharers, picked, hidden: hiddenScreens }) : null
|
|
398
|
+
renderStage({ here: !!mine, showing, others: sharers, colorOf })
|
|
323
399
|
// Closing the preview lasts until we stop sharing; the next share shows it again.
|
|
324
|
-
if (!
|
|
325
|
-
renderSelf(
|
|
400
|
+
if (!mine?.call.sharing) selfClosed = false
|
|
401
|
+
renderSelf(mine ? mine.call : null)
|
|
326
402
|
const now = Date.now()
|
|
327
403
|
const agents = view.agents || []
|
|
328
404
|
redrawWhenMuted(agents, now)
|
|
@@ -345,7 +421,7 @@ export function renderCall () {
|
|
|
345
421
|
<div class="cp-two"><button type="button" class="btn sm primary" data-call-join="transcribed">${others.length ? 'Join' : 'Start'}, transcribed</button><button type="button" class="btn sm" data-call-join="plain">${others.length ? 'Join' : 'Start'}, not transcribed</button></div>`
|
|
346
422
|
} else if (!here) {
|
|
347
423
|
pin.innerHTML = `<div class="cp-top"><span class="call-dot"></span><span class="call-faces">${others.map((p) => face(p.id, p.name, p.color, p.muted)).join('')}${agentFaces}</span>
|
|
348
|
-
<span class="cp-what"><b>${esc(names(others.map((p) => p.name)))} ${others.length === 1 ? 'is' : 'are'} in a call</b><span class="call-sub">${[dur, view.transcribe ? 'transcribed' : '', ...others.filter((p) => p.sharing).map((p) => `${esc(p.name)} sharing a screen`)].filter(Boolean).join(' · ')}</span></span>
|
|
424
|
+
<span class="cp-what"><b>${to ? `${esc(to)} is calling you` : `${esc(names(others.map((p) => p.name)))} ${others.length === 1 ? 'is' : 'are'} in a call`}</b><span class="call-sub">${[dur, view.transcribe ? 'transcribed' : '', ...others.filter((p) => p.sharing).map((p) => `${esc(p.name)} sharing a screen`)].filter(Boolean).join(' · ')}</span></span>
|
|
349
425
|
<button type="button" class="btn sm primary cp-end" data-call-join="ask" ${elsewhere ? 'disabled title="Leave your other call first"' : others.length >= FULL ? 'disabled title="This call is full: calls hold six people for now."' : ''}>Join</button></div>`
|
|
350
426
|
} else {
|
|
351
427
|
const mine = c.transcribing && view.transcribe
|
|
@@ -466,7 +542,8 @@ function paintLines (pin, html) {
|
|
|
466
542
|
|
|
467
543
|
/** Finished calls with a transcript, as cards for the chat: [{ ts, html }], at when each began. */
|
|
468
544
|
export function callCards (id) {
|
|
469
|
-
|
|
545
|
+
// The codebase's calls: a conversation with one person shows none.
|
|
546
|
+
if (!shown || shown.id !== id || shown.to) return []
|
|
470
547
|
const view = views.get(id) || EMPTY
|
|
471
548
|
const now = going(view)
|
|
472
549
|
const { colorOf } = shown.who()
|
|
@@ -483,6 +560,3 @@ export function callCards (id) {
|
|
|
483
560
|
}
|
|
484
561
|
})
|
|
485
562
|
}
|
|
486
|
-
|
|
487
|
-
/** Whether this window is in a call now (for the people list). */
|
|
488
|
-
export const inCallHere = (id) => !!(live && live.sid === id)
|
package/src/ui-server.js
CHANGED
|
@@ -35,7 +35,7 @@ import { queryHistory } from './history.js'
|
|
|
35
35
|
import { contentDisposition } from './api/file-paths.js'
|
|
36
36
|
import { apiCall, getSecrets, putSecretSettings, setSecretWho, deleteSecret, secretUses, saveSecrets, secretAsks, answerAsk } from './secrets-client.js'
|
|
37
37
|
import { envFilesIn, knownEnvFile, envValues } from './secret-import.js'
|
|
38
|
-
import { appWorkspaces } from './app-workspaces.js'
|
|
38
|
+
import { appWorkspaces, projectsToLearn } from './app-workspaces.js'
|
|
39
39
|
import { guessTool } from './tool-guess.js'
|
|
40
40
|
|
|
41
41
|
// A route's answer that streams through instead of going as JSON (an agent's speech).
|
|
@@ -563,6 +563,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
563
563
|
}
|
|
564
564
|
runs.set(id, entry)
|
|
565
565
|
const s = entry.run.session
|
|
566
|
+
// A codebase joined with an invite may be in a project: ask the account's list, which says (learnProjects).
|
|
567
|
+
if (appWorkspaces() && !readConfig(entry.run.dir)?.workspace) Promise.resolve().then(() => workspaceList()).catch(() => {})
|
|
566
568
|
// What the person said they want to build is the project's first ticket, for their AI to pick up.
|
|
567
569
|
const first = project && briefTicket(project.brief)
|
|
568
570
|
if (first) {
|
|
@@ -582,7 +584,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
582
584
|
let voiceWas = ''
|
|
583
585
|
const pushVoice = () => {
|
|
584
586
|
if (runs.get(id) !== entry) return
|
|
585
|
-
const voice = s
|
|
587
|
+
const voice = callView(s)
|
|
586
588
|
const now = JSON.stringify(voice)
|
|
587
589
|
if (now !== voiceWas) { voiceWas = now; broadcast('voice', { id, voice }) }
|
|
588
590
|
}
|
|
@@ -739,6 +741,9 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
739
741
|
// still connect directly through a public STUN server.
|
|
740
742
|
const STUN_ONLY = { iceServers: [{ urls: ['stun:stun.cloudflare.com:3478'] }], turn: false }
|
|
741
743
|
let ice = null
|
|
744
|
+
// The codebase's call with, beside it, the calls with one person going on for us (`dms`); or one of those alone.
|
|
745
|
+
const callView = (s, dm = '') => dm ? s.voice({ dm }) : { ...s.voice(), dms: s.voiceDms() }
|
|
746
|
+
|
|
742
747
|
async function voiceServers () {
|
|
743
748
|
if (ice && ice.expiresAt - Date.now() > 10 * 60 * 1000) return ice
|
|
744
749
|
try {
|
|
@@ -838,6 +843,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
838
843
|
try {
|
|
839
844
|
const workspaces = await listWorkspaces({ token })
|
|
840
845
|
workspacesOn = true
|
|
846
|
+
learnProjects(workspaces)
|
|
841
847
|
return { on: true, workspaces }
|
|
842
848
|
} catch (err) {
|
|
843
849
|
if (err.status === 404) { workspacesOn = false; return { on: false, workspaces: [] } }
|
|
@@ -865,6 +871,19 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
865
871
|
for (const r of recentList()) if (!r.unsupported) add(r.dir, '', '')
|
|
866
872
|
return out
|
|
867
873
|
}
|
|
874
|
+
// A codebase here that the account's projects list in a project is in that project here too
|
|
875
|
+
// (app-workspaces.js projectsToLearn): saved in its folder, so its page, its row and the project's page agree.
|
|
876
|
+
function learnProjects (workspaces) {
|
|
877
|
+
const folders = [...[...runs.values()].map((r) => ({ dir: r.run.dir, room: r.run.session.room, workspace: readConfig(r.run.dir)?.workspace || '' })), ...recentList().map((r) => ({ dir: r.dir, room: r.room, workspace: r.workspace || '' }))]
|
|
878
|
+
for (const { dir, workspace } of projectsToLearn(workspaces, folders)) {
|
|
879
|
+
const saved = readConfig(dir)
|
|
880
|
+
if (!saved) continue
|
|
881
|
+
writePrivateJson(path.join(dir, '.quilt', 'config.json'), { ...saved, workspace })
|
|
882
|
+
rememberWorkspace(dir, workspace)
|
|
883
|
+
const id = idFor(dir)
|
|
884
|
+
if (runs.has(id)) { runs.get(id).run.session.setWorkspace(workspace); pushStatus(id) }
|
|
885
|
+
}
|
|
886
|
+
}
|
|
868
887
|
const needOrgSlug = (slug) => { if (!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(String(slug || ''))) throw httpError(400, 'Which org?'); return slug }
|
|
869
888
|
const ofWorkspace = (id) => ({
|
|
870
889
|
running: [...runs.keys()].filter((k) => (readConfig(runs.get(k).run.dir) || {}).workspace === id),
|
|
@@ -1198,8 +1217,13 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
1198
1217
|
'POST /api/sessions/:id/say': (b, id) => get(id).say(b.text, { to: b.to || null }),
|
|
1199
1218
|
'POST /api/sessions/:id/focus': (b, id) => { get(id).setFocus(b.text); return { ok: true } },
|
|
1200
1219
|
// Voice (voice.js): the call as this app sees it, and our part in it, from the app window, which does the audio.
|
|
1201
|
-
|
|
1202
|
-
'
|
|
1220
|
+
// `?to=<name>`: the call with that person alone (a direct message's), instead of the codebase's.
|
|
1221
|
+
'GET /api/sessions/:id/voice': (b, id, url) => callView(get(id), url.searchParams.get('to') || ''),
|
|
1222
|
+
'POST /api/sessions/:id/voice': (b, id, url) => {
|
|
1223
|
+
const dm = url.searchParams.get('to') || ''
|
|
1224
|
+
get(id).setVoice(b.in === false ? null : { muted: b.muted === true, sig: b.sig, transcribing: b.transcribing === true, sharing: b.sharing === true, agents: b.agents === true }, { dm })
|
|
1225
|
+
return callView(get(id), dm)
|
|
1226
|
+
},
|
|
1203
1227
|
'POST /api/sessions/:id/voice/transcribe': (b, id) => get(id).setVoiceTranscribe(b.on === true),
|
|
1204
1228
|
'POST /api/sessions/:id/voice/clip': (b, id) => voiceClip(get(id), b),
|
|
1205
1229
|
'GET /api/sessions/:id/voice/transcript': (b, id, url) => get(id).voiceTranscript({ call: url.searchParams.get('call') || '' }),
|
package/src/voice.js
CHANGED
|
@@ -58,6 +58,69 @@ export function cleanVoice (raw) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// ------------------------------------------------------- a call with one person --
|
|
62
|
+
// A direct message's call: the two people in it, nobody else. It rides presence like the
|
|
63
|
+
// codebase's call, in a field of its own (`voiceDm`, with who it is with), so an older app, an
|
|
64
|
+
// agent's status and the codebase's own call never count it. It is never transcribed.
|
|
65
|
+
|
|
66
|
+
/** Our part in a call with one person, cleaned: null when not in one. */
|
|
67
|
+
export function cleanDmVoice (raw) {
|
|
68
|
+
const v = cleanVoice(raw)
|
|
69
|
+
const to = raw && typeof raw.with === 'string' ? raw.with.trim().slice(0, 80) : ''
|
|
70
|
+
if (!v || !to) return null
|
|
71
|
+
const { transcribing, ...rest } = v
|
|
72
|
+
return { ...rest, with: to }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The call between us (`name`) and `partner`, as one app sees it: voiceView's shape. Only the
|
|
77
|
+
* partner's presence that names us counts, so nobody else is ever a peer.
|
|
78
|
+
*/
|
|
79
|
+
export function dmVoiceView ({ awareness, clientID, name, partner }) {
|
|
80
|
+
const mine = cleanDmVoice(awareness.getLocalState()?.voiceDm)
|
|
81
|
+
const me = mine && mine.with === partner ? mine : null
|
|
82
|
+
const peers = []
|
|
83
|
+
const here = []
|
|
84
|
+
for (const [id, s] of awareness.getStates()) {
|
|
85
|
+
if (id === clientID || !s || !s.name) continue
|
|
86
|
+
here.push(id)
|
|
87
|
+
if (s.name !== partner || partner === name) continue
|
|
88
|
+
const v = cleanDmVoice(s.voiceDm)
|
|
89
|
+
if (!v || v.with !== name) continue
|
|
90
|
+
peers.push({ id, name: s.name, color: s.color || '', muted: v.muted, since: v.since, call: v.call, ...(v.sharing ? { sharing: true } : {}), signal: v.sig[String(clientID)] || null })
|
|
91
|
+
}
|
|
92
|
+
peers.sort((a, b) => a.since - b.since || a.id - b.id)
|
|
93
|
+
const starts = [...(me ? [me.since] : []), ...peers.map((p) => p.since)].filter((x) => x > 0)
|
|
94
|
+
return {
|
|
95
|
+
me: clientID,
|
|
96
|
+
in: !!me,
|
|
97
|
+
muted: !!(me && me.muted),
|
|
98
|
+
sharing: !!(me && me.sharing),
|
|
99
|
+
call: me ? me.call : (peers[0] ? peers[0].call : ''),
|
|
100
|
+
since: starts.length ? Math.min(...starts) : 0,
|
|
101
|
+
transcribe: false,
|
|
102
|
+
peers,
|
|
103
|
+
here,
|
|
104
|
+
recent: [],
|
|
105
|
+
calls: [],
|
|
106
|
+
agents: [],
|
|
107
|
+
with: partner
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Everyone we are in a call with, or who is in one with us and waiting: their names, sorted. */
|
|
112
|
+
export function dmCallers ({ awareness, clientID, name }) {
|
|
113
|
+
const out = new Set()
|
|
114
|
+
const mine = cleanDmVoice(awareness.getLocalState()?.voiceDm)
|
|
115
|
+
if (mine) out.add(mine.with)
|
|
116
|
+
for (const [id, s] of awareness.getStates()) {
|
|
117
|
+
if (id === clientID || !s || !s.name || s.name === name) continue
|
|
118
|
+
const v = cleanDmVoice(s.voiceDm)
|
|
119
|
+
if (v && v.with === name) out.add(s.name)
|
|
120
|
+
}
|
|
121
|
+
return [...out].sort()
|
|
122
|
+
}
|
|
123
|
+
|
|
61
124
|
/** A new call's id, when nobody is in voice yet. */
|
|
62
125
|
export function newCallId (now = Date.now()) {
|
|
63
126
|
return `${now.toString(36)}-${crypto.randomBytes(4).toString('hex')}`
|