heyquilt 0.3.196 → 0.3.198

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 CHANGED
@@ -11,6 +11,16 @@ 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.198 — 2026-11-24
15
+
16
+ - **Calls in a project's channels.** Call in a channel's header starts a voice call there, in the project's own channel and in the ones its people made. It reaches everyone in the project wherever they are: on the project's page with no codebase open, or inside any of its codebases. Who is in it shows in the header with Join, then mute and leave, and the channel's row in the sidebar says how many are in the call. One call at a time: joining a codebase's call leaves a channel's, and the other way round. These calls are not transcribed, and a screen cannot be shared in them yet.
17
+
18
+ ## 0.3.197 — 2026-11-24
19
+
20
+ - **One short invite.** A codebase's Invite is two tiles: a person (Copy invite link) and an AI (Copy prompt). There is nothing to pick first: no edit or view-only link, no "Invite as", no kinds of AI. Under them the owner can still let someone straight in by their email, or by picking someone they have worked with; invites still waiting sit beside them. A view-only link is one quiet line at the bottom.
21
+ - **One prompt for any AI.** The prompt works in Claude Code, Cursor, Codex or any other tool, and in a chat window such as ChatGPT: it carries a chat link for an AI that can only open web pages. That AI joins the codebase only when it opens the link, so nobody extra shows on the member list before then.
22
+ - **An empty codebase's invite card shows one link too.**
23
+
14
24
  ## 0.3.196 — 2026-11-23
15
25
 
16
26
  Git can throw away only your own uncommitted work.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.196",
