heyquilt 0.3.182 → 0.3.183

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.
Files changed (122) hide show
  1. package/README.md +101 -97
  2. package/RELEASES.md +8 -0
  3. package/bin/quilt.js +32 -32
  4. package/desktop/main.js +1 -1
  5. package/package.json +1 -1
  6. package/src/account.js +2 -2
  7. package/src/admit-policy.js +2 -2
  8. package/src/agent-join.js +3 -3
  9. package/src/agent-task-workflow.js +14 -14
  10. package/src/ai-vm.js +1 -1
  11. package/src/api/agent-placement.js +2 -2
  12. package/src/api/audit.js +1 -1
  13. package/src/api/file-paths.js +1 -1
  14. package/src/api/file-store.js +1 -1
  15. package/src/api/invite-email.js +4 -4
  16. package/src/api/join-text.js +5 -5
  17. package/src/api/notify.js +7 -7
  18. package/src/api/permissions.js +1 -1
  19. package/src/api/routes/agent-wake.js +1 -1
  20. package/src/api/routes/agents.js +2 -2
  21. package/src/api/routes/ai-vm.js +5 -5
  22. package/src/api/routes/connections.js +13 -13
  23. package/src/api/routes/grants.js +2 -2
  24. package/src/api/routes/mail.js +10 -10
  25. package/src/api/routes/relay.js +1 -1
  26. package/src/api/routes/secrets.js +11 -11
  27. package/src/api/routes/session-invites.js +5 -5
  28. package/src/api/routes/sessions.js +3 -3
  29. package/src/api/routes/workspace-agents.js +14 -14
  30. package/src/api/routes/workspace-files.js +12 -12
  31. package/src/api/routes/workspace-invites.js +5 -5
  32. package/src/api/routes/workspaces.js +11 -11
  33. package/src/api/secrets-access.js +1 -1
  34. package/src/api/server.js +3 -3
  35. package/src/api/team-access.js +1 -1
  36. package/src/api/workspace-access.js +1 -1
  37. package/src/api/workspace-reach.js +3 -3
  38. package/src/app-tools.js +10 -10
  39. package/src/autowork.js +4 -4
  40. package/src/branch-view.js +1 -1
  41. package/src/catchup.js +5 -5
  42. package/src/chat-links.js +18 -18
  43. package/src/connection.js +11 -11
  44. package/src/control.js +5 -5
  45. package/src/conversation.js +1 -1
  46. package/src/doctor.js +2 -2
  47. package/src/duties.js +1 -1
  48. package/src/fsutil.js +1 -1
  49. package/src/held.js +4 -4
  50. package/src/hooks.js +3 -3
  51. package/src/hosted-client.js +2 -2
  52. package/src/identity.js +1 -1
  53. package/src/inbox.js +1 -1
  54. package/src/key-cli.js +1 -1
  55. package/src/mail-tools.js +11 -11
  56. package/src/mcp-proxy.js +1 -1
  57. package/src/mcp.js +59 -59
  58. package/src/new-session.js +6 -6
  59. package/src/project-rules.js +2 -2
  60. package/src/relay-ask.js +2 -2
  61. package/src/relay-cluster.js +3 -3
  62. package/src/relay-live-write.js +3 -3
  63. package/src/relay-mcp.js +56 -56
  64. package/src/relay-prune.js +1 -1
  65. package/src/relay-turn-sync.js +1 -1
  66. package/src/secret-import.js +1 -1
  67. package/src/secret-names.js +6 -6
  68. package/src/secret-run.js +3 -3
  69. package/src/server.js +41 -41
  70. package/src/session-access.js +3 -3
  71. package/src/session-name.js +1 -1
  72. package/src/session.js +50 -50
  73. package/src/setup.js +7 -7
  74. package/src/status.js +2 -2
  75. package/src/tasks.js +1 -1
  76. package/src/turn-sync.js +4 -4
  77. package/src/ui/account-sessions.js +2 -2
  78. package/src/ui/agent-env-key.js +1 -1
  79. package/src/ui/agent-guide.js +35 -35
  80. package/src/ui/agent-kinds.js +8 -8
  81. package/src/ui/agent-place.js +16 -16
  82. package/src/ui/agents-table.js +6 -6
  83. package/src/ui/app.css +331 -0
  84. package/src/ui/app.js +28 -13
  85. package/src/ui/board.js +2 -2
  86. package/src/ui/catchup.js +5 -5
  87. package/src/ui/changes-seen.js +2 -2
  88. package/src/ui/changes.js +3 -3
  89. package/src/ui/cloud-ai.js +12 -12
  90. package/src/ui/common.js +1 -1
  91. package/src/ui/connections.js +1 -1
  92. package/src/ui/diffview.js +2 -2
  93. package/src/ui/feed.js +1 -1
  94. package/src/ui/feedback.js +4 -4
  95. package/src/ui/files.js +120 -14
  96. package/src/ui/fileview.js +3 -3
  97. package/src/ui/git-rule.js +3 -3
  98. package/src/ui/home.js +92 -47
  99. package/src/ui/index.html +1 -1
  100. package/src/ui/invite.js +8 -8
  101. package/src/ui/invites.js +3 -3
  102. package/src/ui/new-session.js +3 -3
  103. package/src/ui/prail-model.js +22 -0
  104. package/src/ui/prail.js +43 -0
  105. package/src/ui/project-board.js +359 -0
  106. package/src/ui/project-model.js +197 -0
  107. package/src/ui/project-pop.js +451 -0
  108. package/src/ui/projects.js +406 -0
  109. package/src/ui/sandbox-keys.js +3 -3
  110. package/src/ui/secrets-view.js +5 -5
  111. package/src/ui/session-words.js +2 -2
  112. package/src/ui/session.js +156 -43
  113. package/src/ui/tree.js +3 -3
  114. package/src/ui/voice.js +6 -6
  115. package/src/ui/workspaces.js +23 -23
  116. package/src/ui-server.js +78 -24
  117. package/src/update-check.js +2 -2
  118. package/src/voice.js +7 -7
  119. package/src/wake-tool.js +1 -1
  120. package/src/webhooks.js +1 -1
  121. package/src/workspace-cli.js +12 -12
  122. package/src/workspace-tools.js +33 -33
