samagotchi 0.167.0 → 0.169.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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -1
  3. data/docs/architecture.md +1 -1
  4. data/docs/cli.md +14 -10
  5. data/docs/configuration.md +1 -1
  6. data/docs/guardrails.md +2 -3
  7. data/docs/hooks.md +2 -2
  8. data/docs/internals/block-renderers.md +1 -1
  9. data/docs/internals/bridge.md +16 -4
  10. data/docs/internals/inline-widgets.md +1 -1
  11. data/docs/internals/objectives.md +2 -1
  12. data/docs/internals/remote-sessions.md +1 -1
  13. data/docs/internals/web-frontend.md +99 -19
  14. data/docs/plugins.md +1 -1
  15. data/docs/releasing.md +10 -6
  16. data/docs/testing.md +14 -3
  17. data/lib/samagotchi/bridge.rb +12 -2
  18. data/lib/samagotchi/bundle_command.rb +19 -4
  19. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  20. data/lib/samagotchi/client_id.rb +3 -0
  21. data/lib/samagotchi/command_intake.rb +7 -7
  22. data/lib/samagotchi/compat.rb +12 -7
  23. data/lib/samagotchi/engine/objectives.rb +10 -1
  24. data/lib/samagotchi/guardrails/approvals.rb +10 -29
  25. data/lib/samagotchi/session_continue.rb +8 -11
  26. data/lib/samagotchi/session_manager/removal.rb +3 -3
  27. data/lib/samagotchi/session_stores.rb +79 -0
  28. data/lib/samagotchi/turn_stages/objectives.rb +6 -8
  29. data/lib/samagotchi/version.rb +1 -1
  30. data/lib/samagotchi/web/public/app.js +3 -1
  31. data/lib/samagotchi/web/public/block_watch.js +1 -1
  32. data/lib/samagotchi/web/public/cards_place.js +5 -1
  33. data/lib/samagotchi/web/public/dock_reserve.js +12 -2
  34. data/lib/samagotchi/web/public/history_end.js +16 -0
  35. data/lib/samagotchi/web/public/index.html +89 -44
  36. data/lib/samagotchi/web/public/markdown_place.js +1 -1
  37. data/lib/samagotchi/web/public/question_cards.js +21 -7
  38. data/lib/samagotchi/web/public/refs.js +4 -1
  39. data/lib/samagotchi/web/public/reload_check.js +5 -4
  40. data/lib/samagotchi/web/public/stage_asking.js +283 -0
  41. data/lib/samagotchi/web/public/stage_cards.js +20 -0
  42. data/lib/samagotchi/web/public/stage_frame.js +17 -23
  43. data/lib/samagotchi/web/public/stage_model.js +48 -15
  44. data/lib/samagotchi/web/public/stage_opened.js +239 -0
  45. data/lib/samagotchi/web/public/stage_slots.js +13 -90
  46. data/lib/samagotchi/web/public/stage_view.js +339 -225
  47. data/lib/samagotchi/web/public/stage_waiting.js +180 -0
  48. data/lib/samagotchi/web/public/stage_watch.js +8 -4
  49. data/lib/samagotchi/web/public/stream_handlers.js +1 -1
  50. data/lib/samagotchi/web/public/turn_block.js +14 -2
  51. data/lib/samagotchi/web/public/turn_model.js +1 -1
  52. data/lib/samagotchi/web/session_show.rb +14 -4
  53. data/lib/samagotchi/worker.rb +3 -4
  54. metadata +7 -1