3
+ "version": "0.3.198",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
package/src/account.js CHANGED
@@ -372,6 +372,18 @@ export async function workspaceChannels ({ token, id, api = apiUrl(), fetch: fet
372
372
  if (!Array.isArray(r.channels)) throw new Error(BAD_REPLY)
373
373
  return r
374
374
  }
375
+ /** The calls going on in a project's channels: { calls: { <channel id, or '' for the project's own>: { since, people } } }. */
376
+ export async function workspaceCalls ({ token, id, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
377
+ const r = await call(fetchImpl, api, 'GET', `${ws$(id)}/call`, null, token)
378
+ if (!r.calls || typeof r.calls !== 'object') throw new Error(BAD_REPLY)
379
+ return r
380
+ }
381
+ /** One app window's part in a project channel's call (`body`: { channel, client, in, muted, sharing, sig }); answers the call as that window sees it. */
382
+ export async function workspaceCall ({ token, id, body, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
383
+ const r = await call(fetchImpl, api, 'POST', `${ws$(id)}/call`, body, token)
384
+ if (!Array.isArray(r.peers)) throw new Error(BAD_REPLY)
385
+ return r
386
+ }
375
387
  export async function addWorkspaceChannel ({ token, id, name, api = apiUrl(), fetch: fetchImpl = globalThis.fetch }) {
376
388
  const r = await call(fetchImpl, api, 'POST', `${ws$(id)}/channels`, { name }, token)
377
389
  if (!r.channel) throw new Error(BAD_REPLY)
package/src/api/leader.js CHANGED
@@ -36,5 +36,5 @@ export function leader ({ store, machineId = '', log = () => {}, ttlMs = TTL_MS,
36
36
  }
37
37
  }
38
38
 
39
- /** Requests that only the leader may answer: people's cloud AI machines and their spares. */
40
- export const LEADER_ONLY = /^\/v1\/(?:me\/ai-vm(?:\/|$)|ai-vm\/|relay\/ai-vm\/)/
39
+ /** Requests that only the leader may answer: people's cloud AI machines and their spares, and the calls in projects' channels (routes/workspace-calls.js). */
40
+ export const LEADER_ONLY = /^\/v1\/(?:me\/ai-vm(?:\/|$)|ai-vm\/|relay\/ai-vm\/|workspaces\/[^/]+\/call$)/
@@ -0,0 +1,138 @@
1
+ // A call in a project's channel (plans/voice.md, "A call in a project's channel"): the project's
2
+ // own channel and each one its people made has a voice call of its own, for everyone in the
3
+ // project wherever they are: on the project's page or inside any of its codebases.
4
+ //
5
+ // A codebase's call rides the relay's presence. A project is not on the relay, so this keeps the
6
+ // same thing here: who is in each call, muted or sharing or not, and the call setup each pair
7
+ // leaves the other (their WebRTC offer and answer). The audio goes from app window to app window,
8
+ // never through here. An app window in a call says so every second or two, with everything it
9
+ // has to say; one that stops is out of the call a few seconds later. Nothing is kept in the
10
+ // database: the calls live in this machine's memory, so on several machines they are the
11
+ // leader's (leader.js), and a new leader hears each window's part again within a second or two.
12
+ //
13
+ // These calls are never transcribed, so no agent hears them and they leave no card in the channel.
14
+ import { HttpError, needId, stripInvisible } from '../http.js'
15
+ import { workspaceReach, canSeeFiles } from '../workspace-reach.js'
16
+ import { cleanVoice, newCallId, MAX_IN_CALL, CALL_FULL } from '../../voice.js'
17
+
18
+ // A window that has not said it is in the call for this long has left it.
19
+ export const CALL_STALE_MS = 12 * 1000
20
+ // How long a window that left is still named as there but out of the call, so the others hang up at once.
21
+ const LEFT_MS = 30 * 1000
22
+ // Who may be in a project's calls is looked up again this often, not at every word from a window.
23
+ const KNOWN_MS = 60 * 1000
24
+ const CLIENT = /^[1-9]\d{0,11}$/
25
+
26
+ export function workspaceCallRoutes (ctx) {
27
+ const { store, now = Date.now, workspaces = false } = ctx
28
+ const { reach } = workspaceReach(ctx)
29
+ const gated = (fn) => (...args) => {
30
+ if (!workspaces) throw new HttpError(404, 'not found')
31
+ return fn(...args)
32
+ }
33
+ const rooms = new Map() // `${project}|${channel}` -> { call, in: Map(window -> { account, name, muted, sharing, since, sig, seen }), left: Map(window -> when) }
34
+ const known = new Map() // who asked, for which project -> { ws, account, name, until }
35
+
36
+ /** The project and the caller, a person in it. Looked up at most once a minute for each. */
37
+ async function inProject (req, id) {
38
+ const key = `${req.headers.authorization || ''}|${id}`
39
+ const at = now()
40
+ const hit = known.get(key)
41
+ if (hit && hit.until > at) return hit
42
+ const r = await reach(req, needId(id, 'project'))
43
+ if (!canSeeFiles(r.access)) throw new HttpError(403, 'Only people in this project are in its calls.')
44
+ const [kind, pid] = String(r.me.account).split(':')
45
+ if (kind !== 'person') throw new HttpError(403, 'Agents are not in a project\'s calls.')
46
+ const name = stripInvisible((await store.profile(pid))?.name || '').join('').trim() || 'Someone'
47
+ const got = { ws: r.ws.id, account: r.me.account, name, until: at + KNOWN_MS }
48
+ known.set(key, got)
49
+ if (known.size > 5000) for (const [k, v] of known) if (v.until <= at) known.delete(k)
50
+ return got
51
+ }
52
+
53
+ /** Windows that stopped saying they are in a call are out of it; an empty call is forgotten. */
54
+ function sweep (at) {
55
+ for (const [key, room] of rooms) {
56
+ for (const [id, e] of room.in) if (at - e.seen > CALL_STALE_MS) { room.in.delete(id); room.left.set(id, at) }
57
+ for (const [id, when] of room.left) if (at - when > LEFT_MS) room.left.delete(id)
58
+ if (!room.in.size) room.call = ''
59
+ if (!room.in.size && !room.left.size) rooms.delete(key)
60
+ }
61
+ }
62
+
63
+ /** The call as one window sees it: the shape a codebase's call has (voice.js), so the app's audio code is the same. */
64
+ function viewFor (room, client) {
65
+ const mine = room ? room.in.get(client) : null
66
+ const peers = room ? [...room.in].filter(([id]) => id !== client).map(([id, e]) => ({ id: Number(id), name: e.name, color: '', muted: e.muted, since: e.since, call: room.call, ...(e.sharing ? { sharing: true } : {}), signal: e.sig[client] || null })) : []
67
+ peers.sort((a, b) => a.since - b.since || a.id - b.id)
68
+ const starts = [...(mine ? [mine.since] : []), ...peers.map((p) => p.since)].filter((x) => x > 0)
69
+ return {
70
+ me: Number(client) || 0,
71
+ in: !!mine,
72
+ muted: !!(mine && mine.muted),
73
+ sharing: !!(mine && mine.sharing),
74
+ call: room ? room.call : '',
75
+ since: starts.length ? Math.min(...starts) : 0,
76
+ transcribe: false,
77
+ peers,
78
+ // Everyone this call knows of, in it or just out of it: someone here but not a peer hung up.
79
+ here: room ? [...peers.map((p) => p.id), ...[...room.left.keys()].filter((id) => id !== client).map(Number)] : [],
80
+ recent: [],
81
+ calls: [],
82
+ agents: []
83
+ }
84
+ }
85
+
86
+ /** '' for the project's own channel, or the id of one its people made, which must be this project's. */
87
+ async function channelOf (ws, raw) {
88
+ const cid = String(raw || '')
89
+ if (!cid) return ''
90
+ if (rooms.has(`${ws}|${cid}`)) return cid
91
+ const ch = await store.workspaceChannelById(needId(cid, 'channel')).catch(() => null)
92
+ if (!ch || ch.workspaceId !== ws) throw new HttpError(404, 'no such channel')
93
+ return cid
94
+ }
95
+
96
+ return [
97
+ // The calls going on in the project: for each channel with one ('' is the project's own), who is in it.
98
+ ['GET', /^\/v1\/workspaces\/([^/]+)\/call$/, gated(async (req, body, [id]) => {
99
+ const me = await inProject(req, id)
100
+ sweep(now())
101
+ const calls = {}
102
+ for (const [key, room] of rooms) {
103
+ const [ws, channel] = key.split('|')
104
+ if (ws !== me.ws || !room.in.size) continue
105
+ calls[channel] = { since: Math.min(...[...room.in.values()].map((e) => e.since)), people: [...new Set([...room.in.values()].map((e) => e.name))] }
106
+ }
107
+ return { calls }
108
+ })],
109
+
110
+ // One app window's part in a channel's call: in it or not, muted, sharing, and what it leaves each
111
+ // of the others to set the call up. Answers the call as that window sees it. Said again every
112
+ // second or two while in the call; `in: false` leaves, and asks nothing more.
113
+ ['POST', /^\/v1\/workspaces\/([^/]+)\/call$/, gated(async (req, body, [id]) => {
114
+ const me = await inProject(req, id)
115
+ const client = String(body.client ?? '')
116
+ if (!CLIENT.test(client)) throw new HttpError(400, 'client is this window\'s number in the call.')
117
+ const channel = await channelOf(me.ws, body.channel)
118
+ const key = `${me.ws}|${channel}`
119
+ const at = now()
120
+ sweep(at)
121
+ let room = rooms.get(key)
122
+ const mine = room ? room.in.get(client) : null
123
+ // A window's number is its own: nobody else speaks for it.
124
+ if (mine && mine.account !== me.account) throw new HttpError(409, 'That window is someone else\'s.')
125
+ if (body.in === false) {
126
+ if (mine) { room.in.delete(client); room.left.set(client, at); if (!room.in.size) room.call = '' }
127
+ return viewFor(room, client)
128
+ }
129
+ const v = cleanVoice({ in: true, muted: body.muted, sharing: body.sharing, sig: body.sig })
130
+ if (!mine && room && room.in.size >= MAX_IN_CALL) throw new HttpError(409, CALL_FULL)
131
+ if (!room) { room = { call: '', in: new Map(), left: new Map() }; rooms.set(key, room) }
132
+ if (!room.call) room.call = newCallId(at)
133
+ room.left.delete(client)
134
+ room.in.set(client, { account: me.account, name: me.name, muted: v.muted, sharing: !!v.sharing, since: mine ? mine.since : at, sig: v.sig, seen: at })
135
+ return viewFor(room, client)
136
+ })]
137
+ ]
138
+ }
package/src/api/server.js CHANGED
@@ -37,6 +37,7 @@ import { workspaceFileRoutes } from './routes/workspace-files.js'
37
37
  import { workspaceAgentRoutes } from './routes/workspace-agents.js'
38
38
  import { workspaceInviteRoutes } from './routes/workspace-invites.js'
39
39
  import { workspaceChatRoutes } from './routes/workspace-chat.js'
40
+ import { workspaceCallRoutes } from './routes/workspace-calls.js'
40
41
  import { HOSTED_RELAY } from '../settings.js'
41
42
  import { roomAccessFrom } from './access.js'
42
43
  import { joiningRoom, sessionArg } from '../mcp-room.js'
@@ -454,7 +455,7 @@ export function startApi ({ port = 0, host = '127.0.0.1', store, verifyUser, sit
454
455
  // Always routed: with the flag off each answers a plain 404 of its own, so the app's
455
456
  // check at every launch isn't filed as a missing route.
456
457
  // Only these take a hosted agent's pass (workspaceReach), so they alone get the pass key.
457
- routes.push(...workspaceRoutes({ ...ctx, workspaces, passKey, policyChanged }), ...workspaceInviteRoutes({ ...ctx, workspaces, passKey }), ...workspaceChatRoutes({ ...ctx, workspaces, passKey }), ...workspaceAgentRoutes({ ...ctx, workspaces, passKey, relayUrl, webhookFetch, webhookLookup, allowLocalWebhooks, trackDelivery, limitAnnounce }))
458
+ routes.push(...workspaceRoutes({ ...ctx, workspaces, passKey, policyChanged }), ...workspaceInviteRoutes({ ...ctx, workspaces, passKey }), ...workspaceChatRoutes({ ...ctx, workspaces, passKey }), ...workspaceCallRoutes({ ...ctx, workspaces, passKey }), ...workspaceAgentRoutes({ ...ctx, workspaces, passKey, relayUrl, webhookFetch, webhookLookup, allowLocalWebhooks, trackDelivery, limitAnnounce }))
458
459
  const wsFiles = workspaceFileRoutes({ ...ctx, workspaces, passKey })
459
460
  routes.push(...wsFiles.routes)
460
461
  // Secrets (routes/secrets.js): off until the vault is set up (QUILT_VAULT_SECRET).
package/src/chat-links.js CHANGED
@@ -39,6 +39,10 @@ export const CHAT_LINK_MAX_MINUTES = 30 * 24 * 60
39
39
  const MINUTE = 60 * 1000
40
40
  export const CHAT_ADD_MAX_BYTES = 5 * 1024 * 1024
41
41
  const MAX_LINKS = 20 // per session
42
+ // A link made ahead, inside an AI's invite, before anyone knows a chat AI will use it: it can
43
+ // be opened for this long, and a session keeps this many (the oldest goes for a new one).
44
+ export const CHAT_LINK_WAIT_MINUTES = 60
45
+ const MAX_WAITING = 20
42
46
  const MAX_TEXT = 4000 // a message, a task title is shorter (tasks.js)
43
47
  const MAX_NOTE = 20000
44
48
  const MAX_READ = 100 * 1024
@@ -56,23 +60,54 @@ const memberId = (id) => `chat:${id}`
56
60
  /** Minutes asked for, kept between one and CHAT_LINK_MAX_MINUTES (CHAT_LINK_DEFAULT_MINUTES when not given). */
57
61
  const minutesOf = (minutes) => Math.min(Math.max(Math.round(Number(minutes)) || CHAT_LINK_DEFAULT_MINUTES, 1), CHAT_LINK_MAX_MINUTES)
58
62
 
59
- export function makeChatLink (room, { name, minutes, by } = {}, now = Date.now()) {
63
+ /** `wanted`, or it with a number after, so it is not the name of anyone already in the session. */
64
+ function freeName (room, wanted) {
65
+ const taken = new Set([...Object.values(room.meta.members || {}).map((m) => m && m.name), ...Object.keys(room.meta.identities || {})])
66
+ let label = wanted
67
+ for (let n = 2; taken.has(label); n++) label = `${wanted} ${n}`
68
+ return label
69
+ }
70
+
71
+ const chatMember = (l, now) => ({ name: l.name, kind: 'agent', role: 'editor', scopes: [], scopesExcept: [], talk: true, since: now, chat: true, expiresAt: l.expiresAt })
72
+
73
+ /**
74
+ * Makes a chat link in `room` (someone who may let people in asked). Returns { id, token, name, expiresAt }.
75
+ * `waiting`: made ahead, inside an AI's invite. Nobody joins yet: the link can be opened for
76
+ * CHAT_LINK_WAIT_MINUTES, and whoever opens it first joins then, its minutes counting from that moment.
77
+ */
78
+ export function makeChatLink (room, { name, minutes, by, waiting = false } = {}, now = Date.now()) {
60
79
  const links = room.meta.chatLinks = pruneChatLinks(room, now)
61
- if (Object.keys(links).length >= MAX_LINKS) throw new Error(`a codebase can have ${MAX_LINKS} chat links at most; remove one first`)
80
+ if (!waiting && Object.values(links).filter((l) => !l.waiting).length >= MAX_LINKS) throw new Error(`a codebase can have ${MAX_LINKS} chat links at most; remove one first`)
62
81
  const id = crypto.randomBytes(6).toString('hex')
63
82
  const token = crypto.randomBytes(24).toString('base64url')
64
83
  const wanted = String(name || '').replace(/[\u0000-\u001f\u007f]+/g, ' ').trim().slice(0, 40) || 'Chat AI'
65
- // Not the name of anyone already in the session.
66
- const taken = new Set([...Object.values(room.meta.members || {}).map((m) => m && m.name), ...Object.keys(room.meta.identities || {})])
67
- let label = wanted
68
- for (let n = 2; taken.has(label); n++) label = `${wanted} ${n}`
84
+ if (waiting) {
85
+ const ahead = Object.entries(links).filter(([, l]) => l.waiting).sort((x, y) => x[1].createdAt - y[1].createdAt)
86
+ while (ahead.length >= MAX_WAITING) delete links[ahead.shift()[0]]
87
+ const expiresAt = now + CHAT_LINK_WAIT_MINUTES * MINUTE
88
+ links[hashToken(token)] = { id, name: wanted, by: String(by || ''), createdAt: now, expiresAt, waiting: minutesOf(minutes) }
89
+ room.saveMeta()
90
+ return { id, token, name: wanted, expiresAt, waiting: true }
91
+ }
92
+ const label = freeName(room, wanted)
69
93
  const expiresAt = now + minutesOf(minutes) * MINUTE
70
94
  links[hashToken(token)] = { id, name: label, by: String(by || ''), createdAt: now, expiresAt }
71
- room.meta.members[memberId(id)] = { name: label, kind: 'agent', role: 'editor', scopes: [], scopesExcept: [], talk: true, since: now, chat: true, expiresAt }
95
+ room.meta.members[memberId(id)] = chatMember(links[hashToken(token)], now)
72
96
  room.saveMeta()
73
97
  return { id, token, name: label, expiresAt }
74
98
  }
75
99
 
100
+ /** A link made ahead is opened for the first time: it joins now, under a free name, for the minutes it was made with. False when the session has all the chat links it may. */
101
+ function startChatLink (room, l, now) {
102
+ if (Object.values(room.meta.chatLinks).filter((x) => x && !x.waiting).length >= MAX_LINKS) return false
103
+ l.name = freeName(room, l.name)
104
+ l.expiresAt = now + l.waiting * MINUTE
105
+ delete l.waiting
106
+ room.meta.members[memberId(l.id)] = chatMember(l, now)
107
+ room.saveMeta()
108
+ return true
109
+ }
110
+
76
111
  /**
77
112
  * The owner sets how long a chat link still works: `minutes` from now (shorter or longer).
78
113
  * Only a link that still works: one that ran out is gone, and a new one is needed.
@@ -92,7 +127,7 @@ export function pruneChatLinks (room, now = Date.now()) {
92
127
  const links = room.meta.chatLinks || {}
93
128
  let changed = false
94
129
  for (const [k, l] of Object.entries(links)) {
95
- const gone = !l || l.expiresAt <= now || !room.meta.members[memberId(l.id)]
130
+ const gone = !l || l.expiresAt <= now || (!l.waiting && !room.meta.members[memberId(l.id)]) // one made ahead has no member until it is opened
96
131
  if (!gone) continue
97
132
  delete links[k]
98
133
  if (l && room.meta.members[memberId(l.id)]?.chat) delete room.meta.members[memberId(l.id)]
@@ -107,6 +142,7 @@ export function findChatLink (room, token, now = Date.now()) {
107
142
  if (!room || !room.meta.chatLinks) return null
108
143
  const l = pruneChatLinks(room, now)[hashToken(token)]
109
144
  if (!l) return null
145
+ if (l.waiting && !startChatLink(room, l, now)) return null
110
146
  return { ...l, member: room.meta.members[memberId(l.id)], memberId: memberId(l.id) }
111
147
  }
112
148
 
package/src/server.js CHANGED
@@ -1365,9 +1365,10 @@ class Room {
1365
1365
  if (req.op === 'chatlink') {
1366
1366
  // A link a chat-only AI (ChatGPT, claude.ai, Grok…) works through by opening pages (chat-links.js).
1367
1367
  // It joins as a member of its own; the token is in this reply only, to whoever asked.
1368
- const l = makeChatLink(this, { name: req.name, minutes: req.minutes, by: me.name })
1369
- this.log(`[${this.name}] chat link made for ${l.name}`)
1370
- return { ok: true, token: l.token, name: l.name, expiresAt: l.expiresAt }
1368
+ // `waiting`: made ahead, inside an AI's invite: nobody joins until an AI opens it.
1369
+ const l = makeChatLink(this, { name: req.name, minutes: req.minutes, by: me.name, waiting: req.waiting === true })
1370
+ this.log(`[${this.name}] chat link made for ${l.name}${l.waiting ? ' (waiting to be opened)' : ''}`)
1371
+ return { ok: true, token: l.token, name: l.name, expiresAt: l.expiresAt, ...(l.waiting ? { waiting: true } : {}) }
1371
1372
  }
1372
1373
  if (req.op === 'chatextend') {
1373
1374
  // How long a chat link still works, from now. One that ran out is gone: a new link is needed.
package/src/session.js CHANGED
@@ -5676,12 +5676,15 @@ export class Session extends EventEmitter {
5676
5676
  * opening pages: read and send messages, read and add tasks, read files, add pictures,
5677
5677
  * documents and notes (see chat-links.js). It joins as its own member; removing it ends the link.
5678
5678
  * It works for ten minutes unless `minutes` says otherwise, and the owner can extend it.
5679
+ * `waiting`: made ahead, inside an AI's invite: nobody joins, and its minutes do not start,
5680
+ * until an AI opens it (within the hour); `expiresAt` is then when it stops waiting.
5679
5681
  */
5680
- async createChatLink ({ name = '', minutes } = {}) {
5682
+ async createChatLink ({ name = '', minutes, waiting = false } = {}) {
5681
5683
  if (!this.conn) throw new Error('not connected to the relay')
5682
5684
  if (!this.canAdmit) throw new Error('only people who may let others into this codebase can make a chat link')
5683
- const r = await this.conn.adminRequest({ op: 'chatlink', name: String(name || ''), ...(minutes ? { minutes: Number(minutes) } : {}) })
5684
- return { url: `${this.httpBase()}/c/${this.room}/${r.token}`, name: r.name, expiresAt: r.expiresAt }
5685
+ const r = await this.conn.adminRequest({ op: 'chatlink', name: String(name || ''), ...(minutes ? { minutes: Number(minutes) } : {}), ...(waiting ? { waiting: true } : {}) })
5686
+ // A relay that does not make links ahead yet made one that works now: said as it is.
5687
+ return { url: `${this.httpBase()}/c/${this.room}/${r.token}`, name: r.name, expiresAt: r.expiresAt, ...(r.waiting ? { waiting: true } : {}) }
5685
5688
  }
5686
5689
 
5687
5690
  /** Whoever may let people in: a chat link (by its member key, or its name) works for `minutes` from now. One that ran out can't be. */
package/src/ui/app.css CHANGED
@@ -273,6 +273,44 @@ textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
273
273
  .inv-agent-label { margin: 18px 0 6px; padding-top: 16px; border-top: 1px solid var(--border); }
274
274
  .inv-agent .hint { margin: 0 0 10px; }
275
275
  .inv-agent .error:empty { display: none; }
276
+ /* The invite pop-up: a tile for a person and a tile for an AI, then the way straight in. */
277
+ .modal.inv { width: min(600px, 100%); }
278
+ .inv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
279
+ .inv-head h3 { display: flex; align-items: center; gap: 10px; margin: 0; min-width: 0; }
280
+ .inv-head h3 span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
281
+ .inv-head h3 .pj-block { width: 26px; height: 26px; border-radius: 7px; }
282
+ .inv-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
283
+ .inv-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
284
+ .inv-ic { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); color: var(--text); }
285
+ .inv-ic svg { width: 16px; height: 16px; }
286
+ .inv-tile b { font-size: 15px; }
287
+ .inv-tile p { flex: 1; margin: 0 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
288
+ .inv-tile .btn { height: 38px; justify-content: center; }
289
+ .inv-tile .btn.copied { background: var(--ok); border-color: var(--ok); color: #10231a; }
290
+ .inv-tile .error { flex: none; margin: 6px 0 0; }
291
+ .modal.inv .error:empty { display: none; }
292
+ .inv-shown { margin: 12px 0 0; }
293
+ .inv-shown[hidden] { display: none; }
294
+ .inv-shown code { max-height: 96px; overflow: auto; }
295
+ .inv-in { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
296
+ .inv-in .label { display: block; margin-bottom: 8px; }
297
+ .inv-add { display: flex; gap: 8px; margin-bottom: 10px; }
298
+ .inv-add .input { flex: 1; min-width: 0; }
299
+ .inv-chips, .inv-chips > span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
300
+ .inv-chips > span:empty { display: none; }
301
+ .inv-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
302
+ .inv-chip:hover, .inv-chip:focus-visible { border-color: var(--text); }
303
+ .inv-chip:disabled { opacity: .5; cursor: default; }
304
+ .inv-chip .avatar { width: 20px; height: 20px; font-size: 10px; }
305
+ .inv-chip svg { width: 12px; height: 12px; color: var(--muted); }
306
+ .inv-chip.wait { padding-left: 10px; border-style: dashed; background: none; color: var(--muted); cursor: default; }
307
+ .inv-chip.wait:hover { border-color: var(--border); }
308
+ .inv-chip.wait button { display: grid; place-items: center; width: 18px; height: 18px; margin-right: -4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
309
+ .inv-chip.wait button:hover { color: var(--text); background: var(--border); }
310
+ .inv-more { display: flex; justify-content: flex-end; margin-top: 12px; }
311
+ .inv-quiet { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
312
+ .inv-quiet:hover, .inv-quiet.copied { color: var(--text); }
313
+ @media (max-width: 640px) { .inv-tiles { grid-template-columns: 1fr; } }
276
314
  .agent-row { grid-template-columns: 24px minmax(0, 1fr); align-items: center; }
277
315
  .agent-row svg { width: 16px; height: 16px; }
278
316
  /* Your agents in Settings › Agents with workspaces on: one card each, who it is on top, then
@@ -1184,11 +1222,6 @@ details.choice-foot .hint { display: block; margin-top: 6px; }
1184
1222
  .pm-member .nm { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1185
1223
  .pm-member .input { height: 28px; width: auto; font-size: 12px; padding: 0 6px; }
1186
1224
  .pm-member input.input { width: 110px; }
1187
- .invite-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 4px; text-align: left; }
1188
- .invite-pair .codebox { margin: 6px 0 10px; }
1189
- .invite-pair .codebox code { font-size: 11.5px; max-height: 72px; overflow: auto; }
1190
- .invite-pair .btn { width: 100%; }
1191
- @media (max-width: 900px) { .invite-pair { grid-template-columns: 1fr; } }
1192
1225
  .pm-member.edit { flex-wrap: wrap; padding: 6px; border-radius: 4px; }
1193
1226
  .pm-member.edit + .pm-member.edit { border-top: 1px dashed var(--border); }
1194
1227
  .pm-member.edit .nm { flex-basis: 100%; font-weight: 600; }
@@ -1916,6 +1949,14 @@ iframe.pv-page { flex: 1; min-height: 0; width: 100%; border: 0; background: #ff
1916
1949
  .pj-chanpage, .pj-chan { flex: 1; min-height: 0; display: flex; flex-direction: column; }
1917
1950
  .pj-chan .files-head { flex: none; margin: 0; padding: 16px 24px 12px; border-bottom: 1px solid var(--border); }
1918
1951
  .pj-chan .files-head .pj-hash { margin-right: 6px; color: var(--muted); }
1952
+ /* The channel's call, in its header (project-call.js): Call, or who is in it with Join, or our own mute and leave. */
1953
+ .pj-chan .files-head { display: flex; align-items: center; gap: 16px; }
1954
+ .pj-chan .files-head .t { flex: 1; min-width: 0; }
1955
+ .pj-chan-call { flex: none; display: flex; align-items: center; }
1956
+ .pj-chan-call .chat-call { margin-left: 0; height: 32px; padding: 0 14px; font-size: 13px; }
1957
+ .pc-on { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel); font-size: 13px; }
1958
+ .pc-on b { font-weight: 600; white-space: nowrap; }
1959
+ .pc-who { display: flex; flex-direction: column; line-height: 1.25; }
1919
1960
  .pj-chan .messages { padding: 18px 24px; }
1920
1961
  .pj-chan .composer { flex: none; padding: 12px 24px 20px; }
1921
1962
  .pj-rooms button .avatar { width: 18px; height: 18px; font-size: 9px; flex: none; }
package/src/ui/app.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Quilt app: boot, live events, home screen, folder picker and invites.
2
2
  // The session workspace lives in session.js. Plain ES modules, no build step.
3
3
  import { authorOf } from './chat.js'
4
- import { TOKEN, I, state, $, esc, basename, ago, toast, api, ask, decodeInvite, remember, recall, startDropdowns, avatar, loadAccessTypes, typeOptions, loadingHtml, loadingNote } from './common.js'
4
+ import { TOKEN, I, state, $, esc, basename, ago, toast, api, ask, decodeInvite, remember, recall, startDropdowns, avatar, loadingHtml } from './common.js'
5
5
  import { renderShell, joinSessionDialog, openProjectSettings } from './home.js'
6
6
  import { mountSession, sessionUpdated, sessionMessage, sessionFeed, sessionFileChanged, sessionLog, sessionUnmount } from './session.js'
7
7
  import { quiltMark } from './mark.js'
@@ -9,12 +9,11 @@ import { renderSignIn } from './signin.js'
9
9
  import { checkRelease, openReleaseNotes } from './releases.js'
10
10
  import { loadWorkspaces, openWorkspace, wsIdOf } from './workspaces.js'
11
11
  import { renderRail } from './prail.js'
12
- import { menuCodebases, previewAt } from './project-model.js'
12
+ import { menuCodebases, previewAt, quiltBlock } from './project-model.js'
13
13
  import { knownMachines } from './preview-page.js'
14
14
  import { openNewProject } from './project-pop.js'
15
15
  import { previewBusy } from './files.js'
16
16
  import { agentPaste, NO_LINK_YET } from './invite.js'
17
- import { openKindMenu, kindLineHtml } from './agent-kinds.js'
18
17
  import { messageSound, letInSound, taskSound, soundOn, playSound, unlockSounds } from './sounds.js'
19
18
  import { watchSecretAsks } from './secrets.js'
20
19
  import { voiceEvent } from './voice.js'
@@ -497,142 +496,124 @@ export async function pickFolder (input) {
497
496
 
498
497
 
499
498
  // --------------------------------------------------------------- invite --
499
+ // One short pop-up: a tile for a person (copy the link) and a tile for an AI (copy one prompt,
500
+ // whatever AI it is), then, for the owner, the way straight in: an email, or someone they have
501
+ // worked with. No kinds of link or of AI to pick.
500
502
  export function openInvite (id) {
501
503
  const s = state.sessions.get(id)
502
504
  if (!s) return
503
- const d = decodeInvite(s.invite)
504
- // The owner of a session with approvals can invite people as an access type.
505
+ const name = s.status?.sessionName || basename(s.dir)
506
+ // The owner of a codebase with approvals can let people straight in, by email or by name.
505
507
  const owner = !!(s.viewInvite && s.status.access?.owner)
508
+ const canChat = !!(s.status.access?.owner || s.status.access?.canAdmit)
509
+ const wait = !s.viewInvite ? 'Anyone with it can edit, so send it only to people you trust.' : owner ? 'They wait until you let them in.' : 'They wait until someone lets them in.'
506
510
  const back = document.createElement('div')
507
511
  back.className = 'modal-back'
508
- back.innerHTML = `<div class="card modal" role="dialog" aria-modal="true" aria-labelledby="inv-title">
509
- <h3 id="inv-title">Invite someone</h3>
510
- <p class="lead">Send them a link. Clicking it opens the codebase in Quilt (after signing in). It also works with <code>quilt join &lt;link&gt;</code>.</p>
511
- <div class="label" style="margin-bottom:6px">${s.viewInvite ? 'Can edit' : 'Invite link'}</div>
512
- ${s.invite ? `<div class="codebox"><code id="inv-code">${esc(s.invite)}</code><button class="btn icon" data-copy="inv-code" title="Copy" aria-label="Copy invite link">${I.copy}</button></div>` : `<p class="hint">${esc(NO_LINK_YET)}</p>`}
513
- ${s.viewInvite ? `<div class="label" style="margin-bottom:6px">View only</div>
514
- <div class="codebox"><code id="inv-view">${esc(s.viewInvite)}</code><button class="btn icon" data-copy="inv-view" title="Copy" aria-label="Copy view-only link">${I.copy}</button></div>` : ''}
515
- ${d ? `<p class="hint">Room <code>${esc(d.room)}</code> via <code>${esc(d.server)}</code></p>` : ''}
516
- <p class="hint">${s.viewInvite ? 'Everyone who uses a link waits until you let them in, and you can change what they may do later in Codebase settings.' : 'Anyone with this link can edit the codebase. Only share it with people you trust.'}</p>
517
- ${owner ? `<div class="inv-section" id="inv-access">
518
- <div class="label inv-agent-label">Invite as</div>
519
- <select class="input" id="inv-type" aria-label="Invite as"></select>
520
- <p class="hint">People you invite here get straight in with this access once they sign in. No waiting for you.</p>
521
- <div class="label inv-sub">People you've worked with</div>
522
- <div class="inv-list" id="inv-people"><p class="hint">${loadingNote()}</p></div>
523
- <div class="label inv-sub">Invite by email</div>
524
- <form class="row" id="inv-email-form">
525
- <input class="input grow" type="email" id="inv-email" placeholder="name@example.com" aria-label="Email address" required>
526
- <button class="btn primary" type="submit">Send invite</button>
512
+ back.innerHTML = `<div class="card modal inv" role="dialog" aria-modal="true" aria-labelledby="inv-title">
513
+ <div class="inv-head"><h3 id="inv-title">${quiltBlock(name)}<span>Invite to ${esc(name)}</span></h3><button class="btn sm ghost icon" type="button" id="inv-done" title="Close" aria-label="Close">${I.x}</button></div>
514
+ <div class="inv-tiles">
515
+ <div class="inv-tile"><span class="inv-ic">${I.user}</span><b>A person</b><p>${s.invite ? `Send them the link. ${wait}` : esc(NO_LINK_YET)}</p>
516
+ ${s.invite ? `<button class="btn primary" type="button" id="inv-copy-link">${I.copy}<span>Copy invite link</span></button>` : ''}</div>
517
+ <div class="inv-tile"><span class="inv-ic">${I.bot}</span><b>An AI</b><p id="inv-agent-note">Paste the prompt into any AI: Claude Code, Cursor, Codex or ChatGPT. It joins as your agent.</p>
518
+ <button class="btn" type="button" id="inv-agent-make">${I.bot}<span>Copy prompt</span></button><p class="error" id="inv-agent-error"></p></div>
519
+ </div>
520
+ <div class="codebox inv-shown" id="inv-shown" hidden><code class="paste"></code></div>
521
+ ${owner ? `<div class="inv-in">
522
+ <span class="label">Or let someone straight in</span>
523
+ <form class="inv-add" id="inv-email-form">
524
+ <input class="input" type="email" id="inv-email" placeholder="Add an email" aria-label="Add an email" required>
525
+ <button class="btn" type="submit">Send invite</button>
527
526
  </form>
528
- <div class="label inv-sub">Pending invites</div>
529
- <div class="inv-list" id="inv-pending"></div>
527
+ <div class="inv-chips"><span id="inv-people"></span><span id="inv-pending"></span></div>
530
528
  <p class="error" id="inv-error"></p>
531
529
  </div>` : ''}
532
- <div class="label inv-agent-label">Your AI</div>
533
- <div id="inv-agent" class="inv-agent">
534
- <p class="hint">An AI that already has the Quilt command just needs the link above: tell it "Join my Quilt codebase: &lt;link&gt;". To add an AI that isn't registered with Quilt yet, make it an agent invite and paste the text into it: it carries the link above too. It joins as your own agent, listed in Settings.</p>
535
- <button class="btn" type="button" id="inv-agent-make"${state.workspacesOn ? ' aria-haspopup="menu" aria-expanded="false"' : ''}>${I.bot}<span>Invite an AI agent</span></button>
536
- <p class="error" id="inv-agent-error"></p>
537
- </div>
538
- ${s.status.access?.owner || s.status.access?.canAdmit ? `<div class="label inv-agent-label">A chat AI</div>
539
- <div id="inv-chat" class="inv-agent">
540
- <p class="hint">For ChatGPT, claude.ai, Grok and other AIs you use in a chat window: make a chat link and paste it into the chat. It can read and send messages, add, assign, move and comment on tasks, read files, and add pictures, documents and notes. It can't change existing files. It shows up in the codebase as its own member and works for 10 minutes: extend it in Codebase settings while it works, or make a new one after.</p>
541
- <button class="btn" type="button" id="inv-chat-make">${I.link}<span>Make a chat link</span></button>
542
- <p class="error" id="inv-chat-error"></p>
543
- </div>` : ''}
544
- <div class="actions"><button class="btn primary" id="inv-done">Done</button></div>
530
+ ${s.viewInvite ? `<div class="inv-more"><button type="button" class="inv-quiet" id="inv-copy-view">Copy a view-only link</button></div>` : ''}
545
531
  </div>`
546
532
  document.body.appendChild(back)
547
533
  const close = () => back.remove()
548
- back.addEventListener('click', async (e) => {
549
- const b = e.target.closest('[data-copy]')
550
- if (!b) return
551
- const el = $(`#${b.dataset.copy}`, back)
552
- try { await navigator.clipboard.writeText(el.textContent); toast('Copied') } catch {
553
- const r = document.createRange(); r.selectNodeContents(el)
534
+ // Copies `text` and says so on the button for a moment. Where the clipboard is not to be had, the text is shown, selected, to copy by hand.
535
+ const copy = async (text, btn, said = 'Copied') => {
536
+ const label = btn.querySelector('span') || btn
537
+ try {
538
+ await navigator.clipboard.writeText(text)
539
+ if (!btn.dataset.label) btn.dataset.label = label.textContent
540
+ label.textContent = said
541
+ btn.classList.add('copied')
542
+ clearTimeout(btn._t)
543
+ btn._t = setTimeout(() => { label.textContent = btn.dataset.label; btn.classList.remove('copied') }, 1800)
544
+ } catch {
545
+ const box = $('#inv-shown', back)
546
+ box.hidden = false
547
+ box.firstElementChild.textContent = text
548
+ const r = document.createRange(); r.selectNodeContents(box.firstElementChild)
554
549
  getSelection().removeAllRanges(); getSelection().addRange(r); toast('Press ⌘/Ctrl+C to copy')
555
550
  }
556
- })
551
+ }
552
+ if ($('#inv-copy-link', back)) $('#inv-copy-link', back).onclick = (e) => copy(s.invite, e.currentTarget)
553
+ if ($('#inv-copy-view', back)) $('#inv-copy-view', back).onclick = (e) => copy(s.viewInvite, e.currentTarget, 'View-only link copied')
554
+ // One prompt for any AI: an agent invite (it joins as your agent, in this codebase), and with it a
555
+ // chat link made ahead for an AI that can only open web pages (nobody joins until one opens it).
556
+ // Made at the first press and copied; pressed again, the same prompt is copied again.
557
+ let prompt = ''
557
558
  $('#inv-agent-make', back).onclick = async () => {
558
559
  const btn = $('#inv-agent-make', back)
559
- // With workspaces on: pick a global, workspace or session agent (this session first).
560
- if (state.workspacesOn) {
561
- return openKindMenu(btn, {
562
- sessionId: id,
563
- workspaceId: s.workspace || '',
564
- onInvite: ({ kind, text, where }) => { $('#inv-agent', back).innerHTML = agentInviteHtml(text, 'inv-agent-text', kindLineHtml(kind, where)) }
565
- })
566
- }
560
+ if (prompt) return copy(prompt, btn)
567
561
  btn.disabled = true
562
+ $('#inv-agent-error', back).textContent = ''
568
563
  try {
569
- const inv = await api('POST', '/api/agent-invites')
570
- $('#inv-agent', back).innerHTML = agentInviteHtml(agentPaste({ link: inv.link, session: s.invite }), 'inv-agent-text')
564
+ const [inv, chat] = await Promise.all([
565
+ api('POST', '/api/agent-invites'),
566
+ canChat ? api('POST', `/api/sessions/${id}/chat-link`, { waiting: true }).catch(() => null) : null
567
+ ])
568
+ prompt = agentPaste({ link: inv.link, session: s.invite, chat: chat?.url })
569
+ $('#inv-agent-note', back).textContent = 'Paste it into your AI. It works once, within an hour. Anyone with it can join as your agent, so give it only to your own AI.'
570
+ btn.disabled = false
571
+ copy(prompt, btn)
571
572
  } catch (err) {
572
573
  btn.disabled = false
573
574
  $('#inv-agent-error', back).textContent = err.message
574
575
  }
575
576
  }
576
- const chatMake = $('#inv-chat-make', back)
577
- if (chatMake) {
578
- chatMake.onclick = async () => {
579
- chatMake.disabled = true
580
- try {
581
- const r = await api('POST', `/api/sessions/${id}/chat-link`, {})
582
- const until = new Date(r.expiresAt).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })
583
- $('#inv-chat', back).innerHTML = `<p class="hint">Paste this into the chat. It works until ${esc(until)} (extend it in Codebase settings) and shows in the codebase as <b>${esc(r.name)}</b>. Anyone with it can act as ${esc(r.name)}, so only paste it there.</p>
584
- <div class="codebox"><code id="inv-chat-text">${esc(`Open this link and follow it to join our Quilt codebase: ${r.url}`)}</code><button class="btn icon" data-copy="inv-chat-text" title="Copy" aria-label="Copy chat link">${I.copy}</button></div>`
585
- } catch (err) {
586
- chatMake.disabled = false
587
- $('#inv-chat-error', back).textContent = err.message
588
- }
589
- }
590
- }
591
577
  $('#inv-done', back).onclick = close
592
578
  back.onclick = (e) => { if (e.target === back) close() }
593
- if (owner) bindInviteAs(id, back)
579
+ back.onkeydown = (e) => { if (e.key === 'Escape') close() }
580
+ if (owner) bindInvitePeople(id, back)
581
+ ;($('#inv-copy-link', back) || $('#inv-done', back)).focus()
594
582
  }
595
583
 
596
- /** The owner's invite panel: "Invite as" a type, people you've worked with, by email, and pending invites. */
597
- function bindInviteAs (id, back) {
584
+ /** The owner's part of the invite: by email, or someone they have worked with (a chip each); the invites still waiting are chips beside them. They get straight in, to edit. */
585
+ function bindInvitePeople (id, back) {
598
586
  const error = (msg) => { $('#inv-error', back).textContent = msg || '' }
599
- const typeId = () => $('#inv-type', back).value
587
+ let waiting = [] // the invites still open, as last heard
588
+ let known = [] // the people you have worked with
589
+ const here = () => { const st = state.sessions.get(id)?.status || {}; return new Set([st.me?.name, ...(st.peers || []).map((p) => p.name), ...(st.members || []).map((m) => m.name)]) }
590
+ const draw = () => {
591
+ // Someone already in the codebase, or already invited, is not offered again.
592
+ const asked = new Set(waiting.map((i) => i.name))
593
+ $('#inv-people', back).innerHTML = known.filter((c) => !here().has(c.name) && !asked.has(c.name)).map((c) => `<button type="button" class="inv-chip" data-invite-account="${esc(c.account)}" data-name="${esc(c.name)}" title="Invite ${esc(c.name)}">${avatar(c.name, null)}<span>${esc(c.name)}</span>${c.kind === 'agent' ? I.bot : I.plus}</button>`).join('')
594
+ $('#inv-pending', back).innerHTML = waiting.map((i) => `<span class="inv-chip wait">${esc(i.email || i.name)} · invited<button type="button" data-cancel-invite="${esc(i.id)}" title="Cancel the invite" aria-label="Cancel the invite to ${esc(i.email || i.name)}">${I.x}</button></span>`).join('')
595
+ }
600
596
  const invite = async (to, done) => {
601
597
  error('')
602
598
  try {
603
- await api('POST', `/api/sessions/${id}/invites`, { typeId: typeId(), to })
599
+ await api('POST', `/api/sessions/${id}/invites`, { typeId: 'builtin:edit', to })
604
600
  toast(done)
605
601
  await pending()
606
602
  } catch (err) { error(err.message) }
607
603
  }
608
604
  async function pending () {
609
- const el = $('#inv-pending', back)
610
- try {
611
- const open = (await api('GET', `/api/sessions/${id}/invites`)).invites.filter((i) => i.status === 'waiting')
612
- el.innerHTML = open.length
613
- ? open.map((i) => `<div class="inv-row"><span class="grow">${esc(i.email || i.name)}<span class="hint"> · ${esc(i.typeName)}</span></span><button class="btn sm ghost" type="button" data-cancel-invite="${esc(i.id)}">Cancel</button></div>`).join('')
614
- : '<p class="hint">No pending invites.</p>'
615
- } catch (err) { el.innerHTML = `<p class="hint">${esc(err.message)}</p>` }
605
+ try { waiting = (await api('GET', `/api/sessions/${id}/invites`)).invites.filter((i) => i.status === 'waiting') } catch (err) { error(err.message) }
606
+ draw()
616
607
  }
617
608
  async function people () {
618
- const el = $('#inv-people', back)
619
- try {
620
- const list = (await api('GET', '/api/collaborators')).collaborators
621
- el.innerHTML = list.length
622
- ? list.map((c) => `<div class="inv-row">${avatar(c.name, null)}<span class="grow">${esc(c.name)}${c.kind === 'agent' ? `<span class="tag bot">${I.bot}agent</span>` : ''}</span><button class="btn sm" type="button" data-invite-account="${esc(c.account)}" data-name="${esc(c.name)}">Invite</button></div>`).join('')
623
- : "<p class=\"hint\">Nobody yet. People and agents you've been in a codebase with show up here.</p>"
624
- } catch (err) { el.innerHTML = `<p class="hint">${esc(err.message)}</p>` }
609
+ try { known = (await api('GET', '/api/collaborators')).collaborators } catch {} // the link and the email still work
610
+ draw()
625
611
  }
626
- ;(state.accessTypes ? Promise.resolve(state.accessTypes) : loadAccessTypes()).then((types) => {
627
- const sel = $('#inv-type', back)
628
- if (types) sel.innerHTML = typeOptions()
629
- else { sel.innerHTML = '<option value="builtin:edit">Can edit</option><option value="builtin:view">View only</option>' }
630
- })
631
612
  people()
632
613
  pending()
633
614
  back.addEventListener('click', async (e) => {
634
615
  const inv = e.target.closest('[data-invite-account]')
635
- if (inv) { inv.disabled = true; await invite({ account: inv.dataset.inviteAccount }, `Invited ${inv.dataset.name}`); inv.disabled = false; return }
616
+ if (inv) { inv.disabled = true; await invite({ account: inv.dataset.inviteAccount }, `Invited ${inv.dataset.name}`); return }
636
617
  const cancel = e.target.closest('[data-cancel-invite]')
637
618
  if (cancel) {
638
619
  try { await api('POST', `/api/sessions/${id}/invites/cancel`, { inviteId: cancel.dataset.cancelInvite }); toast('Invite cancelled'); await pending() } catch (err) { error(err.message) }
package/src/ui/invite.js CHANGED
@@ -77,11 +77,13 @@ export function parseInvite (code, { allowRelay = () => false } = {}) {
77
77
  /**
78
78
  * What to paste into an AI so it joins Quilt as your agent. `link` is a one-time agent
79
79
  * invite from the accounts API; `session` is the session invite link when it is made from a
80
- * session's Invite, so the agent joins that session straight after registering. This is the
81
- * one invite prompt: the app (Settings and a session's Invite) and the website (Agents, an
82
- * org's People) all show exactly this.
80
+ * session's Invite, so the agent joins that session straight after registering. `chat` is a
81
+ * chat link made ahead for that session (chat-links.js), for an AI that can only open web
82
+ * pages: with it the one prompt works whatever AI it is pasted into. This is the one invite
83
+ * prompt: the app (Settings and a session's Invite) and the website (Agents, an org's People)
84
+ * all show exactly this.
83
85
  */
84
- export function agentPaste ({ link, session, invitedToSessions = false } = {}) {
86
+ export function agentPaste ({ link, session, chat, invitedToSessions = false } = {}) {
85
87
  let apiUrl
86
88
  try { apiUrl = new URL(link).origin } catch {}
87
89
  const sessionLink = session || '<codebase invite link>'
@@ -94,6 +96,7 @@ export function agentPaste ({ link, session, invitedToSessions = false } = {}) {
94
96
  `- With the CLI (whenever you can run commands): ${INSTALL_CLI} Then run \`quilt agent join ${link} --name <your name>\` (pick a short name), and in the codebase's folder start \`quilt join ${sessionLink} --agent <your name>\` and keep it running (see below).`,
95
97
  `- In a sandbox wiped after every turn: ${SANDBOX_CLI}`,
96
98
  `- Only if you have no computer and can do nothing but make HTTP requests: open ${link} and follow it to join over HTTP (register, then connect to the MCP server it names and call quilt_join_session with ${session ? 'my codebase invite link' : 'the codebase invite link I send you'}).`,
99
+ ...(chat ? [`- If all you can do is open web pages (an AI in a chat window, such as ChatGPT, claude.ai or Grok, that can neither run commands nor send requests): leave the rest of this, open ${chat} and follow what it says. There you read and send messages, work on tasks, read files, and add pictures, documents and notes. It works for 10 minutes from when you first open it, and I can make that longer.`] : []),
97
100
  '- If you joined Quilt before, give the agent id Quilt gave you then (CLI: `--agent-id <your agent id>`; over HTTP: "agentId"), so you come back as the same agent instead of a new one. Not joined before, or lost it? Leave it out.',
98
101
  '- Quilt answers with your agent id. Save it where you will still have it later (your memory, notes or config): it is public, not a secret, and it is how you come back as yourself.',
99
102
  session ? `- My codebase invite link: ${session}. I may have to let you in first.` : '- I will send you a codebase invite link (https://join.heyquilt.com/...).',
@@ -0,0 +1,158 @@
1
+ // A call in one of a project's channels (plans/voice.md, "A call in a project's channel"): Call
2
+ // in the channel's header starts it, and it is there for everyone in the project, on the
3
+ // project's page or inside any of its codebases. The audio is voice-call.js, the same as a
4
+ // codebase's call; who is in the call and each pair's call setup go through the accounts API
5
+ // (routes/workspace-calls.js) instead of the relay, said again every second or two while in it.
6
+ // It is never transcribed, and no screen is shared in it yet.
7
+ import { $, esc, api, toast, avatar, I, TOKEN } from './common.js'
8
+ import { VoiceCall } from './voice-call.js'
9
+ import { playSound } from './sounds.js'
10
+
11
+ // This window's number in a project's calls: its own for as long as the window is open.
12
+ const CLIENT = Math.floor(Math.random() * 9e8) + 1e8
13
+ const BEAT_MS = 1500
14
+ const ASK_MS = 4000
15
+ const FULL = 6
16
+ const NO_MIC = "Quilt can't use your microphone. Allow it for Quilt in System Settings → Privacy & Security → Microphone, then try again."
17
+ const heard = new Map() // project id -> { calls: { <channel>: { since, people } }, asked }
18
+ let live = null // the call this window is in: { ws, channel, call, view, beat }
19
+ let joining = '' // the call being joined (`project|channel`), while the microphone opens
20
+ let shown = null // the channel on screen: { el, ws, channel, changed, drawn }
21
+ const keyOf = (ws, channel) => `${ws}|${channel || ''}`
22
+ const urlOf = (ws) => `/api/workspaces/${encodeURIComponent(ws)}/call`
23
+ const minutes = (from) => { const m = Math.round((Date.now() - from) / 60000); return m < 1 ? 'under a minute' : `${m} min` }
24
+ const names = (list) => list.length <= 2 ? list.join(' and ') : `${list.slice(0, -1).join(', ')} and ${list[list.length - 1]}`
25
+
26
+ /** How many people are in a channel's call (`channel` '' is the project's own), as last heard; 0 with no call. */
27
+ export function channelCall (ws, channel = '') {
28
+ if (live && live.ws === ws && live.channel === channel && live.call.in) return 1 + (live.view ? live.view.peers.length : 0)
29
+ return heard.get(ws)?.calls[channel]?.people.length || 0
30
+ }
31
+
32
+ /** Asks which of a project's channels have a call going (at most every few seconds). `changed()`: one began, ended, or someone came or went. */
33
+ export async function loadCalls (ws, changed = () => {}) {
34
+ if (!heard.has(ws)) heard.set(ws, { calls: {}, asked: 0 })
35
+ const h = heard.get(ws)
36
+ if (Date.now() - h.asked < ASK_MS) return
37
+ h.asked = Date.now()
38
+ try {
39
+ const r = await api('GET', urlOf(ws))
40
+ const was = JSON.stringify(h.calls)
41
+ h.calls = r.calls || {}
42
+ if (JSON.stringify(h.calls) !== was) { changed(); draw() }
43
+ } catch {} // a server without calls in channels yet: no call is shown, and Call says why when pressed
44
+ }
45
+
46
+ async function join (ws, channel) {
47
+ if (joining) return
48
+ joining = keyOf(ws, channel)
49
+ draw()
50
+ try {
51
+ if (live) await leave()
52
+ // One call at a time: a codebase's call this window is in ends (voice.js hears this).
53
+ window.dispatchEvent(new CustomEvent('quilt-call', { detail: 'project' }))
54
+ const mine = { ws, channel, view: null, beat: null }
55
+ const call = new VoiceCall({
56
+ post: (b) => api('POST', urlOf(ws), { ...b, channel, client: CLIENT }).then((v) => { mine.view = v; return v }),
57
+ ice: () => api('GET', '/api/voice/ice'),
58
+ onChange: () => draw(),
59
+ onPeople: (sound) => playSound(sound, { force: true })
60
+ })
61
+ mine.call = call
62
+ live = mine
63
+ await call.join()
64
+ // Still in the call: said again every second or two, which is also how the others' news comes.
65
+ mine.beat = setInterval(() => call.publish(), BEAT_MS)
66
+ playSound('callIn', { force: true })
67
+ } catch (err) {
68
+ if (live && live.ws === ws && live.channel === channel) { clearInterval(live.beat); await live.call.leave().catch(() => {}); live = null }
69
+ toast(err && (err.name === 'NotAllowedError' || err.name === 'NotFoundError') ? NO_MIC : err.status === 404 ? "Calls in a project's channels aren't on Quilt's servers yet." : `Couldn't join the call: ${err.message}`)
70
+ } finally {
71
+ joining = ''
72
+ changedNow()
73
+ }
74
+ }
75
+
76
+ async function leave () {
77
+ if (!live) return
78
+ const { call, beat, ws } = live
79
+ live = null
80
+ clearInterval(beat)
81
+ await call.leave().catch(() => {})
82
+ playSound('callOut', { force: true })
83
+ if (heard.has(ws)) heard.get(ws).asked = 0
84
+ changedNow()
85
+ }
86
+
87
+ /** The page's own counts (the sidebar's rows) and the header, after joining or leaving. */
88
+ function changedNow () {
89
+ draw()
90
+ if (shown) { shown.changed(); loadCalls(shown.ws, shown.changed) }
91
+ }
92
+
93
+ // A codebase's call was joined in this window: this one ends.
94
+ window.addEventListener('quilt-call', (e) => { if (e.detail !== 'project' && live) leave() })
95
+ // Closing or reloading the window leaves the call (the page can't wait for an answer).
96
+ window.addEventListener('pagehide', () => {
97
+ if (!live) return
98
+ navigator.sendBeacon(`${urlOf(live.ws)}?t=${encodeURIComponent(TOKEN || '')}`, new Blob([JSON.stringify({ channel: live.channel, client: CLIENT, in: false })], { type: 'application/json' }))
99
+ })
100
+
101
+ const face = (key, name, muted) => `<span class="call-face" data-face="${key}" title="${esc(name)}${muted ? ' (muted)' : ''}">${avatar(name)}${muted ? `<span class="call-muted">${I.micOff}</span>` : ''}</span>`
102
+
103
+ /** The call's place in the channel's header: Call, or who is in it with Join, or our own mute and leave. */
104
+ function draw () {
105
+ if (!shown || !shown.el.isConnected) return
106
+ const { el, ws, channel } = shown
107
+ const here = !!(live && live.ws === ws && live.channel === channel && live.call.in)
108
+ const starting = joining === keyOf(ws, channel)
109
+ const elsewhere = !!(live && !here)
110
+ const others = here ? (live.view ? live.view.peers : []) : (heard.get(ws)?.calls[channel]?.people || []).map((name, i) => ({ id: `n${i}`, name, muted: false }))
111
+ const since = here ? live.view?.since : heard.get(ws)?.calls[channel]?.since
112
+ const c = here ? live.call : null
113
+ const key = JSON.stringify([ws, channel, here, starting, elsewhere, others.map((p) => [p.id, p.name, p.muted]), here && c.muted, since ? minutes(since) : ''])
114
+ if (key !== shown.drawn) {
115
+ shown.drawn = key
116
+ const you = meName()
117
+ if (starting) {
118
+ el.innerHTML = '<span class="pc-on"><span class="call-dot"></span><b>Joining the call…</b></span>'
119
+ } else if (here) {
120
+ el.innerHTML = `<span class="pc-on"><span class="call-dot"></span><span class="call-faces">${face('me', you, c.muted)}${others.map((p) => face(p.id, p.name, p.muted)).join('')}</span>
121
+ <span class="call-sub">${others.length ? esc(minutes(since || Date.now())) : 'Only you so far'}</span>
122
+ <button type="button" class="call-ic" data-pc-mute aria-pressed="${c.muted}" title="${c.muted ? 'Unmute' : 'Mute'}" aria-label="${c.muted ? 'Unmute' : 'Mute'}">${c.muted ? I.micOff : I.mic}</button>
123
+ <button type="button" class="call-ic bad" data-pc-leave title="Leave the call" aria-label="Leave the call">${I.hangUp}</button></span>`
124
+ } else if (others.length) {
125
+ el.innerHTML = `<span class="pc-on"><span class="call-dot"></span><span class="call-faces">${others.map((p) => face(p.id, p.name, false)).join('')}</span>
126
+ <span class="pc-who"><b>${esc(names(others.map((p) => p.name)))} ${others.length === 1 ? 'is' : 'are'} in a call</b><span class="call-sub">${since ? esc(minutes(since)) : ''}</span></span>
127
+ <button type="button" class="btn sm primary" data-pc-join ${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></span>`
128
+ } else {
129
+ el.innerHTML = `<button type="button" class="chat-call" data-pc-join title="${elsewhere ? 'Leave your other call first' : 'Start a voice call in this channel'}"${elsewhere ? ' disabled' : ''}>${I.headset}<span>Call</span></button>`
130
+ }
131
+ }
132
+ // Who is speaking: a ring, painted without drawing the buttons again under a press.
133
+ if (here) for (const f of el.querySelectorAll('[data-face]')) f.classList.toggle('talk', c.speaking(f.dataset.face === 'me' ? 'me' : Number(f.dataset.face)))
134
+ }
135
+
136
+ let meName = () => 'You'
137
+
138
+ /**
139
+ * A channel is on screen: its call goes in `el`, in the channel's header. `me`: your name;
140
+ * `changed()`: how many are in a call changed (the sidebar's rows show it).
141
+ */
142
+ export function mountChannelCall (el, { ws, channel = '', me = 'You', changed = () => {} }) {
143
+ meName = () => me
144
+ shown = { el, ws, channel, changed, drawn: '' }
145
+ el.onclick = (e) => {
146
+ const b = e.target.closest('button')
147
+ if (!b || !shown || shown.el !== el) return
148
+ if (b.hasAttribute('data-pc-join')) join(ws, channel)
149
+ else if (b.hasAttribute('data-pc-leave')) leave()
150
+ else if (b.hasAttribute('data-pc-mute') && live) live.call.setMuted(!live.call.muted)
151
+ }
152
+ draw()
153
+ if (heard.has(ws)) heard.get(ws).asked = 0
154
+ loadCalls(ws, changed)
155
+ }
156
+
157
+ // The call's minutes, and who is in a call we are not in, as the page stays open.
158
+ setInterval(() => { if (shown && shown.el.isConnected) { draw(); if (!live) loadCalls(shown.ws, shown.changed) } }, ASK_MS)
@@ -4,6 +4,7 @@
4
4
  // seconds while a project's page is open. A codebase's own channel is its chat.
5
5
  import { I, state, $, esc, api, toast, avatar, clock } from './common.js'
6
6
  import { textHtml } from './chat.js'
7
+ import { mountChannelCall } from './project-call.js'
7
8
 
8
9
  const ASK_MS = 4000
9
10
  // `channel` everywhere here: the id of a channel someone made, or '' for the project's own.
@@ -96,12 +97,14 @@ export function mountChannel (el, { d, changed = () => {}, channel = null }) {
96
97
  const names = () => [...new Set([d.owner?.name, ...(d.members || []).map((m) => m.name), ...(d.agents || []).map((a) => a.name)].filter(Boolean))]
97
98
  el.innerHTML = `
98
99
  <div class="pj-chan">
99
- <div class="files-head"><div class="t"><h2 class="crumbs"><span class="pj-hash">#</span>${esc(title)}</h2><p class="hint">Everyone in ${esc(d.workspace.name)} and its agents. It is here with no codebase open.</p></div></div>
100
+ <div class="files-head"><div class="t"><h2 class="crumbs"><span class="pj-hash">#</span>${esc(title)}</h2><p class="hint">Everyone in ${esc(d.workspace.name)} and its agents. It is here with no codebase open.</p></div><div class="pj-chan-call" data-chan-call></div></div>
100
101
  <div class="messages" data-chan-list aria-live="polite"></div>
101
102
  <form class="composer" data-chan-form><div class="box"><textarea rows="1" maxlength="8000" placeholder="Message ${esc(title)}…" aria-label="Message ${esc(title)}"></textarea><button type="submit" class="btn primary icon" title="Send" aria-label="Send">${I.send}</button></div></form>
102
103
  </div>`
103
104
  const list = $('[data-chan-list]', el)
104
105
  const box = $('textarea', el)
106
+ // The channel's call, in its header: for everyone in the project, wherever they are.
107
+ mountChannelCall($('[data-chan-call]', el), { ws: id, channel: cid, me: me || 'You', changed })
105
108
  const draw = () => {
106
109
  const near = list.scrollHeight - list.scrollTop - list.clientHeight < 80
107
110
  const all = names()
@@ -118,6 +121,7 @@ export function mountChannel (el, { d, changed = () => {}, channel = null }) {
118
121
  box.value = c.draft
119
122
  box.oninput = () => { c.draft = box.value; grow() }
120
123
  grow()
124
+ requestAnimationFrame(grow) // again once the page is laid out: measured too early, an empty box comes out tall
121
125
  box.onkeydown = (e) => { if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) { e.preventDefault(); $('[data-chan-form]', el).requestSubmit() } }
122
126
  $('[data-chan-form]', el).onsubmit = async (e) => {
123
127
  e.preventDefault()
@@ -6,6 +6,7 @@ import { I, state, $, esc, ago, api, toast, ask, avatar, COLORS, loadingHtml } f
6
6
  import { quiltMark } from './mark.js'
7
7
  import { quiltBlock, projectCodebases, looseCodebases, whoLine, readFolded, projectDms } from './project-model.js'
8
8
  import { mountChannel, loadChannel, channelUnread, projectChannels, loadChannels, addChannel } from './project-channel.js'
9
+ import { channelCall, loadCalls } from './project-call.js'
9
10
  import { tileLetter } from './prail-model.js'
10
11
  import { loadWorkspaces, openWorkspace, wsIdOf } from './workspaces.js'
11
12
  import { openNewProject, openProjectPop } from './project-pop.js'
@@ -42,6 +43,8 @@ export function drawSideShut (ws) {
42
43
  b.title = `${shut ? 'Show' : 'Hide'} the sidebar`
43
44
  b.setAttribute('aria-label', b.title)
44
45
  }
46
+ // A call going on in a project's channel, on its row: how many are in it.
47
+ const callMark = (n) => n ? `<span class="pj-call" title="${n === 1 ? '1 person is' : `${n} people are`} in a call here">${I.headset}${n}</span>` : ''
45
48
  // The plus beside Channels, in a project's sidebar and a codebase's: a row to name the new one in, in the list.
46
49
  const newChannelBtn = `<button type="button" class="btn sm ghost icon" data-new-channel title="New channel" aria-label="New channel">${I.plus}</button>`
47
50
  const newChannelRow = () => `<form class="pj-newchan" data-new-channel-form autocomplete="off"><span class="pj-hash">#</span><input name="name" maxlength="40" placeholder="Name the channel" aria-label="The new channel's name" value="${esc(state.newChannelDraft || '')}" spellcheck="false"></form>`
@@ -260,7 +263,7 @@ function sideHtml (p, d, page) {
260
263
  const onChannel = page === 'channel' ? (made.list.some((c) => c.id === state.projectChannel) ? state.projectChannel : '') : null
261
264
  const newHere = own + made.list.reduce((n, c) => n + c.unread, 0) + open.reduce((n, c) => n + ((state.sessions.get(c.id)?.status.unread) || 0), 0)
262
265
  const naming = state.newChannel === p.id && made.canAdd
263
- const room = (attrs, name, n, on) => `<button type="button" class="${on ? 'on' : ''}" ${attrs}${on ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>`
266
+ const room = (attrs, name, n, on, call = 0) => `<button type="button" class="${on ? 'on' : ''}" ${attrs}${on ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(name)}</span>${callMark(call)}${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>`
264
267
  // Direct messages, across the codebases open here: a row opens that codebase's chat on them.
265
268
  const dms = projectDms(open.map((c) => ({ id: c.id, name: c.name, messages: state.messages.get(c.id) || [], me: state.sessions.get(c.id)?.status.me?.name || '' })))
266
269
  const row = (c) => {
@@ -277,8 +280,8 @@ function sideHtml (p, d, page) {
277
280
  <div class="side-sessions">${isFolded('codebases') ? '' : list.map(row).join('')}</div>
278
281
  ${label('channels', 'Channels', newHere, made.canAdd ? newChannelBtn : '')}
279
282
  <div class="side-sessions pj-rooms">${isFolded('channels') && page !== 'channel' && !newHere && !naming ? '' : `
280
- ${isFolded('channels') && onChannel !== '' && !own ? '' : room(`data-page="channel" title="Everyone in ${esc(p.name)}"`, p.name, own, onChannel === '')}
281
- ${made.list.filter((c) => !isFolded('channels') || c.id === onChannel || c.unread).map((c) => room(`data-channel="${esc(c.id)}" title="Everyone in ${esc(p.name)}"`, c.name, c.unread, c.id === onChannel)).join('')}
283
+ ${isFolded('channels') && onChannel !== '' && !own && !channelCall(p.id) ? '' : room(`data-page="channel" title="Everyone in ${esc(p.name)}"`, p.name, own, onChannel === '', channelCall(p.id))}
284
+ ${made.list.filter((c) => !isFolded('channels') || c.id === onChannel || c.unread || channelCall(p.id, c.id)).map((c) => room(`data-channel="${esc(c.id)}" title="Everyone in ${esc(p.name)}"`, c.name, c.unread, c.id === onChannel, channelCall(p.id, c.id))).join('')}
282
285
  ${naming ? newChannelRow() : ''}
283
286
  ${isFolded('channels') ? '' : open.map((c) => room(`data-go-chat="${esc(c.id)}" title="Everyone working in ${esc(c.name)}"`, c.name, (state.sessions.get(c.id)?.status.unread) || 0, false)).join('')}`}</div>
284
287
  ${dms.length ? `${label('dms', 'Direct messages')}
@@ -321,7 +324,7 @@ export function codeSideHtml ({ page, name, project, tasks = 0, artifacts = 0, c
321
324
  const ch = project && channels
322
325
  const onCh = page.startsWith('channel:') ? page.slice('channel:'.length) : null
323
326
  const chNew = ch ? ch.own + ch.list.reduce((n, c) => n + c.unread, 0) : 0
324
- const room = (id, nm, n) => !isFolded('channels') || onCh === id || n ? `<button type="button" class="${onCh === id ? 'on' : ''}" data-code-page="channel:${esc(id)}" title="Everyone in ${esc(project.name)}"${onCh === id ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(nm)}</span>${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>` : ''
327
+ const room = (id, nm, n) => !isFolded('channels') || onCh === id || n || channelCall(project.id, id) ? `<button type="button" class="${onCh === id ? 'on' : ''}" data-code-page="channel:${esc(id)}" title="Everyone in ${esc(project.name)}"${onCh === id ? ' aria-current="page"' : ''}><span class="pj-hash">#</span><span class="nm">${esc(nm)}</span>${callMark(channelCall(project.id, id))}${n ? `<span class="ct new">${n > 99 ? '99+' : n}</span>` : ''}</button>` : ''
325
328
  return `
326
329
  <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>
327
330
  ${pvHtml}
@@ -509,14 +512,22 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
509
512
  for (const c of made().list) count([...root.querySelectorAll('.pj-side [data-channel]')].find((b) => b.dataset.channel === c.id), c.unread)
510
513
  }
511
514
  const made = () => projectChannels(p.id)
515
+ // A call began or ended in one of the channels, or someone came or went: the rows say so. With a channel open the page is not drawn again (what is being typed stays): only its rows' marks are.
516
+ const callsChanged = () => {
517
+ if (state.view !== view) return
518
+ if (!root.querySelector('[data-project-channel]') && !root.querySelector('[data-new-channel-form] input')) return rerender()
519
+ const mark = (row, n) => { if (!row) return; row.querySelector('.pj-call')?.remove(); if (n) row.querySelector('.nm').insertAdjacentHTML('afterend', callMark(n)) }
520
+ mark(root.querySelector('.pj-side [data-page="channel"]'), channelCall(p.id))
521
+ for (const c of made().list) mark([...root.querySelectorAll('.pj-side [data-channel]')].find((b) => b.dataset.channel === c.id), channelCall(p.id, c.id))
522
+ }
512
523
  // The channel on the page: one someone made, by its id, or the project's own (also when that one is gone).
513
524
  const openChannel = () => made().list.find((c) => c.id === state.projectChannel) || null
514
- const ask = () => { loadChannel(p.id, newCount); loadChannels(p.id, newCount); const c = openChannel(); if (c && root.querySelector('[data-project-channel]')) loadChannel(p.id, newCount, { channel: c.id }) }
525
+ const ask = () => { loadChannel(p.id, newCount); loadChannels(p.id, newCount); loadCalls(p.id, callsChanged); const c = openChannel(); if (c && root.querySelector('[data-project-channel]')) loadChannel(p.id, newCount, { channel: c.id }) }
515
526
  clearInterval(channelTimer)
516
527
  channelTimer = setInterval(() => { if (state.view !== view || !root.isConnected) return clearInterval(channelTimer); ask() }, 4000)
517
528
  ask()
518
529
  const channel = root.querySelector('[data-project-channel]')
519
- if (channel) mountChannel(channel, { d, changed: newCount, channel: openChannel() })
530
+ if (channel) mountChannel(channel, { d, changed: () => { newCount(); callsChanged() }, channel: openChannel() })
520
531
  // A channel someone made opens as the project's own does.
521
532
  root.querySelectorAll('.pj-side [data-channel]').forEach((b) => { b.onclick = () => { state.projectPage = 'channel'; state.projectChannel = b.dataset.channel; if (state.view === `ws:${p.id}`) rerender(); else go(`ws:${p.id}`) } })
522
533
  // The plus beside Channels: a row to name the new one in, in the list. Enter makes it and opens it; Escape, or leaving it empty, takes the row away.
package/src/ui/session.js CHANGED
@@ -29,6 +29,7 @@ import { heldCard } from './session-words.js'
29
29
  import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, callCounts, callScope } from './voice.js'
30
30
  import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, drawSideShut, foldSection, startNewChannel, bindNewChannel } from './projects.js'
31
31
  import { mountChannel, loadChannel, loadChannels, channelUnread, projectChannels } from './project-channel.js'
32
+ import { loadCalls } from './project-call.js'
32
33
  import { mountPreview } from './preview-page.js'
33
34
  import { dmThreads } from './project-model.js'
34
35
 
@@ -501,6 +502,7 @@ function askChannels () {
501
502
  if (!p) return
502
503
  loadChannel(p.id, renderCodeSide)
503
504
  loadChannels(p.id, renderCodeSide)
505
+ loadCalls(p.id, renderCodeSide) // a call going on in one of them shows on its row
504
506
  const on = (ws(current).side || '').startsWith('channel:') ? ws(current).side.slice('channel:'.length) : ''
505
507
  if (on) loadChannel(p.id, renderCodeSide, { channel: on })
506
508
  }
@@ -1399,10 +1401,9 @@ function bindMain () {
1399
1401
  $('#main').addEventListener('click', async (e) => {
1400
1402
  const copy = e.target.closest('[data-copy-invite]')
1401
1403
  if (copy) {
1402
- const view = copy.dataset.copyInvite === 'view'
1403
- const link = view ? sum().viewInvite : sum().invite
1404
+ const link = sum().invite
1404
1405
  if (!link) return toast(NO_LINK_YET)
1405
- try { await navigator.clipboard.writeText(link); toast(view ? 'View-only link copied' : 'Invite link copied') } catch { openInvite(current) }
1406
+ try { await navigator.clipboard.writeText(link); toast('Invite link copied') } catch { openInvite(current) }
1406
1407
  return
1407
1408
  }
1408
1409
  const b = e.target.closest('[data-person]')
@@ -2173,12 +2174,8 @@ function renderMain () {
2173
2174
  el.innerHTML = `<div class="main-empty invite-empty">
2174
2175
  <div class="ill">${I.link}</div>
2175
2176
  <h3>Invite someone to code with you</h3>
2176
- <p class="hint">Send a link. Clicking it opens this codebase in Quilt${viewInvite ? ', and you approve them before they get in' : ''}. To add an AI, use <b>Invite</b> above.</p>
2177
- ${viewInvite ? `
2178
- <div class="invite-pair">
2179
- <div><div class="label">Can edit</div><div class="codebox"><code>${esc(invite)}</code></div><button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy edit link</span></button></div>
2180
- <div><div class="label">View only</div><div class="codebox"><code>${esc(viewInvite)}</code></div><button class="btn" data-copy-invite="view">${I.copy}<span>Copy view link</span></button></div>
2181
- </div>` : invite ? `
2177
+ <p class="hint">Send a link. Clicking it opens this codebase in Quilt${viewInvite ? ', and you approve them before they get in' : ''}. For an AI, or a view-only link, use <b>Invite</b> above.</p>
2178
+ ${invite ? `
2182
2179
  <div class="codebox"><code id="empty-invite">${esc(invite)}</code></div>
2183
2180
  <button class="btn primary" data-copy-invite="edit">${I.copy}<span>Copy invite link</span></button>` : `<p class="hint">${esc(NO_LINK_YET)}</p>`}
2184
2181
  <p class="hint small">Once they join, you'll see their AI chat here as it happens.</p>
package/src/ui/voice.js CHANGED
@@ -179,6 +179,8 @@ async function join (id, transcribing) {
179
179
  renderCall()
180
180
  try {
181
181
  if (live) await leave()
182
+ // One call at a time: a call in a project's channel this window is in ends (project-call.js hears this).
183
+ window.dispatchEvent(new CustomEvent('quilt-call', { detail: 'codebase' }))
182
184
  const call = new VoiceCall({
183
185
  post: (b) => api('POST', voiceUrl(id), b).then((v) => keep(id, v)),
184
186
  ice: () => api('GET', '/api/voice/ice'),
@@ -229,6 +231,8 @@ async function leave () {
229
231
  renderCall()
230
232
  }
231
233
 
234
+ // A call in a project's channel was joined in this window: this one ends.
235
+ window.addEventListener('quilt-call', (e) => { if (e.detail !== 'codebase' && live) leave() })
232
236
  // Closing or reloading the window leaves the call (the page can't wait for an answer).
233
237
  window.addEventListener('pagehide', () => {
234
238
  if (!live) return
package/src/ui-server.js CHANGED
@@ -21,7 +21,7 @@ import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
21
21
  import { migrateDir } from './legacy.js'
22
22
  import { writePrivateJson } from './private-file.js'
23
23
  import { autoToolFor } from './autowork-tools.js'
24
- import { workspaceMessages, sayInWorkspace, readWorkspaceMessages, workspaceChannels, addWorkspaceChannel } from './account.js'
24
+ import { workspaceMessages, sayInWorkspace, readWorkspaceMessages, workspaceChannels, addWorkspaceChannel, workspaceCalls, workspaceCall } from './account.js'
25
25
  import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, signUpForLink, confirmSignUpForLink, fetchMe, signOut, revokeToken, accountFromProfile, renameSession, createAgentInvite, listAgents, agentDetails, listAccessTypes, listCollaborators, listGrants, putGrant, deleteGrant, inviteToSession, listSessionInvites, cancelSessionInvite, listWorkspaces, listOrgs, createWorkspace, getWorkspace, updateWorkspace, deleteWorkspace, putWorkspaceMember, removeWorkspaceMember, getAgentPlacement, putAgentPlacement, listOrgAgents, putWorkspaceAgent, deleteWorkspaceAgent, createWorkspaceAgentInvite, excludeSessionAgent, listExcludedSessionAgents, listSessionAgents, includeSessionAgent, setSessionWorkspace, moveSessionToWorkspace, listWorkspaceInvites, inviteToWorkspace, cancelWorkspaceInvite, listMyInvites, answerMyInvite, listMySessions, announceSessionStarted, announceWhenReported, listWorkspaceFiles, createWorkspaceFile, confirmWorkspaceFile, workspaceFileDownload, updateWorkspaceFile, deleteWorkspaceFile, createWorkspaceFolder, listWorkspaceFileVersions, listSandboxKeys, createSandboxKey, rotateSandboxKey, revokeSandboxKey, removeSandboxKey, aiVmFollow, aiVmUnfollow, aiVmStatus, aiVmConnect, aiVmUpdate, aiVmSignIn, aiVmWake, aiVmDisconnect, voiceIce, transcribeVoice, speakVoice, speakVoiceStream, openPreview, apiUrl } from './account.js'
26
26
  import { aiName } from './persona.js'
27
27
  import { effectiveAccess, builtinType } from './session-access.js'
@@ -192,6 +192,7 @@ export const STATIC = {
192
192
  '/project-board.js': ['project-board.js', 'text/javascript; charset=utf-8'],
193
193
  '/project-pop.js': ['project-pop.js', 'text/javascript; charset=utf-8'],
194
194
  '/project-channel.js': ['project-channel.js', 'text/javascript; charset=utf-8'],
195
+ '/project-call.js': ['project-call.js', 'text/javascript; charset=utf-8'],
195
196
  '/preview-page.js': ['preview-page.js', 'text/javascript; charset=utf-8'],
196
197
  '/prail.js': ['prail.js', 'text/javascript; charset=utf-8'],
197
198
  '/prail-model.js': ['prail-model.js', 'text/javascript; charset=utf-8'],
@@ -262,7 +263,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
262
263
  // below — it returns earlier — so it needs no entry here.)
263
264
  const UNRECORDED = new Set(['POST /api/report'])
264
265
  // Sent many times a call (call setup, each clip of speech): only kept when slow or failed.
265
- const QUIET_WHEN_OK = new Set(['POST /api/sessions/:id/voice', 'POST /api/sessions/:id/voice/clip', 'GET /api/sessions/:id/voice/speech', 'GET /api/sessions/:id/voice/speech-stream'])
266
+ const QUIET_WHEN_OK = new Set(['POST /api/workspaces/:id/call', 'POST /api/sessions/:id/voice', 'POST /api/sessions/:id/voice/clip', 'GET /api/sessions/:id/voice/speech', 'GET /api/sessions/:id/voice/speech-stream'])
266
267
  function recordRoute (key, { startedAt, status, body, error }) {
267
268
  // The reporter's own `enabled()` is the single gate on the "report" setting.
268
269
  if (UNRECORDED.has(key)) return
@@ -1199,6 +1200,9 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1199
1200
  'GET /api/workspaces/:id/channels/:cid/messages': (b, id, url, cid) => asAccount((token) => workspaceMessages({ token, id: needWorkspaceId(id), channel: needChannelId(cid), after: Number(url.searchParams.get('after')) || 0 })),
1200
1201
  'POST /api/workspaces/:id/channels/:cid/messages': (b, id, url, cid) => asAccount((token) => sayInWorkspace({ token, id: needWorkspaceId(id), channel: needChannelId(cid), text: String(b.text || '').slice(0, 8000) })),
1201
1202
  'POST /api/workspaces/:id/channels/:cid/messages/read': (b, id, url, cid) => asAccount((token) => readWorkspaceMessages({ token, id: needWorkspaceId(id), channel: needChannelId(cid) })),
1203
+ // A call in one of a project's channels (project-call.js): the calls going on, and this window's part in one.
1204
+ 'GET /api/workspaces/:id/call': (b, id) => asAccount((token) => workspaceCalls({ token, id: needWorkspaceId(id) })),
1205
+ 'POST /api/workspaces/:id/call': (b, id) => asAccount((token) => workspaceCall({ token, id: needWorkspaceId(id), body: { channel: b.channel ? needChannelId(b.channel) : '', client: Number(b.client), in: b.in !== false, muted: b.muted === true, sharing: b.sharing === true, sig: b.sig && typeof b.sig === 'object' ? b.sig : {} } })),
1202
1206
  'GET /api/workspaces/:id/files': (b, id, url) => asAccount(async (token) => ({ files: await listWorkspaceFiles({ token, id: needWorkspaceId(id), folder: url.searchParams.get('folder') ?? undefined }) })),
1203
1207
  'GET /api/workspaces/:id/files/:fid/versions': (b, id, url, fid) => asAccount(async (token) => ({ versions: await listWorkspaceFileVersions({ token, id: needWorkspaceId(id), fileId: fid }) })),
1204
1208
  // The address an HTML artifact's frame loads (serveSealed): asked for by the page, with its token.
@@ -1335,7 +1339,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1335
1339
  'POST /api/sessions/:id/members/set': async (b, id) => (await get(id).setMember(b.key, { role: b.role, scopes: b.scopes }), { ok: true }),
1336
1340
  'POST /api/sessions/:id/members/remove': (b, id) => removeMember(id, b.key),
1337
1341
  // Owner only: a link a chat-only AI (ChatGPT, claude.ai, Grok…) works through (chat-links.js).
1338
- 'POST /api/sessions/:id/chat-link': (b, id) => get(id).createChatLink({ name: b.name || 'Chat AI', minutes: b.minutes }),
1342
+ 'POST /api/sessions/:id/chat-link': (b, id) => get(id).createChatLink({ name: b.name || 'Chat AI', minutes: b.minutes, waiting: b.waiting === true }),
1339
1343
  'POST /api/sessions/:id/chat-link/extend': (b, id) => get(id).extendChatLink(String(b.key || ''), b.minutes),
1340
1344
  // Agents kept out of this session (removing one in a workspace does it), and letting one back in.
1341
1345
  'GET /api/sessions/:id/agents/excluded': (b, id) => { const s = owned(id); return asAccount(async (token) => ({ agents: await listExcludedSessionAgents({ token, room: s.room }) })) },