@@ -7,11 +7,11 @@ import { I, state, $, esc, toast, api, loadingNote } from './common.js'
7
7
  import { toolLogo } from './tool-logo.js'
8
8
  import { CLOUD_TOOLS, cloudTool, cloudPhase, cloudStatus, signInSteps, cloudUsage, shortTokens } from './cloud-ai-model.js'
9
9
 
10
- const STEPS = ['Name', 'AI tool', 'What it does', 'Sessions', 'Sign in']
10
+ const STEPS = ['Name', 'AI tool', 'What it does', 'Codebases', 'Sign in']
11
11
  export const AI_COLORS = ['#2e7a80', '#4f4fa0', '#4a7a45', '#855a9c', '#a8701c', '#9c4f6b', '#3b6a9a']
12
12
  const NAMES = ['Juniper', 'Atlas', 'Wren', 'Moss', 'Pilot']
13
13
  const TASKS = [['asked', 'When asked'], ['mine', 'Assigned to it'], ['any', 'Any open task']]
14
- const SESSIONS = [['every', 'Every session I join'], ['pick', 'Only the ones I pick'], ['none', 'None for now']]
14
+ const SESSIONS = [['every', 'Every codebase I join'], ['pick', 'Only the ones I pick'], ['none', 'None for now']]
15
15
  const LIMITS = [[0, 'No limit'], [1e6, '1 million tokens'], [2e6, '2 million tokens'], [5e6, '5 million tokens'], [1e7, '10 million tokens']]
