samagotchi 0.183.0 → 0.184.0

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -1
  3. data/docs/architecture.md +11 -10
  4. data/docs/bundles.md +1 -1
  5. data/docs/configuration.md +2 -1
  6. data/docs/internals/bridge.md +1 -1
  7. data/docs/internals/bundles.md +6 -2
  8. data/docs/internals/engine.md +2 -1
  9. data/docs/internals/participants.md +1 -1
  10. data/docs/internals/prompt-caching.md +8 -1
  11. data/docs/internals/remote-sessions.md +19 -3
  12. data/docs/internals/web-frontend.md +15 -10
  13. data/docs/internals/web-push.md +11 -0
  14. data/docs/internals/working-set.md +238 -6
  15. data/docs/mcp-server.md +5 -1
  16. data/docs/memory.md +2 -1
  17. data/docs/plugins.md +6 -6
  18. data/docs/scheduling.md +14 -0
  19. data/docs/sessions.md +1 -1
  20. data/docs/thin-clients.md +29 -10
  21. data/lib/samagotchi/bridge_client.rb +12 -4
  22. data/lib/samagotchi/bundle_command/check.rb +20 -2
  23. data/lib/samagotchi/bundle_manifest.rb +5 -1
  24. data/lib/samagotchi/bundles/mcp/http_client.rb +79 -54
  25. data/lib/samagotchi/bundles/mcp/manifest.yml +2 -2
  26. data/lib/samagotchi/bundles/system/manifest.yml +2 -2
  27. data/lib/samagotchi/bundles/system/self_map.md +7 -2
  28. data/lib/samagotchi/engine/session.rb +14 -6
  29. data/lib/samagotchi/engine/turn_helpers.rb +4 -3
  30. data/lib/samagotchi/mcp_server/http.rb +3 -3
  31. data/lib/samagotchi/mcp_server/protocol.rb +23 -4
  32. data/lib/samagotchi/mcp_server/stdio.rb +1 -0
  33. data/lib/samagotchi/mcp_server/tools.rb +2 -1
  34. data/lib/samagotchi/model_notes.rb +34 -12
  35. data/lib/samagotchi/prompt_files.rb +11 -4
  36. data/lib/samagotchi/prompt_layout.rb +88 -0
  37. data/lib/samagotchi/prompt_part.rb +82 -20
  38. data/lib/samagotchi/reply_wait.rb +6 -3
  39. data/lib/samagotchi/schedule_command.rb +18 -4
  40. data/lib/samagotchi/schedules.rb +40 -8
  41. data/lib/samagotchi/session_access/ask.rb +53 -12
  42. data/lib/samagotchi/session_access/exchange.rb +5 -2
  43. data/lib/samagotchi/session_access/local.rb +11 -2
  44. data/lib/samagotchi/session_inbox.rb +15 -0
  45. data/lib/samagotchi/session_manager/delivery.rb +8 -4
  46. data/lib/samagotchi/system_prompt.rb +196 -161
  47. data/lib/samagotchi/tools/memory.rb +11 -3
  48. data/lib/samagotchi/turn_stages/warmup.rb +2 -2
  49. data/lib/samagotchi/version.rb +1 -1
  50. data/lib/samagotchi/web/app.rb +1 -2
  51. data/lib/samagotchi/web/ask_routes.rb +89 -19
  52. data/lib/samagotchi/web/mcp_route.rb +7 -4
  53. data/lib/samagotchi/web/public/delete_sheet.js +20 -18
  54. data/lib/samagotchi/web/public/removal_sheet_model.js +3 -4
  55. data/lib/samagotchi/web/public/running_tasks.js +0 -16
  56. data/lib/samagotchi/web/public/session_actions.js +0 -9
  57. data/lib/samagotchi/web/public/working_set_view.js +167 -21
  58. data/lib/samagotchi/web/public/ws_part_peek.js +277 -0
  59. data/lib/samagotchi/web/public/ws_peek.js +3 -1
  60. data/lib/samagotchi/web/public/ws_preview.css +30 -0
  61. data/lib/samagotchi/web/public/ws_reader.js +7 -3
  62. data/lib/samagotchi/web/public/ws_sections.js +37 -7
  63. data/lib/samagotchi/web/push/notifier.rb +33 -6
  64. data/lib/samagotchi/web/server.rb +1 -1
  65. data/lib/samagotchi/web/session_hub.rb +26 -4
  66. data/lib/samagotchi/web/working_set_routes.rb +93 -5
  67. data/lib/samagotchi/worker_link.rb +2 -2
  68. data/lib/samagotchi/working_set.rb +162 -90
  69. data/lib/samagotchi/working_set_locator.rb +221 -0
  70. data/lib/samagotchi/working_set_own_changes.rb +221 -0
  71. data/lib/samagotchi/working_set_part.rb +281 -0
  72. metadata +6 -1
@@ -42,7 +42,6 @@ import { repeat } from "./vendor/directives/repeat.js";
42
42
  import { createChipPopover, SHEET_SHARE, SHEET_TALL } from "./chip_popover.js";
43
43
  import { stillOn } from "./latest.js";
44
44
  import { showRow } from "./refs.js";
45
- import { PEEK_WIDTH } from "./ws_peek.js";
46
45
  import { read as readPref, write as writePref } from "./session_prefs.js";
