heyquilt 0.3.189 → 0.3.191
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/desktop/main.js +17 -1
- package/package.json +1 -1
- package/src/preview/address.js +19 -0
- package/src/preview/proxy.js +9 -4
- package/src/previews.js +26 -1
- package/src/ui/app.css +25 -11
- package/src/ui/app.js +19 -7
- package/src/ui/preview-page.js +16 -6
- package/src/ui/project-model.js +44 -0
- package/src/ui/projects.js +32 -2
- package/src/ui/session.js +10 -5
- package/src/ui-server.js +2 -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.191 — 2026-11-23
|
|
15
|
+
|
|
16
|
+
- **"Open in Quilt" on a preview's address.** A preview's address opened by itself in a browser said to open it from Quilt and left you there. It now has an Open in Quilt button: Quilt comes forward on that preview, on the branch that address shows. The link carries only the address, so it tells nobody which codebase or branch it is.
|
|
17
|
+
|
|
18
|
+
## 0.3.190 — 2026-11-23
|
|
19
|
+
|
|
20
|
+
- **A preview's app can be given its settings.** A preview's form has a Values box: one setting a line as `NAME=value`, such as an address or a public key the app needs to start. A pasted `.env` file reads the same. Everyone in the codebase can read them, so they are never for a password or a secret key.
|
|
21
|
+
- **The sidebar slides.** Closing or opening the sidebar of a project or a codebase (the button beside the logo) slides it instead of snapping, and folding a section (Previews, Channels, Codebases, Direct messages) slides its rows. With "reduce motion" on, nothing slides.
|
|
22
|
+
- **A preview's header is one line.** Its name, the branch you are on and how it stands sit side by side, instead of the state under the name.
|
|
23
|
+
- **The codebase menu stays in its project.** The menu on a codebase's name lists only the codebases of the project it is in. It used to list every codebase on your computer, other projects' included. A codebase in no project lists the others in none.
|
|
24
|
+
|
|
14
25
|
## 0.3.189 — 2026-11-23
|
|
15
26
|
|
|
16
27
|
- **Agents can read a codebase's previews.** `quilt_previews` tells an agent who has a preview open, the address of each branch that is running, and what an app printed when it did not start, so it can say where a change can be looked at or see why it broke. It works for an agent on a computer and for one over HTTP. An agent cannot start a preview: a person opens it.
|
package/desktop/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Quilt desktop app: the same app as `quilt ui`, in its own window. Sessions
|
|
2
2
|
// keep syncing from the menu bar when the window is closed, and invite links
|
|
3
|
-
// (quilt://join?invite=…) open straight into the join screen.
|
|
3
|
+
// (quilt://join?invite=…) open straight into the join screen. A preview's address opened in a
|
|
4
|
+
// browser sends people back with quilt://preview?at=…, which opens that preview.
|
|
4
5
|
import '../src/quiet-warnings.js'
|
|
5
6
|
import { app, BrowserWindow, Tray, Menu, shell, dialog, ipcMain, nativeTheme, systemPreferences, desktopCapturer } from 'electron'
|
|
6
7
|
import { execFile } from 'node:child_process'
|
|
@@ -9,6 +10,7 @@ import os from 'node:os'
|
|
|
9
10
|
import path from 'node:path'
|
|
10
11
|
import { fileURLToPath } from 'node:url'
|
|
11
12
|
import { startUi } from '../src/ui-server.js'
|
|
13
|
+
import { parsePreviewLink } from '../src/preview/address.js'
|
|
12
14
|
import { registerProcess } from '../src/procs.js'
|
|
13
15
|
import { decodeInvite } from '../src/runner.js'
|
|
14
16
|
import { quiltHome, adoptLegacyEnv } from '../src/legacy.js'
|
|
@@ -40,6 +42,7 @@ let win = null
|
|
|
40
42
|
let tray = null
|
|
41
43
|
let quitting = false
|
|
42
44
|
let pendingInvite = null
|
|
45
|
+
let pendingPreview = null // { machine, slot } of a quilt://preview link opened before the page was ready
|
|
43
46
|
let rendererReady = false
|
|
44
47
|
let shareWired = false // the screen share handler (and its answer channel), set up with the first window
|
|
45
48
|
|
|
@@ -61,6 +64,14 @@ function openInvite (link) {
|
|
|
61
64
|
win.webContents.send('invite', link)
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
/** Shows the preview a quilt://preview link names (the page finds the codebase it belongs to). */
|
|
68
|
+
function openPreviewLink (at) {
|
|
69
|
+
if (!at) return
|
|
70
|
+
if (!win || !rendererReady) { pendingPreview = at; if (win) showWindow(); return }
|
|
71
|
+
showWindow()
|
|
72
|
+
win.webContents.send('preview-link', at)
|
|
73
|
+
}
|
|
74
|
+
|
|
64
75
|
/** Tells Quilt about a crash in this process, when the app is far enough along to. Never throws. */
|
|
65
76
|
async function reportCrash (name, err) {
|
|
66
77
|
try {
|
|
@@ -82,13 +93,16 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
82
93
|
app.on('second-instance', (e, argv) => {
|
|
83
94
|
showWindow()
|
|
84
95
|
openInvite(argv.map(inviteFrom).find(Boolean))
|
|
96
|
+
openPreviewLink(argv.map(parsePreviewLink).find(Boolean))
|
|
85
97
|
})
|
|
86
98
|
// macOS delivers quilt:// links here, possibly before the app is ready.
|
|
87
99
|
// Any other quilt:// link (e.g. quilt://open from the website) just brings the app forward.
|
|
88
100
|
app.on('open-url', (e, url) => {
|
|
89
101
|
e.preventDefault()
|
|
90
102
|
const link = inviteFrom(url)
|
|
103
|
+
const preview = parsePreviewLink(url)
|
|
91
104
|
if (link) openInvite(link)
|
|
105
|
+
else if (preview) openPreviewLink(preview)
|
|
92
106
|
else if (win) showWindow()
|
|
93
107
|
})
|
|
94
108
|
|
|
@@ -96,6 +110,7 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
96
110
|
else app.setAsDefaultProtocolClient('quilt')
|
|
97
111
|
|
|
98
112
|
pendingInvite = process.argv.map(inviteFrom).find(Boolean) || null
|
|
113
|
+
pendingPreview = process.argv.map(parsePreviewLink).find(Boolean) || null
|
|
99
114
|
app.whenReady().then(start).catch(async (err) => {
|
|
100
115
|
await reportCrash('start', err)
|
|
101
116
|
dialog.showErrorBox('quilt could not start', err.stack || err.message)
|
|
@@ -113,6 +128,7 @@ async function start () {
|
|
|
113
128
|
registerOnStart((line) => console.log(line))
|
|
114
129
|
|
|
115
130
|
ipcMain.handle('ready', () => { rendererReady = true; const l = pendingInvite; pendingInvite = null; return l })
|
|
131
|
+
ipcMain.handle('pending-preview', () => { const p = pendingPreview; pendingPreview = null; return p })
|
|
116
132
|
ipcMain.handle('pick-folder', async (e, current) => {
|
|
117
133
|
const expanded = String(current || '').replace(/^~(?=$|\/)/, os.homedir())
|
|
118
134
|
const r = await dialog.showOpenDialog(win, {
|
package/package.json
CHANGED
package/src/preview/address.js
CHANGED
|
@@ -26,6 +26,25 @@ export function previewHost (machine, slot, domain = PREVIEW_DOMAIN) {
|
|
|
26
26
|
/** `https://<host>`, the origin a preview's pages are served from. */
|
|
27
27
|
export const previewOrigin = (machine, slot, domain = PREVIEW_DOMAIN) => `https://${previewHost(machine, slot, domain)}`
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The link that opens a preview in the Quilt app, for a page shown outside it: it carries the
|
|
31
|
+
* preview's own host and nothing else, so it tells nobody what the address did not.
|
|
32
|
+
*/
|
|
33
|
+
export const previewAppLink = (host) => `quilt://preview?at=${encodeURIComponent(String(host))}`
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The machine and slot a quilt://preview link names ({ machine, slot }), or null when it is not
|
|
37
|
+
* one. Whatever the domain: the app looks for the machine among the codebases it has open.
|
|
38
|
+
*/
|
|
39
|
+
export function parsePreviewLink (url) {
|
|
40
|
+
try {
|
|
41
|
+
const u = new URL(String(url))
|
|
42
|
+
if (u.protocol !== 'quilt:' || u.hostname !== 'preview') return null
|
|
43
|
+
const m = /^([0-9a-f]{8,24})-(\d)\.[a-z0-9.-]{1,253}$/.exec(String(u.searchParams.get('at') || '').toLowerCase())
|
|
44
|
+
return m ? { machine: m[1], slot: Number(m[2]) } : null
|
|
45
|
+
} catch { return null }
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
/**
|
|
30
49
|
* The machine and slot a `Host` header names, or null when it is not a preview's address under
|
|
31
50
|
* `domain` (a port on it is ignored: Fly's proxy may leave one).
|
package/src/preview/proxy.js
CHANGED
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
import http from 'node:http'
|
|
12
12
|
import net from 'node:net'
|
|
13
13
|
import crypto from 'node:crypto'
|
|
14
|
-
import { parsePreviewHost, previewDomain, previewHost } from './address.js'
|
|
14
|
+
import { parsePreviewHost, previewDomain, previewHost, previewAppLink } from './address.js'
|
|
15
15
|
import { verifyPreviewTicket, mintCookie, readCookie, cookieFrom, withoutCookie, setCookieHeader, TICKET_PARAM } from './ticket.js'
|
|
16
16
|
|
|
17
17
|
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c])
|
|
18
|
-
const page = (title, body, extra = '') => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${extra}<title>${esc(title)}</title><style>body{font:15px/1.5 system-ui,sans-serif;margin:0;min-height:100vh;display:grid;place-items:center;background:#f3f3f6;color:#1d1b2e}main{max-width:34em;padding:24px}h1{font-size:19px;margin:0 0 6px}p{margin:0 0 10px;color:#55536a}pre{font:12px/1.5 ui-monospace,Menlo,monospace;background:#fff;border:1px solid #dfdfe6;border-radius:6px;padding:12px;overflow:auto;max-height:50vh;white-space:pre-wrap}</style></head><body><main><h1>${esc(title)}</h1>${body}</main></body></html>`
|
|
18
|
+
const page = (title, body, extra = '') => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${extra}<title>${esc(title)}</title><style>body{font:15px/1.5 system-ui,sans-serif;margin:0;min-height:100vh;display:grid;place-items:center;background:#f3f3f6;color:#1d1b2e}main{max-width:34em;padding:24px}h1{font-size:19px;margin:0 0 6px}p{margin:0 0 10px;color:#55536a}.btn{display:inline-block;margin-top:6px;padding:8px 14px;border-radius:6px;background:#1d1b2e;color:#fff;font-weight:600;text-decoration:none}.btn:hover{background:#34314d}pre{font:12px/1.5 ui-monospace,Menlo,monospace;background:#fff;border:1px solid #dfdfe6;border-radius:6px;padding:12px;overflow:auto;max-height:50vh;white-space:pre-wrap}</style></head><body><main><h1>${esc(title)}</h1>${body}</main></body></html>`
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* What someone with no ticket gets: a preview's address opened by itself, in a browser. `host`:
|
|
22
|
+
* the preview's own (this machine, that slot); the button opens it in the Quilt app, where a
|
|
23
|
+
* member of the codebase is given a ticket.
|
|
24
|
+
*/
|
|
25
|
+
export const notAllowedPage = (host) => page('Open this preview from Quilt', `<p>A preview is for the people in its codebase. Open it from the codebase in Quilt, or ask someone in it for an invite.</p><p><a class="btn" href="${esc(previewAppLink(host))}">Open in Quilt</a></p>`)
|
|
21
26
|
|
|
22
27
|
/** What a slot with no running app answers: it is starting, it failed (with the last of what it printed), or nothing is there. */
|
|
23
28
|
export function waitingPage (app) {
|
|
@@ -117,7 +122,7 @@ export async function startPreviewProxy ({ port = 8080, host = '0.0.0.0', machin
|
|
|
117
122
|
}
|
|
118
123
|
if (at.replay) { res.writeHead(409, { 'fly-replay': `instance=${at.replay}`, 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' }); return res.end('This preview is on another machine.') }
|
|
119
124
|
const member = who(req)
|
|
120
|
-
if (!member) return send(res, 401,
|
|
125
|
+
if (!member) return send(res, 401, notAllowedPage(previewHost(me, at.slot, dom)))
|
|
121
126
|
// A ticket is taken once: the cookie replaces it, and the address is clean from then on.
|
|
122
127
|
if (member.fresh) { res.writeHead(302, { location: withoutTicket(req.url), 'set-cookie': setCookieHeader(mintCookie({ sub: member.sub, now: now() }, secret)), 'cache-control': 'no-store' }); return res.end() }
|
|
123
128
|
lastRequestAt = now()
|
package/src/previews.js
CHANGED
|
@@ -12,6 +12,9 @@ import { previewHost } from './preview/address.js'
|
|
|
12
12
|
|
|
13
13
|
export const PREVIEW_KINDS = ['app', 'link']
|
|
14
14
|
export const MAX_PREVIEWS = 12
|
|
15
|
+
// A preview's plain values: how many, and how long each may be.
|
|
16
|
+
export const MAX_VALUES = 30
|
|
17
|
+
const VALUE_MAX = 500
|
|
15
18
|
// The preview a codebase with a `dev` script has without anyone adding it.
|
|
16
19
|
export const APP_ID = 'app'
|
|
17
20
|
export const RUN_STATES = ['starting', 'running', 'failed']
|
|
@@ -40,7 +43,29 @@ function cleanUrl (v) {
|
|
|
40
43
|
function cleanEnv (v) {
|
|
41
44
|
const out = {}
|
|
42
45
|
if (!v || typeof v !== 'object' || Array.isArray(v)) return out
|
|
43
|
-
for (const [k, val] of Object.entries(v).slice(0,
|
|
46
|
+
for (const [k, val] of Object.entries(v).slice(0, MAX_VALUES)) if (ENV_NAME.test(k) && ['string', 'number', 'boolean'].includes(typeof val)) out[k] = String(val).replace(CONTROL, '').slice(0, VALUE_MAX)
|
|
47
|
+
return out
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A preview's plain values as a person typed them, one a line as NAME=value. A pasted .env file
|
|
52
|
+
* reads the same: blank lines and # comments are skipped, `export ` and the quotes around a value
|
|
53
|
+
* dropped. Throws, naming the line, on one that is neither (never repeating what it holds).
|
|
54
|
+
*/
|
|
55
|
+
export function envFromText (text) {
|
|
56
|
+
const out = {}
|
|
57
|
+
const lines = String(text ?? '').split(/\r?\n/)
|
|
58
|
+
for (let i = 0; i < lines.length; i++) {
|
|
59
|
+
const l = lines[i].trim()
|
|
60
|
+
if (!l || l.startsWith('#')) continue
|
|
61
|
+
const m = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(l)
|
|
62
|
+
if (!m || !ENV_NAME.test(m[1])) throw new Error(`Line ${i + 1} of the values is not NAME=value.`)
|
|
63
|
+
let v = m[2]
|
|
64
|
+
if (v.length >= 2 && (v[0] === '"' || v[0] === "'") && v.endsWith(v[0])) v = v.slice(1, -1)
|
|
65
|
+
if (v.length > VALUE_MAX) throw new Error(`${m[1]} is longer than ${VALUE_MAX} characters.`)
|
|
66
|
+
out[m[1]] = v.replace(CONTROL, '')
|
|
67
|
+
}
|
|
68
|
+
if (Object.keys(out).length > MAX_VALUES) throw new Error(`A preview has at most ${MAX_VALUES} values.`)
|
|
44
69
|
return out
|
|
45
70
|
}
|
|
46
71
|
|
package/src/ui/app.css
CHANGED
|
@@ -1705,10 +1705,14 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1705
1705
|
|
|
1706
1706
|
/* A project: a sidebar of its own just right of the strip of projects, then the page. The sidebar's
|
|
1707
1707
|
rows are the app's own (.side-nav, .side-label, .side-sessions, .side-foot), drawn short. */
|
|
1708
|
-
.pj-home .page.pj-proj { display: grid; grid-template-columns: 244px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 0; overflow: hidden; }
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
.pj-
|
|
1708
|
+
.pj-home .page.pj-proj { display: grid; grid-template-columns: 244px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 0; overflow: hidden; transition: grid-template-columns var(--side-slide); }
|
|
1709
|
+
/* The sidebar slides shut and open: its column closes while it moves out to the left at the same
|
|
1710
|
+
pace, so its rows never squeeze. Closed, nothing in it can be reached. */
|
|
1711
|
+
.pj-home, .ws.pj-cb { --side-slide: .22s cubic-bezier(.3, .7, .2, 1); }
|
|
1712
|
+
.pj-home[data-side="shut"] .page.pj-proj { grid-template-columns: 0px minmax(0, 1fr); }
|
|
1713
|
+
:is(.pj-home, .ws.pj-cb)[data-side="shut"] .pj-side { transform: translateX(-100%); visibility: hidden; transition: transform var(--side-slide), visibility 0s .22s; }
|
|
1714
|
+
@media (prefers-reduced-motion: reduce) { .pj-home, .ws.pj-cb { --side-slide: 0s; } :is(.pj-home, .ws.pj-cb)[data-side="shut"] .pj-side { transition: none; } }
|
|
1715
|
+
.pj-side { width: 244px; transition: transform var(--side-slide), visibility 0s; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; padding: 14px 10px 10px; background: var(--panel); border-right: 1px solid var(--border); }
|
|
1712
1716
|
.pj-side .side-nav, .pj-side .side-sessions { display: flex; flex-direction: column; gap: 1px; }
|
|
1713
1717
|
.pj-side .side-nav button, .pj-side .side-sessions button { height: 28px; }
|
|
1714
1718
|
.pj-side .side-nav svg { flex: none; color: var(--muted); }
|
|
@@ -1736,13 +1740,17 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1736
1740
|
.pj-fold svg { flex: none; width: 12px; height: 12px; opacity: 0; transition: transform .15s, opacity .15s; }
|
|
1737
1741
|
.pj-side-label:hover .pj-fold svg, .pj-fold:focus-visible svg, .pj-fold[aria-expanded="false"] svg { opacity: 1; }
|
|
1738
1742
|
.pj-fold[aria-expanded="false"] svg { transform: rotate(-90deg); }
|
|
1743
|
+
/* a section's rows while they slide shut or open (projects.js foldSection) */
|
|
1744
|
+
.pj-side .folding { overflow: hidden; }
|
|
1745
|
+
.pj-side .folding > * { flex-shrink: 0; }
|
|
1739
1746
|
.pj-pmain { min-width: 0; min-height: 0; overflow-y: auto; padding: 16px 24px 32px; }
|
|
1740
1747
|
.pj-pmain > section { margin-bottom: 28px; }
|
|
1741
1748
|
.pj-pmain .files-head { margin-bottom: 14px; }
|
|
1742
1749
|
.pj-pmain .files-head .crumbs { font-size: 17px; }
|
|
1743
1750
|
@media (max-width: 760px) {
|
|
1744
|
-
.pj-home .page.pj-proj { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
|
1745
|
-
.pj-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
|
|
1751
|
+
.pj-home .page.pj-proj, .pj-home[data-side="shut"] .page.pj-proj { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); transition: none; }
|
|
1752
|
+
.pj-side { width: auto; border-right: 0; border-bottom: 1px solid var(--border); max-height: 40vh; }
|
|
1753
|
+
.pj-home[data-side="shut"] .pj-side { display: none; }
|
|
1746
1754
|
.pj-home .page, .pj-pmain { padding: 14px 14px 24px; }
|
|
1747
1755
|
}
|
|
1748
1756
|
|
|
@@ -1755,9 +1763,8 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1755
1763
|
.pj-side .side-sessions.pj-rooms button.on { background: var(--panel-2); font-weight: 600; }
|
|
1756
1764
|
.pj-side .pj-rooms button.on .pj-hash { color: var(--text); }
|
|
1757
1765
|
.pj-side .ct.new, .pj-side .side-nav button.on .ct.new, .pj-side .side-nav button:hover .ct.new { background: var(--accent); color: light-dark(#fff, #1d1b2e); }
|
|
1758
|
-
.ws.pj-cb .ws-body { grid-template-columns: 244px minmax(0, 1fr); transition:
|
|
1759
|
-
.ws.pj-cb[data-side="shut"] .ws-body { grid-template-columns: minmax(0, 1fr); }
|
|
1760
|
-
.ws.pj-cb[data-side="shut"] .pj-side { display: none; }
|
|
1766
|
+
.ws.pj-cb .ws-body { grid-template-columns: 244px minmax(0, 1fr); transition: grid-template-columns var(--side-slide); }
|
|
1767
|
+
.ws.pj-cb[data-side="shut"] .ws-body { grid-template-columns: 0px minmax(0, 1fr); }
|
|
1761
1768
|
.ws.pj-cb .ws-people, .ws.pj-cb #tasks-btn, .ws.pj-cb #toggle-chat, .ws.pj-cb #toggle-tree, .ws.pj-cb #connections-btn { display: none !important; }
|
|
1762
1769
|
.ws.pj-cb .ws-chat { display: none; position: relative; width: auto; border-left: 0; box-shadow: none; }
|
|
1763
1770
|
.ws.pj-cb .chat-resize, .ws.pj-cb .chat-rail, .ws.pj-cb #collapse-chat { display: none; }
|
|
@@ -1782,11 +1789,17 @@ body.has-asks .prail { margin-top: calc(var(--update-bar, 0px) + var(--asks-bar)
|
|
|
1782
1789
|
.pv-view > [data-pv-head], .pv-view > .pv-head { flex: none; }
|
|
1783
1790
|
.pv-head { display: flex; align-items: center; gap: 10px; padding: 14px 24px; margin: 0; border-bottom: 1px solid var(--border); }
|
|
1784
1791
|
.pv-head .pj-block, .pv-head > svg:first-child { flex: none; width: 34px; height: 34px; border-radius: 8px; }
|
|
1792
|
+
.pv-head { flex-wrap: nowrap; }
|
|
1785
1793
|
.pv-head .t { flex: 0 1 auto; min-width: 120px; overflow: hidden; }
|
|
1786
1794
|
.pv-head h2, .pv-head p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1795
|
+
.pv-head h2.crumbs { display: block; flex: 0 1 auto; min-width: 90px; font-size: 17px; }
|
|
1787
1796
|
.pv-head h2 .sep { margin: 0 6px; color: var(--faint); font-weight: 400; }
|
|
1788
1797
|
.pv-head p { display: flex; align-items: center; gap: 4px; }
|
|
1789
1798
|
.pv-head p svg { flex: none; width: 13px; height: 13px; }
|
|
1799
|
+
/* how it stands, on the header's one line: the dot and the word are kept, what follows gives way first */
|
|
1800
|
+
.pv-head .pv-state { flex: 0 1 auto; min-width: 0; margin: 0 0 0 4px; font-size: 13px; }
|
|
1801
|
+
.pv-head .pv-state > span { flex: none; }
|
|
1802
|
+
.pv-head .pv-state .more { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
1790
1803
|
.pv-head .spacer { flex: 1; }
|
|
1791
1804
|
.pv-pick { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; margin-left: 14px; padding: 0 4px 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--panel); color: var(--muted); }
|
|
1792
1805
|
.pv-pick svg { width: 14px; height: 14px; }
|
|
@@ -1808,6 +1821,7 @@ iframe.pv-page { flex: 1; min-height: 0; width: 100%; border: 0; background: #ff
|
|
|
1808
1821
|
.pv-form { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 28px; }
|
|
1809
1822
|
.pv-form .seg.pv-kind { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1810
1823
|
.pv-form .seg.pv-kind button { font-size: 13px; padding: 9px 8px; }
|
|
1824
|
+
.pv-form textarea.pv-values { width: 100%; min-height: 112px; font-size: 13px; line-height: 1.5; white-space: pre; overflow-x: auto; }
|
|
1811
1825
|
.pv-form-foot { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
|
|
1812
1826
|
.pv-form-foot .spacer { flex: 1; }
|
|
1813
1827
|
@media (max-width: 760px) {
|
|
@@ -1820,13 +1834,13 @@ iframe.pv-page { flex: 1; min-height: 0; width: 100%; border: 0; background: #ff
|
|
|
1820
1834
|
/* a call is in the channel: a screen someone shares there sits in the middle, the channel beside it */
|
|
1821
1835
|
.ws.pj-cb[data-side-page="chat"]:has(#screen-stage:not([hidden])) .ws-main { display: flex; }
|
|
1822
1836
|
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: 244px minmax(0, 1fr) 380px; }
|
|
1823
|
-
.ws.pj-cb[data-side="shut"][data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: minmax(0, 1fr) 380px; }
|
|
1837
|
+
.ws.pj-cb[data-side="shut"][data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: 0px minmax(0, 1fr) 380px; }
|
|
1824
1838
|
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) .ws-chat { border-left: 1px solid var(--border); }
|
|
1825
1839
|
/* a call going on shows on its channel's row */
|
|
1826
1840
|
.pj-side .pj-call { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--ok); }
|
|
1827
1841
|
.pj-side .pj-call svg { width: 13px; height: 13px; color: inherit; }
|
|
1828
1842
|
@media (max-width: 900px) {
|
|
1829
|
-
.ws.pj-cb .ws-body { grid-template-columns: minmax(0, 1fr); }
|
|
1843
|
+
.ws.pj-cb .ws-body, .ws.pj-cb[data-side="shut"] .ws-body { grid-template-columns: minmax(0, 1fr); }
|
|
1830
1844
|
.ws.pj-cb .pj-side { position: absolute; top: 0; bottom: 0; left: 0; z-index: 5; width: min(244px, 80vw); max-height: none; border-right: 1px solid var(--border); border-bottom: 0; box-shadow: var(--shadow-pop); }
|
|
1831
1845
|
/* too narrow for both: the screen takes the page, and Hide puts the channel back */
|
|
1832
1846
|
.ws.pj-cb[data-side-page="chat"] .ws-body:has(#screen-stage:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
|
package/src/ui/app.js
CHANGED
|
@@ -9,6 +9,8 @@ import { renderSignIn } from './signin.js'
|
|
|
9
9
|
import { checkRelease, openReleaseNotes } from './releases.js'
|
|
10
10
|
import { loadWorkspaces, openWorkspace, wsIdOf } from './workspaces.js'
|
|
11
11
|
import { renderRail } from './prail.js'
|
|
12
|
+
import { menuCodebases, previewAt } from './project-model.js'
|
|
13
|
+
import { knownMachines } from './preview-page.js'
|
|
12
14
|
import { openNewProject } from './project-pop.js'
|
|
13
15
|
import { previewBusy } from './files.js'
|
|
14
16
|
import { agentPaste, NO_LINK_YET } from './invite.js'
|
|
@@ -66,7 +68,7 @@ async function boot () {
|
|
|
66
68
|
render()
|
|
67
69
|
pollWorkspace()
|
|
68
70
|
// Invite links that opened the desktop app wait until you're signed in.
|
|
69
|
-
if (!boot.invites) { boot.invites = true; window.quiltDesktop?.onInvite(openInviteLink); window.quiltDesktop?.onReleaseNotes?.(openReleaseNotes) }
|
|
71
|
+
if (!boot.invites) { boot.invites = true; window.quiltDesktop?.onInvite(openInviteLink); window.quiltDesktop?.onPreviewLink?.(openPreviewLink); window.quiltDesktop?.onReleaseNotes?.(openReleaseNotes) }
|
|
70
72
|
// Is a newer Quilt out, and has this version's "what's new" been shown? Never blocks the app.
|
|
71
73
|
checkRelease()
|
|
72
74
|
} catch (err) {
|
|
@@ -349,13 +351,12 @@ export function renderLocked (msg) {
|
|
|
349
351
|
export function renderTabs () {
|
|
350
352
|
const el = $('#tabs')
|
|
351
353
|
if (!el) return
|
|
352
|
-
// The
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
const earlier = (state.recent || []).filter((r) => !r.unsupported && !dirs.has(r.dir))
|
|
354
|
+
// The codebase menu lists the codebases on this computer that are where this one is: its
|
|
355
|
+
// project's, or for one in no project the others in none. Open ones to switch to, with their
|
|
356
|
+
// connection, and earlier ones to rejoin. The button's dot is this codebase's connection.
|
|
357
|
+
const { project, open, earlier } = menuCodebases({ sessions: state.sessions, recent: state.recent || [], projects: state.workspaces || [], view: state.view })
|
|
357
358
|
el.hidden = false
|
|
358
|
-
el.innerHTML =
|
|
359
|
+
el.innerHTML = `<div class="pop-label">${project ? `Codebases in ${esc(project.name)}` : 'Your codebases'}</div>` + open.map((s) => {
|
|
359
360
|
const unread = s.status.unread
|
|
360
361
|
const on = state.view === s.id
|
|
361
362
|
return `<button class="pop-item tab${on ? ' on' : ''}" role="menuitem" data-go="${s.id}"${on ? ' aria-current="true"' : ''}>
|
|
@@ -414,6 +415,17 @@ export function bindTopbar () {
|
|
|
414
415
|
// In the desktop app, clicking an invite link opens the join dialog with it filled in. An invite to a
|
|
415
416
|
// session already on this computer opens that session instead (running, or from Recent in its own
|
|
416
417
|
// folder): joining it again would only make a second copy of the same files.
|
|
418
|
+
/**
|
|
419
|
+
* A preview's address opened in a browser has a button back to Quilt (quilt://preview): shows
|
|
420
|
+
* that preview, on the branch running at that address, in the codebase it belongs to.
|
|
421
|
+
*/
|
|
422
|
+
export async function openPreviewLink ({ machine, slot } = {}) {
|
|
423
|
+
const hit = previewAt(state.sessions, machine, slot, knownMachines())
|
|
424
|
+
if (!hit) return toast('That preview belongs to a codebase that is not open on this computer. Open the codebase, then its preview.')
|
|
425
|
+
state.openPreview = { id: hit.session, preview: hit.preview, branch: hit.branch }
|
|
426
|
+
await go(hit.session)
|
|
427
|
+
}
|
|
428
|
+
|
|
417
429
|
async function openInviteLink (link) {
|
|
418
430
|
document.querySelectorAll('.modal-back').forEach((m) => m.remove())
|
|
419
431
|
const room = decodeInvite(link)?.room
|
package/src/ui/preview-page.js
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
// page. An app's preview runs on the codebase's cloud machine only while someone has it open:
|
|
3
3
|
// this page says it is open (and on which branch) while it shows, the machine starts that
|
|
4
4
|
// branch's app, and the page frames it at its address once it is up. A link is an address to open.
|
|
5
|
-
import { I, esc, avatar, api, toast, ask } from './common.js'
|
|
6
|
-
import { quiltBlock } from './project-model.js'
|
|
5
|
+
import { I, esc, avatar, api, toast, ask, remember, recall } from './common.js'
|
|
6
|
+
import { quiltBlock, knownMachine } from './project-model.js'
|
|
7
7
|
|
|
8
8
|
// The app keeps saying "still open" this often; the machine sleeps ten minutes after it stops.
|
|
9
9
|
const KEEP_OPEN_MS = 60 * 1000
|
|
10
10
|
const BRANCH = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="6" cy="5" r="2.5"/><circle cx="6" cy="19" r="2.5"/><circle cx="18" cy="8" r="2.5"/><path d="M6 7.5v9M18 10.5c0 4-6 3-6 6"/></svg>'
|
|
11
11
|
|
|
12
|
+
/** The preview machines this computer has opened: machine -> the room of the codebase it previews. */
|
|
13
|
+
export function knownMachines () {
|
|
14
|
+
try { const k = JSON.parse(recall('preview-machines', '{}')); return k && typeof k === 'object' && !Array.isArray(k) ? k : {} } catch { return {} }
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
/** Whether an app's preview is running for anyone: a dot on its row. */
|
|
13
18
|
export const previewRunning = (p) => p.kind === 'app' && (p.running || []).some((r) => r.state !== 'failed')
|
|
14
19
|
|
|
@@ -58,6 +63,8 @@ export function mountPreview (el, { session, id, status, code = '', saved = () =
|
|
|
58
63
|
if (dead || asked !== want) return
|
|
59
64
|
open = r.open
|
|
60
65
|
failed = ''
|
|
66
|
+
// Which codebase this machine previews, kept: its address opened in a browser leads back here (app.js).
|
|
67
|
+
if (open && open.machine) remember('preview-machines', JSON.stringify(knownMachine(knownMachines(), open.machine, status().room)))
|
|
61
68
|
} catch (err) {
|
|
62
69
|
if (dead || asked !== want) return
|
|
63
70
|
failed = err.message || 'The preview could not be opened.'
|
|
@@ -75,7 +82,7 @@ export function mountPreview (el, { session, id, status, code = '', saved = () =
|
|
|
75
82
|
const edit = mayEdit() ? `<button type="button" class="btn sm ghost icon" data-pv-edit title="Change or remove this preview" aria-label="Change or remove this preview">${I.pencil}</button>` : ''
|
|
76
83
|
const title = `<h2 class="crumbs">${esc(code)}<span class="sep">/</span>${esc(p.name)}</h2>`
|
|
77
84
|
if (p.kind === 'link') {
|
|
78
|
-
return `<div class="files-head pv-head">${quiltBlock(code)}
|
|
85
|
+
return `<div class="files-head pv-head">${quiltBlock(code)}${title}<p class="hint pv-state">${I.link}<span>A link</span><span class="more"> · ${esc(p.url)}</span></p><span class="spacer"></span>${edit}</div>`
|
|
79
86
|
}
|
|
80
87
|
const list = branches()
|
|
81
88
|
const at = branch()
|
|
@@ -87,8 +94,10 @@ export function mountPreview (el, { session, id, status, code = '', saved = () =
|
|
|
87
94
|
const word = failed ? 'Not running' : r && r.state === 'running' ? 'Running' : r && r.state === 'failed' ? 'It did not start' : 'Starting'
|
|
88
95
|
const opt = (b) => { const w = others.filter((l) => l.branch === b.key).map((l) => l.name); return `<option value="${esc(b.key)}"${b.key === at ? ' selected' : ''}>${esc(branchLabel(b))}${w.length ? ` · ${esc(w.join(', '))}` : ''}</option>` }
|
|
89
96
|
const up = r && r.state === 'running' && open
|
|
90
|
-
|
|
97
|
+
// One line: what it is, the branch you are on, how that branch's app stands, who else is here.
|
|
98
|
+
return `<div class="files-head pv-head">${quiltBlock(code)}${title}
|
|
91
99
|
<label class="pv-pick" title="The branch this preview shows you. Each person picks their own.">${BRANCH}<select data-pv-branch aria-label="Branch to preview">${list.map(opt).join('')}</select></label>
|
|
100
|
+
<p class="hint pv-state" title="It runs only while someone has it open."><span class="pv-run${word === 'Running' ? ' on' : ''}"></span><span>${word}</span>${who ? `<span class="more"> · ${esc(who)}</span>` : ''}</p>
|
|
92
101
|
<span class="spacer"></span>
|
|
93
102
|
${here.length ? `<span class="pj-faces sm" title="${esc(who)}">${here.map((n) => avatar(n)).join('')}</span>` : ''}
|
|
94
103
|
<button type="button" class="btn sm ghost icon" data-pv-reload title="Reload" aria-label="Reload"${up ? '' : ' disabled'}>${I.refresh}</button><button type="button" class="btn sm ghost icon" data-pv-out title="Open in your browser" aria-label="Open in your browser"${up ? '' : ' disabled'}>${I.external}</button>${edit}</div>`
|
|
@@ -126,7 +135,8 @@ export function mountPreview (el, { session, id, status, code = '', saved = () =
|
|
|
126
135
|
? f('Address', `<input class="input mono" name="url" type="url" required spellcheck="false" placeholder="https://" value="${v(p && p.url)}">`)
|
|
127
136
|
: f('Command', `<input class="input mono" name="command" maxlength="300" spellcheck="false" placeholder="npm run dev" value="${v(p && p.command)}">`, 'Left empty, it is the codebase\'s dev script. It is run on a cloud machine, on the branch each person picks.') +
|
|
128
137
|
f('Folder', `<input class="input mono" name="folder" spellcheck="false" placeholder="The codebase's own folder" value="${v(p && p.folder)}">`, 'Where the command is run, for an app that lives in a folder of the codebase.') +
|
|
129
|
-
f('Port', `<input class="input mono" name="port" inputmode="numeric" pattern="[0-9]*" placeholder="Found by itself" value="${v(p && p.port)}">`, 'Only when the app opens another port than the one it is given (PORT) and does not print its address.')
|
|
138
|
+
f('Port', `<input class="input mono" name="port" inputmode="numeric" pattern="[0-9]*" placeholder="Found by itself" value="${v(p && p.port)}">`, 'Only when the app opens another port than the one it is given (PORT) and does not print its address.') +
|
|
139
|
+
f('Values', `<textarea class="input mono pv-values" name="values" rows="5" spellcheck="false" autocapitalize="off" autocomplete="off" placeholder="API_URL=https://api.example.com">${esc(Object.entries((p && p.env) || {}).map(([n, x]) => `${n}=${x}`).join('\n'))}</textarea>`, 'Settings the app is started with, one a line as NAME=value. Everyone in this codebase can read them, so never a password or a secret key.')}
|
|
130
140
|
<span class="hint warn" data-pv-warn hidden></span>
|
|
131
141
|
<div class="pv-form-foot"><button type="submit" class="btn primary">${p ? 'Save' : 'Add preview'}</button><button type="button" class="btn ghost" data-pv-cancel>Cancel</button><span class="spacer"></span>${p ? `<button type="button" class="btn danger" data-pv-remove>${I.trash}<span>Remove</span></button>` : ''}</div>
|
|
132
142
|
</form>`
|
|
@@ -204,7 +214,7 @@ export function mountPreview (el, { session, id, status, code = '', saved = () =
|
|
|
204
214
|
const p = def()
|
|
205
215
|
const get = (n) => form.elements[n] ? form.elements[n].value.trim() : undefined
|
|
206
216
|
const k = p ? p.kind : kind
|
|
207
|
-
const body = { ...(p ? { id: p.id } : { kind: k }), name: get('name'), ...(k === 'link' ? { url: get('url') } : { command: get('command'), folder: get('folder'), port: Number(get('port')) || 0 }) }
|
|
217
|
+
const body = { ...(p ? { id: p.id } : { kind: k }), name: get('name'), ...(k === 'link' ? { url: get('url') } : { command: get('command'), folder: get('folder'), port: Number(get('port')) || 0, values: get('values') }) }
|
|
208
218
|
const warn = form.querySelector('[data-pv-warn]')
|
|
209
219
|
try {
|
|
210
220
|
const r = await post('/previews', body)
|
package/src/ui/project-model.js
CHANGED
|
@@ -59,6 +59,50 @@ export function looseCodebases ({ sessions = new Map(), recent = [], projects =
|
|
|
59
59
|
return [...open, ...here]
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The codebases in the menu on a codebase's header: the ones in the same project as the open one
|
|
64
|
+
* (or, for a codebase in no project, the others in none), never another project's. `view`: the
|
|
65
|
+
* open codebase's id. Answers { project (null in none), open (running here), earlier (on this
|
|
66
|
+
* computer, not open) }.
|
|
67
|
+
*/
|
|
68
|
+
export function menuCodebases ({ sessions = new Map(), recent = [], projects = [], view = '' } = {}) {
|
|
69
|
+
const known = new Map(projects.map((w) => [w.id, w]))
|
|
70
|
+
const place = (ws) => (ws && known.has(ws) ? ws : '')
|
|
71
|
+
const here = place(sessions.get(view)?.workspace)
|
|
72
|
+
const open = [...sessions.values()].filter((s) => place(s.workspace) === here)
|
|
73
|
+
const dirs = new Set([...sessions.values()].map((s) => s.dir))
|
|
74
|
+
const earlier = recent.filter((r) => !r.unsupported && !dirs.has(r.dir) && place(r.workspace) === here)
|
|
75
|
+
return { project: known.get(here) || null, open, earlier }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The preview a machine's address belongs to, among the codebases open here: the app running in
|
|
80
|
+
* that slot ({ session, preview, branch }); when nothing runs there now, the first app preview of
|
|
81
|
+
* the codebase that machine previews (by anything it runs, or `known`: machine -> the codebase's
|
|
82
|
+
* room, kept as previews are opened); null when none of them is that machine's.
|
|
83
|
+
*/
|
|
84
|
+
export function previewAt (sessions = new Map(), machine = '', slot = 0, known = {}) {
|
|
85
|
+
const all = [...sessions.values()].map((s) => ({ s, previews: s.status?.previews || [] }))
|
|
86
|
+
for (const { s, previews } of all) {
|
|
87
|
+
for (const p of previews) {
|
|
88
|
+
const r = (p.running || []).find((x) => x.machine === machine && x.slot === slot)
|
|
89
|
+
if (r) return { session: s.id, preview: p.id, branch: r.branch }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const { s, previews } of all) {
|
|
93
|
+
const its = previews.some((p) => (p.running || []).some((x) => x.machine === machine)) || (!!known[machine] && known[machine] === s.status?.room)
|
|
94
|
+
const first = its && previews.find((p) => p.kind === 'app')
|
|
95
|
+
if (first) return { session: s.id, preview: first.id, branch: '' }
|
|
96
|
+
}
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** `known` with `machine` now the one that previews `room`: the latest twenty are kept. */
|
|
101
|
+
export function knownMachine (known = {}, machine = '', room = '') {
|
|
102
|
+
if (!machine || !room) return known
|
|
103
|
+
return Object.fromEntries([...Object.entries(known).filter(([m]) => m !== machine), [machine, room]].slice(-20))
|
|
104
|
+
}
|
|
105
|
+
|
|
62
106
|
/** Who is in a codebase, in a few words: "Brandon and Lin are here", "just you", "not on this computer yet". */
|
|
63
107
|
export function whoLine (c, ago = () => '') {
|
|
64
108
|
if (c.where === 'away') return 'not on this computer yet'
|
package/src/ui/projects.js
CHANGED
|
@@ -29,8 +29,38 @@ const foldedNow = () => (folded ||= readFolded(saved('quilt.sideFolded')))
|
|
|
29
29
|
/** Whether the sidebar of a project or a codebase is closed (one choice for both, kept on this computer). */
|
|
30
30
|
export const sideShut = () => saved('quilt.projectSide') === 'shut'
|
|
31
31
|
export const toggleSideShut = () => save('quilt.projectSide', sideShut() ? 'open' : 'shut')
|
|
32
|
+
/** Shows the sidebar closed or open, as it was just set: on the page's shell (`ws`), where it slides, and on its button. */
|
|
33
|
+
export function drawSideShut (ws) {
|
|
34
|
+
const shut = sideShut()
|
|
35
|
+
if (ws) ws.dataset.side = shut ? 'shut' : 'open'
|
|
36
|
+
const b = $('#pj-side-btn')
|
|
37
|
+
if (b) { b.setAttribute('aria-pressed', String(!shut)); b.title = `${shut ? 'Show' : 'Hide'} the sidebar`; b.setAttribute('aria-label', b.title) }
|
|
38
|
+
}
|
|
32
39
|
/** Folds or unfolds one of the sidebar's sections. */
|
|
33
40
|
export function toggleFolded (k) { const f = foldedNow(); f.has(k) ? f.delete(k) : f.add(k); save('quilt.sideFolded', JSON.stringify([...f])) }
|
|
41
|
+
/**
|
|
42
|
+
* Folds or opens a section of the sidebar, its rows sliding shut or open. `redraw` draws the
|
|
43
|
+
* sidebar again; a section's rows are the element after its label, before and after.
|
|
44
|
+
*/
|
|
45
|
+
export function foldSection (key, redraw) {
|
|
46
|
+
const rows = () => [...document.querySelectorAll('.pj-side [data-fold]')].find((b) => b.dataset.fold === key)?.closest('.pj-side-label')?.nextElementSibling
|
|
47
|
+
const was = rows()
|
|
48
|
+
const from = was ? was.offsetHeight : 0
|
|
49
|
+
const ghost = was ? was.cloneNode(true) : null
|
|
50
|
+
toggleFolded(key)
|
|
51
|
+
redraw()
|
|
52
|
+
const now = rows()
|
|
53
|
+
if (!now || !now.animate || window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return
|
|
54
|
+
const to = now.offsetHeight
|
|
55
|
+
if (from === to) return
|
|
56
|
+
// Opening uncovers the new rows. Folding covers the rows that were there (a copy nobody can press), then they are gone.
|
|
57
|
+
const el = to > from || !ghost ? now : ghost
|
|
58
|
+
if (el === ghost) { ghost.inert = true; ghost.setAttribute('aria-hidden', 'true'); now.before(ghost); now.hidden = true }
|
|
59
|
+
el.classList.add('folding')
|
|
60
|
+
const done = () => { el.classList.remove('folding'); if (el === ghost) { ghost.remove(); now.hidden = false } }
|
|
61
|
+
const slide = el.animate([{ height: `${from}px` }, { height: `${to}px` }], { duration: 180, easing: 'cubic-bezier(.3, .7, .2, 1)' })
|
|
62
|
+
slide.onfinish = slide.oncancel = done
|
|
63
|
+
}
|
|
34
64
|
|
|
35
65
|
/** The project a view shows, as the list of projects has it; null on Home. */
|
|
36
66
|
const projectOfView = (view) => /^(ws|wsfiles):/.test(view) ? (state.workspaces || []).find((w) => w.id === wsIdOf(view)) || { id: wsIdOf(view), name: '', color: '' } : null
|
|
@@ -395,7 +425,7 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
|
|
|
395
425
|
if (!p) return
|
|
396
426
|
// The sidebar: its pages, closing it, folding a section.
|
|
397
427
|
const side = $('#pj-side-btn')
|
|
398
|
-
if (side) side.onclick = () => { toggleSideShut();
|
|
428
|
+
if (side) side.onclick = () => { toggleSideShut(); drawSideShut(root) }
|
|
399
429
|
root.querySelectorAll('[data-page]').forEach((b) => {
|
|
400
430
|
b.onclick = () => {
|
|
401
431
|
const page = b.dataset.page
|
|
@@ -405,7 +435,7 @@ export function bindProjectShell (view, { go, rerender, newSessionDialog, joinSe
|
|
|
405
435
|
}
|
|
406
436
|
})
|
|
407
437
|
root.querySelectorAll('[data-fold]').forEach((b) => {
|
|
408
|
-
b.onclick = () =>
|
|
438
|
+
b.onclick = () => foldSection(b.dataset.fold, rerender)
|
|
409
439
|
})
|
|
410
440
|
// Team and Invite open the project's own pop-up on People.
|
|
411
441
|
root.querySelector('[data-team]')?.addEventListener('click', () => openProjectPop({ id: p.id, section: 'people' }))
|
package/src/ui/session.js
CHANGED
|
@@ -27,7 +27,7 @@ import { sessionAgentsHtml } from './agent-place.js'
|
|
|
27
27
|
import { renderCatchUp, bindCatchUp } from './catchup.js'
|
|
28
28
|
import { heldCard } from './session-words.js'
|
|
29
29
|
import { callButtonMarkup, callPinMarkup, screenStageMarkup, mountCall, unmountCall, renderCall, callCards, callCounts, callScope } from './voice.js'
|
|
30
|
-
import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut,
|
|
30
|
+
import { codeSideHtml, codeCrumbHtml, sideShut, toggleSideShut, drawSideShut, foldSection } from './projects.js'
|
|
31
31
|
import { mountPreview } from './preview-page.js'
|
|
32
32
|
import { dmThreads } from './project-model.js'
|
|
33
33
|
|
|
@@ -110,9 +110,14 @@ export function mountSession (id) {
|
|
|
110
110
|
current = id
|
|
111
111
|
// Opened from a channel or a direct message in the project's sidebar: on its chat.
|
|
112
112
|
if (state.openChat === id) { ws(id).side = 'chat'; state.openChat = null }
|
|
113
|
-
// Opened from a preview's row under the codebase in the project's sidebar: on that preview.
|
|
113
|
+
// Opened from a preview's row under the codebase in the project's sidebar: on that preview. From a
|
|
114
|
+
// preview's address (app.js openPreviewLink): on the branch that address shows, too.
|
|
114
115
|
// A preview left open when the codebase was last on screen is not opened again by itself: opening one starts a machine.
|
|
115
|
-
if (state.openPreview && state.openPreview.id === id) {
|
|
116
|
+
if (state.openPreview && state.openPreview.id === id) {
|
|
117
|
+
if (state.openPreview.branch) { if (!pvPick.has(id)) pvPick.set(id, {}); pvPick.get(id)[state.openPreview.preview] = state.openPreview.branch }
|
|
118
|
+
ws(id).side = `preview:${state.openPreview.preview}`
|
|
119
|
+
state.openPreview = null
|
|
120
|
+
} else if (String(ws(id).side || '').startsWith('preview:')) ws(id).side = ''
|
|
116
121
|
pendingAssign = null
|
|
117
122
|
resetLoom()
|
|
118
123
|
boardQuery = '' // a search is for the board it was typed on
|
|
@@ -511,7 +516,7 @@ function bindCodeSide () {
|
|
|
511
516
|
// The channel is for everyone; a direct message's row is that person alone.
|
|
512
517
|
if (b.dataset.dm !== undefined) { state.to = b.dataset.dm; showCodePage('chat'); renderRecipients(); updatePlaceholder(); return renderCodeSide() }
|
|
513
518
|
if (b.dataset.codePage) return showCodePage(b.dataset.codePage)
|
|
514
|
-
if (b.dataset.fold)
|
|
519
|
+
if (b.dataset.fold) return foldSection(b.dataset.fold, renderCodeSide)
|
|
515
520
|
if (b.dataset.go) return go(b.dataset.go)
|
|
516
521
|
if (b.hasAttribute('data-code-team')) { e.stopPropagation(); return $('#people-btn').click() }
|
|
517
522
|
if (b.hasAttribute('data-code-invite')) return openInvite(current)
|
|
@@ -520,7 +525,7 @@ function bindCodeSide () {
|
|
|
520
525
|
const b = e.target.closest('button')
|
|
521
526
|
if (!b) return
|
|
522
527
|
if (b.dataset.go) return go(b.dataset.go)
|
|
523
|
-
if (b.id === 'pj-side-btn') { toggleSideShut(); $('#ws')
|
|
528
|
+
if (b.id === 'pj-side-btn') { toggleSideShut(); drawSideShut($('#ws')); renderCodeSide() }
|
|
524
529
|
}, { signal: mounted.signal })
|
|
525
530
|
}
|
|
526
531
|
|
package/src/ui-server.js
CHANGED
|
@@ -27,6 +27,7 @@ import { aiName } from './persona.js'
|
|
|
27
27
|
import { effectiveAccess, builtinType } from './session-access.js'
|
|
28
28
|
import { cleanSessionName, BAD_SESSION_NAME, SESSION_NAME_MAX } from './session-name.js'
|
|
29
29
|
import { personPasses, personApiAuth } from './pass-source.js'
|
|
30
|
+
import { envFromText } from './previews.js'
|
|
30
31
|
import { INVALID_INVITE, NO_LINK_YET, joinFolderName } from './ui/invite.js'
|
|
31
32
|
import { loadIdentity } from './identity.js'
|
|
32
33
|
import { currentVersion, localReleases, latestRelease, compareVersions, downloadUrl, seenVersion, markSeen, hiddenUpdate, hideUpdate } from './releases.js'
|
|
@@ -1230,7 +1231,7 @@ export async function startUi ({ port = 7420, onShutdown, preview = false, repor
|
|
|
1230
1231
|
// and say which one this window has open, on which branch (`id` null: none). For an app that is also told to the
|
|
1231
1232
|
// accounts API, which makes or wakes the codebase's preview machine and answers with where it is and a ticket;
|
|
1232
1233
|
// the window asks again each minute while the preview stays open.
|
|
1233
|
-
'POST /api/sessions/:id/previews': (b, id) => withStatus(id, { preview: get(id).savePreview({ ...(b.id ? { id: String(b.id) } : {}), ...(b.name !== undefined ? { name: b.name } : {}), ...(b.kind !== undefined ? { kind: b.kind } : {}), ...(b.command !== undefined ? { command: b.command } : {}), ...(b.folder !== undefined ? { folder: b.folder } : {}), ...(b.port !== undefined ? { port: Number(b.port) || 0 } : {}), ...(b.url !== undefined ? { url: b.url } : {}) }) }),
|
|
1234
|
+
'POST /api/sessions/:id/previews': (b, id) => withStatus(id, { preview: get(id).savePreview({ ...(b.id ? { id: String(b.id) } : {}), ...(b.name !== undefined ? { name: b.name } : {}), ...(b.kind !== undefined ? { kind: b.kind } : {}), ...(b.command !== undefined ? { command: b.command } : {}), ...(b.folder !== undefined ? { folder: b.folder } : {}), ...(b.port !== undefined ? { port: Number(b.port) || 0 } : {}), ...(b.url !== undefined ? { url: b.url } : {}), ...(b.values !== undefined ? { env: envFromText(b.values) } : {}) }) }),
|
|
1234
1235
|
'POST /api/sessions/:id/previews/remove': (b, id) => withStatus(id, { ok: get(id).removePreview(String(b.id || '')) }),
|
|
1235
1236
|
'POST /api/sessions/:id/previews/open': async (b, id) => {
|
|
1236
1237
|
const s = get(id)
|