@@ -49,10 +49,10 @@ body{font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetic
49
49
  /* A session that waits on the user (a question, an approval, a card with actions): the warning colour of its question card, also when active or hovered. */
50
50
  #topStrip .card.waiting,#allList .card.waiting{border-color:color-mix(in srgb,var(--warn) 75%,transparent)}
51
51
  @media(hover:hover){#topStrip .card.waiting:hover,#allList .card.waiting:hover{border-color:var(--warn)}}
52
- @supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.turn-stage,#topStrip .card,#allList .card,#allHead input{background:var(--bg-panel)}.bubble.question{background:color-mix(in srgb,var(--warn) 7%,var(--bg-panel))}.bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel))}}
53
- @media (prefers-reduced-transparency:reduce){.turn-stage,#topStrip .card,#allList .card,#allHead input{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}.bubble.question{background:color-mix(in srgb,var(--warn) 7%,var(--bg-panel));-webkit-backdrop-filter:none;backdrop-filter:none}.bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel));-webkit-backdrop-filter:none;backdrop-filter:none}}
52
+ @supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.turn-stage,#topStrip .card,#allList .card,#allHead input{background:var(--bg-panel)}.bubble.question{background:var(--bg-panel)}.bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel))}}
53
+ @media (prefers-reduced-transparency:reduce){.turn-stage,#topStrip .card,#allList .card,#allHead input{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}.bubble.question{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}.bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel));-webkit-backdrop-filter:none;backdrop-filter:none}}
54
54
  body.no-glass .turn-stage,body.no-glass #topStrip .card,body.no-glass #allList .card,body.no-glass #allHead input{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}
55
- body.no-glass .bubble.question{background:color-mix(in srgb,var(--warn) 7%,var(--bg-panel));-webkit-backdrop-filter:none;backdrop-filter:none}
55
+ body.no-glass .bubble.question{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}
56
56
  body.no-glass .bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel));-webkit-backdrop-filter:none;backdrop-filter:none}
57
57
  button,input,textarea,select{font:inherit}
58
58
  button{background:var(--primary);border:0;color:var(--on-solid);padding:8px 12px;border-radius:8px;cursor:pointer;transition:filter .12s ease,background .12s ease}
@@ -426,30 +426,57 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
426
426
  .gen:not(.live) .gen-text{font-size:14px;color:var(--text-2)}
427
427
  .gen-text:empty{display:none}
428
428
  .gen .activity-body{margin-top:6px}
429
- /* One gen, no thinking, no tool rows: nothing to stack yet, so the narration streams like a plain answer bubble. A step that closed with text (a line steered in after it, its answer gone from the block) is a row: its summary is the way to its text. */
430
- .turn-work:not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)){border:0;padding:0;background:transparent}
431
- .turn-work:not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text))>summary,.turn-work:not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen>summary{display:none}
432
- .turn-work:not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen{margin:0;padding:0;border:0;background:transparent}
433
- .turn-work:not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen-text{margin:0;background:var(--bg-panel);border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:12px;padding:12px 14px;opacity:.95}
429
+ /* One gen, no thinking, no tool rows: nothing to stack yet, so the narration streams like a plain answer bubble. A step that closed with text (a line steered in after it, its answer gone from the block) is a row: its summary is the way to its text. So is a running turn's block opened in the
430
+ history (data-opened-turn, stage_asking.js openTurn): the step's text is in it while a card without a lead-in waits. */
431
+ .turn-work:not([data-opened-turn]):not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)){border:0;padding:0;background:transparent}
432
+ .turn-work:not([data-opened-turn]):not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text))>summary,.turn-work:not([data-opened-turn]):not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen>summary{display:none}
433
+ .turn-work:not([data-opened-turn]):not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen{margin:0;padding:0;border:0;background:transparent}
434
+ .turn-work:not([data-opened-turn]):not(:has(.gen~.gen,.thinking-body,.activity-body,.gen:not(.live)>.gen-text)) .gen-text{margin:0;background:var(--bg-panel);border:1px solid var(--border);border-left:3px solid var(--accent);border-radius:12px;padding:12px 14px;opacity:.95}
434
435
  @media(max-width:600px){.gen{--step-indent:8px}}
435
- /* A question card asks for input like the composer card, so it wears the same glass (the recipe above); only its warm tint is its own. */
436
- .bubble.question{border-left:3px solid var(--warn);background:color-mix(in srgb,var(--warn) 7%,var(--glass-bg));padding:10px 12px}
436
+ /* A question card asks for input like the composer card, so it wears the same glass (the recipe above), no amber: what
437
+ waits says so in the stage's status row ("waiting for you", its dot) and on a waiting lead-in bubble. */
438
+ .bubble.question{border-left:3px solid var(--border-strong);padding:10px 12px}
437
439
  /* Collapsed (resolved) question: one line, like the thinking and activity blocks.
438
- The left bar keeps --warn here; the existing answered/cancelled/denied classes
440
+ The left bar is neutral here; the existing answered/cancelled/denied classes
439
441
  (which apply whether open or not) recolour it once resolved. */
440
442
  .bubble.question:not([open]){padding:3px 10px;background:transparent;border-color:transparent;box-shadow:none;-webkit-backdrop-filter:none;backdrop-filter:none;align-self:flex-start;border-radius:6px;transition:background .12s ease}
441
- .bubble.question:not([open]){border-left-color:var(--warn)}
443
+ .bubble.question:not([open]){border-left-color:var(--border-strong)}
442
444
  @media(hover:hover){.bubble.question:not([open]):hover{background:var(--bg-panel)}}
443
445
  .bubble.question:not([open])>summary{font-size:12px;font-weight:500}
444
446
  .bubble.question>summary{cursor:pointer;color:var(--text-muted);font-size:13px;font-weight:600;user-select:none;list-style:none}
445
447
  .bubble.question>summary::-webkit-details-marker{display:none}
446
- .bubble.question>summary::before{content:"▸ ";color:var(--warn)}
448
+ .bubble.question>summary::before{content:"▸ ";color:var(--text-faint)}
447
449
  .bubble.question[open]>summary::before{content:"▾ "}
