clavarium 0.2.429-next.1 → 0.2.430-next.1

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.429-next.1",
3
+ "version": "0.2.430-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.429-next.1",
9
+ "version": "0.2.430-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.429-next.1",
3
+ "version": "0.2.430-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -1031,7 +1031,8 @@ export class Conversations {
1031
1031
  async #copying(from, to, c, tool, building, open = () => {}) {
1032
1032
  const dir = mkdtempSync(join(tmpdir(), 'clv-copy-'));
1033
1033
  const carried = join(dir, 'state.tar.gz');
1034
- let woke = false;
1034
+ let woke = false; let putBack = 'sleep';
1035
+ const back = () => (putBack === 'stop' ? this.machineAction(from, 'stop', { wait: true }) : this.sleep(from));
1035
1036
  try {
1036
1037
  /* Said as it goes, once a second at most: a long copy is seen moving (13-11, "on ne sait pas si ça marche"). */
1037
1038
  let said = 0;
@@ -1040,7 +1041,9 @@ export class Conversations {
1040
1041
  this.#store.patch(to, { step: `Copying ${tool.label}'s memory` });
1041
1042
  const state = await this.#vms.state(from, { fresh: true }).catch(() => undefined);
1042
1043
  if (state !== 'Running') {
1043
- this.#store.patch(to, { step: `Copying ${tool.label}'s memory: waking its original` });
1044
+ /* Put back as it was found (14-11: one stopped was left asleep, its memory held). */
1045
+ putBack = state === 'Stopped' ? 'stop' : 'sleep';
1046
+ this.#store.patch(to, { step: `Copying ${tool.label}'s memory: ${putBack === 'stop' ? 'starting its original (it was stopped)' : 'waking its original'}` });
1044
1047
  await this.room({ kind: 'start', name: from, memoryMb: Number(c.memoryMb) || tool.memoryMb });
1045
1048
  /* Woken outside a wake, it is still marked asleep: borrowed, so that the server's sweep of sleepers
1046
1049
  holding memory (capacity.mjs, reclaimSleepers) does not put it back to sleep while it is read --
@@ -1081,7 +1084,7 @@ export class Conversations {
1081
1084
  }
1082
1085
  if (code !== 0) throw new Error(`its tool's memory could not be read (exit ${code}${firstLine(child.said) ? `: ${firstLine(child.said)}` : ''}).`);
1083
1086
  /* Read: its original back to sleep at once, before the copy's machine is made. */
1084
- if (woke) { await this.sleep(from).catch(() => {}); woke = false; }
1087
+ if (woke) { await back().catch(() => {}); woke = false; }
1085
1088
  this.#borrowed.delete(from);
1086
1089
  }
1087
1090
  open(true);
@@ -1114,7 +1117,7 @@ export class Conversations {
1114
1117
  return undefined;
1115
1118
  } finally {
1116
1119
  rmSync(dir, { recursive: true, force: true });
1117
- if (woke) await this.sleep(from).catch(() => {});
1120
+ if (woke) await back().catch(() => {});
1118
1121
  this.#borrowed.delete(from);
1119
1122
  }
1120
1123
  }
package/web/app.js CHANGED
@@ -522,7 +522,7 @@
522
522
  const old = document.getElementById('room')?.querySelector(':scope > header');
523
523
  if (old) old.replaceWith(DEVICE
524
524
  ? KIT.TopBar({ variant: 'main', title: $('name'), actions: [...old.children].filter((n) => n.id !== 'name') })
525
- : KIT.TopBar({ variant: 'main', fold: $('fold'), back: { element: $('back'), label: 'Conversations' }, state: $('state'), title: $('name'), actions: [$('views')] }));
525
+ : KIT.TopBar({ variant: 'main', fold: $('fold'), back: { element: $('back'), label: 'Conversations' }, state: $('state'), title: $('name'), actions: [$('jobs-room'), $('views')] }));
526
526
  }