16
16
  const NAME_OK = /^[\p{L}\p{N}][\p{L}\p{N} .'’-]{0,39}$/u
17
17
 
@@ -74,7 +74,7 @@ export function cloudAiCardHtml () {
74
74
  function inviteHtml (ui) {
75
75
  return `<div class="ai-invite">
76
76
  <div class="ai-patch" aria-hidden="true">${I.plus}</div>
77
- <div><h2>Give your AI a seat in your sessions</h2><p>An AI of yours on its own cloud machine. People write to it by name, and it keeps working when your computer is closed.</p></div>
77
+ <div><h2>Give your AI a seat in your codebases</h2><p>An AI of yours on its own cloud machine. People write to it by name, and it keeps working when your computer is closed.</p></div>
78
78
  <div class="ai-facts">
79
79
  <div class="ai-fact"><i>${I.chat}</i><div><b>Answers for you</b><span>@mentions and messages for your AI.</span></div></div>
80
80
  <div class="ai-fact"><i>${I.board}</i><div><b>Takes tasks you allow</b><span>Each on a branch of its own.</span></div></div>
@@ -106,7 +106,7 @@ function doesHtml (d, name) {
106
106
  <div class="ai-row"><i>${I.chat}</i><div><b>Answer people who write to it</b><span class="hint">@mentions and direct messages for ${esc(name)}${name === own() ? '' : ` or ${esc(own())}`}.</span></div><span class="ai-always">Always</span></div>
107
107
  <div class="ai-row wide"><i>${I.board}</i><div><b>Pick up tasks from the board</b><span class="hint">When it finishes one, it starts the next.</span></div><div class="ctl">${seg(TASKS, d.tasks, 'data-ai-tasks')}</div></div>
108
108
  <div class="ai-row"><i>${I.branch}</i><div><b>Change files and push its own branches</b><span class="hint">Each task on a branch of its own with a pull request. A person merges it.</span></div>${sw(d.files, 'data-ai-files', 'Change files and push its own branches')}</div>
109
- <div class="ai-row"><i>${I.power}</i><div><b>Wake for every message</b><span class="hint">${d.wake ? 'A message to it wakes its machine within a minute.' : 'Messages wait until it next wakes: for a task, or when you work in one of its sessions.'}</span></div>${sw(d.wake, 'data-ai-wake', 'Wake for every message')}</div>
109
+ <div class="ai-row"><i>${I.power}</i><div><b>Wake for every message</b><span class="hint">${d.wake ? 'A message to it wakes its machine within a minute.' : 'Messages wait until it next wakes: for a task, or when you work in one of its codebases.'}</span></div>${sw(d.wake, 'data-ai-wake', 'Wake for every message')}</div>
110
110
  </div>`
111
111
  }
112
112
 
@@ -114,14 +114,14 @@ function readyHtml (vm, ui) {
114
114
  const u = cloudUsage(vm)
115
115
  const sleeping = ['suspended', 'stopped', 'failed'].includes(vm.state)
116
116
  const sessions = vm.sessions || []
117
- const where = { every: 'Joins every session you join', pick: 'Joins the sessions you picked', none: 'Joins no session for now' }[vm.sessionsMode || 'every']
117
+ const where = { every: 'Joins every codebase you join', pick: 'Joins the codebases you picked', none: 'Joins no codebase for now' }[vm.sessionsMode || 'every']
118
118
  return `<div class="sec-intro"><h2>Your AI</h2><p>On its own cloud machine. What people write to it, and the tasks you let it take, go here.</p></div>
119
119
  <div class="sec-body ai-run">
120
120
  ${aiCard({ name: vm.name, color: vm.color || AI_COLORS[0], tool: vm.tool, status: cloudStatus(vm) })}
121
121
  ${vm.state === 'failed' && vm.error ? `<p class="error">${esc(vm.error)}</p>` : ''}
122
- ${sleeping ? `<div class="ai-asleep"><span class="hint">${vm.state === 'suspended' ? 'Asleep while there is nothing to do. It wakes for a task, a message to it, or when you work in one of its sessions.' : 'Its machine stopped.'}</span><button class="btn sm" type="button" data-cloud-wake ${ui.busy === 'wake' ? 'disabled' : ''}>${vm.state === 'suspended' ? 'Wake now' : 'Start it again'}</button></div>` : ''}
122
+ ${sleeping ? `<div class="ai-asleep"><span class="hint">${vm.state === 'suspended' ? 'Asleep while there is nothing to do. It wakes for a task, a message to it, or when you work in one of its codebases.' : 'Its machine stopped.'}</span><button class="btn sm" type="button" data-cloud-wake ${ui.busy === 'wake' ? 'disabled' : ''}>${vm.state === 'suspended' ? 'Wake now' : 'Start it again'}</button></div>` : ''}
123
123
  <div class="ai-meters">
124
- <div title="${esc(where)}"><b>${sessions.length}</b><span>session${sessions.length === 1 ? '' : 's'}</span></div>
124
+ <div title="${esc(where)}"><b>${sessions.length}</b><span>codebase${sessions.length === 1 ? '' : 's'}</span></div>
125
125
  <div><b>${esc(u.tokens)}</b><span>tokens today${u.pct === null ? '' : `, ${u.pct}% of ${esc(u.cap)}`}</span></div>
126
126
  <div><b>${u.runs}</b><span>run${u.runs === 1 ? '' : 's'} today</span></div>
127
127
  </div>
@@ -163,17 +163,17 @@ function toolStep (d) {
163
163
  function doesStep (d) {
164
164
  return q(`What may ${esc(d.name)} do?`, `It always answers people who write to ${esc(at(d.name))}. The rest is up to you, and you can change it any time.`,
165
165
  `${doesHtml(d, d.name)}
166
- <div class="field ai-rules"><label for="ai-rules">House rules</label><textarea class="input" id="ai-rules" rows="3" maxlength="4000" data-ai-rules placeholder="Anything it should always do, or never do.">${esc(d.prompt)}</textarea><span class="hint">Read at the start of every run, on top of the project's own rules.</span></div>`)
166
+ <div class="field ai-rules"><label for="ai-rules">House rules</label><textarea class="input" id="ai-rules" rows="3" maxlength="4000" data-ai-rules placeholder="Anything it should always do, or never do.">${esc(d.prompt)}</textarea><span class="hint">Read at the start of every run, on top of the codebase's own rules.</span></div>`)
167
167
  }
168
168
 
169
169
  function sessionsStep (d) {
170
170
  const list = openSessions()
171
171
  const rows = list.length
172
172
  ? `<div class="ai-list">${list.map((s) => `<label class="ai-sess${d.sessionsMode === 'pick' ? '' : ' off'}"><input type="checkbox" data-ai-room="${esc(s.room)}" ${d.sessionsMode === 'every' || (d.sessionsMode === 'pick' && d.rooms.includes(s.room)) ? 'checked' : ''} ${d.sessionsMode === 'pick' ? '' : 'disabled'}><span><b>${esc(s.name)}</b><span class="hint">${esc(s.people.length > 1 ? s.people.join(', ') : 'Only you')}</span></span><span class="ai-faces">${s.people.slice(0, 5).map((n) => `<span class="avatar" title="${esc(n)}">${esc((n === 'You' ? person() : n)[0] || '')}</span>`).join('')}</span></label>`).join('')}</div>
173
- <p class="hint">${d.sessionsMode === 'every' ? 'And every session you open or join from now on.' : 'Sessions you open later: pick them here when you want it there.'}</p>`
174
- : `<p class="hint">${d.sessionsMode === 'every' ? 'No session is open on this computer now: it joins the ones you open or join from now on.' : 'No session is open on this computer now. Open one, then pick it here.'}</p>`
175
- return q(`Where does ${esc(d.name)} work?`, 'It joins sessions as you do, and stays in them when you close your computer.',
176
- `${seg(SESSIONS, d.sessionsMode, 'data-ai-sessions')}${d.sessionsMode === 'none' ? '<p class="hint">It joins no session until you pick some here.</p>' : rows}`)
173
+ <p class="hint">${d.sessionsMode === 'every' ? 'And every codebase you open or join from now on.' : 'Codebases you open later: pick them here when you want it there.'}</p>`
174
+ : `<p class="hint">${d.sessionsMode === 'every' ? 'No codebase is open on this computer now: it joins the ones you open or join from now on.' : 'No codebase is open on this computer now. Open one, then pick it here.'}</p>`
175
+ return q(`Where does ${esc(d.name)} work?`, 'It joins codebases as you do, and stays in them when you close your computer.',
176
+ `${seg(SESSIONS, d.sessionsMode, 'data-ai-sessions')}${d.sessionsMode === 'none' ? '<p class="hint">It joins no codebase until you pick some here.</p>' : rows}`)
177
177
  }
178
178
 
179
179
  function signInStep (vm, d) {
package/src/ui/common.js CHANGED
@@ -196,7 +196,7 @@ export async function api (method, path, body, headers = {}) {
196
196
  }
197
197
 
198
198
  // ------------------------------------------------------------ access types --
199
- export const NO_POSTING = "You can't post in this session."
199
+ export const NO_POSTING = "You can't post in this codebase."
200
200
  export const ACCOUNT_KEY = /^(person|agent):[A-Za-z0-9_-]{1,64}$/
201
201
 
202
202
  /** Loads this account's access types into state.accessTypes (null when the accounts API can't be reached). */
@@ -8,7 +8,7 @@ const SEARCH_ICON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
8
8
 
9
9
  const views = new Map() // `${type}:${id}` -> the last view, so a redraw shows it at once
10
10
  const urlOf = (type, id, rest = '') => `/api/connections/${type}/${encodeURIComponent(id)}${rest}`
11
- const LEVEL = { session: 'this session', workspace: 'the workspace', org: 'the team' }
11
+ const LEVEL = { session: 'this codebase', workspace: 'the project', org: 'the team' }
12
12
  const STATUS = { active: 'Connected', pending: 'Waiting for sign-in', failed: 'Didn\'t connect' }
13
13
  const SHOWN = 12
14
14
 
@@ -32,7 +32,7 @@ export const changeCount = (entries, summary) => entries.length + rolledOff(entr
32
32
  */
33
33
  export function historyMarkup (entries, { who = (n) => n, colorOf = () => null, summary = null } = {}) {
34
34
  const gone = rolledOff(entries, summary)
35
- if (!entries.length && !gone.length) return '<div class="fv-note">No changes to this file are kept. A session keeps its latest 2,000 changes, so older ones may have rolled off.</div>'
35
+ if (!entries.length && !gone.length) return '<div class="fv-note">No changes to this file are kept. A codebase keeps its latest 2,000 changes, so older ones may have rolled off.</div>'
36
36
  return entries.map((e) => {
37
37
  const span = e.from && e.ts - e.from > 60000 ? ` · over ${Math.round((e.ts - e.from) / 60000)}m` : ''
38
38
  const tag = e.pulled ? '<span class="chg-kind pulled">pulled from git</span>' : kindTag(e.kind)
@@ -58,7 +58,7 @@ function goneMarkup (gone, { who, colorOf, alone }) {
58
58
  <li>${avatar(b.name, colorFor(b.name, colorOf(b.name)))}<b>${esc(who(b.name))}</b>${b.pulled ? '<span class="chg-kind pulled">pulled from git</span>' : ''}
59
59
  <span class="hint">${esc(ago(b.ts))}</span><span class="spacer"></span><span class="chg-delta"><span class="add">+${b.added}</span> <span class="del">−${b.removed}</span></span></li>`).join('')}
60
60
  </ul>
61
- <p class="hint">Their line-by-line diff is no longer kept. A session keeps its latest 2,000 changes, and a big one, like moving many files, can push older ones out. The totals still count them.</p>
61
+ <p class="hint">Their line-by-line diff is no longer kept. A codebase keeps its latest 2,000 changes, and a big one, like moving many files, can push older ones out. The totals still count them.</p>
62
62
  </section>`
63
63
  }
64
64
 
package/src/ui/feed.js CHANGED
@@ -31,7 +31,7 @@ export function renderFeed (el, { entries, person, isMe, color, agent, online, c
31
31
  let title, hint
32
32
  if (!sharing) {
33
33
  title = isMe ? 'You paused sharing your AI chat' : `${person} paused sharing`
34
- hint = isMe ? 'Turn sharing back on in Session settings when you want partners to follow along.' : 'Their AI conversation shows up here when they resume.'
34
+ hint = isMe ? 'Turn sharing back on in Codebase settings when you want partners to follow along.' : 'Their AI conversation shows up here when they resume.'
35
35
  } else if (agent && agent.status === 'unavailable') {
36
36
  title = `${isMe ? 'Your' : `${person}'s`} ${agent.tool || 'AI'} feed isn't available`
37
37
  hint = agent.reason || ''
@@ -33,7 +33,7 @@ export function bindFeedback (root, opts = {}) {
33
33
 
34
34
  /** The sessions running in this app a form can file into: [{ id, name }]. */
35
35
  function sessionChoices () {
36
- return [...(state.sessions?.values?.() || [])].map((s) => ({ id: s.id, name: s.status?.sessionName || basename(s.dir || '') || 'Session' }))
36
+ return [...(state.sessions?.values?.() || [])].map((s) => ({ id: s.id, name: s.status?.sessionName || basename(s.dir || '') || 'Codebase' }))
37
37
  }
38
38
 
39
39
  /** Opens the form for `kind` ('bug' or 'feature'). Resolves with the task made, or null when closed. */
@@ -49,7 +49,7 @@ export function openFeedback (kind, { session = null, where = '', from = null }
49
49
  back.innerHTML = `<form class="card modal fb-form fb-form-${kind}" role="dialog" aria-modal="true" aria-labelledby="fb-title" autocomplete="off" novalidate>
50
50
  <h3 id="fb-title"><span class="fb-ico">${ICONS[kind]}</span>${esc(k.title)}</h3>
51
51
  <p class="lead">${esc(k.lead)}</p>
52
- ${choices.length > 1 ? `<div class="field"><label for="fb-session">Session</label><select class="input" id="fb-session" name="session">${choices.map((c) => `<option value="${esc(c.id)}">${esc(c.name)}</option>`).join('')}</select></div>` : ''}
52
+ ${choices.length > 1 ? `<div class="field"><label for="fb-session">Codebase</label><select class="input" id="fb-session" name="session">${choices.map((c) => `<option value="${esc(c.id)}">${esc(c.name)}</option>`).join('')}</select></div>` : ''}
53
53
  <div class="field"><label for="fb-summary">${esc(k.summary)}</label><input class="input" id="fb-summary" name="summary" maxlength="180" placeholder="${esc(k.summaryHint)}" required></div>
54
54
  <div class="field"><label for="fb-details">${esc(k.details)}</label><textarea class="input" id="fb-details" name="details" rows="5" placeholder="${esc(k.detailsHint)}"></textarea></div>
55
55
  ${k.shot ? `<div class="field fb-shot-field"><label for="fb-shot">Screenshot <span class="fb-opt">(optional)</span></label>
@@ -58,7 +58,7 @@ export function openFeedback (kind, { session = null, where = '', from = null }
58
58
  <div class="fb-drop-empty" id="fb-drop-empty"><button type="button" class="btn sm" id="fb-pick">Choose a picture</button><span>or paste or drop one here</span></div>
59
59
  <div class="fb-drop-full" id="fb-drop-full" hidden><img id="fb-shot-img" alt="The screenshot you attached"><span class="fb-shot-name" id="fb-shot-name"></span><button type="button" class="btn sm ghost" id="fb-shot-clear">Remove</button></div>
60
60
  </div></div>` : ''}
61
- ${none ? '<p class="note fb-none">Open a session first: what you send goes on its task board.</p>' : ''}
61
+ ${none ? '<p class="note fb-none">Open a codebase first: what you send goes on its task board.</p>' : ''}
62
62
  <p class="error" id="fb-error" role="alert"></p>
63
63
  <div class="actions"><button type="button" class="btn ghost" data-cancel>Cancel</button><button class="btn primary" type="submit" id="fb-send"${none ? ' disabled' : ''}>${esc(k.ok)}</button></div>
64
64
  </form>`
@@ -126,7 +126,7 @@ export function openFeedback (kind, { session = null, where = '', from = null }
126
126
  e.preventDefault()
127
127
  err.textContent = ''
128
128
  const sid = $f('#fb-session')?.value || target
129
- if (!sid) { err.textContent = 'Open a session first: what you send goes on its task board.'; return }
129
+ if (!sid) { err.textContent = 'Open a codebase first: what you send goes on its task board.'; return }
130
130
  const made = feedbackTask(kind, {
131
131
  summary: $f('#fb-summary').value,
132
132
  details: $f('#fb-details').value,
package/src/ui/files.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // thumbnails and previews stay same-origin under the page's CSP.
6
6
  import { I, state, esc, toast, api, ask, ago, bytes, TOKEN, loadingNote } from './common.js'
7
7
  import { parseCsv } from './csv.js'
8
- import { previewKind as viewKind, bytesPreviewHtml, prettyAndRawHtml, hydrate } from './preview.js'
8
+ import { previewKind as viewKind, bytesPreviewHtml, prettyAndRawHtml, hydrate, fallbackHtml } from './preview.js'
9
9
 
10
10
  const wsUrl = (id, rest = '') => `/api/workspaces/${encodeURIComponent(id)}${rest}`
11
11
  const fileUrl = (id, fid, rest = '') => wsUrl(id, '/files/' + encodeURIComponent(fid) + rest)
@@ -199,10 +199,10 @@ export function filesSectionHtml (d) {
199
199
  const empty = !root.length && !newest.length && !canEdit(d)
200
200
  return `
201
201
  <section class="sec files-sec" data-files-drop>
202
- <div class="sec-head"><h2>Files</h2><span class="count">${count}</span>${usage ? `<span class="hint">${esc(usage)}</span>` : ''}<span class="spacer"></span>
202
+ <div class="sec-head"><h2>Artifacts</h2><span class="count">${count}</span>${usage ? `<span class="hint">${esc(usage)}</span>` : ''}<span class="spacer"></span>
203
203
  ${canEdit(d) ? `<button type="button" class="btn sm ghost" data-new-folder>${I.plus}<span>New folder</span></button>` : ''}
204
- <a href="#" class="sec-link" data-all-files>All files ${I.caret}</a></div>
205
- ${empty ? '<p class="hint">No files yet.</p>' : `<div class="tiles">
204
+ <a href="#" class="sec-link" data-all-files>All artifacts ${I.caret}</a></div>
205
+ ${empty ? '<p class="hint">No artifacts yet.</p>' : `<div class="tiles">
206
206
  ${root.map((f) => folderTileHtml(d, f)).join('')}
207
207
  ${newest.map((f) => fileTileHtml(d, f, { meta: [whoOf(d, f.uploadedBy), when(f.uploadedAt)].filter(Boolean).join(' · ') })).join('')}
208
208
  ${canEdit(d) ? uploadTileHtml(d.workspace.id, 'Upload or drop files') : ''}
@@ -368,7 +368,7 @@ async function loadPreviewText (root, d, f) {
368
368
  markdownText.set(`${f.id}:${f.version}`, text)
369
369
  html = markdownPreview(f, text)
370
370
  } else {
371
- html = kind === 'csv' ? csvTableHtml(parseCsv(text, CSV_ROWS)) : `<pre class="fp-pre">${esc(text)}</pre>`
371
+ html = kind === 'csv' ? csvTableHtml(parseCsv(text, CSV_ROWS)) : box.hasAttribute('data-numbered') ? codeHtml(text) : `<pre class="fp-pre">${esc(text)}</pre>`
372
372
  previewCache.set(`${f.id}:${f.version}`, html)
373
373
  }
374
374
  } catch (err) {
@@ -427,7 +427,7 @@ export function allFilesHtml (d) {
427
427
  return `
428
428
  <a class="ws-back" href="#" data-ws-open="${esc(id)}">${I.caret} ${esc(d.workspace.name)}</a>
429
429
  <header class="files-head">
430
- <div class="t">${crumbsHtml(d, fv.folder)}<p class="hint">${esc(`${plural(here.length, 'file', 'files')} · ${bytes(here.reduce((n, f) => n + (f.size || 0), 0))}${usage ? ` · ${usage} in this workspace` : ''}`)}</p></div>
430
+ <div class="t">${crumbsHtml(d, fv.folder)}<p class="hint">${esc(`${plural(here.length, 'file', 'files')} · ${bytes(here.reduce((n, f) => n + (f.size || 0), 0))}${usage ? ` · ${usage} in this project` : ''}`)}</p></div>
431
431
  <span class="spacer"></span>
432
432
  <div class="segmented files-mode" role="tablist" aria-label="Show as">
433
433
  <button type="button" role="tab" data-files-mode="tiles" class="${fv.mode !== 'list' ? 'on' : ''}" aria-selected="${fv.mode !== 'list'}">Tiles</button>
@@ -442,12 +442,115 @@ export function allFilesHtml (d) {
442
442
  </div>`
443
443
  }
444
444
 
445
+ // ------------------------------------------------------------- Artifacts --
446
+ // A project's files as its Artifacts page (projects.js draws it in a project's sidebar shell):
447
+ // tiles or a list across the whole page, and an artifact that is open takes the page and is shown
448
+ // as what it is. An HTML one runs, sealed in a frame; Markdown is formatted; CSV and spreadsheets
449
+ // are tables; pictures, PDFs, Word files, video and audio show; code has line numbers; anything
450
+ // else gets its name, its size and a download.
451
+ const HTML_EXT = new Set(['html', 'htm'])
452
+ const isHtml = (f) => HTML_EXT.has(extOf(f.name))
453
+ const CODE_LINES = 5000
454
+
455
+ /** Text as numbered lines (the numbers are drawn by the stylesheet, so copying takes only the text). */
456
+ function codeHtml (text) {
457
+ const lines = String(text).replace(/\r\n?/g, '\n').replace(/\n$/, '').split('\n')
458
+ const shown = lines.slice(0, CODE_LINES)
459
+ return `<pre class="fp-pre art-code">${shown.map((l) => `<span class="cl">${esc(l) || ' '}</span>`).join('\n')}</pre>${lines.length > shown.length ? `<p class="hint">The first ${CODE_LINES} lines of ${lines.length}. Download it to see the rest.</p>` : ''}`
460
+ }
461
+
462
+ /** An open artifact, drawn as what it is. `source`: an HTML one as its text, not running. */
463
+ function artifactBodyHtml (d, f, source) {
464
+ const id = d.workspace.id
465
+ const kind = previewKind(f)
466
+ const text = (numbered) => (f.size || 0) > MAX_TEXT_PREVIEW ? '<p class="hint">Too big to show here; download it.</p>'
467
+ : `<div class="fp-text" data-preview-load="text"${numbered ? ' data-numbered' : ''}><p class="hint">${loadingNote()}</p></div>`
468
+ if (isHtml(f)) {
469
+ return source ? text(true)
470
+ // The answer it loads seals the page itself (ui-server.js serveSealed: `Content-Security-Policy: sandbox allow-scripts`), whatever frames it.
471
+ : `<iframe class="art-frame" title="${esc(f.name)}" referrerpolicy="no-referrer" data-sealed="${esc(f.id)}" data-version="${esc(f.version || 1)}"></iframe>`
472
+ }
473
+ if (kind === 'text') return text(true)
474
+ if (kind === 'none') return fallbackHtml({ name: f.name, size: f.size, href: dataUrl(id, f, '&download=1') })
475
+ return previewMediaHtml(d, f)
476
+ }
477
+
478
+ /** Gives each sealed frame its address: asked for with the page's token, loaded without it. One per version, kept while the page is redrawn. */
479
+ const sealedUrls = new Map() // `${fid}:${version}` -> { url, until }
480
+ function runSealedFrames (root, id) {
481
+ for (const frame of root.querySelectorAll('iframe[data-sealed]')) {
482
+ const key = `${frame.dataset.sealed}:${frame.dataset.version}`
483
+ const have = sealedUrls.get(key)
484
+ if (have && have.until > Date.now()) { frame.src = have.url; continue }
485
+ api('POST', fileUrl(id, frame.dataset.sealed, '/view'), { version: frame.dataset.version }).then((r) => {
486
+ sealedUrls.set(key, { url: r.url, until: Date.now() + 8 * 60 * 1000 })
487
+ if (frame.isConnected) frame.src = r.url
488
+ }).catch((err) => toast(err.message))
489
+ }
490
+ }
491
+
492
+ function artifactViewHtml (d, f) {
493
+ const edit = canEdit(d)
494
+ const html = isHtml(f)
495
+ const source = html && !!state.filesView.source
496
+ const who = whoOf(d, f.uploadedBy)
497
+ return `
498
+ <div class="art-view file-preview" aria-label="${esc(f.name)}">
499
+ <header class="art-bar">
500
+ <button type="button" class="btn sm ghost" data-close-preview title="Back to Artifacts">${I.arrowLeft}<span>Artifacts</span></button>
501
+ <span class="badge" style="background:${badgeColor(f)}">${esc(badgeText(f))}</span><b class="fp-name" title="${esc(f.path)}">${esc(f.name)}</b>
502
+ <span class="hint art-meta">${esc([bytes(f.size || 0), who, when(f.uploadedAt)].filter(Boolean).join(' · '))}</span>
503
+ <span class="spacer"></span>
504
+ ${html ? `<div class="segmented sm" role="tablist" aria-label="Show it running or as its source"><button type="button" role="tab" data-art-show="page" class="${source ? '' : 'on'}" aria-selected="${!source}">Preview</button><button type="button" role="tab" data-art-show="source" class="${source ? 'on' : ''}" aria-selected="${source}">Source</button></div>` : ''}
505
+ ${edit ? `<button class="btn sm ghost" data-rename>Rename</button><button class="btn sm ghost" data-move>Move</button><button class="btn sm ghost danger" data-delete>Delete</button>` : ''}
506
+ <a class="btn sm primary" download="${esc(f.name)}" href="${esc(dataUrl(d.workspace.id, f, '&download=1'))}">${I.down}<span>Download</span></a>
507
+ </header>
508
+ ${f.note ? `<p class="fp-note art-note">${esc(f.note)}</p>` : ''}
509
+ <div class="art-body fp-media art-${html && !source ? 'html' : previewKind(f)}">${artifactBodyHtml(d, f, source)}</div>
510
+ <div class="fp-versions art-versions" data-versions-box><button class="btn sm ghost" data-versions>Versions${f.version > 1 ? ` (${esc(f.version)})` : ''}</button></div>
511
+ </div>`
512
+ }
513
+
514
+ /** The Artifacts page of the project that is open (`state.workspace`), for the folder and the artifact `state.filesView` names. */
515
+ export function artifactsHtml (d) {
516
+ const id = d.workspace.id
517
+ const fv = state.filesView
518
+ if (fv.folder && !foldersOf(d).some((f) => f.path === fv.folder)) fv.folder = ''
519
+ const picked = filesOf(d).find((f) => f.id === fv.picked) || null
520
+ if (!picked) { fv.picked = null; fv.source = false }
521
+ if (picked) return artifactViewHtml(d, picked)
522
+ const folders = foldersOf(d).filter((f) => f.folder === fv.folder).sort(byName)
523
+ const files = filesOf(d).filter((f) => f.folder === fv.folder).sort(byName)
524
+ const edit = canEdit(d)
525
+ const parts = fv.folder ? fv.folder.split('/') : []
526
+ const crumbs = [fv.folder ? '<a href="#" data-folder="">Artifacts</a>' : '<span class="here">Artifacts</span>', ...parts.map((p, i) => i === parts.length - 1 ? `<span class="here">${esc(p)}</span>` : `<a href="#" data-folder="${esc(parts.slice(0, i + 1).join('/'))}">${esc(p)}</a>`)]
527
+ const grid = fv.mode === 'list' ? (folders.length || files.length ? listHtml(d, folders, files, null) : '') + (edit ? `<button type="button" class="pj-slot art-drop" data-upload>${I.upload}<span>Upload or drop files</span></button>` : '')
528
+ : `<div class="tiles art-tiles">
529
+ ${folders.map((f) => folderTileHtml(d, f, { acts: edit })).join('')}
530
+ ${files.map((f) => fileTileHtml(d, f, { meta: [whoOf(d, f.uploadedBy), when(f.uploadedAt)].filter(Boolean).join(' · ') })).join('')}
531
+ ${edit ? uploadTileHtml(id, fv.folder ? `Upload to ${fv.folder.split('/').pop()}` : 'Upload or drop files') : ''}
532
+ </div>`
533
+ return `
534
+ <header class="files-head">
535
+ <div class="t"><h2 class="crumbs">${crumbs.join('<span class="sep">/</span>')}</h2><p class="hint">Plans, designs and notes that belong to the project, not to one repository.</p></div>
536
+ <span class="spacer"></span>
537
+ <div class="segmented sm files-mode" role="tablist" aria-label="How artifacts are shown">
538
+ <button type="button" role="tab" data-files-mode="tiles" class="${fv.mode !== 'list' ? 'on' : ''}" aria-selected="${fv.mode !== 'list'}">Tiles</button>
539
+ <button type="button" role="tab" data-files-mode="list" class="${fv.mode === 'list' ? 'on' : ''}" aria-selected="${fv.mode === 'list'}">List</button>
540
+ </div>
541
+ ${edit ? `<button class="btn sm ghost" data-new-folder>${I.plus}<span>New folder</span></button><button class="btn sm primary" data-upload>${I.upload}<span>Upload</span></button>` : ''}
542
+ </header>
543
+ ${fv.mode === 'list' && edit ? `<p class="hint files-progress" data-progress>${uploadingTo(id) ? esc(progressLabel()) : ''}</p><input type="file" multiple hidden data-upload-input>` : ''}
544
+ <div class="art-list" data-files-drop>${grid || '<p class="hint">Nothing here yet.</p>'}</div>`
545
+ }
546
+
445
547
  /** `rerender` draws the page again from state (home.js passes renderShell); without it, go(). */
446
548
  export function bindAllFiles (root, { id, reload, go, rerender = () => go(`wsfiles:${id}`) }) {
447
549
  const d = state.workspace
448
550
  if (!d || d.workspace.id !== id) return
449
551
  const fv = state.filesView
450
- root.querySelector('[data-ws-open]').onclick = (e) => { e.preventDefault(); go(`ws:${id}`) }
552
+ const back = root.querySelector('[data-ws-open]')
553
+ if (back) back.onclick = (e) => { e.preventDefault(); go(`ws:${id}`) }
451
554
  root.querySelectorAll('[data-folder]').forEach((el) => {
452
555
  const open = (e) => { e?.preventDefault(); fv.folder = el.dataset.folder; fv.picked = null; rerender() }
453
556
  el.onclick = open
@@ -461,7 +564,8 @@ export function bindAllFiles (root, { id, reload, go, rerender = () => go(`wsfil
461
564
  root.querySelectorAll('[data-files-mode]').forEach((b) => { b.onclick = () => { fv.mode = b.dataset.filesMode; rerender() } })
462
565
  root.querySelector('[data-close-preview]')?.addEventListener('click', () => { fv.picked = null; rerender() })
463
566
 
464
- if (canEdit(d)) {
567
+ // An artifact that is open fills the page: there are no tiles then, so nothing to upload onto.
568
+ if (canEdit(d) && root.querySelector('[data-files-drop]')) {
465
569
  const upload = (list) => startUpload(id, list, fv.folder, { reload, go })
466
570
  bindUpload(root, upload)
467
571
  bindDrop(root.querySelector('[data-files-drop]'), upload)
@@ -469,6 +573,8 @@ export function bindAllFiles (root, { id, reload, go, rerender = () => go(`wsfil
469
573
  bindFolderActs(root, d, id, reload)
470
574
  bindMoveToFolder(root, d, id, reload)
471
575
  }
576
+ root.querySelectorAll('[data-art-show]').forEach((b) => { b.onclick = () => { fv.source = b.dataset.artShow === 'source'; rerender() } })
577
+ runSealedFrames(root, id)
472
578
 
473
579
  const f = filesOf(d).find((x) => x.id === fv.picked)
474
580
  if (!f) return
@@ -497,7 +603,7 @@ export function bindAllFiles (root, { id, reload, go, rerender = () => go(`wsfil
497
603
  await update({ path: folder ? `${folder}/${f.name}` : f.name }, 'Moved', () => { fv.folder = folder })
498
604
  })
499
605
  root.querySelector('[data-delete]')?.addEventListener('click', async () => {
500
- if (!await ask({ title: `Delete ${f.name}?`, message: 'It goes for everyone in this workspace, with its earlier versions.', ok: 'Delete', danger: true })) return
606
+ if (!await ask({ title: `Delete ${f.name}?`, message: 'It goes for everyone in this project, with its earlier versions.', ok: 'Delete', danger: true })) return
501
607
  try { await api('POST', fileUrl(id, f.id, '/delete')); fv.picked = null; toast('Deleted'); await reload() } catch (err) { toast(err.message) }
502
608
  })
503
609
  const showVersions = async () => {
@@ -546,7 +652,7 @@ function bindFolderActs (root, d, id, reload) {
546
652
  const f = byId(b.dataset.folderDelete)
547
653
  if (!f) return
548
654
  const n = folderStats(d, f.path).count
549
- const message = n ? `Everything in it goes too (${plural(n, 'file', 'files')}), for everyone in this workspace.` : 'It is empty.'
655
+ const message = n ? `Everything in it goes too (${plural(n, 'file', 'files')}), for everyone in this project.` : 'It is empty.'
550
656
  if (!await ask({ title: `Delete the folder ${f.name}?`, message, ok: 'Delete', danger: true })) return
551
657
  try {
552
658
  await api('POST', fileUrl(id, f.id, '/delete'))
@@ -566,13 +672,13 @@ export function previewBusy () {
566
672
  /** A dialog to choose one of the workspace's files. Resolves { id, name }, or null. */
567
673
  export async function workspaceFilePicker (id) {
568
674
  let files
569
- try { files = (await api('GET', wsUrl(id, '/files'))).files.filter((f) => f.kind !== 'folder').sort((a, b) => a.path.localeCompare(b.path)) } catch (err) { toast(err.status === 404 || /not found/i.test(err.message) ? "Only this workspace's members can see its files." : err.message); return null }
675
+ try { files = (await api('GET', wsUrl(id, '/files'))).files.filter((f) => f.kind !== 'folder').sort((a, b) => a.path.localeCompare(b.path)) } catch (err) { toast(err.status === 404 || /not found/i.test(err.message) ? "Only this project's members can see its artifacts." : err.message); return null }
570
676
  return new Promise((resolve) => {
571
677
  const back = document.createElement('div')
572
678
  back.className = 'modal-back'
573
679
  back.innerHTML = `<div class="card modal file-picker" role="dialog" aria-modal="true" aria-labelledby="fpk-title">
574
- <h3 id="fpk-title">Choose a file</h3>
575
- <input class="input" type="search" placeholder="Search files" aria-label="Search files" data-pick-search>
680
+ <h3 id="fpk-title">Choose an artifact</h3>
681
+ <input class="input" type="search" placeholder="Search artifacts" aria-label="Search artifacts" data-pick-search>
576
682
  <div class="fpk-list" data-pick-list></div>
577
683
  <div class="actions"><button type="button" class="btn" data-no>Cancel</button></div>
578
684
  </div>`
@@ -585,7 +691,7 @@ export async function workspaceFilePicker (id) {
585
691
  const shown = files.filter((f) => !q || f.path.toLowerCase().includes(q))
586
692
  list.innerHTML = shown.length
587
693
  ? shown.map((f) => `<button type="button" class="fpk-row" data-pick="${esc(f.id)}"><span class="badge" style="background:${badgeColor(f)}">${esc(badgeText(f))}</span><span class="grow">${esc(f.path)}</span><span class="hint">${esc(bytes(f.size || 0))}</span></button>`).join('')
588
- : `<p class="hint">${files.length ? 'No file matches.' : 'This workspace has no files yet.'}</p>`
694
+ : `<p class="hint">${files.length ? 'No artifact matches.' : 'This project has no artifacts yet.'}</p>`
589
695
  }
590
696
  draw()
591
697
  search.oninput = draw
@@ -38,7 +38,7 @@ export function renderFileView (el, { path, file, meta, me, prevText, bannerOnly
38
38
  let pvKey = null
39
39
  if (tab === 'changes') body = history ? `<div class="fv-history">${historyMarkup(history, { ...people, summary })}</div>` : '<div class="fv-note">Reading what changed…</div>'
40
40
  else if (!file) body = `<div class="fv-note">${loadingNote()}</div>`
41
- else if (file.missing) body = `<div class="fv-note">${file.deleted ? 'This file was deleted.' : 'This file isn’t in the session. It may be too large to sync, or ignored.'}</div>`
41
+ else if (file.missing) body = `<div class="fv-note">${file.deleted ? 'This file was deleted.' : 'This file isn’t in the codebase. It may be too large to sync, or ignored.'}</div>`
42
42
  else {
43
43
  const shown = fileBody({ path, file, prevText, rawHref })
44
44
  body = shown.html
@@ -118,13 +118,13 @@ const IMAGE = /\.(png|jpe?g|gif|webp)$/i
118
118
  function renderChatFile (el, { path, file, chat, me, href, rawHref, keep }) {
119
119
  const who = (n) => n === me ? 'you' : esc(n)
120
120
  const banner = `<div class="fv-banner"><span class="fv-path mono">${esc(path)}</span><span class="fv-edited">Sent in chat by ${who(chat.by)}${chat.to ? ` to ${who(chat.to)}` : ''} ${agoLong(chat.ts)}</span>
121
- <span class="hint">Only people in the session get it. Never synced or committed.</span><span class="spacer"></span>${href ? `<a class="btn sm" href="${href}" download>${I.down}<span>Download</span></a>` : ''}</div>`
121
+ <span class="hint">Only people in the codebase get it. Never synced or committed.</span><span class="spacer"></span>${href ? `<a class="btn sm" href="${href}" download>${I.down}<span>Download</span></a>` : ''}</div>`
122
122
  let body
123
123
  let pvKey = null
124
124
  if (!file) body = `<div class="fv-note">${loadingNote()}</div>`
125
125
  else if (file.missing) body = '<div class="fv-note">This file is no longer in your Chat files folder.</div>'
126
126
  else if (file.binary && !rawHref && IMAGE.test(path) && href) body = `<div class="fv-image"><img src="${href}&amp;inline=1" alt="${esc(path.split('/').pop())}"></div>`
127
- else if (file.binary && !rawHref) body = `<div class="fv-note">${I.file} ${bytes(file.size)}. It is in the Chat files folder in this session's folder.</div>`
127
+ else if (file.binary && !rawHref) body = `<div class="fv-note">${I.file} ${bytes(file.size)}. It is in the Chat files folder in this codebase's folder.</div>`
128
128
  else {
129
129
  const shown = fileBody({ path, file, prevText: null, rawHref, download: href ? href.replace(/&amp;/g, '&') : null })
130
130
  body = shown.html
@@ -11,7 +11,7 @@ export const GIT_SEGMENTS = [
11
11
  ]
12
12
  const RANK = { off: 0, branches: 1, any: 2 }
13
13
  const UP_TO = { off: 'git off', branches: 'up to own branches', any: 'up to any branch' }
14
- const LEVEL = { org: 'Org', team: 'Team', workspace: 'Workspace' }
14
+ const LEVEL = { org: 'Org', team: 'Team', workspace: 'Project' }
15
15
  const FIXER = {
16
16
  workspace: 'Its admins change that in its GitHub settings.',
17
17
  org: 'Its admins change that in the org\'s settings.',
@@ -20,7 +20,7 @@ const FIXER = {
20
20
 
21
21
  /** "Workspace Platform", "Org Acme", "Team Night shift" (or "The workspace" without a name). */
22
22
  export function ruleWho (rule) {
23
- const level = LEVEL[rule && rule.by] || 'Workspace'
23
+ const level = LEVEL[rule && rule.by] || 'Project'
24
24
  return rule && rule.name ? `${level} ${rule.name}` : `The ${level.toLowerCase()}`
25
25
  }
26
26
 
@@ -53,6 +53,6 @@ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '
53
53
  export function thisSessionGitHtml (session) {
54
54
  if (!session) return ''
55
55
  return `<section class="card settings-sec" id="this-session-git-sec">
56
- <div class="sec-intro"><h2>This session${session.name ? `: ${esc(session.name)}` : ''}</h2><p>Source control here is git: you and your AI commit, pull and push in this session's folder as usual, and Quilt shares everyone's files live in between.</p></div>
56
+ <div class="sec-intro"><h2>This codebase${session.name ? `: ${esc(session.name)}` : ''}</h2><p>Source control here is git: you and your AI commit, pull and push in this codebase's folder as usual, and Quilt shares everyone's files live in between.</p></div>
57
57
  </section>`
58
58
  }