448
450
  /* An answered card keeps the reply that asked it (question_cards.js): muted under its "Q → A" line, two lines while
449
451
  closed (newlines as spaces); open, the summary's copy goes and the body's starts the card, whole, as written and
450
452
  selectable. */
451
453
  .bubble.question>summary .question-said{max-width:72ch;margin:2px 0 1px 1.05em;font-size:12.5px;font-weight:400;line-height:1.5;color:var(--text-muted);white-space:normal;overflow-wrap:anywhere;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden}
452
454
  .bubble.question[open]>summary .question-said{display:none}
455
+ /* A turn opened in the history (stage_opened.js): while the turn runs, a card answered under its reason doesn't repeat it;
456
+ the reason goes at the hand-off and the card's clamp says it then. The card's way back to its reason sits at the right of its
457
+ title line while it waits. */
458
+ .bubble.said+.bubble.question :is(.question-said,.question-said-full){display:none}
459
+ /* Its asking step in the steps block doesn't repeat the reason either (stage_opened.js data-said, until the hand-off). */
460
+ .turn-work>details.gen[data-said]>.gen-text{display:none}
461
+ /* A card that waits in the stage has no toggle of its own (stage_view.js): the stage's fold is the one. */
462
+ .turn-stage .bubble.question:not(.answered):not(.cancelled)>summary{cursor:default}
463
+ .turn-stage .bubble.question:not(.answered):not(.cancelled)>summary::before{content:none}
464
+ .question-reason-link{float:right;margin-left:12px;padding:0;border:0;background:none;color:var(--accent);font-size:12.5px;font-weight:500;line-height:inherit}
465
+ @media(hover:hover){.question-reason-link:hover:not(:disabled){filter:none;text-decoration:underline}}
466
+ /* The reply that asked the model's own question, a conversation bubble while its turn runs (live only): a label line ("chi ·
467
+ step N", "asking you" while its card waits), the text at the answer's size; the edge amber while it waits, neutral after. */
468
+ .bubble.said{border-left:3px solid var(--border-strong);font-size:15px;line-height:1.55;color:var(--text)}
469
+ .bubble.said.pending{border-left-color:var(--warn)}
470
+ .said-label{display:flex;gap:8px;margin-bottom:4px;font-size:12px;line-height:1.4;color:var(--text-faint);white-space:normal}
471
+ .said-asking{color:var(--warn-text);font-weight:600}
472
+ .bubble.said:not(.pending) .said-asking{display:none}
473
+ .said-text{white-space:pre-wrap;overflow-wrap:anywhere}
474
+ .said-text.md-compact{
475
+ --md-heading-size:16px;--md-heading-color:var(--text-bright);
476
+ --md-subheading-size:15px;--md-subheading-color:var(--text-2);
477
+ --md-strong-color:var(--text-bright);--md-blockquote-color:var(--text-muted);--md-code-color:var(--text);
478
+ --md-pre-size:13px;--md-cell-size:13.5px
479
+ }
453
480
  .question-said-full{margin:4px 0 6px;font-size:13px;line-height:1.55;color:var(--text-muted);white-space:pre-wrap;overflow-wrap:anywhere}
454
481
  .question-said-full.md-compact{
455
482
  --md-heading-size:13.5px;--md-heading-color:var(--text-2);
@@ -457,19 +484,13 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
457
484
  --md-strong-color:currentColor;--md-blockquote-color:currentColor;--md-code-color:currentColor;
458
485
  --md-pre-size:12px;--md-cell-size:12.5px
459
486
  }
460
- .ts-asking.md-compact{
461
- --md-heading-size:14.5px;--md-heading-color:var(--text-bright);
462
- --md-subheading-size:14px;--md-subheading-color:var(--text-2);
463
- --md-strong-color:var(--text-bright);--md-blockquote-color:var(--text-muted);--md-code-color:var(--text);
464
- --md-pre-size:12.5px;--md-cell-size:13px
465
- }
466
487
  .gen-text.md-compact{
467
488
  --md-heading-size:14.5px;--md-heading-color:var(--text);
468
489
  --md-subheading-size:14px;--md-subheading-color:var(--text-2);
469
490
  --md-strong-color:var(--text);--md-blockquote-color:var(--text-muted);--md-code-color:var(--text);
470
491
  --md-pre-size:12.5px;--md-cell-size:13px
471
492
  }
472
- .md-compact:is(.ts-asking,.question-said-full,.gen-text){white-space:normal}
493
+ .md-compact:is(.question-said-full,.gen-text,.said-text){white-space:normal}
473
494
  .md-compact :is(h1,h2,h3,h4,h5,h6){font-size:var(--md-heading-size);font-weight:600;line-height:1.4;margin:8px 0 2px;color:var(--md-heading-color)}
474
495
  .md-compact :is(h4,h5,h6){font-size:var(--md-subheading-size);color:var(--md-subheading-color)}
475
496
  .md-compact :is(p,ul,ol,blockquote,table,pre){margin:0 0 6px}
