heyquilt 0.3.190 → 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 CHANGED
@@ -11,6 +11,10 @@ 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
+
14
18
  ## 0.3.190 — 2026-11-23
15
19
 
16
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.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyquilt",
3
- "version": "0.3.190",
3
+ "version": "0.3.191",
4
4
  "description": "Real-time, tool-agnostic pair vibe coding: sync a project folder live between collaborators using any AI coding tool.",
5
5
  "author": {
6
6
  "name": "Daniel Carmichael",
@@ -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).
@@ -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) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[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
- export const NOT_ALLOWED = 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>')
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, NOT_ALLOWED)
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/ui/app.js CHANGED
@@ -9,7 +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 } from './project-model.js'
12
+ import { menuCodebases, previewAt } from './project-model.js'
13
+ import { knownMachines } from './preview-page.js'
13
14
  import { openNewProject } from './project-pop.js'
14
15
  import { previewBusy } from './files.js'
15
16
  import { agentPaste, NO_LINK_YET } from './invite.js'
@@ -67,7 +68,7 @@ async function boot () {
67
68
  render()
68
69
  pollWorkspace()
69
70
  // Invite links that opened the desktop app wait until you're signed in.
70
- 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) }
71
72
  // Is a newer Quilt out, and has this version's "what's new" been shown? Never blocks the app.
72
73
  checkRelease()
73
74
  } catch (err) {
@@ -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
@@ -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,6 +75,34 @@ export function menuCodebases ({ sessions = new Map(), recent = [], projects = [
75
75
  return { project: known.get(here) || null, open, earlier }
76
76
  }
77
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
+
78
106
  /** Who is in a codebase, in a few words: "Brandon and Lin are here", "just you", "not on this computer yet". */
79
107
  export function whoLine (c, ago = () => '') {
80
108
  if (c.where === 'away') return 'not on this computer yet'
package/src/ui/session.js CHANGED
@@ -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) { ws(id).side = `preview:${state.openPreview.preview}`; state.openPreview = null } else if (String(ws(id).side || '').startsWith('preview:')) ws(id).side = ''
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