heyquilt 0.3.155 → 0.3.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/RELEASES.md CHANGED
@@ -11,6 +11,13 @@ 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.156 — 2026-11-12
15
+
16
+ - **Every app you can connect.** Connections lists all 1,600+ apps Composio can connect for you, most used first, with categories, search, and Load more. Each says how you sign in: one click, or your own API key. **Add a connection** takes you to them.
17
+ - **Home, Files, People and Connections stay put.** Clicking their button again no longer jumps back to the session. To go back, pick the session in the session menu at the top.
18
+ - **Your dev server shows in Preview by itself.** Start the project's dev server in the session's folder and Preview lists it as "Your localhost:3000". Saved links (staging, production) are behind **Add a link**.
19
+ - **Tidier menus and Files.** The session menu and notifications look alike. An empty Files page says what goes there instead of showing a drop box.
20
+
14
21
  ## 0.3.155 — 2026-11-12
15
22
 
16
23
  A new look: one bar across the top instead of the sidebar, and the session's chat is the loom.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.155",
3
+ "version": "0.3.156",
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",
@@ -5,6 +5,8 @@
5
5
  import { HttpError } from './http.js'
6
6
 
7
7
  export const COMPOSIO_API = 'https://backend.composio.dev/api/v3.1'
8
+ // How long the app catalog (1,700+ apps, a few pages from Composio) is kept before it's fetched again.
9
+ export const CATALOG_MS = 6 * 60 * 60 * 1000
8
10
 
9
11
  // Composio tags each action with what it does; only reads run without a person's approval.
10
12
  export const READ_TAG = 'readOnlyHint'
@@ -63,6 +65,17 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
63
65
  noAuth: !!t.no_auth
64
66
  })
65
67
 
68
+ /**
69
+ * An app in the catalog: appView with its categories and how one connects it (`how`: 'oneclick', Composio's own
70
+ * sign-in; 'key', the person's own API key or token; 'none', no sign-in), or how '' when it needs an OAuth app of ours.
71
+ */
72
+ const catalogView = (t) => {
73
+ const a = appView(t)
74
+ const how = a.noAuth ? 'none' : a.managed ? 'oneclick' : a.schemes.some((x) => !/^OAUTH[12]$/.test(x)) ? 'key' : ''
75
+ const categories = ((t.meta && t.meta.categories) || []).map((c) => ({ id: String(c.id || c.slug || c.name || c), name: String(c.name || c.id || c) })).filter((c) => c.id)
76
+ return { ...a, how, categories }
77
+ }
78
+
66
79
  /** An action as agents see it: { slug, name, description, app, readOnly, input }. */