@@ -519,7 +540,7 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
519
540
  .question-option{display:flex;gap:8px;align-items:center;font-size:13px;color:var(--text-2);padding:6px 8px;border:1px solid var(--border);border-radius:8px;cursor:pointer}
520
541
  @media(hover:hover){.question-option:hover{background:var(--bg-hover)}}
521
542
  .question-option.selected{border-color:var(--ok);color:var(--text)}
522
- .question-option input{margin:0;accent-color:var(--warn)}
543
+ .question-option input{margin:0;accent-color:var(--accent)}
523
544
  /* The model's recommended option (a label ending in "(Recommended)"): an accent row and a small tag. */
524
545
  .question-option.recommended{border-color:var(--accent-border);background:var(--accent-bg);color:var(--text)}
525
546
  .question-option.recommended.selected{border-color:var(--ok)}
@@ -536,7 +557,7 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
536
557
  .bubble.question.cancelled .question-result{color:var(--text-muted)}
537
558
  .question-submit{align-self:flex-end;font-size:13px}
538
559
  .question-dismiss{font-size:13px;margin-left:8px}
539
- .bubble.question.approval{border-left-color:var(--warn);background:color-mix(in srgb,var(--warn) 7%,var(--glass-bg))}
560
+ .bubble.question.approval{border-left-color:var(--border-strong)}
540
561
  .bubble.question.approval.answered:not(.denied){border-left-color:var(--ok)}
541
562
  .bubble.question.approval:not([open]){background:transparent}
542
563
  @media(hover:hover){.bubble.question.approval:not([open]):hover{background:var(--bg-panel)}}
@@ -553,9 +574,9 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
553
574
  .question-relayed.hidden{display:none}
554
575
  .question-relayed a{color:var(--text);font-weight:600}
555
576
  .approval-tool{font-weight:700;color:var(--text);margin-bottom:4px}
556
- .approval-what{margin:0 0 6px;padding:8px 10px;background:var(--bg-inset);border:1px solid var(--warn-border);border-radius:6px;white-space:pre-wrap;word-break:break-all;color:var(--warn-bright);font-size:12.5px}
577
+ /* What it approves, neutral like the card (no amber on question cards): the command in the code's own box. */
578
+ .approval-what{margin:0 0 6px;padding:8px 10px;background:var(--bg-inset);border:1px solid var(--border);border-radius:6px;white-space:pre-wrap;word-break:break-all;color:var(--text-2);font-size:12.5px}
557
579
  .approval-where,.approval-why{font-size:12px;color:var(--text-muted);overflow-wrap:anywhere}
558
- .approval-why{color:var(--warn-text)}
559
580
  .approval-label{color:var(--text-faint)}
560
581
  /* A diff (diff_view.js): the approval card's dry run and a tool row's change. */
561
582
  .approval-diff{margin:0 0 6px}
@@ -682,8 +703,11 @@ body.has-session #center{background:color-mix(in srgb,var(--bg) 35%,transparent)
682
703
  body.has-session #stage,body.has-session #history{background:transparent}
683
704
  @media (prefers-reduced-transparency:reduce){body.has-session #center{background:var(--bg);border-color:var(--border)}}
684
705
  body.no-glass.has-session #center{background:var(--bg);border-color:var(--border)}
685
- /* --dock-bottom: the card's offset from the panel's bottom (16px; a phone's is below). stage_frame.js fitCap reads it. */
686
- body.has-session #dock{position:absolute;left:16px;right:16px;bottom:var(--dock-bottom,16px);margin:0;z-index:3}
706
+ /* --dock-bottom: the card's offset from the panel's bottom (16px; a phone's is below). stage_frame.js fitCap reads it.
707
+ Its sides are the history's column (#history's padding, both in #center): the stage and the composer are as wide as
708
+ the conversation, so a text moved from the stage into the history keeps its line breaks. A classic scrollbar on the
709
+ history narrows its column on the right: --history-sb (dock_reserve.js) moves the dock's right edge with it. */
710
+ body.has-session #dock{position:absolute;left:max(16px,calc((100% - 960px)/2));right:calc(max(16px,calc((100% - 960px)/2)) + var(--history-sb,0px));bottom:var(--dock-bottom,16px);margin:0;z-index:3}
687
711
  body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 16px + var(--dock-bottom,16px))}