47
46
  import {
48
47
  foldedSections, headItems, headLine, headSections, heldTwice, heldTwiceNote, lensTouched, memoryPartWords, promptKeys, startTokensText, WS_SECTION_FOLD,
@@ -53,8 +52,20 @@ import {
53
52
  steerId, steerLine, stepRange, stepTag, tokensText, turnLens, undroppable,
54
53
  } from "./working_set.js";
55
54
  import { serverSig } from "./ws_item_sig.js";
55
+ import { placeOf } from "./ws_timeline.js";
56
56
  import { heldOrder, recencyOrder } from "./ws_order.js";
57
57
 
58
+ // The popover's width, open row or not (a peek no longer widens it: the rows
59
+ // stayed put only at one width).
60
+ const WIDTH = 520;
61
+ // A stale start row's title words (ws_part_peek.js's now tab says the same).
62
+ const PART_CHANGED = "changed after chi's prompt was built";
63
+ const BOTH_CHANGED = "read changed · prompt text changed";
64
+ // A prompt row whose source chi changed itself (the GET's by_chi, current):
65
+ // its title after "chi edited it at …".
66
+ const OWN_EDITED = "the new text is in its conversation; its prompt still sends the old text until it is next built";
67
+ const OWN_REMOVED = "its prompt still sends it until it is next built";
68
+
58
69
  // The popover's files fold to this many lines (groups open in place, one at
59
70
  // a time), its memories past this many to one group.
60
71
  const POP_BUDGET = 6;
@@ -198,6 +209,64 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
198
209
  let stripOpen = null;
199
210
  const listeners = new Set();
200
211
  const lit = (items) => overlay(items, server);
212
+ // The prompt parts whose source changed since chi was sent them (chi
213
+ // web's GET's parts, WorkingSetPart.states): a GET's word, kept across
214
+ // the events' sets (takeServer), asked again at each open, a rebuilt
215
+ // prompt and a hand-off.
216
+ const partStates = () => (Array.isArray(server?.parts) ? server.parts : null);
217
+ // What the states say, to tell two answers' apart ("" for none).
218
+ const partsSig = (parts) => (Array.isArray(parts) && parts.length ? JSON.stringify(parts) : "");
219
+ // chi's own change of each stale part the GET named (by_chi: {tool_id,
220
+ // step, op, current}), by part key. Read here, off the GET's parts, not
221
+ // through ws_sections.js (an older cached one maps states to "stale").
222
+ const partChanges = () => new Map((partStates() || []).filter((s) => s && typeof s.key === "string" && s.by_chi && typeof s.by_chi === "object").map((s) => [s.key, s.by_chi]));
223
+ // Where a call sits in the page's turns ({turn, step, row}), by its chi id
224
+ // (ws_timeline.js placeOf over every turn's items), or null.
225
+ const placeFor = (toolId) => {
226
+ for (const items of [...turns.map((t) => t.items), live?.items || []]) {
227
+ for (const item of items || []) {
228
+ const at = placeOf({ tool_id: toolId }, item);
229
+ if (at) return at;
230
+ }
231
+ }
232
+ return null;
233
+ };
234
+ // A change's step tag: its place in the turns ("t3·s2"), else the
235
+ // server's step ("step 5"); +where+ the title's words.
236
+ const changeTag = (change) => {
237
+ const at = placeFor(change.tool_id);
238
+ if (at) return { at, text: stepTag({ at }, { session: true }), where: `turn ${at.turn + 1}, step ${at.step + 1}` };
239
+ const step = Number.isFinite(change.step) ? `step ${change.step}` : "";
240
+ return { at: null, text: step, where: step || "a step" };
241
+ };
242
+ // A start row with chi's own changes laid on it: each stale part chi's
243
+ // current change made "edited" (partStates; the peek's edited tab), the
244
+ // row partEdited ({op, tag}) when no part of it is stale any more;
245
+ // partByChi and partTags beside partKeys for the peek's lines (a stale
246
+ // part chi changed, then it changed again). A row without partKeys (an
247
+ // older cached ws_sections.js) as it is.
248
+ const ownRow = (row) => {
249
+ const keys = row?.partKeys;
250
+ if (!Array.isArray(keys) || !Array.isArray(row.partStates)) return row;
251
+ const changes = partChanges();
252
+ const byChi = keys.map((key) => changes.get(key) || null);
253
+ if (!byChi.some(Boolean)) return row;
254
+ const tags = byChi.map((change) => (change ? changeTag(change) : null));
255
+ const partStates = row.partStates.map((st, i) => (st === "stale" && byChi[i]?.current === true ? "edited" : st));
256
+ const partStale = partStates.includes("stale");
257
+ const edited = !partStale && partStates.includes("edited");
258
+ const last = edited ? partStates.map((st, i) => (st === "edited" ? i : -1)).filter((i) => i >= 0).sort((a, b) => (byChi[a].step || 0) - (byChi[b].step || 0)).at(-1) : -1;
259
+ return { ...row, partStates, partStale, partByChi: byChi, partTags: tags.map((t) => t?.text || ""), partEdited: edited ? { op: byChi[last].op, tag: tags[last] } : null };
260
+ };
261
+ // The session's prompt parts as built (each part's head and digest): a new
262
+ // build asks the GET again, so a rebuilt prompt's stale states go.
263
+ let builtSig = null;
264
+ let builtOf = null;
265
+ const builtSigOf = (parts) => JSON.stringify((Array.isArray(parts) ? parts : []).map((p) => [p?.kind, p?.head, p?.digest]));
266
+ // The prompt peek of "From the start" rows (ws_part_peek.js), on the peek
267
+ // a newer ws_reader.js makes; none (an older cached one): today's rows.
268
+ const part = peek?.part || null;
269
+ const anyPeek = () => !!(peek?.any() || part?.any());
201
270
 
202
271
  const sessionSet = () => {
203
272
  const st = state();
@@ -214,8 +283,8 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
214
283
  const promptOf = (t) => (live && t === live.ordinal ? live.prompt : turns[t]?.prompt || "");
215
284
 
216
285
  const popover = createChipPopover({
217
- id: "workingSetPopover", className: "ctx-popover ws-popover", width: () => (peek?.any() ? PEEK_WIDTH : 420), el: infoEl, anchor: ".ws-chip",
218
- openers: ".ws-chip, .ts-ws, .ws-foot", sheet: true, label: "Working set", sheetShare: () => (peek?.any() ? SHEET_TALL : SHEET_SHARE),
286
+ id: "workingSetPopover", className: "ctx-popover ws-popover", width: () => WIDTH, el: infoEl, anchor: ".ws-chip",
287
+ openers: ".ws-chip, .ts-ws, .ws-foot", sheet: true, label: "Working set", sheetShare: () => (anyPeek() ? SHEET_TALL : SHEET_SHARE),
219
288
  // The chip opens the session lens; the rail and a footprint set theirs
220
289
  // before they open it.
221
290
  summary: (anchor) => {
@@ -236,7 +305,7 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
236
305
  draw();
237
306
  if (opening) fetchServer();
238
307
  },
239
- onClose: () => { openGroup = null; openKeys = null; peek?.close(); onChange(); },
308
+ onClose: () => { openGroup = null; openKeys = null; part?.close(); peek?.close(); onChange(); },
240
309
  // The foot's + add (the popover's submit): one KEY as typed (quoted
241
310
  // when it has spaces).
242
311
  onSubmit: (form) => {
@@ -300,7 +369,9 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
300
369
  // +start+: a "From the start" memory row (ws_sections.js): its part's
301
370
  // words and tokens, no "prompt" tag (the section says it), "held twice"
302
371
  // when it was read again, and the note in a turn lens that read it.
303
- function rowTemplate(row0, { session: inSession, group = null, now, pend = new Map(), forget = false, touched = null, start = false }) {
372
+ function rowTemplate(given, { session: inSession, group = null, now, pend = new Map(), forget = false, touched = null, start = false }) {
373
+ // A start row with chi's own changes of its parts laid on it (ownRow).
374
+ const row0 = start ? ownRow(given) : given;
304
375
  // +row0+ is the session's item: its state, tokens, actions, peek. +item+ is
305
376
  // what the lens shows of it: the turn's `at`, ops and count (the step tag,
306
377
  // the words, the edited mark) and nothing else.
@@ -347,23 +418,72 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
347
418
  const isPending = pill !== nothing;
348
419
  const strip = stripOpen === id && buttons !== nothing;
349
420
  const open = item.kind === "file" ? html`<button type="button" class="ws-act-b open ref" data-ref-kind="file" data-ref-path=${item.ref?.path || full}>open</button>` : nothing;
350
- // The ▸ that peeks at what chi has of it (the owner's: +peek+).
351
- const canPeek = peek && peekable(row0);
352
- const peeked = canPeek && peek.isOpen(id);
353
- const toggle = canPeek ? html`<button type="button" class="ws-peek-toggle" data-ws="peek" data-ws-id=${id} aria-expanded=${String(peeked)} aria-label=${`What chi has of ${name}`} title="What chi has of it">${peeked ? "▾" : "▸"}</button>` : nothing;
354
- const row = html`<div class=${`ws-row ${item.kind}${row0.added ? " added" : ""}${fresh ? " fresh" : ""}${row0.muted ? " muted" : ""}${group ? " member" : ""}${state}${isPending ? " pending" : ""}${strip ? " strip-open" : ""}${peeked ? " peeked" : ""}${canPeek ? " peekable" : ""}${note ? " twice" : ""}${lensClass}`} data-ws-id=${id}>${toggle}<span class="k">${glyph}</span>${nameEl}${pin}${edited ? html`<span class="e">✎</span>` : nothing}<span class="st">${words}</span>${pill}${tokens ? html`<span class="tk" title=${start ? "about its tokens in the prompt, + its reads'" : `about ${row0.tokens} tokens of it are sent`}>${tokens}</span>` : nothing}${tagEl}${buttons !== nothing ? html`<span class="ws-act">${buttons}</span>` : nothing}</div>`;
421
+ // The ▸ that peeks at what chi has of it (the owner's: +peek+); a start
422
+ // row's opens the prompt peek, its read (when it has one) a tab of it;
423
+ // a row without its parts' keys (an older cached ws_sections.js) keeps today's.
424
+ const prompt = start && !!part && !!row0.partKeys?.length;
425
+ const partId = prompt ? `start:${itemKey(row0)}` : null;
426
+ const canPeek = prompt || (peek && peekable(row0));
427
+ const peeked = prompt ? part.isOpen(partId) : canPeek && peek.isOpen(id);
428
+ // Its read tab: the item peek, when it has one. A row chi only wrote has none: its edited tab (or the now
429
+ // tab's "chi edited it" line) says that write.
430
+ const readTab = !!peek && peekable(row0) && !(row0.partByChi?.some(Boolean) && !row0.ops.includes("read"));
431
+ const toggle = prompt ? partToggle(partId, row0, name, peeked, { read: readTab, item: id })
432
+ : canPeek ? html`<button type="button" class="ws-peek-toggle" data-ws="peek" data-ws-id=${id} aria-expanded=${String(peeked)} aria-label=${`What chi has of ${name}`} title="What chi has of it">${peeked ? "▾" : "▸"}</button>` : nothing;
433
+ const peekEl = !peeked ? nothing : prompt ? part.template(row0, { read: readTab, readTag: stepTag({ ...row0, preloaded: false, at: row0.last || row0.at }, { session: true }) }) : peek.template(row0);
434
+ // A prompt row whose source changed since chi was sent it says "stale" in place of its words, kept in
435
+ // its title; a read stale too: still one word, both causes in the title.
436
+ const pstale = start && !item.added && row0.partStale;
437
+ // A prompt row whose source chi changed itself: ✎, its words then "edited" (the read's own stale wins), its
438
+ // tag the call's.
439
+ const pedited = start && !item.added && !!row0.partEdited && row0.state !== "stale";
440
+ // The call's tag in place of the row's own (a turn lens's step), beside "held twice".
441
+ if (pedited) tagEl = start && inSession && heldTwice(row0) ? html`${tagEl}${ownTagTemplate(row0.partEdited)}` : ownTagTemplate(row0.partEdited);
442
+ const staleTitle = pstale ? `${row0.state === "stale" ? `${memoryPartWords(row0)} · ${row0.ops.includes("read") ? BOTH_CHANGED : PART_CHANGED}` : `${what} · ${PART_CHANGED}`}${fresh ? " · just now" : ""}` : "";
443
+ const row = html`<div class=${`ws-row ${item.kind}${row0.added ? " added" : ""}${fresh ? " fresh" : ""}${row0.muted ? " muted" : ""}${group ? " member" : ""}${state}${isPending ? " pending" : ""}${strip ? " strip-open" : ""}${peeked ? " peeked" : ""}${canPeek ? " peekable" : ""}${note ? " twice" : ""}${lensClass}`} data-ws-id=${id}>${toggle}<span class="k">${glyph}</span>${nameEl}${pin}${edited || pedited ? html`<span class="e">✎</span>` : nothing}${pstale ? staleTemplate(staleTitle) : pedited ? ownTemplate(memoryPartWords(row0), row0.partEdited) : html`<span class="st">${words}</span>`}${pill}${tokens ? html`<span class="tk" title=${start ? "about its tokens in the prompt, + its reads'" : `about ${row0.tokens} tokens of it are sent`}>${tokens}</span>` : nothing}${tagEl}${buttons !== nothing ? html`<span class="ws-act">${buttons}</span>` : nothing}</div>`;
355
444
  // One template either way, so the tapped row stays the same node (a
356
445
  // click outside the popover closes it).
357
446
  const noteEl = note ? html`<div class="ws-note twice" role="note">${note}</div>` : nothing;
358
- return html`${row}${noteEl}${strip ? html`<div class="ws-strip">${buttons}${open}</div>` : nothing}${peeked ? peek.template(row0) : nothing}`;
447
+ return html`${row}${noteEl}${strip ? html`<div class="ws-strip">${buttons}${open}</div>` : nothing}${peekEl}`;
359
448
  }
360
449
 
361
- // A prompt part's row: its label, its sub, its tokens; read-only, no
362
- // peek. Never touched by a turn: dim in a turn lens.
363
- function partRowTemplate(row, { touched = null }) {
450
+ // A prompt row's "stale": its source changed since chi was sent it.
451
+ const staleTemplate = (title = `its source ${PART_CHANGED}`) => html`<span class="st ws-pstale" title=${title}>stale</span>`;
452
+
453
+ // A prompt row chi changed itself: its part words (a phone's sheet hides them, .ws-pwords) then "edited"
454
+ // ("removed"), the title saying both facts.
455
+ function ownTemplate(words, own) {
456
+ const removed = own.op === "remove";
457
+ const title = `${words ? `${words} · ` : ""}chi ${removed ? "removed" : "edited"} it at ${own.tag.where}: ${removed ? OWN_REMOVED : OWN_EDITED}`;
458
+ return html`<span class="st ws-pedited" title=${title}>${words ? html`<span class="ws-pwords">${words} · </span>` : nothing}${removed ? "removed" : "edited"}</span>`;
459
+ }
460
+
461
+ // Its tag: the call's place, a jump as the read rows' (a plain "step N" without one).
462
+ function ownTagTemplate(own) {
463
+ const { at, text, where } = own.tag;
464
+ if (!text) return nothing;
465
+ const title = `chi ${own.op === "remove" ? "removed" : "edited"} it at ${where}: go to the call`;
466
+ return at ? html`<button type="button" class="ws-step p ws-own" data-ws="jump" data-at=${atAttr(at)} title=${title}>${text}</button>`
467
+ : html`<span class="ws-step p ws-own" title=${title}>${text}</span>`;
468
+ }
469
+
470
+ // A start row's ▸: the prompt peek (+opts+: its read, its item's id).
471
+ function partToggle(id, row, name, peeked, opts) {
472
+ return html`<button type="button" class="ws-peek-toggle" data-ws-part-peek=${id} aria-expanded=${String(peeked)} aria-label=${`What chi was sent of ${name}`} title="What chi was sent" @click=${() => part.toggle(id, row, opts)}>${peeked ? "▾" : "▸"}</button>`;
473
+ }
474
+
475
+ // A prompt part's row: its label, its sub, its tokens; read-only. Its ▸
476
+ // (with the prompt peek: a newer ws_reader.js) opens what chi was sent.
477
+ // Never touched by a turn: dim in a turn lens.
478
+ function partRowTemplate(given, { touched = null }) {
479
+ const row = ownRow(given);
364
480
  const lensClass = touched ? " dim" : "";
365
481
  const tokens = tokensText(row.partTokens);
366
- return html`<div class=${`ws-row ${row.kind}${lensClass}`} data-ws-part=${row.key}><span class="k"></span><span class="t" title=${row.sub ? `${row.label}: ${row.sub}` : row.label}>${row.label}</span>${row.sub ? html`<span class="st">${row.sub}</span>` : nothing}${tokens ? html`<span class="tk" title="about its tokens in every request">${tokens}</span>` : nothing}</div>`;
482
+ const opens = !!part && !!row.partKeys?.length;
483
+ const id = opens ? `start:part:${row.key}` : null;
484
+ const peeked = opens && part.isOpen(id);
485
+ const toggle = opens ? partToggle(id, row, row.label, peeked, {}) : nothing;
486
+ return html`<div class=${`ws-row ${row.kind}${lensClass}${opens ? " peekable" : ""}${peeked ? " peeked" : ""}`} data-ws-part=${row.key}>${toggle}<span class="k"></span><span class="t" title=${row.sub ? `${row.label}: ${row.sub}` : row.label}>${row.label}</span>${row.partEdited ? html`<span class="e">✎</span>` : nothing}${row.partStale ? staleTemplate(row.sub ? `${row.sub} · ${PART_CHANGED}` : undefined) : row.partEdited ? ownTemplate(row.sub, row.partEdited) : row.sub ? html`<span class="st">${row.sub}</span>` : nothing}${tokens ? html`<span class="tk" title="about its tokens in every request">${tokens}</span>` : nothing}${row.partEdited ? ownTagTemplate(row.partEdited) : nothing}</div>${peeked ? part.template(row) : nothing}`;
367
487
  }
368
488
 
369
489
  // The Conversation section as one row at section level ("Conversation ·
@@ -465,7 +585,7 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
465
585
  const set = { ...full, items: heldOrder(full.items, openKeys) };
466
586
  // The head view (no parts: today's list); a turn's read of `system/x`
467
587
  // lights the start row of `x`, and a prompt memory is never new.
468
- const head = headSections(set, POP_BUDGET, { parts: st.promptParts, ctxTokens: st.ctxTokens, turns: last + 1, inTurn: !inSession });
588
+ const head = headSections(set, POP_BUDGET, { parts: st.promptParts, ctxTokens: st.ctxTokens, turns: last + 1, inTurn: !inSession, states: partStates() });
469
589
  const inPrompt = promptKeys(head);
470
590
  const picked = inSession ? null : turnLens(headItems(set, st.promptParts).filter((item) => !inPrompt.has(itemKey(item))), turnItems(at), at);
471
591
  const opts = { session: inSession, now, pend, forget, touched: lensTouched(head, picked?.touched || null) };
@@ -552,7 +672,8 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
552
672
  }
553
673
  } else if (act.dataset.ws === "peek" && peek) {
554
674
  const item = rowItem(act.dataset.wsId);
555
- if (item) peek.toggle(act.dataset.wsId, item);
675
+ // One peek at a time across both kinds.
676
+ if (item) { part?.close(); peek.toggle(act.dataset.wsId, item); }
556
677
  } else if (act.dataset.ws === "timeline" && onTimeline) {
557
678
  const item = rowItem(act.dataset.wsId);
558
679
  if (popover.isOpen()) popover.close();
@@ -635,10 +756,20 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
635
756
  }
636
757
 
637
758
  // A newer server snapshot redraws every form; an older one (a GET that
638
- // answered after a newer event) is dropped. +how+: newerSnapshot's.
759
+ // answered after a newer event) is dropped, all but its parts. +how+:
760
+ // newerSnapshot's. The parts (the stale prompt parts) are a GET's word
761
+ // alone: an event's set carries none, so the session's last GET's stay
762
+ // (stale lasts until chi rebuilds its prompt; #sessionChanged and a
763
+ // hand-off ask again), and a GET an event overtook still gives them.
639
764
  function takeServer(snapshot, how) {
640
- const next = newerSnapshot(server, snapshot, how);
641
- if (next === server) return;
765
+ let next = newerSnapshot(server, snapshot, how);
766
+ const same = !!server && serverOf === session();
767
+ if (next === server) {
768
+ if (how?.event || !same || !Array.isArray(snapshot?.items) || partsSig(snapshot.parts) === partsSig(server.parts)) return;
769
+ next = withParts(server, snapshot.parts);
770
+ } else if (how?.event && same && !("parts" in next) && server.parts) {
771
+ next = withParts(next, server.parts);
772
+ }
642
773
  server = next;
643
774
  serverOf = session();
644
775
  changed();
@@ -649,6 +780,12 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
649
780
  if (how?.event && popover.isOpen()) peek?.refresh();
650
781
  }
651
782
 
783
+ // +snapshot+ with +parts+ (none: without the field).
784
+ function withParts(snapshot, parts) {
785
+ const { parts: _drop, ...rest } = snapshot;
786
+ return Array.isArray(parts) && parts.length ? { ...rest, parts } : rest;
787
+ }
788
+
652
789
  // The server's set for the open session, asked again; an answer for a
653
790
  // session no longer open is dropped.
654
791
  function fetchServer() {
@@ -692,7 +829,14 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
692
829
  if (popover.isOpen()) popover.refresh();
693
830
  },
694
831
  // Prompt memories changed; the open session list reads them from state.
832
+ // A new prompt build (its parts' heads or digests) asks the server's set
833
+ // again: its stale states are the build's.
695
834
  sessionChanged() {
835
+ const sig = builtSigOf(state().promptParts);
836
+ const rebuilt = builtOf === session() && builtSig !== null && sig !== builtSig;
837
+ builtSig = sig;
838
+ builtOf = session();
839
+ if (rebuilt) fetchServer();
696
840
  if (popover.isOpen()) popover.refresh();
697
841
  },
698
842
  // The context's tokens or window changed (a chunk, a context_status):
@@ -702,7 +846,7 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
702
846
  const st = state();
703
847
  const inSession = curLens() === null;
704
848
  const set = sessionSet();
705
- const head = headSections(set, POP_BUDGET, { parts: st.promptParts, ctxTokens: st.ctxTokens, turns: lastTurn() + 1, inTurn: !inSession });
849
+ const head = headSections(set, POP_BUDGET, { parts: st.promptParts, ctxTokens: st.ctxTokens, turns: lastTurn() + 1, inTurn: !inSession, states: partStates() });
706
850
  if (tokenText(lensLines(st, set, head, inSession), head) !== shownTokens) popover.refresh();
707
851
  },
708
852
  // A :working_set_updated event's set ({items, at}).
@@ -750,6 +894,8 @@ export function createWorkingSet({ historyEl, stageRoot = () => null, state, ses
750
894
  turns.push({ items, prompt });
751
895
  live = null;
752
896
  changed();
897
+ // A turn's end: the stale states asked again when there are some, or the list is open.
898
+ if (server?.parts || popover.isOpen()) fetchServer();
753
899
  return footprintNode(lit(items), ordinal);
754
900
  },
755
901
  // The running turn left without a hand-off (a reset): forgotten.
@@ -0,0 +1,277 @@
1
+ // The working set popover's prompt peek: a "From the start" row's ▸ opens,
2
+ // under the row, the text chi was sent for that prompt part (chi web's GET
3
+ // …/working_set/part, a slice of the session's saved head: WorkingSetPart).
4
+ // A memory's text and an .md file's render through the reader's markdown
5
+ // cache (+md+: ws_markdown.js), anything else as its source; the line chi
6
+ // adds before it folds under "chi adds a line before it". Tools open as
7
+ // their declared names and sizes. A prompt peek has no foot buttons: a
8
+ // memory never read has no timeline, and the row's name is not a link.
9
+ //
10
+ // One row, several holds (a note also preloaded, a prompt memory also
11
+ // read): one tab per hold, its kind and size ("note · ~0.9k"), and "read ·
12
+ // t1·s1" for the item's read, which is the item peek's (ws_peek.js, +itemPeek+)
13
+ // and opens first when there is one. When the sent text isn't there, one
14
+ // line says why (the route's words, case C of the plan), the source now
15
+ // under it when chi could fetch it.
16
+ //
17
+ // A stale hold (the row's partStates, from chi web's GET: its source
18
+ // changed since chi was sent it) gets a "now · changed" tab right after
19
+ // its own: the part route's &now=1, its diff from the sent text drawn as
20
+ // the reader draws a diff (diff_view.js). It opens first when the row has
21
+ // no read. Under it, when chi gets the new text (the route's rebuild: a
22
+ // live worker at its prompt's next build, else at its next turn), and,
23
+ // when chi changed it and it changed again after (the row's partByChi,
24
+ // current false), a line naming chi's edit.
25
+ //
26
+ // A hold chi changed itself ("edited" in partStates: the view lays the
27
+ // GET's by_chi on the row) gets an "edited · t3·s2" tab ("removed · …")
28
+ // in its place: the same &now=1 answer, headed "chi edited <label> at
29
+ // t3·s2", its diff, and the line that says both facts (the prompt still
30
+ // sends the old text; chi has the new text from its edit). An older
31
+ // cached peek sees no stale there and shows the sent text.
32
+ //
33
+ // Made by ws_reader.js createWorkingSetPreview and handed to the view as
34
+ // its peek's +part+ (no new export on ws_reader.js): a view without it
35
+ // (an older cached ws_reader.js) draws today's rows. One peek open at a
36
+ // time across both kinds: opening here closes the item peek.
37
+
38
+ import { html, nothing } from "./vendor/lit-html.js";
39
+ import { api } from "./data.js";
40
+ import { diffCounts, diffTemplate } from "./diff_view.js";
41
+ import { createLatest } from "./latest.js";
42
+ import { textTemplate } from "./ws_cards.js";
43
+ import { peekMarkdownTemplate, peekText } from "./ws_markdown.js";
44
+ import { tokensText } from "./working_set.js";
45
+
46
+ // The part route's path for session +id+ and part +key+ (PromptPart.keys);
47
+ // +now+: with the source now and its diff.
48
+ export function partPath(id, key, { now = false } = {}) {
49
+ return `/api/sessions/${encodeURIComponent(id)}/working_set/part?key=${encodeURIComponent(key)}${now ? "&now=1" : ""}`;
50
+ }
51
+
52
+ // The part route's answer.
53
+ export function getWorkingSetPart(id, key, opts = {}) {
54
+ return api(partPath(id, key, opts));
55
+ }
56
+
57
+ // A hold's tab word, by the part's kind.
58
+ const HOLD_WORDS = { notes: "note", preloads: "preload" };
59
+ const MEMORY_KINDS = ["identity", "notes", "preloads"];
60
+ const SENT = "in the prompt · sent with every request";
61
+ // A now tab's words when its row's read is stale too: both causes (the row says one "stale").
62
+ const BOTH_CHANGED = "read changed · prompt text changed";
63
+ // When chi's prompt gets the source now (the part route's rebuild).
64
+ const REBUILD_LIVE = "when its prompt is next built (a restart, a model switch)";
65
+ const REBUILD_NEXT = "at its next turn";
66
+ const STILL_SENT = "Its prompt still sends the old text with every request; chi has the new text from its edit.";
67
+ const PROMPT_GETS = { restart: "The prompt gets it when it is next built (a restart, a model switch).", next_turn: "The prompt gets it when it is next built (at its next turn)." };
68
+
69
+ // Whether the row's read is stale too (its item stale and read; one chi only wrote is stale by that write).
70
+ const readStale = (r) => r?.state === "stale" && (r.ops || []).includes("read");
71
+ // A part key's kind ("notes:model_notes_y@system" → "notes").
72
+ const kindOf = (key) => String(key).split(":", 1)[0];
73
+ // A stale hold's now tab: "now:" and its part's key.
74
+ const NOW = "now:";
75
+ const nowOf = (key) => (String(key).startsWith(NOW) ? String(key).slice(NOW.length) : null);
76
+ // A hold chi changed itself: "edited:" and its part's key.
77
+ const EDITED = "edited:";
78
+ const editedOf = (key) => (String(key).startsWith(EDITED) ? String(key).slice(EDITED.length) : null);
79
+ // The &now=1 tabs' part key (a now tab's, an edited tab's), else null.
80
+ const sourceOf = (key) => nowOf(key) ?? editedOf(key);
81
+
82
+ // Whether a part's text renders as markdown: a memory's, an .md file's.
83
+ function renders(part) {
84
+ if (!part) return false;
85
+ if (MEMORY_KINDS.includes(part.kind)) return true;
86
+ return (part.kind === "agents" || part.kind === "appended") && /\.md$/i.test(String(part.ref || ""));
87
+ }
88
+
89
+ // +text+ rendered (+md+ has its HTML) or as its source.
90
+ function bodyTemplate(text, part, md) {
91
+ const rendered = md && renders(part) ? peekMarkdownTemplate(text, md) : null;
92
+ if (rendered) return rendered;
93
+ return textTemplate(renders(part) ? peekText(text) : text, { fold: Infinity });
94
+ }
95
+
96
+ const leadTemplate = (lead) => (lead ? html`<details class="ws-lead"><summary>chi adds a line before it</summary><pre>${lead}</pre></details>` : nothing);
97
+
98
+ // The tools' names and sizes (a size only where the build had one per tool).
99
+ function toolsTemplate(tools) {
100
+ return html`<div class="ws-tools">${tools.map((t) => html`<span class="ws-tool-n">${t.name}</span><span class="ws-tool-k">${Number.isFinite(t.chars) ? tokensText(Math.ceil(t.chars / 4)) : ""}</span>`)}</div>`;
101
+ }
102
+
103
+ // +session()+: the open session's id; +getPart(id, key)+: the part route;
104
+ // +itemPeek+: the rows' item peek (ws_peek.js; its template is the "read"
105
+ // tab); +md+: the reader's markdown cache; +onChange()+: the peek's content
106
+ // changed (the popover redraws and places itself again).
107
+ export function createPartPeek({ session, getPart = getWorkingSetPart, itemPeek = null, md = null, onChange = () => {} }) {
108
+ let openId = null;
109
+ let itemId = null;
110
+ let row = null;
111
+ let tab = null;
112
+ // Answers by part key, for the open row; whether one failed.
113
+ let answers = new Map();
114
+ let failed = new Set();
115
+ const latest = createLatest(() => `${session()}|${openId}|${tab}`);
116
+
117
+ // The row's tabs: its read, then each part's, a stale one's now after it.
118
+ const holdsOf = (r, read) => [
119
+ ...(read ? ["read"] : []),
120
+ ...(r?.partKeys || []).flatMap((key, i) => {
121
+ const st = r.partStates?.[i];
122
+ return st === "stale" ? [key, `${NOW}${key}`] : st === "edited" ? [key, `${EDITED}${key}`] : [key];
123
+ }),
124
+ ];
125
+ // The tab a row opens on: its read, else a changed part's now or edited tab, else its first.
126
+ const firstOf = (holds) => (holds.includes("read") ? "read" : holds.find((key) => sourceOf(key)) || holds[0] || null);
127
+ // A part's own change on the open row (+r+'s partByChi, its tag), by part key.
128
+ const ownOf = (r, key) => {
129
+ const i = (r?.partKeys || []).indexOf(key);
130
+ return i < 0 ? { change: null, tag: "" } : { change: r.partByChi?.[i] || null, tag: r.partTags?.[i] || "" };
131
+ };
132
+
133
+ function load(key) {
134
+ const id = session();
135
+ if (!id || !key || key === "read" || answers.has(key)) return;
136
+ const fresh = latest.begin();
137
+ const now = sourceOf(key);
138
+ Promise.resolve()
139
+ .then(() => (now ? getPart(id, now, { now: true }) : getPart(id, key)))
140
+ .then((answer) => {
141
+ if (!fresh()) return;
142
+ answers.set(key, answer);
143
+ failed.delete(key);
144
+ onChange();
145
+ })
146
+ .catch(() => {
147
+ if (!fresh()) return;
148
+ failed.add(key);
149
+ onChange();
150
+ });
151
+ }
152
+
153
+ // Shows +key+ (a part key, or "read": the item peek's).
154
+ function show(key) {
155
+ tab = key;
156
+ if (key === "read") {
157
+ if (itemPeek && !itemPeek.isOpen(itemId)) itemPeek.toggle(itemId, row);
158
+ } else {
159
+ if (itemPeek?.any()) itemPeek.close();
160
+ load(key);
161
+ }
162
+ }
163
+
164
+ function close() {
165
+ if (openId && tab === "read") itemPeek?.close();
166
+ openId = null;
167
+ itemId = null;
168
+ row = null;
169
+ tab = null;
170
+ answers = new Map();
171
+ failed = new Set();
172
+ latest.drop();
173
+ }
174
+
175
+ // A now tab's body (+key+: its part's): what changed since chi was sent
176
+ // it, as a diff, and when chi gets it; chi's edit when it changed again
177
+ // after chi's own change. A head changed since (case C 4-5): build 1's
178
+ // line and the source under it.
179
+ function nowBody(data, r, key) {
180
+ const now = data.now;
181
+ if (!data.sent) return null;
182
+ // The route fetched nothing (the guard refused, the part no longer fetchable): never the sent text under "now".
183
+ if (!now) return html`<div class="ws-peek-note">Couldn't fetch its source now.</div>`;
184
+ const { change, tag } = ownOf(r, key);
185
+ const again = change && change.current === false && tag ? html`<div class="ws-peek-copy warn">chi edited it at ${tag}; it changed again after that.</div>` : nothing;
186
+ const when = data.rebuild ? html`<div class="ws-peek-copy">chi gets the new text ${data.rebuild === "restart" ? REBUILD_LIVE : REBUILD_NEXT}.</div>` : nothing;
187
+ if (now.gone) return html`<div class="ws-peek-note">Its source is gone now.</div>${again}${when}`;
188
+ const counts = now.diff?.text ? html`<div class="ws-peek-h"><span class="ws-peek-t">${readStale(r) ? `${data.part?.label || "It"}: ${BOTH_CHANGED}` : `${data.part?.label || "It"} changed after chi's prompt was built`}</span><span class="ws-peek-c">${diffCounts(now.diff)}</span></div>` : nothing;
189
+ return html`${counts}<div class="ws-peek-b">${diffTemplate(now.diff)}</div>${again}${when}`;
190
+ }
191
+
192
+ // An edited tab's body: chi's own change (the &now=1 answer: sent → now),
193
+ // and the line that says both facts; a remove, its one line.
194
+ function editedBody(data, r, key) {
195
+ if (!data.sent) return null;
196
+ const { change, tag } = ownOf(r, key);
197
+ const at = tag ? ` at ${tag}` : "";
198
+ // The words follow chi's call, as the row's do: a remove says removed; an edit or a write says edited (an
199
+ // AGENTS.md chi's write emptied reads gone, and is still chi's edit).
200
+ if (change?.op === "remove") {
201
+ return html`<div class="ws-peek-copy">chi removed it${at}; its prompt still sends it until it is next built.</div>`;
202
+ }
203
+ const now = data.now;
204
+ if (!now) return html`<div class="ws-peek-note">Couldn't fetch its source now.</div>`;
205
+ const head = html`<div class="ws-peek-h"><span class="ws-peek-t">chi edited ${data.part?.label || "it"}${at}</span>${now.diff?.text ? html`<span class="ws-peek-c">${diffCounts(now.diff)}</span>` : nothing}</div>`;
206
+ const gets = PROMPT_GETS[data.rebuild] ? ` ${PROMPT_GETS[data.rebuild]}` : "";
207
+ const body = now.gone ? html`<div class="ws-peek-note">Its source is gone now.</div>` : html`<div class="ws-peek-b">${diffTemplate(now.diff)}</div>`;
208
+ return html`${head}${body}<div class="ws-peek-copy">${STILL_SENT}${gets}</div>`;
209
+ }
210
+
211
+ function partBody(key, r) {
212
+ if (failed.has(key)) return html`<div class="ws-peek-note">Couldn't load the prompt part.</div>`;
213
+ const data = answers.get(key);
214
+ if (!data) return html`<div class="ws-peek-note">Loading…</div>`;
215
+ const changed = nowOf(key) ? nowBody(data, r, nowOf(key)) : editedOf(key) ? editedBody(data, r, editedOf(key)) : null;
216
+ if (changed) return changed;
217
+ if (Array.isArray(data.tools)) return html`<div class="ws-peek-b">${toolsTemplate(data.tools)}</div>`;
218
+ if (data.sent) return html`<div class="ws-peek-b">${bodyTemplate(data.sent.text, data.part, md)}</div>${leadTemplate(data.sent.lead)}`;
219
+ const now = data.now?.gone ? html`<div class="ws-peek-note">Its source is gone now.</div>`
220
+ : data.now ? html`<div class="ws-peek-b">${bodyTemplate(data.now.text, data.part, md)}</div>` : nothing;
221
+ return html`<div class="ws-peek-note">${data.note || ""}</div>${now}`;
222
+ }
223
+
224
+ const peek = {
225
+ // +id+'s row opened, or closed when it was. +read+: the row's item has
226
+ // a read to peek at (the item peek's tab, first), +item+ its id there
227
+ // (working_set.js steerId: the timeline's way in).
228
+ toggle(id, r, { read = false, item = null } = {}) {
229
+ if (openId === id) close();
230
+ else if (!holdsOf(r, read).length) return;
231
+ else {
232
+ if (openId) close();
233
+ if (itemPeek?.any()) itemPeek.close();
234
+ openId = id;
235
+ itemId = item;
236
+ row = r;
237
+ show(firstOf(holdsOf(r, read)));
238
+ }
239
+ onChange();
240
+ },
241
+ isOpen: (id) => openId === id,
242
+ any: () => openId !== null,
243
+ close,
244
+ // A tab of the open row chosen.
245
+ tab(key) {
246
+ if (!openId || key === tab) return;
247
+ show(key);
248
+ onChange();
249
+ },
250
+ // The peek under +r+ (the open row); +read+: its item has a read, +readTag+
251
+ // its step tag ("t1·s1").
252
+ template(r, { read = false, readTag = "" } = {}) {
253
+ const holds = holdsOf(r, read);
254
+ const current = holds.includes(tab) ? tab : holds[0];
255
+ // A tab gone (its row's states changed): the one shown instead is asked for, never left loading.
256
+ if (current !== tab && current !== "read") {
257
+ tab = current;
258
+ load(current);
259
+ }
260
+ const tabs = holds.length > 1 ? html`<div class="ws-tabs" role="tablist">${holds.map((key) => {
261
+ const own = editedOf(key) ? ownOf(r, editedOf(key)) : null;
262
+ const words = key === "read" ? `read${readTag ? ` · ${readTag}` : ""}` : nowOf(key) ? "now · changed"
263
+ : own ? `${own.change?.op === "remove" ? "removed" : "edited"}${own.tag ? ` · ${own.tag}` : ""}`
264
+ : `${HOLD_WORDS[kindOf(key)] || "in the prompt"} · ${tokensText(r.partSizes?.[r.partKeys.indexOf(key)])}`;
265
+ const title = nowOf(key) ? (readStale(r) ? BOTH_CHANGED : "its source changed after chi's prompt was built")
266
+ : own ? "chi changed it itself: the new text is in its conversation" : nothing;
267
+ return html`<button type="button" class=${`ws-tab${key === current ? " on" : ""}${nowOf(key) ? " warn" : ""}`} title=${title} role="tab" aria-selected=${String(key === current)} @click=${() => peek.tab(key)}>${words}</button>`;
268
+ })}</div>` : nothing;
269
+ if (current === "read") return html`<div class="ws-peek ws-held" role="region" aria-label="What chi has">${tabs}${itemPeek ? itemPeek.template(r) : nothing}</div>`;
270
+ const data = answers.get(current);
271
+ const declared = Array.isArray(data?.tools) ? ` · ${data.tools.length} declared` : "";
272
+ const head = holds.length < 2 && (data?.sent || data?.tools) ? html`<div class="ws-peek-h"><span class="ws-peek-t">${SENT}${declared}</span></div>` : nothing;
273
+ return html`<div class="ws-peek ws-part-peek" role="region" aria-label="What chi was sent">${tabs}${head}${partBody(current, r)}</div>`;
274
+ },
275
+ };
276
+ return peek;
277
+ }
@@ -32,7 +32,9 @@ import { peekMarkdownTemplate, peekText, renderableEvent } from "./ws_markdown.j
32
32
  // step whose tool batch hasn't ended.
33
33
  const STEP_RUNNING = "chi read this in the step still running. It shows here when that step's tools finish.";
34
34
 
35
- // The popover's width while a row is peeked (it is 420 otherwise).
35
+ // The popover's width while a row is peeked. Kept for an older cached
36
+ // working_set_view.js, which imports it (the view is 520 wide always now):
37
+ // goes at the next release.
36
38
  export const PEEK_WIDTH = 520;
37
39
 
38
40
  // +session()+: the open session's id; +getItem(id, kind, key, opts)+: the item
@@ -27,6 +27,36 @@
27
27
  .ws-popover.sheet .ws-peek-f>button{flex:1;height:44px;text-align:center}
28
28
  .ws-popover.sheet .ws-peek-f>button+button{border-left:1px solid var(--border)}
29
29
 
30
+ /* The prompt peek (ws_part_peek.js): a "From the start" row's sent text,
31
+ the line chi adds before it folded, the tools' names and sizes, one tab
32
+ per hold. A held row's read tab is the item peek, drawn inside it. */
33
+ .ws-part-peek .ws-peek-b{padding:0}
34
+ .ws-part-peek .ws-peek-b .wsr-md{padding:8px 12px}
35
+ .ws-lead{margin:6px 12px 8px;border:1px dashed var(--border-strong);border-radius:6px;font-size:11.5px;color:var(--ws-muted)}
36
+ .ws-lead>summary{cursor:pointer;padding:4px 8px}
37
+ .ws-lead>pre{margin:0;padding:6px 8px;border-top:1px dashed var(--border-strong);font:11px ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;color:var(--text-2)}
38
+ .ws-tools{display:grid;grid-template-columns:1fr auto;gap:2px 12px;padding:8px 12px;max-height:220px;overflow:auto;font:11.5px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text-2)}
39
+ .ws-tool-k{color:var(--ws-faint);text-align:right;font-variant-numeric:tabular-nums}
40
+ .ws-tabs{display:flex;gap:2px;padding:4px 6px 0;border-bottom:1px solid var(--border)}
41
+ .ws-tab{padding:5px 10px;border:1px solid transparent;border-bottom:0;border-radius:6px 6px 0 0;background:transparent;color:var(--ws-muted);font:inherit;font-size:12px;cursor:pointer}
42
+ .ws-tab.on{color:var(--text);background:var(--bg-panel);border-color:var(--border);margin-bottom:-1px;padding-bottom:6px}
43
+ .ws-tab:hover:not(:disabled){filter:none}@media(hover:hover){.ws-tab:not(.on):hover{color:var(--text-2)}}
44
+ .ws-held>.ws-peek{margin:0;border:0;border-radius:0}
45
+ /* A prompt row whose source changed since chi was sent it, and its now tab. */
46
+ .ws-row .st.ws-pstale{color:var(--warn-text)}
47
+ .ws-tab.warn,.ws-tab.warn.on{color:var(--warn-text)}
48
+ @media(hover:hover){.ws-tab.warn:not(.on):hover{color:var(--warn-bright)}}
49
+ /* A prompt row whose source chi changed itself: "edited" in the plain secondary colour (not the warn one); a
50
+ phone's sheet drops its part words (D7), and a part row keeps "edited" where it drops its sub text. The
51
+ peek's copy lines under the diff: when chi gets the new text, and (warn) chi's edit it changed again after. */
52
+ .ws-row .st.ws-pedited{color:var(--text-2)}
53
+ .ws-popover.sheet .ws-pwords{display:none}
54
+ .ws-popover.sheet .ws-row.part .st.ws-pedited{display:block}
55
+ .ws-peek-copy{padding:7px 12px 9px;border-top:1px solid var(--border);font-size:12px;line-height:1.45;color:var(--text-2)}
56
+ .ws-peek-copy.warn{color:var(--warn-text)}
57
+ .ws-peek-copy.warn+.ws-peek-copy{border-top:0;padding-top:0}
58
+ .ws-popover.sheet .ws-tabs{flex-wrap:wrap}
59
+
30
60
  /* A tool row's way in. */
31
61
  .activity-ws{flex:none;padding:0 6px;border:1px solid var(--ws-act-border);border-radius:4px;background:transparent;font-size:11px;line-height:16px;color:var(--ws-muted);cursor:pointer;opacity:0}
32
62
  .activity-row:hover .activity-ws,.activity-row:focus-within .activity-ws{opacity:1}