67
80
  const toolView = (t) => ({
68
81
  slug: t.slug,
@@ -80,6 +93,27 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
80
93
  return (r.items || []).filter((t) => !t.deprecated || !t.deprecated.is_deprecated).map(appView)
81
94
  }
82
95
 
96
+ // The whole catalog, cached CATALOG_MS: every app that can be connected without an OAuth app of our own (one-click
97
+ // sign-in through Composio, the person's own API key or token, or none at all), most used first.
98
+ let catalogCache = { at: 0, apps: null, pending: null }
99
+ async function catalog () {
100
+ if (catalogCache.apps && Date.now() - catalogCache.at < CATALOG_MS) return catalogCache.apps
101
+ if (catalogCache.pending) return catalogCache.pending
102
+ catalogCache.pending = (async () => {
103
+ const items = []
104
+ let cursor = ''
105
+ do {
106
+ const r = await call('GET', `/toolkits${q({ sort_by: 'usage', limit: 1000, cursor })}`)
107
+ items.push(...(r.items || []))
108
+ cursor = r.next_cursor || ''
109
+ } while (cursor && items.length < 5000)
110
+ const apps = items.filter((t) => !t.deprecated || !t.deprecated.is_deprecated).map(catalogView).filter((a) => a.how && a.slug !== 'composio')
111
+ catalogCache = { at: Date.now(), apps, pending: null }
112
+ return apps
113
+ })().catch((err) => { catalogCache.pending = null; throw err })
114
+ return catalogCache.pending
115
+ }
116
+
83
117
  async function toolkit (slug) {
84
118
  return appView(await call('GET', `/toolkits/${encodeURIComponent(slug)}`))
85
119
  }
@@ -135,5 +169,5 @@ export function composioClient ({ apiKey = '', base = COMPOSIO_API, fetch: fetch
135
169
  return { ok: r.successful !== false && !r.error, data: r.data ?? null, error: r.error || null }
136
170
  }
137
171
 
138
- return { on: !!apiKey, toolkits, toolkit, tools, tool, link, account, remove, execute }
172
+ return { on: !!apiKey, toolkits, catalog, toolkit, tools, tool, link, account, remove, execute }
139
173
  }
@@ -25,6 +25,34 @@ const MAX_KEPT = 16_000
25
25
  const MAX_ARGS = 32_000
26
26
 
27
27
  /** An action's arguments in a line: what people read on the approval card. */
28
+ /**
29
+ * A page of the catalog for the Connections page: { apps, total, categories }. A search matches names first, then
30
+ * descriptions and categories; a category narrows to it. `categories`: the biggest ones, with how many apps each.
31
+ */
32
+ export function pickApps (all, { search = '', category = '', offset = 0, limit = 48 }) {
33
+ const words = String(search).toLowerCase().trim().slice(0, 100).split(/\s+/).filter(Boolean)
34
+ let list = category ? all.filter((a) => a.categories.some((c) => c.id === category)) : all
35
+ if (words.length) {
36
+ const score = (a) => {
37
+ const name = a.name.toLowerCase()
38
+ const rest = `${a.slug} ${a.description} ${a.categories.map((c) => c.name).join(' ')}`.toLowerCase()
39
+ if (!words.every((w) => name.includes(w) || rest.includes(w))) return 0
40
+ return words.every((w) => name.includes(w)) ? (name.startsWith(words[0]) ? 3 : 2) : 1
41
+ }
42
+ list = list.map((a, i) => ({ a, s: score(a), i })).filter((x) => x.s).sort((x, y) => y.s - x.s || x.i - y.i).map((x) => x.a)
43
+ }
44
+ const counts = new Map()
45
+ for (const a of all) for (const c of a.categories) { const k = counts.get(c.id) || { id: c.id, name: c.name, n: 0 }; k.n++; counts.set(c.id, k) }
46
+ const from = Math.max(0, offset)
47
+ const n = Math.min(200, Math.max(1, limit))
48
+ return {
49
+ apps: list.slice(from, from + n),
50
+ total: list.length,
51
+ all: all.length,
52
+ categories: [...counts.values()].filter((c) => c.n >= 5 && !/other|misc/i.test(c.name)).sort((x, y) => y.n - x.n).slice(0, 12)
53
+ }
54
+ }
55
+
28
56
  export function argsLine (args, max = 400) {
29
57
  const s = JSON.stringify(args || {})
30
58
  return s.length > max ? `${s.slice(0, max)}…` : s
@@ -175,7 +203,12 @@ export function connectionRoutes (ctx) {
175
203
  ['GET', /^\/v1\/connections\/apps$/, async (req, body, params, url) => {
176
204
  await whoCalls(req)
177
205
  const u = url || new URL(req.url, 'http://x')
178
- return { apps: await composio.toolkits({ search: u.searchParams.get('search') || '', limit: Number(u.searchParams.get('limit')) || 60 }) }
206
+ return pickApps(await composio.catalog(), {
207
+ search: u.searchParams.get('search') || '',
208
+ category: u.searchParams.get('category') || '',
209
+ offset: Number(u.searchParams.get('offset')) || 0,
210
+ limit: Number(u.searchParams.get('limit')) || 48
211
+ })
179
212
  }],
180
213
 
181
214
  // Composio sends the browser back here once someone signed in (or gave up).
@@ -0,0 +1,65 @@
1
+ // Dev servers running from a session's folder on this computer, for the Preview tab: every program
2
+ // listening on a local TCP port whose working folder is the session's folder (or inside it), found
3
+ // with lsof. Nothing is found where lsof isn't (Windows): the tab still has its saved links.
4
+ import { execFile } from 'node:child_process'
5
+ import fs from 'node:fs'
6
+ import path from 'node:path'
7
+
8
+ const run = (args) => new Promise((resolve) => {
9
+ execFile('lsof', args, { timeout: 3000, maxBuffer: 4 * 1024 * 1024 }, (err, out) => resolve(err && !out ? '' : String(out || '')))
10
+ })
11
+
12
+ /**
13
+ * lsof's -F output as records: each `p<pid>` starts one, `c<command>` and `n<name>` lines fill it.
14
+ * Answers [{ pid, command, names: [] }].
15
+ */
16
+ export function parseLsof (text) {
17
+ const out = []
18
+ let cur = null
19
+ for (const line of String(text || '').split('\n')) {
20
+ const tag = line[0]
21
+ const v = line.slice(1)
22
+ if (tag === 'p') { cur = { pid: Number(v), command: '', names: [] }; out.push(cur) } else if (cur && tag === 'c') cur.command = v
23
+ else if (cur && tag === 'n') cur.names.push(v)
24
+ }
25
+ return out
26
+ }
27
+
28
+ /** The port of a listening socket's name ("*:3000", "127.0.0.1:5173", "[::1]:8080"), or 0. */
29
+ export function portOf (name) {
30
+ const m = /:(\d{2,5})$/.exec(String(name || ''))
31
+ return m ? Number(m[1]) : 0
32
+ }
33
+
34
+ // A folder's real path (lsof reports them: on a Mac /var is /private/var), or the path as given.
35
+ const real = (p) => { try { return fs.realpathSync(p) } catch { return path.resolve(p) } }
36
+
37
+ /** Whether `cwd` is `dir` or inside it, comparing real paths. */
38
+ export function within (cwd, dir) {
39
+ const rel = path.relative(real(dir), real(cwd))
40
+ return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel))
41
+ }
42
+
43
+ /**
44
+ * The dev servers running from `dir`: [{ port, url, command, pid }], lowest port first. `skip`: ports
45
+ * that are Quilt's own (its app), never listed.
46
+ */
47
+ export async function devServers (dir, { skip = [] } = {}) {
48
+ if (process.platform === 'win32' || !dir) return []
49
+ const listening = parseLsof(await run(['-nP', '-iTCP', '-sTCP:LISTEN', '-Fpcn']))
50
+ if (!listening.length) return []
51
+ const cwds = new Map(parseLsof(await run(['-a', '-d', 'cwd', '-Fpn', '-p', listening.map((l) => l.pid).join(',')])).map((r) => [r.pid, r.names[0] || '']))
52
+ const seen = new Set()
53
+ const out = []
54
+ for (const l of listening) {
55
+ const cwd = cwds.get(l.pid)
56
+ if (!cwd || !within(cwd, dir)) continue
57
+ for (const n of l.names) {
58
+ const port = portOf(n)
59
+ if (!port || seen.has(port) || skip.includes(port)) continue
60
+ seen.add(port)
61
+ out.push({ port, url: `http://localhost:${port}`, command: l.command, pid: l.pid })
62
+ }
63
+ }
64
+ return out.sort((a, b) => a.port - b.port)
65
+ }
package/src/ui/app.css CHANGED
@@ -3530,3 +3530,65 @@ button.sh-repo:hover { color: var(--text); }
3530
3530
  .cl-lines { list-style: none; margin: 0; padding: 4px 16px 14px 64px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
3531
3531
  .cl-lines li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline; } .cl-lines time { font-size: 11.5px; color: var(--faint); }
3532
3532
  .cl-none { padding: 40px 0; text-align: center; color: var(--muted); } .cl-none b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; } .cl-none p { margin: 0; font-size: 13px; }