688
712
  /* A phone's session panel runs edge to edge: its sides, corners and bottom line go (main's 16px side padding is taken
689
713
  back), so only the message cards are framed and an answer gets the width. The history, the objectives' strip and the
@@ -695,7 +719,7 @@ body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 16px + var(-
695
719
  body.has-session #center{margin:0 -16px;border-width:1px 0 0;border-radius:0}
696
720
  body.has-session #history{padding-left:8px;padding-right:8px}
697
721
  body.has-session #objectivesStrip{padding-left:8px;padding-right:8px}
698
- body.has-session #dock{left:8px;right:8px}
722
+ body.has-session #dock{left:8px;right:calc(8px + var(--history-sb,0px))}
699
723
  }
700
724
  /* The delivery line (delivery_line.js): above a phone's width, a session's row above the text field, always there so the composer never changes height: the key hint while idle; while a turn runs, where a message typed now goes in, then the cut and queue links. One quiet row, ellipsised. A phone has no such row (its composer is shorter, and as steady): while a turn runs the line, its short text and chips, lies over the session bar's left, where status, ctx and speed are (hidden while it shows), up to ⚙, only while you type or have a choice armed (below). */
701
725
  #deliveryLine{display:flex;align-items:center;gap:10px}
@@ -816,7 +840,9 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
816
840
  .turn-stage[hidden]{display:none}
817
841
  .turn-stage.ended{border-left-color:var(--border-strong)}
818
842
  .turn-stage[data-phase="answered"]{border-left-color:var(--ok)}
819
- .turn-stage[data-phase="canceled"],.turn-stage[data-phase="waiting for you"]{border-left-color:var(--warn)}
843
+ .turn-stage[data-phase="canceled"]{border-left-color:var(--warn)}
844
+ /* A card waits: the box has no amber edge (the status row's word and dot say it). */
845
+ .turn-stage[data-phase="waiting for you"]{border-left-color:var(--border-strong)}
820
846
  .turn-stage[data-phase="failed"]{border-left-color:var(--danger)}
821
847
  .turn-stage[data-phase="no answer"]{border-left-color:var(--warn)}
822
848
  .turn-stage.enter{animation:ts-rise .35s cubic-bezier(.3,.7,.2,1)}
@@ -875,15 +901,36 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
875
901
  .ts-headline.thinking{font-size:13.5px;font-style:italic;color:var(--text-muted)}
876
902
  .ts-think-tag{font-style:normal;font-size:12.5px;color:var(--think-text);margin-right:6px}
877
903
  .ts-headline.fresh{animation:ts-fade .3s ease}
878
- /* While a question or approval waits: the whole reply that asked it, in the headline's place; raw as a closed step's
879
- text, then its markdown when web.markdown is on (.markdown, stage_slots.js drawAsking); capped so the card keeps
880
- its room, read from the top. */
881
- .ts-asking{max-height:calc(var(--stage-max,60vh) * .35);overflow:auto;scrollbar-width:thin;white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:1.55;color:var(--narr);border-left:2px solid var(--border-strong);padding-left:10px}
882
- /* The question room (stage_view.js drawRoom): a model's own question whose asking text overflows that cap. The slot loses its
883
- cap and its own scroll, and the stage's one scroll covers the whole reply (the stage's cap rises until the next step, stage_frame.js).
884
- --stage-max also scales the extras, the cloud and the queued slot: a ceiling only, content that fit stays as it is. */
885
- .turn-stage.question-room .ts-asking{max-height:none;overflow:visible}
886
- .turn-stage.asking .ts-headline{display:none}
904
+ /* The asking form (stage_view.js, a card docked: its turn opened in the history, a reply before chi's own question or
905
+ approval a bubble there, .bubble.said): the stage shows the status row and the card alone; the prompt, the live
906
+ slots (the working set's rail with them) and the steps chip come back with the working form after the answer. */
907
+ .turn-stage.asking-form :is(.ts-prompt,.ts-live,.ts-foot){display:none}
908
+ /* It is one box (the mock-up's option A): the stage's frame takes the card's look (opaque, no glass, no amber: the status
909
+ row's "waiting for you" and its dot say it waits), the status row is the box's first line, and the card inside drops
910
+ its own box, so there is no box in a box. */
911
+ .turn-stage.asking-form{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none;border-radius:12px}
912
+ .turn-stage.asking-form .ts-scroll{padding-top:6px}
913
+ .turn-stage.asking-form .ts-extras>:is(.bubble.question,.bubble.plugin-card:not(.warn)){border:0;border-radius:0;background:transparent;padding:0}
914
+ /* The asking form folded (stage_view.js, its fold is that question's only): the status row says "waiting for you" and the
915
+ question (the mini tool's slot, in the UI font, right after the phase), then the step and the timing. On a phone those
916
+ two leave the row and the question takes a second line under it. */
917
+ .ts-mini.ts-mini-question{order:1;font-family:inherit;font-size:12.5px;color:var(--text)}
918
+ /* Two cards docked (stage_view.js drawDocked): one at a time, the one that stops chi in front; the pager after the phase
919
+ says where it is ("‹ 1 of 2 ›"), the other waits behind it. */
920
+ .turn-stage .ts-extras>.ts-behind{display:none}
921
+ .ts-pager{flex:none;display:inline-flex;align-items:center;gap:2px;color:var(--text-2)}
922
+ .ts-pager[hidden]{display:none}
923
+ .ts-page{flex:none;min-width:22px;height:22px;padding:0 4px;border-radius:6px;background:transparent;color:var(--text-muted);font-size:14px;line-height:1}
924
+ .ts-page:disabled{opacity:.35}
925
+ @media(hover:hover){.ts-page:hover:not(:disabled){filter:none;background:var(--bg-hover);color:var(--text)}}
926
+ .ts-page-label{font-variant-numeric:tabular-nums}
927
+ /* check-in docked while nothing blocks (stage_view.js .asks-live): the row says the running call right after the phase,
928
+ then the turn's time; the step count is the history's steps line. The live step's text streams under the card. */
929
+ .turn-stage.asks-live .ts-status>:not(.ts-mark,.ts-phase,.ts-mini){order:2}
930
+ .turn-stage.asks-live .ts-mini{order:1}
931
+ .turn-stage.asks-live .ts-step{display:none}
932
+ .ts-asks-text{padding-top:8px;border-top:1px dashed var(--border-strong);white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:1.55;color:var(--text)}
933
+ .turn-stage.asking-form.collapsed .ts-status>:not(.ts-mark,.ts-phase,.ts-mini){order:2}
887
934
  @keyframes ts-fade{from{opacity:.35}}