527
527
  /* A room (the device page has none): its dot, its name, under it who speaks now (only then); on its right who is
528
528
  in it (07-11: small stacked avatars, a click opens the list) then its settings, in the same group of views a
@@ -1993,12 +1993,18 @@
1993
1993
  async function paintJobs() {
1994
1994
  try { const r = await fetch(`${API}/jobs`); if (!r.ok) return; jobsNow = await r.json(); } catch { return; }
1995
1995
  const failed = jobsNow.done.filter((j) => j.result === 'failed' && String(j.endedAt) > jobsSeen()).length;
1996
- const badge = $('jobs-open');
1997
1996
  const n = jobsNow.running.length;
1998
- badge.hidden = !n && !failed;
1999
- badge.dataset.tone = !n && failed ? 'bad' : '';
2000
- badge.textContent = n ? `${n} under way` : `${failed} failed`;
2001
- badge.title = n ? jobsNow.running.map((j) => j.what).join(' · ') : 'Tap to see what failed';
1997
+ /* Two places, one state: by the list's title, and in the bar of the conversation open (its list folded
1998
+ away, or a phone's, a screen of its own) -- shorter there, the bar is narrow. */
1999
+ for (const [id, words] of [['jobs-open', n ? `${n} under way` : `${failed} failed`], ['jobs-room', n ? String(n) : '!']]) {
2000
+ const badge = $(id);
2001
+ badge.hidden = !n && !failed;
2002
+ badge.dataset.tone = !n && failed ? 'bad' : '';
2003
+ badge.textContent = words;
2004
+ badge.title = n ? `Under way: ${jobsNow.running.map((j) => j.what).join(' · ')}` : 'Failed: tap to see what';
2005
+ badge.setAttribute('aria-label', n ? `${n} under way` : `${failed} failed`);
2006
+ }
2007
+ if (n || failed) $('back').dataset.jobs = n ? 'on' : 'bad'; else delete $('back').dataset.jobs;
2002
2008
  if (!$('jobs').hidden) paintJobsList();
2003
2009
  }
2004
2010
  function paintJobsList() {
@@ -2018,15 +2024,22 @@
2018
2024
  if (!parts.length) parts.push(Object.assign(document.createElement('p'), { className: 'hint', textContent: 'Nothing under way.' }));
2019
2025
  $('jobs').replaceChildren(...parts);
2020
2026
  }