3533
+ /* The catalog's Every app and Load more: a full-width bar under the grid, as People's Load more */
3534
+ .cn .cn-more { align-self: stretch; justify-content: center; height: 36px; gap: 6px; }
3535
+ .cn .cn-more i { font-style: normal; color: var(--muted); font-weight: 400; }
3536
+ .cn-subh i { font-style: normal; color: var(--faint); margin: 0 6px 0 2px; }
3537
+ /* Preview's list foot (dm06): Add a link as a button, and a note on where dev servers come from */
3538
+ .pt-foot, .pt-side > .pt-note { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 4px 0; }
3539
+ .pt-addbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; } .pt-addbtn svg { width: 14px; height: 14px; }
3540
+ .pt-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); font-size: 12px; line-height: 1.5; color: var(--muted); }
3541
+ .pt-add-row { display: flex; gap: 8px; } .pt-add-row .btn { flex: 1; }
3542
+ /* An empty Files page or folder: what goes here and how, under the header's Upload and New folder */
3543
+ .fv-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 56px 16px; text-align: center; color: var(--muted); }
3544
+ .fv-empty .fv-ico { margin-bottom: 6px; }
3545
+ .fv-empty b { font-size: 15px; font-weight: 600; color: var(--text); }
3546
+ .fv-empty p { margin: 0; font-size: 13px; line-height: 1.5; }
3547
+
3548
+ /* The top bar's menus (dm06): the session menu and notifications drawn alike, a soft card with a small caps title,
3549
+ rows with an icon tile, name, state and faces */
3550
+ .wb-sessmenu, .sh-notes-pop { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: 0 12px 30px light-dark(rgba(29, 27, 46, .12), rgba(0, 0, 0, .45)); padding: 6px 0 8px; }
3551
+ .wb-mhead, .sh-notes-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 14px 8px 18px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
3552
+ .wb-srow { gap: 11px; margin: 2px 6px; padding: 9px 10px 9px 12px; border-radius: 9px; }
3553
+ .wb-srow:hover { background: color-mix(in srgb, var(--text) 5%, var(--panel)); } .wb-srow.on { background: color-mix(in srgb, var(--text) 8%, var(--panel)); }
3554
+ .wb-hico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--panel-2); color: var(--muted); flex: none; } .wb-hico svg { width: 15px; height: 15px; }
3555
+ .wb-sname { gap: 2px; } .wb-sname b { font-size: 14px; font-weight: 600; color: var(--text); }
3556
+ .wb-sname small { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--faint); } .wb-sname small.live { color: var(--accent); font-weight: 600; }
3557
+ .wb-srow.quiet .wb-sname b { color: var(--muted); font-weight: 500; } .wb-srow.quiet .wb-hico { color: var(--faint); } .wb-srow.quiet .wb-faces { opacity: .55; }
3558
+ .wb-sessmenu .pop-sep { margin: 6px 0; height: 1px; background: var(--border); }
3559
+ .wb-sessmenu .pop-item { margin: 0 6px; width: calc(100% - 12px); padding: 8px 12px; border-radius: 9px; font-size: 13.5px; }
3560
+ .wb-sessmenu .pop-item:hover { background: color-mix(in srgb, var(--text) 5%, var(--panel)); }
3561
+ .sh-notes-pop { width: 380px; }
3562
+ .sh-notes-empty { padding: 10px 18px 12px; }
3563
+ .sh-notes-pop #requests { gap: 2px; padding: 0 6px; }
3564
+ .sh-notes-pop .request { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "av who" "av acts"; column-gap: 11px; row-gap: 10px; align-items: center; padding: 10px 12px; border: 0; border-radius: 9px; background: none; }
3565
+ .sh-notes-pop .request:hover { background: color-mix(in srgb, var(--text) 4%, var(--panel)); }
3566
+ .sh-notes-pop .request .avatar { grid-area: av; align-self: start; width: 30px; height: 30px; font-size: 12px; }
3567
+ .sh-notes-pop .request .rq-main { grid-area: who; gap: 2px; } .sh-notes-pop .request .rq-main b { font-size: 14px; font-weight: 600; } .sh-notes-pop .request .rq-main .hint { font-size: 12px; color: var(--faint); }
3568
+ .sh-notes-pop .request .rq-acts { grid-area: acts; display: flex; gap: 8px; }
3569
+ .sh-notes-pop .request .rq-acts > * { height: 32px; font-size: 13px; }
3570
+ .sh-notes-pop .request .rq-acts .dd-btn, .sh-notes-pop .request .rq-acts select:not(.dd-native) { flex: 1; min-width: 0; border-radius: 8px; }
3571
+ .sh-notes-pop .request .rq-acts .btn { flex: none; padding: 0 14px; border-radius: 8px; }
3572
+ .request .rq-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
3573
+
3574
+ /* The catalog on the Connections page: a title with how many apps, category chips, and a card per app with its
3575
+ logo, what it is, how you sign in and Connect */
3576
+ .cn-cat { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; scroll-margin-top: 12px; }
3577
+ .cn-cath { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
3578
+ .cn-cath h3 { margin: 0; font-size: 15px; font-weight: 600; } .cn-cath small { font-size: 12.5px; color: var(--muted); }
3579
+ .cn-chips { display: flex; flex-wrap: wrap; gap: 6px; }
3580
+ .cn-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--muted); font: 500 12.5px var(--sans); cursor: pointer; white-space: nowrap; }
3581
+ .cn-chip i { font-style: normal; font-size: 11.5px; color: var(--faint); }
3582
+ .cn-chip:hover { color: var(--text); border-color: var(--border-strong); }
3583
+ .cn-chip.on { background: var(--text); border-color: var(--text); color: var(--bg); } .cn-chip.on i { color: color-mix(in srgb, var(--bg) 70%, var(--text)); }
3584
+ .cn-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
3585
+ .cn-app { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; row-gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); transition: border-color .15s, box-shadow .15s; }
3586
+ .cn-app:hover { border-color: var(--border-strong); box-shadow: 0 4px 14px light-dark(rgba(29, 27, 46, .06), rgba(0, 0, 0, .3)); }
3587
+ .cn-app .cn-logo { width: 40px; height: 40px; padding: 6px; box-sizing: border-box; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--border); object-fit: contain; }
3588
+ .cn-app .cn-logo.none { display: grid; place-items: center; background: var(--panel-2); font-size: 15px; }
3589
+ .cn-at { min-width: 0; display: flex; flex-direction: column; gap: 3px; } .cn-at b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3590
+ .cn-at small { font-size: 12.5px; line-height: 1.4; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
3591
+ .cn-af { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
3592
+ .cn-how { flex: 1; min-width: 0; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .cn-how.oneclick { color: var(--ok); }
3593
+ .cn-af .btn { height: 30px; padding: 0 14px; }
3594
+ .cn-ready { font-size: 12px; font-weight: 600; color: var(--ok); }
@@ -7,6 +7,8 @@ import { SEARCH_ICON } from './quiltview.js'
7
7
 
8
8
  const views = new Map() // `${type}:${id}` -> the last view, so a redraw shows it at once
9
9
  const urlOf = (type, id, rest = '') => `/api/connections/${type}/${encodeURIComponent(id)}${rest}`
10
+ const PAGE = 48 // apps fetched at a time for the catalog
11
+ const cap = (t) => String(t || '').replace(/(^|[\s/&-])(\p{L})/gu, (m, a, b) => a + b.toUpperCase()).replace(/\bAi\b/g, 'AI').replace(/\bCrm\b/g, 'CRM')
10
12
  const LEVEL = { session: 'this session', workspace: 'the workspace', org: 'the team' }
11
13
  const STATUS = { active: 'Connected', pending: 'Waiting for sign-in', failed: 'Didn\'t connect' }
12
14
 
@@ -19,7 +21,8 @@ const logoHtml = (a) => a.logo
19
21
  * team's slug). Answers { refresh, destroy }.
20
22
  */
21
23
  export function mountConnections (root, { type, id, page = false, sessions = [], callsRoom = null, me = '' }) {
22
- const ui = { search: '', apps: null, appsFor: null, more: false, busy: '', error: '', calls: null, confirm: null }
24
+ // The catalog: `apps` the page shown so far, `total` how many match, `cat` the category picked ('' every app).
25
+ const ui = { search: '', apps: null, total: 0, all: 0, categories: [], cat: '', loadingMore: false, busy: '', error: '', calls: null, confirm: null }
23
26
  let view = views.get(`${type}:${id}`) || null
24
27
  let alive = true
25
28
  let poll = null
@@ -49,9 +52,15 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
49
52
  <div class="cn-where">${chips.map((x) => `<span>${esc(x)}</span>`).join('')}</div><div class="cn-by">Connected by ${esc(by)}${page ? pageManage : ` · ${esc(ago(c.createdAt))}${manage}`}</div></div>`
50
53
  }
51
54
 
52
- function suggestHtml (a, connected) {
55
+ // An app to add (dm06's catalog): its logo, name and what it is, how you sign in, and Connect.
56
+ const HOW = { oneclick: 'Sign in with one click', key: 'Uses your own API key', none: 'No sign-in needed' }
57
+ function appCardHtml (a, connected) {
53
58
  const busy = ui.busy === a.slug
54
- return `<div class="cn-sug">${logoHtml(a)}<b title="${esc(a.description || a.name)}">${esc(a.name)}</b><button type="button" class="btn sm" data-connect="${esc(a.slug)}"${busy ? ' disabled' : ''}>${busy ? 'Opening…' : connected ? 'Add another' : 'Connect'}</button></div>`
59
+ const act = a.how === 'none'
60
+ ? '<span class="cn-ready">Agents can use it</span>'
61
+ : `<button type="button" class="btn sm" data-connect="${esc(a.slug)}"${busy ? ' disabled' : ''}>${busy ? 'Opening…' : connected ? 'Add another' : 'Connect'}</button>`
62
+ return `<div class="cn-app">${logoHtml(a)}<div class="cn-at"><b>${esc(a.name)}</b><small title="${esc(a.description)}">${esc(a.description || (a.categories[0] ? cap(a.categories[0].name) : ''))}</small></div>
63
+ <div class="cn-af"><span class="cn-how ${esc(a.how)}">${esc(HOW[a.how] || '')}</span>${act}</div></div>`
55
64
  }
56
65
 
57
66
  function callsHtml () {
@@ -70,7 +79,8 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
70
79
  const inherited = view.inherited || []
71
80
  const ownApps = new Set(own.map((c) => c.app))
72
81
  const apps = ui.apps || []
73
- const picks = ui.search ? apps : apps.filter((a) => !ownApps.has(a.slug) && !inherited.some((c) => c.app === a.slug)).slice(0, ui.more ? 60 : 8)
82
+ const left = ui.total - apps.length
83
+ const catName = ui.cat ? cap((ui.categories.find((c) => c.id === ui.cat) || { name: ui.cat }).name) : ''
74
84
  const count = own.filter((c) => c.status === 'active').length + inherited.length
75
85
  const lead = page
76
86
  ? (type === 'workspace' ? 'Apps your sessions and their AIs can use, connected once for the whole workspace through Composio' : 'Apps this session and its AIs can use, connected through Composio')
@@ -79,9 +89,12 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
79
89
  <div class="cn-h"><div>${page ? `<h2>Connections <i>${count}</i></h2>` : `<h3>Connections <i>${count}</i></h3>`}<small>${lead}</small></div>
80
90
  ${view.canManage ? `<label class="cn-src">${SEARCH_ICON}<input data-search placeholder="Search thousands of apps" value="${esc(ui.search)}" aria-label="Search apps"></label><button type="button" class="btn primary" data-add-focus>${I.plus}<span>Add a connection</span></button>` : ''}</div>
81
91
  ${own.length || inherited.length ? `<div class="cn-grid">${own.map((c) => cardHtml(c, true)).join('')}${inherited.map((c) => cardHtml(c, false)).join('')}</div>` : '<p class="hint cn-none">Nothing connected yet: pick an app below, and agents can use it once you sign in.</p>'}
82
- ${view.canManage ? `<div class="cn-subh">${ui.search ? `Apps matching “${esc(ui.search)}”` : `Suggested for ${esc(view.scope.name || LEVEL[type])}`}</div>
83
- ${ui.apps === null ? '<p class="hint">Loading apps…</p>' : picks.length ? `<div class="cn-sugs">${picks.map((a) => suggestHtml(a, ownApps.has(a.slug))).join('')}</div>` : `<p class="hint">No app matches “${esc(ui.search)}”.</p>`}
84
- ${!ui.search && !ui.more && apps.length > 8 ? '<button type="button" class="btn sm ghost cn-more" data-more>More apps</button>' : ''}` : ''}
92
+ ${view.canManage ? `<section class="cn-cat" id="cn-catalog">
93
+ <div class="cn-cath"><h3>${ui.search ? `Apps matching “${esc(ui.search)}”` : catName ? esc(catName) : 'Add an app'}</h3><small>${ui.apps === null ? 'Loading…' : `${ui.total.toLocaleString()} app${ui.total === 1 ? '' : 's'}${ui.search || ui.cat ? ` of ${ui.all.toLocaleString()}` : ' you can connect, most used first'}`}</small></div>
94
+ ${ui.categories.length ? `<div class="cn-chips" role="tablist" aria-label="Categories"><button type="button" class="cn-chip${ui.cat ? '' : ' on'}" role="tab" aria-selected="${!ui.cat}" data-cat="">All</button>${ui.categories.map((c) => `<button type="button" class="cn-chip${ui.cat === c.id ? ' on' : ''}" role="tab" aria-selected="${ui.cat === c.id}" data-cat="${esc(c.id)}">${esc(cap(c.name))}<i>${c.n}</i></button>`).join('')}</div>` : ''}
95
+ ${ui.apps === null ? '' : apps.length ? `<div class="cn-apps">${apps.map((a) => appCardHtml(a, ownApps.has(a.slug))).join('')}</div>` : `<p class="hint cn-none">No app matches${ui.search ? ` “${esc(ui.search)}”` : ''}${catName ? ` in ${esc(catName)}` : ''}.</p>`}
96
+ ${left > 0 ? `<button type="button" class="btn cn-more" data-load-more${ui.loadingMore ? ' disabled' : ''}>${ui.loadingMore ? 'Loading…' : `Load more <i>${left.toLocaleString()} more</i>`}</button>` : ''}
97
+ </section>` : ''}
85
98
  ${callsHtml()}
86
99
  </div>`
87
100
  if (had) { const s = root.querySelector('[data-search]'); s.focus(); s.setSelectionRange(s.value.length, s.value.length) }
@@ -104,13 +117,20 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
104
117
  if (alive && view && (view.connections || []).some((c) => c.status === 'pending' && Date.now() - c.createdAt < 10 * 60 * 1000)) poll = setTimeout(load, 3000)
105
118
  }
106
119
 
107
- async function loadApps () {
108
- const q = ui.search
120
+ // A page of the catalog: the first (`more` false, after a new search or category) or the next one.
121
+ async function loadApps (more = false) {
122
+ const key = `${ui.search}|${ui.cat}`
123
+ const offset = more ? (ui.apps || []).length : 0
124
+ if (more) { ui.loadingMore = true; draw() }
109
125
  try {
110
- const r = await api('GET', `/api/connections/apps?search=${encodeURIComponent(q)}&limit=${q ? 40 : 60}`)
111
- if (q !== ui.search) return
112
- ui.apps = r.apps || []
113
- } catch (err) { ui.apps = []; if (err.status !== 503) toast(err.message) }
126
+ const r = await api('GET', `/api/connections/apps?search=${encodeURIComponent(ui.search)}&category=${encodeURIComponent(ui.cat)}&offset=${offset}&limit=${PAGE}`)
127
+ if (key !== `${ui.search}|${ui.cat}`) return
128
+ ui.apps = more ? [...(ui.apps || []), ...(r.apps || [])] : (r.apps || [])
129
+ ui.total = r.total ?? ui.apps.length
130
+ ui.all = r.all ?? ui.total
131
+ if (r.categories && r.categories.length) ui.categories = r.categories
132
+ } catch (err) { if (!more) ui.apps = []; if (err.status !== 503) toast(err.message) }
133
+ ui.loadingMore = false
114
134
  draw()
115
135
  }
116
136
 
@@ -151,8 +171,14 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
151
171
  load()
152
172
  return
153
173
  }
154
- if (e.target.closest('[data-more]')) { ui.more = true; draw() }
155
- if (e.target.closest('[data-add-focus]')) root.querySelector('[data-search]')?.focus()
174
+ const cat = e.target.closest('[data-cat]')
175
+ if (cat) { ui.cat = cat.dataset.cat; ui.apps = null; draw(); loadApps(); return }
176
+ if (e.target.closest('[data-load-more]')) { loadApps(true); return }
177
+ // Add a connection: to the catalog, with the search ready to narrow it.
178
+ if (e.target.closest('[data-add-focus]')) {
179
+ root.querySelector('#cn-catalog')?.scrollIntoView({ block: 'start', behavior: 'smooth' })
180
+ root.querySelector('[data-search]')?.focus()
181
+ }
156
182
  })