888
935
  .ts-now{height:var(--ts-now-h);display:flex;align-items:center;gap:8px;min-width:0;padding:0 9px;border-radius:8px;background:var(--accent-tint);font-size:13px}
889
936
  .ts-spin{flex:none;width:11px;height:11px;border:2px solid var(--warn);border-right-color:transparent;border-radius:50%;animation:init-spin .8s steps(16) infinite}
@@ -943,7 +990,7 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
943
990
  :is(.ts-extras>.bubble.user,.ts-prompt:not(.full)>.bubble.user)>.user-message.markdown :is(hr,img,.copy-btn){display:none}
944
991
  /* Inside the dock's own blur a second backdrop-filter sees nothing: the cards are opaque here (as #commandList is). */
945
992
  .turn-stage .bubble.question,.turn-stage .bubble.plugin-card{-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:none}
946
- .turn-stage .bubble.question{background:color-mix(in srgb,var(--warn) 7%,var(--bg-panel))}
993
+ .turn-stage .bubble.question{background:var(--bg-panel)}
947
994
  .turn-stage .bubble.plugin-card{background:color-mix(in srgb,var(--accent) 6%,var(--bg-panel))}
948
995
  .turn-stage .bubble.plugin-card.warn{background:color-mix(in srgb,var(--warn) 7%,var(--bg-panel))}
949
996
  .ts-answer{display:flex;flex-direction:column;gap:8px}
@@ -952,11 +999,6 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
952
999
  /* The cloud: one chip (steps, calls, a tick per call), the turn block behind it. */
953
1000
  /* The footer: the chip at the stage's bottom edge (the cloud's steps open above it, the scroller's last slot). */
954
1001
  .ts-foot{position:relative;flex:none;padding:0 14px 10px}
955
- /* The question room's jump pill (stage_view.js drawPill): at the scroller's bottom edge, above the chip, while the waiting
956
- card is out of the stage's view; absolute, so the frame never counts it. */
957
- .ts-room-pill{position:absolute;bottom:100%;right:14px;margin-bottom:6px;padding:4px 11px;border:1px solid var(--warn-border);border-radius:999px;background:var(--warn-bg);color:var(--warn-text);font-size:12.5px;font-weight:600;line-height:1.4;white-space:nowrap;box-shadow:0 2px 8px var(--shadow-strong);animation:ts-fade .2s ease}
958
- @media(hover:hover){.ts-room-pill:hover:not(:disabled){filter:none;color:var(--warn-bright);border-color:var(--warn);background:var(--warn-bg)}}
959
- .ts-room-pill[hidden]{display:none}
960
1002
  /* Below the turn's card: the lines queued for after it (each a turn of its own), apart from the turn by a dashed rule. */
961
1003
  .ts-queued{flex:none;display:flex;flex-direction:column;gap:6px;padding:8px 14px 10px;border-top:1px dashed var(--border-strong);max-height:calc(var(--stage-max,60vh) * .3);overflow:auto;scrollbar-width:thin}
962
1004
  .ts-queued:empty{display:none}
