heyquilt 0.3.155 → 0.3.157
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 +11 -0
- package/package.json +1 -1
- package/src/api/composio.js +35 -1
- package/src/api/routes/connections.js +34 -1
- package/src/dev-servers.js +65 -0
- package/src/ui/app.css +90 -0
- package/src/ui/connections.js +69 -19
- package/src/ui/files.js +4 -4
- package/src/ui/session.js +59 -21
- package/src/ui-server.js +4 -1
package/RELEASES.md
CHANGED
|
@@ -11,6 +11,17 @@ 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.157 — 2026-11-12
|
|
15
|
+
|
|
16
|
+
- **A new Connections page.** The apps you've connected are cards at the top. Below them, one search box for every app you can connect, a row of categories, and a grid of app icons. Click an app to see what it is and how you sign in, and connect it right there.
|
|
17
|
+
|
|
18
|
+
## 0.3.156 — 2026-11-12
|
|
19
|
+
|
|
20
|
+
- **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.
|
|
21
|
+
- **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.
|
|
22
|
+
- **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**.
|
|
23
|
+
- **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.
|
|
24
|
+
|
|
14
25
|
## 0.3.155 — 2026-11-12
|
|
15
26
|
|
|
16
27
|
A new look: one bar across the top instead of the sidebar, and the session's chat is the loom.
|
package/package.json
CHANGED
package/src/api/composio.js
CHANGED
|
@@ -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
|
|
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,93 @@ 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); }
|
|
3595
|
+
|
|
3596
|
+
/* Connections, layout C (conn-options.html): connected cards, one big search with a row of category tabs, and an
|
|
3597
|
+
icon grid; the open app's details sit under its row */
|
|
3598
|
+
.cn-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 0 4px; }
|
|
3599
|
+
.cn-bigsrc { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--faint); }
|
|
3600
|
+
.cn-bigsrc:focus-within { border-color: var(--border-strong); }
|
|
3601
|
+
.cn-bigsrc svg { width: 16px; height: 16px; flex: none; }
|
|
3602
|
+
.cn-bigsrc input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 14px var(--sans); color: var(--text); }
|
|
3603
|
+
.cn-tabs { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
|
|
3604
|
+
.cn-tab { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 500 12.5px var(--sans); white-space: nowrap; cursor: pointer; }
|
|
3605
|
+
.cn-tab:hover { color: var(--text); } .cn-tab.on { background: var(--panel-2); color: var(--text); }
|
|
3606
|
+
.cn-tab svg { width: 12px; height: 12px; }
|
|
3607
|
+
.cn-tabmore { position: relative; }
|
|
3608
|
+
.cn-tabmenu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 220px; padding: 6px; 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)); display: flex; flex-direction: column; }
|
|
3609
|
+
.cn-tabmenu button { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: 13px var(--sans); text-align: left; cursor: pointer; }
|
|
3610
|
+
.cn-tabmenu button:hover { background: var(--panel-2); } .cn-tabmenu i { font-style: normal; color: var(--faint); font-size: 12px; }
|
|
3611
|
+
.cn-found { margin: 0; font-size: 12.5px; color: var(--muted); }
|
|
3612
|
+
.cn-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; margin-top: 6px; }
|
|
3613
|
+
.cn-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; padding: 16px 8px 12px; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--text); font: inherit; cursor: pointer; }
|
|
3614
|
+
.cn-tile:hover, .cn-tile.open { background: var(--panel); border-color: var(--border); }
|
|
3615
|
+
.cn-tile .cn-logo { width: 44px; height: 44px; padding: 6px; box-sizing: border-box; border-radius: 11px; background: #fff; box-shadow: 0 0 0 1px var(--border); object-fit: contain; }
|
|
3616
|
+
.cn-tile .cn-logo.none { display: grid; place-items: center; background: var(--panel-2); font-size: 16px; }
|
|
3617
|
+
.cn-tile b { max-width: 100%; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
3618
|
+
.cn-detail { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
|
|
3619
|
+
.cn-detail .cn-logo { width: 44px; height: 44px; padding: 6px; box-sizing: border-box; border-radius: 11px; background: #fff; box-shadow: 0 0 0 1px var(--border); object-fit: contain; flex: none; }
|
|
3620
|
+
.cn-detail > div { flex: 1; min-width: 0; } .cn-detail b { font-size: 15px; font-weight: 600; } .cn-detail p { margin: 3px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
|
|
3621
|
+
.cn-detail .btn { flex: none; height: 36px; }
|
|
3622
|
+
.cn-page .cn-grid { margin-bottom: 4px; }
|
package/src/ui/connections.js
CHANGED
|
@@ -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
|
-
|
|
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: '', open: null, moreCats: false, 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,16 @@ 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
|
-
|
|
55
|
+
// The catalog as an icon grid (Daniel picked layout C, conn-options.html): a tile per app; the open one's
|
|
56
|
+
// details (what it is, how you sign in, Connect) open in a row under its row of tiles.
|
|
57
|
+
const HOW = { oneclick: 'Sign in with one click', key: 'Uses your own API key', none: 'No sign-in needed' }
|
|
58
|
+
const tileHtml = (a) => `<button type="button" class="cn-tile${ui.open === a.slug ? ' open' : ''}" data-tile="${esc(a.slug)}" aria-expanded="${ui.open === a.slug}" title="${esc(a.name)}">${logoHtml(a)}<b>${esc(a.name)}</b></button>`
|
|
59
|
+
function detailHtml (a, connected) {
|
|
53
60
|
const busy = ui.busy === a.slug
|
|
54
|
-
|
|
61
|
+
const act = a.how === 'none'
|
|
62
|
+
? '<span class="cn-ready">No sign-in: agents can use it</span>'
|
|
63
|
+
: `<button type="button" class="btn primary" data-connect="${esc(a.slug)}"${busy ? ' disabled' : ''}>${busy ? 'Opening…' : connected ? `Add another ${esc(a.name)}` : `Connect ${esc(a.name)}`}</button>`
|
|
64
|
+
return `<div class="cn-detail" data-detail="${esc(a.slug)}">${logoHtml(a)}<div><b>${esc(a.name)}</b><p>${esc(a.description || '')}${a.description ? ' · ' : ''}<span class="cn-how ${esc(a.how)}">${esc(HOW[a.how] || '')}</span></p></div>${act}</div>`
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
function callsHtml () {
|
|
@@ -70,20 +80,43 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
|
|
|
70
80
|
const inherited = view.inherited || []
|
|
71
81
|
const ownApps = new Set(own.map((c) => c.app))
|
|
72
82
|
const apps = ui.apps || []
|
|
73
|
-
const
|
|
83
|
+
const left = ui.total - apps.length
|
|
84
|
+
const catName = ui.cat ? cap((ui.categories.find((c) => c.id === ui.cat) || { name: ui.cat }).name) : ''
|
|
74
85
|
const count = own.filter((c) => c.status === 'active').length + inherited.length
|
|
75
86
|
const lead = page
|
|
76
87
|
? (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')
|
|
77
88
|
: `Apps ${esc(LEVEL[type] || type)}’s AIs can use. They read at once and ask a person before they send, change or delete anything; each sign-in stays with Composio, never in Quilt.`
|
|
89
|
+
const TABS = 7
|
|
90
|
+
// Apps already connected here are in the cards above, not in the grid (unless you search for one).
|
|
91
|
+
const shown = ui.search ? apps : apps.filter((a) => !ownApps.has(a.slug))
|
|
92
|
+
const tabs = ui.categories.slice(0, TABS)
|
|
93
|
+
const rest = ui.categories.slice(TABS)
|
|
94
|
+
const inRest = rest.find((c) => c.id === ui.cat)
|
|
95
|
+
const open = ui.open && apps.find((a) => a.slug === ui.open)
|
|
78
96
|
root.innerHTML = `<div class="cn${page ? ' cn-page' : ''}">
|
|
79
|
-
<div class="cn-h"><div>${page ? `<h2>Connections <i>${count}</i></h2>` : `<h3>Connections <i>${count}</i></h3>`}<small>${lead}</small></div>
|
|
80
|
-
|
|
81
|
-
${
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
<div class="cn-h"><div>${page ? `<h2>Connections <i>${count}</i></h2>` : `<h3>Connections <i>${count}</i></h3>`}<small>${lead}</small></div></div>
|
|
98
|
+
${own.length || inherited.length ? `<div class="cn-grid">${own.map((c) => cardHtml(c, true)).join('')}${inherited.map((c) => cardHtml(c, false)).join('')}</div>` : ''}
|
|
99
|
+
${view.canManage ? `<section class="cn-cat" id="cn-catalog">
|
|
100
|
+
<div class="cn-hero">
|
|
101
|
+
<label class="cn-bigsrc">${SEARCH_ICON}<input data-search placeholder="Search ${ui.all ? ui.all.toLocaleString() : 'thousands of'} apps to connect" value="${esc(ui.search)}" aria-label="Search apps to connect"></label>
|
|
102
|
+
${ui.categories.length && !ui.search ? `<div class="cn-tabs" role="tablist" aria-label="Categories">
|
|
103
|
+
<button type="button" class="cn-tab${ui.cat ? '' : ' on'}" role="tab" aria-selected="${!ui.cat}" data-cat="">Popular</button>
|
|
104
|
+
${tabs.map((c) => `<button type="button" class="cn-tab${ui.cat === c.id ? ' on' : ''}" role="tab" aria-selected="${ui.cat === c.id}" data-cat="${esc(c.id)}">${esc(cap(c.name))}</button>`).join('')}
|
|
105
|
+
${rest.length ? `<span class="cn-tabmore"><button type="button" class="cn-tab${inRest ? ' on' : ''}" data-cat-more aria-expanded="${!!ui.moreCats}">${inRest ? esc(cap(inRest.name)) : 'More'} ${I.chevDown || '▾'}</button>${ui.moreCats ? `<span class="cn-tabmenu" role="menu">${rest.map((c) => `<button type="button" role="menuitem" data-cat="${esc(c.id)}">${esc(cap(c.name))}<i>${c.n}</i></button>`).join('')}</span>` : ''}</span>` : ''}
|
|
106
|
+
</div>` : ui.search ? `<p class="cn-found">${ui.apps === null ? 'Looking…' : `${ui.total.toLocaleString()} app${ui.total === 1 ? '' : 's'} match “${esc(ui.search)}”`}</p>` : ''}
|
|
107
|
+
</div>
|
|
108
|
+
${ui.apps === null ? '<p class="hint cn-none">Loading apps…</p>' : shown.length ? `<div class="cn-tiles">${shown.map(tileHtml).join('')}</div>` : `<p class="hint cn-none">No app matches${ui.search ? ` “${esc(ui.search)}”` : ''}${catName ? ` in ${esc(catName)}` : ''}.</p>`}
|
|
109
|
+
${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>` : ''}
|
|
110
|
+
</section>` : ''}
|
|
85
111
|
${callsHtml()}
|
|
86
112
|
</div>`
|
|
113
|
+
// The open tile's details go after the last tile of its row, the width of the grid.
|
|
114
|
+
if (open) {
|
|
115
|
+
const t = root.querySelector(`[data-tile="${CSS.escape(open.slug)}"]`)
|
|
116
|
+
let end = t
|
|
117
|
+
while (end && end.nextElementSibling && end.nextElementSibling.offsetTop === t.offsetTop) end = end.nextElementSibling
|
|
118
|
+
end?.insertAdjacentHTML('afterend', detailHtml(open, ownApps.has(open.slug)))
|
|
119
|
+
}
|
|
87
120
|
if (had) { const s = root.querySelector('[data-search]'); s.focus(); s.setSelectionRange(s.value.length, s.value.length) }
|
|
88
121
|
}
|
|
89
122
|
|
|
@@ -104,19 +137,27 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
|
|
|
104
137
|
if (alive && view && (view.connections || []).some((c) => c.status === 'pending' && Date.now() - c.createdAt < 10 * 60 * 1000)) poll = setTimeout(load, 3000)
|
|
105
138
|
}
|
|
106
139
|
|
|
107
|
-
|
|
108
|
-
|
|
140
|
+
// A page of the catalog: the first (`more` false, after a new search or category) or the next one.
|
|
141
|
+
async function loadApps (more = false) {
|
|
142
|
+
const key = `${ui.search}|${ui.cat}`
|
|
143
|
+
const offset = more ? (ui.apps || []).length : 0
|
|
144
|
+
if (more) { ui.loadingMore = true; draw() }
|
|
109
145
|
try {
|
|
110
|
-
const r = await api('GET', `/api/connections/apps?search=${encodeURIComponent(
|
|
111
|
-
if (
|
|
112
|
-
ui.apps = r.apps || []
|
|
113
|
-
|
|
146
|
+
const r = await api('GET', `/api/connections/apps?search=${encodeURIComponent(ui.search)}&category=${encodeURIComponent(ui.cat)}&offset=${offset}&limit=${PAGE}`)
|
|
147
|
+
if (key !== `${ui.search}|${ui.cat}`) return
|
|
148
|
+
ui.apps = more ? [...(ui.apps || []), ...(r.apps || [])] : (r.apps || [])
|
|
149
|
+
ui.total = r.total ?? ui.apps.length
|
|
150
|
+
ui.all = r.all ?? ui.total
|
|
151
|
+
if (r.categories && r.categories.length) ui.categories = r.categories
|
|
152
|
+
} catch (err) { if (!more) ui.apps = []; if (err.status !== 503) toast(err.message) }
|
|
153
|
+
ui.loadingMore = false
|
|
114
154
|
draw()
|
|
115
155
|
}
|
|
116
156
|
|
|
117
157
|
root.addEventListener('input', (e) => {
|
|
118
158
|
if (!e.target.matches('[data-search]')) return
|
|
119
159
|
ui.search = e.target.value.trim()
|
|
160
|
+
ui.open = null
|
|
120
161
|
clearTimeout(searchTimer)
|
|
121
162
|
searchTimer = setTimeout(loadApps, 250)
|
|
122
163
|
})
|
|
@@ -151,16 +192,25 @@ export function mountConnections (root, { type, id, page = false, sessions = [],
|
|
|
151
192
|
load()
|
|
152
193
|
return
|
|
153
194
|
}
|
|
154
|
-
|
|
155
|
-
if (
|
|
195
|
+
const tile = e.target.closest('[data-tile]')
|
|
196
|
+
if (tile) { ui.open = ui.open === tile.dataset.tile ? null : tile.dataset.tile; draw(); return }
|
|
197
|
+
if (e.target.closest('[data-cat-more]')) { ui.moreCats = !ui.moreCats; draw(); return }
|
|
198
|
+
const cat = e.target.closest('[data-cat]')
|
|
199
|
+
if (cat) { ui.cat = cat.dataset.cat; ui.moreCats = false; ui.open = null; ui.apps = null; draw(); loadApps(); return }
|
|
200
|
+
if (ui.moreCats && !e.target.closest('.cn-tabmenu')) { ui.moreCats = false; draw() }
|
|
201
|
+
if (e.target.closest('[data-load-more]')) { loadApps(true); return }
|
|
202
|
+
|
|
156
203
|
})
|
|
157
204
|
|
|
205
|
+
// A resize moves tiles between rows: the open one's details move with it.
|
|
206
|
+
const onResize = () => { if (ui.open) draw() }
|
|
207
|
+
window.addEventListener('resize', onResize)
|
|
158
208
|
draw()
|
|
159
209
|
load()
|
|
160
210
|
loadApps()
|
|
161
211
|
return {
|
|
162
212
|
refresh: load,
|
|
163
|
-
destroy () { alive = false; clearTimeout(poll); clearTimeout(searchTimer) }
|
|
213
|
+
destroy () { alive = false; clearTimeout(poll); clearTimeout(searchTimer); window.removeEventListener('resize', onResize) }
|
|
164
214
|
}
|
|
165
215
|
}
|
|
166
216
|
|
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
|
|
421
|
-
const grid = !folders.length && !files.length
|
|
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
|
|
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: () =>
|
|
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
|
-
|
|
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 = () =>
|
|
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 = () =>
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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}
|
|
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
|
|
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
|
-
|
|
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">
|
|
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
|
|
3475
|
-
// the session
|
|
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
|
|
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 (
|
|
3480
|
-
|
|
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') || '
|
|
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),
|