2021
- function closeJobs() { $('jobs').hidden = true; $('jobs-open').setAttribute('aria-expanded', 'false'); }
2022
- $('jobs-open').addEventListener('click', () => {
2027
+ function closeJobs() { $('jobs').hidden = true; for (const id of ['jobs-open', 'jobs-room']) $(id).setAttribute('aria-expanded', 'false'); }
2028
+ for (const id of ['jobs-open', 'jobs-room']) $(id).addEventListener('click', () => {
2023
2029
  if (!$('jobs').hidden) { closeJobs(); return; }
2024
- paintJobsList(); $('jobs').hidden = false; $('jobs-open').setAttribute('aria-expanded', 'true');
2030
+ paintJobsList();
2031
+ /* Under the badge tapped, kept within the screen. */
2032
+ const at = $(id).getBoundingClientRect(); const pop = $('jobs');
2033
+ pop.hidden = false;
2034
+ pop.style.top = `${Math.round(at.bottom + 6)}px`;
2035
+ pop.style.left = `${Math.round(Math.max(8, Math.min(at.left, window.innerWidth - pop.offsetWidth - 8)))}px`;
2036
+ $(id).setAttribute('aria-expanded', 'true');
2025
2037
  try { localStorage.setItem(JOBS_SEEN, new Date().toISOString()); } catch { /* kept for this visit only */ }
2026
- if (!jobsNow.running.length) $('jobs-open').hidden = true;
2038
+ if (!jobsNow.running.length) { $('jobs-open').hidden = true; $('jobs-room').hidden = true; delete $('back').dataset.jobs; }
2027
2039
  });
2028
- document.addEventListener('click', (event) => { if (!$('jobs').hidden && !event.target.closest('#jobs, #jobs-open')) closeJobs(); });
2029
- document.addEventListener('keydown', (event) => { if (event.key === 'Escape' && !$('jobs').hidden) closeJobs(); });
2040
+ document.addEventListener('click', (event) => { if (!$('jobs').hidden && !event.target.closest('#jobs, #jobs-open, #jobs-room')) closeJobs(); });
2041
+ /* Escape closes the list, and only it: never the conversation under it too (14-11: the page went to « No conversation »). */
2042
+ document.addEventListener('keydown', (event) => { if (event.key === 'Escape' && !$('jobs').hidden) { event.stopImmediatePropagation(); event.preventDefault(); closeJobs(); } }, true);
2030
2043
 
2031
2044
  /* ---------- A NEW CONVERSATION: a page of its own, as Settings ----------
2032
2045
  "+ New" opens it beside the list (the whole screen on a phone), with an
package/web/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  <link rel="stylesheet" href="/vendor/diff2html.css">
15
15
  <div id="app" data-place="conversations">
16
16
  <aside id="list" hidden>
17
- <div class="top"><b id="list-title" title="Conversations">Clavarium</b><!-- WHAT IT IS DOING (jobs.mjs, 14-11): shown only while something runs, or failed unseen. --><button type="button" id="jobs-open" class="jobs-badge" hidden aria-expanded="false" aria-controls="jobs"></button><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="install-top" class="icon-btn" hidden aria-label="Install as an app" title="Install as an app: its own icon, full screen, no browser bar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="icon-btn new-btn" aria-label="New conversation" title="New conversation"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg></button></span><div id="jobs" class="jobs-pop" role="dialog" aria-label="Under way" hidden></div></div>
17
+ <div class="top"><b id="list-title" title="Conversations">Clavarium</b><!-- WHAT IT IS DOING (jobs.mjs, 14-11): shown only while something runs, or failed unseen. --><button type="button" id="jobs-open" class="jobs-badge" hidden aria-expanded="false" aria-controls="jobs"></button><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="install-top" class="icon-btn" hidden aria-label="Install as an app" title="Install as an app: its own icon, full screen, no browser bar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="icon-btn new-btn" aria-label="New conversation" title="New conversation"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg></button></span></div>
18
18
  <!-- SEARCH, discreet: opened by the magnifier, "/" or Ctrl+K; filters as it is typed. -->
19
19
  <div id="search" role="search" hidden><input id="search-field" type="search" placeholder="Search" aria-label="Search conversations: name, folder, identifier, tool" autocomplete="off" spellcheck="false" maxlength="60" aria-controls="items"></div>
20
20
  <!-- Needs you and Recent: copies of rows of the list below, by when they were last used (app.js, paint). -->
@@ -46,6 +46,7 @@
46
46
  <button type="button" id="fold" aria-label="Hide the list of conversations" aria-pressed="false" title="Hide or show the list of conversations">&laquo;</button>
47
47
  <span id="state" data-state="connecting" role="status">connecting</span>
48
48
  <b id="name"></b>
49
+ <button type="button" id="jobs-room" class="jobs-badge jobs-room" hidden aria-expanded="false" aria-controls="jobs"></button>
49
50
  <!-- THE BAR: its chat, its terminal, what it was given, its binders (once it has one), its settings (G). -->
50
51
  <div id="views" class="views" role="group" aria-label="What to see">
51
52
  <button type="button" id="view-chat" aria-pressed="false" title="Its chat"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414 .586l-2.202 2.202A.71 .71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/></svg><span>Chat</span></button>
@@ -1499,6 +1500,7 @@
1499
1500
  <script src="/vendor/diff2html.js"></script>
1500
1501
  <script src="/gitgraph.js"></script>
1501
1502
  <script src="/links.js"></script>
1503
+ <div id="jobs" class="jobs-pop" role="dialog" aria-label="Under way" hidden></div>
1502
1504
  <script src="/features.js"></script>
1503
1505
  <script src="/kit.js"></script>
1504
1506
  <script src="/mail-view.js"></script>
package/web/style.css CHANGED
@@ -1426,11 +1426,16 @@ select.pill { appearance: auto; }
1426
1426
  #list .top-acts { display: flex; align-items: center; gap: 6px; }
1427
1427
  #list-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
1428
1428
  /* What it is doing (14-11): a small badge by the title, its list folded under it. */
1429
- #list .top { position: relative; }
1430
1429
  .jobs-badge { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-left: 8px; margin-right: auto; padding: 2px 10px; min-height: 0; border: 1px solid var(--brass); border-radius: 999px; background: transparent; color: var(--brass-ink); font-size: .75rem; font-weight: 600; white-space: nowrap; }
1431
1430
  .jobs-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
1431
+ .jobs-room { margin: 0; padding: 2px 4px; gap: 4px; border-color: transparent; }
1432
+ /* A phone's bar has no room for it: a dot on its way back to the list, where the badge is. */
1433
+ @media (max-width: 480px) { .jobs-room { display: none !important; } }
1434
+ #back[data-jobs] { position: relative; }
1435
+ #back[data-jobs]::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--brass); }
1436
+ #back[data-jobs="bad"]::after { background: var(--danger); }
1432
1437
  .jobs-badge[data-tone="bad"] { border-color: var(--danger); color: var(--danger); }
1433
- .jobs-pop { position: absolute; z-index: 30; top: 100%; left: 8px; right: 8px; margin-top: 4px; min-width: 260px; max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / .35); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
1438
+ .jobs-pop { position: fixed; z-index: 60; width: min(340px, calc(100vw - 16px)); max-height: 60vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / .35); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
1434
1439
  .jobs-pop h3 { margin: 2px 0 0; font-size: .8125rem; }
1435
1440
  .jobs-pop .job { display: grid; grid-template-columns: 16px 1fr; gap: 2px 8px; text-align: left; background: transparent; border: 0; padding: 4px 0; color: var(--ink); font: inherit; font-size: .8125rem; cursor: pointer; }
1436
1441
  .jobs-pop .job small { grid-column: 2; color: var(--ink2); overflow-wrap: anywhere; }