@@ -1168,7 +1210,10 @@ button.ws-row:hover:not(:disabled){filter:none}@media(hover:hover){button.ws-row
1168
1210
  /* The quiet signal's short text on a phone; in the status row it takes the step's and the mini tool's room. */
1169
1211
  .ts-stall .long{display:none}
1170
1212
  .ts-stall .short{display:inline}
1171
- .turn-stage.stalled:is(.collapsed,.plain) :is(.ts-step,.ts-mini){display:none}
1213
+ .turn-stage.stalled:is(.collapsed,.plain) :is(.ts-step,.ts-mini:not(.ts-mini-question)){display:none}
1214
+ .turn-stage.asking-form.collapsed .ts-status{flex-wrap:wrap;row-gap:4px}
1215
+ .turn-stage.asking-form.collapsed :is(.ts-step,.ts-timing){display:none}
1216
+ .ts-mini.ts-mini-question{order:3;flex-basis:100%}
1172
1217
  /* An approval's Submit in sight on a phone: its folder, reason and rows a little tighter. */
1173
1218
  .approval-where,.approval-why{line-height:1.35}
1174
1219
  .bubble.question.approval .question-option{padding:5px 8px}
@@ -36,7 +36,7 @@ export function createMarkdownPlace({
36
36
  pairAnswerRefs(el);
37
37
  }
38
38
 
39
- // The refs in one rendered text (the stage's asking slot, a kept reply),
39
+ // The refs in one rendered text (a lead-in bubble, a kept reply),
40
40
  // as linkTextRefs links the answers': a plugin's +refs+ first
41
41
  // (pairRefsIn), then the `path:line` ones.
42
42
  function linkRefsIn(el, refs) {
@@ -24,6 +24,7 @@ import { clientLabel, isOwn } from "./turn_events.js";
24
24
  import { continueLine } from "./commands.js";
25
25
  import { plainText } from "./plain_line.js";
26
26
  import { noContactFill } from "./no_contact_fill.js";
27
+ import { CONTINUE_KEY, questionKey } from "./stage_waiting.js";
27
28
 
28
29
  // A card's text fields' name: not a contact field (no_contact_fill.js).
29
30
  const CARD_NOTE = "chi-card-note";
@@ -35,8 +36,9 @@ const CARD_NOTE = "chi-card-note";
35
36
  // @param isNearBottom () => whether the history follows its end
36
37
  // @param scrollToEnd () scrolls the history to its end
37
38
  // @param removeHintIfEmpty () drops the history's placeholder hint
38
- // @param askingText () => the running turn's asking reply (turn_model.js
39
- // askingText via the page's view), kept by a question or own approval card
39
+ // @param askingText (pq) => the running turn's reply that asked +pq+
40
+ // (stage_asking.js askedText via the page's view), kept by a question or
41
+ // own approval card
40
42
  // @param renderMarkdown (text) => Promise<html|null>: the kept reply's
41
43
  // markdown (the page's POST /api/render; null keeps the raw text)
42
44
  // @param linkRefs (el, refs) the page's ref pass on it: a plugin's +refs+
@@ -48,6 +50,9 @@ const CARD_NOTE = "chi-card-note";
48
50
  // @param onPending (pending|null) called whenever the open question changes:
49
51
  // the page touches the redraws that read pendingQuestion() (the session
50
52
  // bar's waiting chip, docs/internals/web-frontend.md write -> redraw)
53
+ // @param onSettled (key) a card stopped waiting (answered, cancelled,
54
+ // replaced or removed; the continue card resolved or dropped), by its
55
+ // stage_waiting.js key: the stage's waiting cards as data
51
56
  // @return {renderQuestion(pq, {said}), resolveQuestion(id, opts), removeQuestion(),
52
57
  // questionCard() (the live card or null), pendingQuestion() (or null),
53
58
  // isResolved(id) (this page already saw that question answered),
@@ -56,7 +61,7 @@ export function createQuestionCards({
56
61
  sessionId, clientId, place, isNearBottom, scrollToEnd, removeHintIfEmpty, askingText = () => "",
57
62
  renderMarkdown = () => Promise.resolve(null), linkRefs = () => {}, pairRefs = () => {},
58
63
  api = { sendAnswer, dismissQuestion, sendCommand }, doc = globalThis.document,
59
- onPending = () => {},
64
+ onPending = () => {}, onSettled = () => {},
60
65
  }) {
61
66
  // Live ask_user_question card, keyed by pending question id. Re-rendered from
62
67
  // pending_question on session select so a reload mid-question restores it.
@@ -95,11 +100,13 @@ export function createQuestionCards({
95
100
  const card = doc.createElement("details");
96
101
  card.className = approval ? "bubble question approval" : stepLimit ? "bubble question step-limit" : "bubble question";
97
102
  card.dataset.qid = pq.id;
98
- // What asks (the stage's question room is a model's own question's,
103
+ // What asks (a model's own question opens its turn in the history,
99
104
  // stage_view.js): the kind, and a delegate's question relayed here.
100
105
  card.dataset.kind = pq.kind || "question";
101
106
  if (relayView(pq)) card.dataset.relay = "1";
102
- const asked = keepsAskingText(pq) ? String(said ?? askingText() ?? "").trim() : "";
107
+ // An approval says the tool it approves (the stage's replay rule for its lead-in).
108
+ if (approval && pq.approval?.tool) card.dataset.tool = String(pq.approval.tool);
109
+ const asked = keepsAskingText(pq) ? String(said ?? askingText(pq) ?? "").trim() : "";
103
110
  if (asked) saidOf.set(card, asked);
104
111
  // Open while pending: the question must be actionable.
105
112
  card.open = true;
@@ -110,8 +117,10 @@ export function createQuestionCards({
110
117
  summary.textContent = summaryText(pq);
111
118
  card.appendChild(summary);
112
119
  // A hand toggle: the resolve's auto-collapse then leaves it as the user
113
- // left it (rememberToggle-style, as turn_block.js does).
114
- summary.addEventListener("click", () => { card.dataset.toggled = "1"; });
120
+ // left it (rememberToggle-style, as turn_block.js does). Not a click whose
121
+ // toggle was refused: a card that waits in the stage has none of its own
122
+ // (stage_view.js).
123
+ summary.addEventListener("click", (e) => { if (!e.defaultPrevented) card.dataset.toggled = "1"; });
115
124
 
116
125
  // Relayed to the parent: say where else it waits (QuestionDesk#annotate).
117
126
  card.appendChild(renderRelayedTo(pq));
@@ -502,6 +511,7 @@ export function createQuestionCards({
502
511
  // After the collapse: a card left open by hand renders at once.
503
512
  if (full) renderSaidOnOpen(questionEl, full, asked, refs);
504
513
  resolvedId = pending.id;
514
+ onSettled(questionKey(questionEl.dataset.qid));
505
515
  setPending(null);
506
516
  }
507
517
 
@@ -567,8 +577,10 @@ export function createQuestionCards({
567
577
  function replaceQuestionCard() {
568
578
  if (!questionEl) return;
569
579
 
580
+ const key = questionKey(questionEl.dataset.qid);
570
581
  questionEl.remove();
571
582
  questionEl = null;
583
+ onSettled(key);
572
584
  }
573
585
 
574
586
  // ── continue card ──────────────────────────────────────────────────────────
@@ -587,6 +599,7 @@ export function createQuestionCards({
587
599
  // The old card goes: the step-limit question asks the same (a worker that
588
600
  // posts it announces continue_offered too, for older pages).
589
601
  function dropContinueCard() {
602
+ if (continueEl) onSettled(CONTINUE_KEY);
590
603
  continueEl?.remove();
591
604
  continueEl = null;
592
605
  }
@@ -656,6 +669,7 @@ export function createQuestionCards({
656
669
  continueEl = null;
657
670
  if (!card) return;
658
671
  card.classList.add("resolved");
672
+ onSettled(CONTINUE_KEY);
659
673
  card.querySelectorAll("button, input").forEach((el) => { el.disabled = true; });
660
674
  const note = doc.createElement("div");
661
675
  note.className = "question-result";
@@ -381,8 +381,11 @@ export function turnRowFor(target) {
381
381
  // history). null when there is none.
382
382
  function turnBlockOf(el) {
383
383
  const own = el.closest(".turn-work, .turn-stage");
384
- if (own) return own;
385
384
  const doc = el.ownerDocument;
385
+ // A turn opened in the history (stage_view.js): its block is the
386
+ // history's last one, the stage's rows are that turn's.
387
+ if (own?.dataset.block === "history") return [...doc.querySelectorAll("#history .turn-work")].at(-1) || null;
388
+ if (own) return own;
386
389
  const block = [...doc.querySelectorAll(".turn-work")].filter((b) => precedes(b, el)).at(-1);
387
390
  if (!block) return null;
388
391
  const prompt = [...doc.querySelectorAll(".bubble.user")].some((u) => precedes(block, u) && precedes(u, el));
@@ -13,9 +13,10 @@
13
13
  // fallback, data-undrawn): 0 unless chi web missed one. Fire-and-forget: no toast, no
14
14
  // store write, a failure is dropped.
15
15
  //
16
- // Cards are left out on both sides: a reload places them after the render
17
- // (CardStore's stamps, cards_place.js), which the offscreen render doesn't
18
- // run; the e2e reload checks compare them.
16
+ // Cards and answered question cards are left out on both sides: a reload
17
+ // places them after the render (CardStore's stamps and the snapshot's
18
+ // questions, cards_place.js placeResolvedQuestion), which the offscreen
19
+ // render doesn't run; the e2e reload checks compare them.
19
20
  import { compareShapes, historyShape } from "./history_shape.js";
20
21
  import { turnElements } from "./turn_range.js";
21
22
 
@@ -29,7 +30,7 @@ function openingId(el) {
29
30
  }
30
31
 
31
32
  function withoutCards(shape) {
32
- return shape.filter((item) => item.kind !== "card");
33
+ return shape.filter((item) => item.kind !== "card" && item.kind !== "question");
33
34
  }
34
35
 
35
36
  // @param enabled () => whether the check is on (the body's attribute)