157
183
 
158
184
  draw()
package/src/ui/files.js CHANGED
@@ -417,12 +417,12 @@ export function allFilesHtml (d, { id = String(state.view).slice('wsfiles:'.leng
417
417
  const here = filesOf(d).filter((f) => inside(fv.folder, f.path))
418
418
  const usage = usageText(d)
419
419
  const edit = canEdit(d)
420
- // The dm06 Files page: folder cards and file tiles, an upload tile only where a folder is empty.
421
- const grid = !folders.length && !files.length && !edit ? ''
420
+ // The dm06 Files page: folder cards and file tiles. Upload and New folder are in the header; an empty folder says so.
421
+ const grid = !folders.length && !files.length
422
+ ? `<div class="fv-empty"><span class="fv-ico">${I.folder}</span><b>${fv.folder ? 'Nothing in this folder yet' : 'No files yet'}</b><p>${edit ? `Upload files${fv.folder ? '' : ' or make a folder'} with the buttons above, or drop them here. Every session in ${esc(d.workspace.name)} and everyone's AI can use them.` : `When someone in ${esc(d.workspace.name)} adds files, they show here.`}</p></div>`
422
423
  : `<div class="tiles fv-grid">
423
424
  ${folders.map((f) => folderTileHtml(d, f, { acts: edit })).join('')}
424
425
  ${files.map((f) => fileTileHtml(d, f, { on: f.id === fv.picked, meta: [bytes(f.size || 0), whoOf(d, f.uploadedBy)].filter(Boolean).join(' · ') })).join('')}
425
- ${edit && !folders.length && !files.length ? uploadTileHtml(id, fv.folder ? `Upload to ${fv.folder.split('/').pop()}` : 'Upload or drop files') : ''}
426
426
  </div>`
427
427
  const title = fv.folder ? crumbsHtml(d, fv.folder) : '<h1>Files</h1>'
428
428
  const sub = fv.folder
@@ -437,7 +437,7 @@ export function allFilesHtml (d, { id = String(state.view).slice('wsfiles:'.leng
437
437
  </header>
438
438
  ${edit ? `<p class="hint files-progress" data-progress>${uploadingTo(id) ? esc(progressLabel()) : ''}</p><input type="file" multiple hidden data-upload-input>` : ''}
439
439
  <div class="files-body${picked ? '' : ' no-preview'}" data-files-drop>
440
- <div class="files-main">${grid || '<p class="hint">Nothing in this folder yet.</p>'}</div>
440
+ <div class="files-main">${grid}</div>
441
441
  ${picked ? previewHtml(d, picked) : ''}
442
442
  </div>`
443
443
  }
package/src/ui/session.js CHANGED
@@ -265,7 +265,7 @@ export function mountSession (id) {
265
265
  ...(s.workspace ? [{ group: 'Go to', title: 'Workspace home', sub: 'Charts, sessions and previews', icon: I.home, run: go2('home') }, { group: 'Go to', title: 'Files', sub: 'Shared across the workspace', icon: I.folder, run: go2('wsfiles') }] : []),
266
266
  { group: 'Go to', title: 'People', sub: 'Humans and AI', icon: I.users, run: go2('people') },
267
267
  { group: 'Settings', title: 'Session settings', sub: here, icon: I.gear, run: () => openSessionSettings() },
268
- ...(state.connectionsOn ? [{ group: 'Settings', title: 'Connections', sub: 'Apps agents here can use', icon: I.plug, run: () => { if (ws(current).mode !== 'connections') togglePage('connections') } }] : [])
268
+ ...(state.connectionsOn ? [{ group: 'Settings', title: 'Connections', sub: 'Apps agents here can use', icon: I.plug, run: () => openPage('connections') }] : [])
269
269
  ]
270
270
  if (state.workspace && state.workspace.workspace?.id === s.workspace) {
271
271
  for (const f of (state.workspace.files || []).slice(0, 200)) out.push({ group: 'Files', title: f.name || basename(f.path), sub: f.path, icon: f.kind === 'folder' ? I.folder : I.file, run: go2('wsfiles') })
@@ -511,7 +511,8 @@ function bindTop () {
511
511
  pop.appendChild(req)
512
512
  const set = (open) => { pop.hidden = !open; bell.setAttribute('aria-expanded', String(open)) }
513
513
  bell.onclick = () => set(pop.hidden)
514
- pop.addEventListener('keydown', (e) => { if (e.key === 'Escape') { set(false); bell.focus() } })
514
+ // Escape closes it wherever the focus is, as a click elsewhere does.
515
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !pop.hidden) { set(false); bell.focus() } }, { signal: mounted.signal })
515
516
  // The access picker's list opens outside the panel: picking from it keeps the panel open.
516
517
  document.addEventListener('mousedown', (e) => { if (!e.target.closest('.sh-notes, [role=listbox], .dd-list, .dd-menu')) set(false) }, { signal: mounted.signal })
517
518
  let seen = new Set()
@@ -542,7 +543,7 @@ function bindTop () {
542
543
  const open = () => { menu.hidden = false; btn.setAttribute('aria-expanded', 'true'); renderPeopleMenu() }
543
544
  const close = () => { menu.hidden = true; btn.setAttribute('aria-expanded', 'false') }
544
545
  // Everyone here, as a page of its own (dm06), a toggle like Files and Home; the member list is in Session settings.
545
- btn.onclick = () => togglePage('people')
546
+ btn.onclick = () => openPage('people')
546
547
  wrap.addEventListener('keydown', (e) => { if (e.key === 'Escape') { close(); btn.focus() } })
547
548
  document.addEventListener('mousedown', (e) => { if (!wrap.contains(e.target) && !menu.classList.contains('in-ss')) close() }, { signal: mounted.signal })
548
549
 
@@ -581,7 +582,7 @@ function bindTop () {
581
582
  })
582
583
 
583
584
  $('#toggle-tree').onclick = () => toggleDrawer('tree')
584
- $('#connections-btn').onclick = () => togglePage('connections')
585
+ $('#connections-btn').onclick = () => openPage('connections')
585
586
  $('#toggle-chat').onclick = () => { toggleDrawer('chat'); $('#chat-badge').hidden = true }
586
587
  $('#scrim').onclick = () => toggleDrawer(null)
587
588
  }
@@ -995,7 +996,7 @@ function renderAccess () {
995
996
  ${avatar(p.name, null)}
996
997
  <div class="rq-main"><b>${esc(p.name)}</b>${p.kind === 'agent' ? `<span class="tag bot">${I.bot}agent</span>` : ''}
997
998
  <span class="hint">wants to join · invited to ${p.invitedAs === 'viewer' ? 'view' : 'edit'}</span></div>
998
- ${asType
999
+ <div class="rq-acts">${asType
999
1000
  ? `<select class="input" name="typeId" aria-label="Let ${esc(p.name)} in as" title="What they may do: an access type">${typeOptions()}</select>`
1000
1001
  : `<select class="input" name="role" aria-label="Role for ${esc(p.name)}">
1001
1002
  <option value="editor" ${p.invitedAs !== 'viewer' ? 'selected' : ''}>Can edit</option>
@@ -1003,7 +1004,7 @@ function renderAccess () {
1003
1004
  </select>
1004
1005
  ${p.kind === 'agent' ? `<input class="input" name="scopes" placeholder="All folders (or e.g. src, docs)" aria-label="Folders ${esc(p.name)} may change" title="Folders this agent may change, separated by commas">` : ''}`}
1005
1006
  <button type="button" class="btn sm ghost" data-deny>Deny</button>
1006
- <button type="submit" class="btn sm primary">Let in</button>
1007
+ <button type="submit" class="btn sm primary">Let in</button></div>
1007
1008
  </form>`).join('')
1008
1009
  }
1009
1010
 
@@ -1529,11 +1530,11 @@ function bindWbar () {
1529
1530
  const conn = $('#connections-btn')
1530
1531
  if (conn) { conn.className = 'wb-btn conn-btn'; tools.prepend(conn) }
1531
1532
  // Home is the workspace's home inside this window (dm06), a toggle like Files.
1532
- $('#wb-home').onclick = () => { if (!sum()?.workspace) go('home'); else togglePage('home') }
1533
+ $('#wb-home').onclick = () => { if (!sum()?.workspace) go('home'); else openPage('home') }
1533
1534
  // Files is a page of this session's window (dm06): a second click goes back to where you were.
1534
1535
  $('#wb-files').onclick = () => {
1535
1536
  if (!sum()?.workspace) { toast('Files are shared in a workspace. Move this session into one first.'); return }
1536
- togglePage('wsfiles')
1537
+ openPage('wsfiles')
1537
1538
  }
1538
1539
  const btn = $('#wb-sessbtn')
1539
1540
  const menu = $('#wb-sessmenu')
@@ -1544,9 +1545,9 @@ function bindWbar () {
1544
1545
  if (e.target.closest('[data-wb-settings]')) { set(false); openSessionSettings('general'); return }
1545
1546
  if (e.target.closest('[data-wb-invite]')) { set(false); openInvite(current); return }
1546
1547
  const r = e.target.closest('[data-wb-go]')
1547
- if (r) { set(false); if (r.dataset.wbGo !== current) go(r.dataset.wbGo) }
1548
+ if (r) { set(false); if (r.dataset.wbGo !== current) go(r.dataset.wbGo); else backToSession() }
1548
1549
  })
1549
- $('#wb-sess').addEventListener('keydown', (e) => { if (e.key === 'Escape') { set(false); btn.focus() } })
1550
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu.hidden) { set(false); btn.focus() } }, { signal: mounted.signal })
1550
1551
  document.addEventListener('mousedown', (e) => { if (!e.target.closest('#wb-sess')) set(false) }, { signal: mounted.signal })
1551
1552
  }
1552
1553
 
@@ -1568,7 +1569,7 @@ function renderWbar () {
1568
1569
  const rows = [...state.sessions.values()].map((x) => {
1569
1570
  const k = working(x.status)
1570
1571
  const unread = x.status.unread && x.id !== current ? `<span class="badge">${x.status.unread}</span>` : ''
1571
- return `<button type="button" class="wb-srow${x.id === current ? ' on' : ''}" role="menuitem" data-wb-go="${esc(x.id)}" title="${esc(x.dir)}">${I.grid}<span class="wb-sname"><b>${esc(x.status.sessionName || basename(x.dir))}</b><small>${k ? `${k} working` : x.status.connected ? 'Quiet' : 'Not connected'}</small></span>${facesHtml(workingFaces(x.status))}${unread}</button>`
1572
+ return `<button type="button" class="wb-srow${x.id === current ? ' on' : ''}${k ? '' : ' quiet'}" role="menuitem" data-wb-go="${esc(x.id)}" title="${esc(x.dir)}"><span class="wb-hico">${I.grid}</span><span class="wb-sname"><b>${esc(x.status.sessionName || basename(x.dir))}</b><small${k ? ' class="live"' : ''}>${k ? `<span class="pulse"></span>${k} working` : x.status.connected ? 'Quiet' : 'Not connected'}</small></span>${facesHtml(workingFaces(x.status))}${unread}</button>`
1572
1573
  }).join('')
1573
1574
  const html = `<div class="wb-mhead">Sessions<button type="button" class="wb-mplus" data-wb-new title="New session" aria-label="New session">${I.plus}</button></div>${rows || '<p class="wb-mempty">No sessions open.</p>'}
1574
1575
  <div class="pop-sep"></div><button type="button" class="pop-item" role="menuitem" data-wb-settings>${I.gear}Session settings…</button><button type="button" class="pop-item" role="menuitem" data-wb-invite>${I.users}Invite people…</button>`
@@ -3424,22 +3425,44 @@ function bindCallsTab (el) {
3424
3425
  }
3425
3426
  }
3426
3427
 
3428
+ // Dev servers running from this session's folder on this computer, found by the app (dev-servers.js): they show in
3429
+ // Preview by themselves, before the links people saved.
3430
+ let devView = { id: null, servers: [], at: 0 }
3431
+ function loadDevServers () {
3432
+ const id = current
3433
+ if (devView.id === id && Date.now() - devView.at < 10000) return
3434
+ devView = { id, servers: devView.id === id ? devView.servers : [], at: Date.now() }
3435
+ api('GET', `/api/sessions/${id}/dev-servers`).then((r) => {
3436
+ if (devView.id !== id || JSON.stringify(r.servers) === JSON.stringify(devView.servers)) return
3437
+ devView.servers = r.servers
3438
+ if (ws(current).mode === 'preview') renderMain()
3439
+ }).catch(() => {})
3440
+ }
3441
+
3427
3442
  function previewTabHtml (w) {
3428
3443
  const s = sum()
3429
3444
  const room = s.status.room
3445
+ loadDevServers()
3430
3446
  const d = state.workspace && state.workspace.workspace?.id === s.workspace ? state.workspace : null
3431
- const links = d ? (d.links || []).filter((l) => !l.room || l.room === room).sort((a, b) => (a.room === room ? 0 : 1) - (b.room === room ? 0 : 1)) : []
3447
+ const here = s.status.sessionName || basename(s.dir)
3448
+ const found = devView.servers.map((x) => ({ id: `dev:${x.port}`, name: `Your localhost:${x.port}`, url: x.url, note: `${x.command} · running in ${here} on this computer`, dev: true }))
3449
+ const links = [...found, ...(d ? (d.links || []).filter((l) => !l.room || l.room === room).sort((a, b) => (a.room === room ? 0 : 1) - (b.room === room ? 0 : 1)) : [])]
3432
3450
  const pick = links.find((l) => l.id === w.previewSel) || links[0] || null
3433
3451
  const host = (u) => { try { return new URL(u).host } catch { return u } }
3434
3452
  const local = (u) => /^(localhost|127\.|0\.0\.0\.0)/.test(host(u))
3435
- const list = links.map((l) => `<button type="button" class="pt-link${pick && l.id === pick.id ? ' on' : ''}" data-pt-pick="${esc(l.id)}"><span class="pt-ico${local(l.url) ? ' live' : ''}">${local(l.url) ? I.play : I.globe}</span><span class="pt-x"><b>${esc(l.name)}</b><small>${esc([host(l.url), l.note].filter(Boolean).join(' · '))}</small></span></button>`).join('')
3436
- const form = `<form class="pt-add" data-pt-add>${s.workspace ? `<input class="input" name="name" placeholder="Name (Staging, Bob's localhost…)" maxlength="80" required><input class="input" name="url" placeholder="https://… or http://localhost:3000" maxlength="500" required><button class="btn" type="submit">${I.plus}<span>Add a link</span></button>` : '<p class="hint">Links are kept in a workspace: move this session into one to add them.</p>'}</form>`
3453
+ const list = links.map((l) => `<button type="button" class="pt-link${pick && l.id === pick.id ? ' on' : ''}" data-pt-pick="${esc(l.id)}"><span class="pt-ico${local(l.url) ? ' live' : ''}">${local(l.url) ? I.play : I.globe}</span><span class="pt-x"><b>${esc(l.name)}</b><small>${esc(l.dev ? l.note : [host(l.url), l.note].filter(Boolean).join(' · '))}</small></span></button>`).join('')
3454
+ // Adding a link (staging, production, a preview someone shares) is a button; its two fields open in place.
3455
+ const form = !s.workspace
3456
+ ? '<p class="pt-note">Dev servers you run in this folder show up here by themselves. Saved links are kept in a workspace: move this session into one to add them.</p>'
3457
+ : w.ptAdding
3458
+ ? `<form class="pt-add" data-pt-add><input class="input" name="name" placeholder="Name (Staging, Production…)" maxlength="80" required><input class="input" name="url" placeholder="https://…" maxlength="500" required><div class="pt-add-row"><button class="btn ghost" type="button" data-pt-cancel>Cancel</button><button class="btn primary" type="submit">Add</button></div></form>`
3459
+ : `<div class="pt-foot"><button type="button" class="btn pt-addbtn" data-pt-adding>${I.plus}<span>Add a link</span></button><p class="pt-note">Dev servers you run in ${esc(here)} show up here by themselves.</p></div>`
3437
3460
  const frame = pick
3438
- ? `<div class="pt-bar"><button type="button" class="pt-btn" data-pt-reload title="Reload" aria-label="Reload">${I.refresh}</button><span class="pt-url">${I.lock}<code>${esc(pick.url.replace(/^https?:\/\//, ''))}</code></span>${local(pick.url) ? '<span class="pt-live"><span class="pulse"></span>Live from a computer in this session</span>' : ''}<span class="pt-sp"></span>
3461
+ ? `<div class="pt-bar"><button type="button" class="pt-btn" data-pt-reload title="Reload" aria-label="Reload">${I.refresh}</button><span class="pt-url">${I.lock}<code>${esc(pick.url.replace(/^https?:\/\//, ''))}</code></span>${pick.dev ? '<span class="pt-live"><span class="pulse"></span>Running on this computer</span>' : local(pick.url) ? '<span class="pt-live"><span class="pulse"></span>Live from a computer in this session</span>' : ''}<span class="pt-sp"></span>
3439
3462
  <span class="pt-size" role="group" aria-label="Width"><button type="button" class="pt-btn${w.previewPhone ? '' : ' on'}" data-pt-size="desktop" title="Desktop" aria-label="Desktop width"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg></button><button type="button" class="pt-btn${w.previewPhone ? ' on' : ''}" data-pt-size="phone" title="Phone" aria-label="Phone width"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="2" width="10" height="20" rx="2"/><path d="M11 18h2"/></svg></button></span>
3440
3463
  <a class="btn sm" href="${esc(pick.url)}" target="_blank" rel="noopener">${I.external}<span>Open in browser</span></a></div>
3441
3464
  <div class="pt-stage${w.previewPhone ? ' phone' : ''}"><iframe class="pt-frame" src="${esc(pick.url)}" title="${esc(pick.name)}" sandbox="allow-scripts allow-forms allow-same-origin allow-popups" referrerpolicy="no-referrer"></iframe></div>`
3442
- : `<div class="main-empty"><div class="ill">${I.globe}</div><h3>Nothing to preview yet</h3><p class="hint">Add the links that matter for this session: its dev server, a square's preview, staging, production.</p></div>`
3465
+ : `<div class="main-empty"><div class="ill">${I.globe}</div><h3>Nothing to preview yet</h3><p class="hint">Start the project's dev server in ${esc(here)} and it shows up here. Staging and production are a link away: Add a link.</p></div>`
3443
3466
  return `<div class="pt-view"><aside class="pt-side"><div class="pt-h">Running</div>${list || '<p class="hint pt-none">No links yet.</p>'}${form}</aside><section class="pt-main">${frame}</section></div>`
3444
3467
  }
3445
3468
 
@@ -3452,6 +3475,8 @@ function bindPreviewTab (el) {
3452
3475
  const sz = e.target.closest('[data-pt-size]')
3453
3476
  if (sz) { w.previewPhone = sz.dataset.ptSize === 'phone'; saveWs(current); return redraw() }
3454
3477
  if (e.target.closest('[data-pt-reload]')) { const f = el.querySelector('.pt-frame'); if (f) f.src = f.src }
3478
+ if (e.target.closest('[data-pt-adding]')) { w.ptAdding = true; redraw(); el.querySelector('[data-pt-add] input')?.focus(); return }
3479
+ if (e.target.closest('[data-pt-cancel]')) { w.ptAdding = false; redraw() }
3455
3480
  }
3456
3481
  const form = el.querySelector('[data-pt-add]')
3457
3482
  if (form && form.elements.name) {
@@ -3462,6 +3487,7 @@ function bindPreviewTab (el) {
3462
3487
  const l = await api('POST', `/api/workspaces/${encodeURIComponent(id)}/links`, { name: form.elements.name.value, url: form.elements.url.value, room: sum().status.room })
3463
3488
  state.workspace = await api('GET', `/api/workspaces/${encodeURIComponent(id)}`)
3464
3489
  w.previewSel = l.id
3490
+ w.ptAdding = false
3465
3491
  saveWs(current)
3466
3492
  redraw()
3467
3493
  } catch (err) { toast(err.message) }
@@ -3471,14 +3497,26 @@ function bindPreviewTab (el) {
3471
3497
 
3472
3498
  let filesLoading = false // the workspace's files, fetched for the Files page
3473
3499
  let pageConnections = null // the Connections page's manager while it is drawn
3474
- // Pages over the session (dm06): Home, Files, People and Connections. Each is a toggle: a second click goes back to
3475
- // the session's view you came from, whose tab stays lit meanwhile.
3500
+ // Pages of the workspace (dm06): Home, Files, People and Connections. Their button opens the page (and stays lit
3501
+ // on it); the session menu brings you back to the session, to the view you left it on.
3476
3502
  const PAGES = ['home', 'wsfiles', 'people', 'connections']
3477
- function togglePage (mode) {
3503
+ function openPage (mode) {
3504
+ const w = ws(current)
3505
+ if (w.mode === mode) return
3506
+ if (!PAGES.includes(w.mode)) w.pageBack = w.mode
3507
+ w.mode = mode
3508
+ saveWs(current)
3509
+ renderMain()
3510
+ renderSessHead()
3511
+ renderWbar()
3512
+ }
3513
+ /** Back from a workspace page to the session's own view (the one you left it on). */
3514
+ function backToSession () {
3478
3515
  const w = ws(current)
3479
- if (w.mode === mode) w.mode = PAGES.includes(w.pageBack) ? 'ai' : (w.pageBack || 'ai')
3480
- else { if (!PAGES.includes(w.mode)) w.pageBack = w.mode; w.mode = mode }
3516
+ if (!PAGES.includes(w.mode)) return
3517
+ w.mode = PAGES.includes(w.pageBack) || !w.pageBack ? 'ai' : w.pageBack
3481
3518
  saveWs(current)
3519
+ renderMainBar()
3482
3520
  renderMain()
3483
3521
  renderSessHead()
3484
3522
  renderWbar()
package/src/ui-server.js CHANGED
@@ -18,6 +18,7 @@ import { execFile } from 'node:child_process'
18
18
  import { installedEditors, openIn, copyToClipboard } from './editors.js'
19
19
  import { autowork, autoConfig, publicConfig, AUTO_MODES } from './autowork.js'
20
20
  import { migrateDir } from './legacy.js'
21
+ import { devServers } from './dev-servers.js'
21
22
  import { writePrivateJson } from './private-file.js'
22
23
  import { autoToolFor } from './autowork-tools.js'
23
24
  import { readAccount, saveAccount, clearAccount, clearAccountIf, resumeAccount, startLink, waitForLink, 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, apiUrl } from './account.js'
@@ -961,7 +962,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
961
962
  const enc = (v) => encodeURIComponent(String(v))
962
963
  return asAccount(async (token) => {
963
964
  const c = secretsApi(token)
964
- if (method === 'GET' && p === '/api/connections/apps') return apiCall(c, 'GET', `/v1/connections/apps?search=${enc(url.searchParams.get('search') || '')}&limit=${enc(url.searchParams.get('limit') || '60')}`)
965
+ if (method === 'GET' && p === '/api/connections/apps') return apiCall(c, 'GET', `/v1/connections/apps?search=${enc(url.searchParams.get('search') || '')}&category=${enc(url.searchParams.get('category') || '')}&offset=${enc(url.searchParams.get('offset') || '0')}&limit=${enc(url.searchParams.get('limit') || '48')}`)
965
966
  const sc = p.match(/^\/api\/connections\/(org|workspace|session)\/([^/]+)(?:\/([0-9a-f-]{36}))?$/i)
966
967
  if (sc && SECRET_SCOPE_ID[sc[1]].test(decodeURIComponent(sc[2]))) {
967
968
  const base = `/v1/connections/${sc[1]}/${enc(decodeURIComponent(sc[2]))}`
@@ -1143,6 +1144,8 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
1143
1144
  const { lines, calls } = get(id).voiceTranscript({ limit: 1000 })
1144
1145
  return { calls: calls.reverse().slice(0, 50).map((c) => ({ ...c, opening: lines.filter((l) => l.call === c.call).slice(0, 3).map((l) => ({ by: l.by, text: l.text })) })) }
1145
1146
  },
1147
+ // The Preview tab: dev servers running from this session's folder on this computer (dev-servers.js).
1148
+ 'GET /api/sessions/:id/dev-servers': async (b, id) => { get(id); return { servers: await devServers(runs.get(id)?.run.dir, { skip: [server.address()?.port].filter(Boolean) }) } },
1146
1149
  'GET /api/sessions/:id/calls/:call': (b, id, url, call) => ({ lines: get(id).voiceTranscript({ call, limit: 1000 }).lines }),
1147
1150
  'POST /api/sessions/:id/voice': (b, id) => 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 }),
1148
1151
  'POST /api/sessions/:id/voice/transcribe': (b, id) => get(id).setVoiceTranscribe(b.on === true),