samagotchi 0.165.0 → 0.166.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -1
  3. data/docs/cli.md +6 -2
  4. data/docs/configuration.md +3 -1
  5. data/docs/guardrails.md +6 -2
  6. data/docs/internals/bridge.md +6 -0
  7. data/docs/internals/remote-sessions.md +1 -1
  8. data/docs/internals/web-frontend.md +36 -3
  9. data/docs/releasing.md +12 -3
  10. data/docs/sessions.md +4 -4
  11. data/docs/testing.md +12 -3
  12. data/lib/samagotchi/bundles/system/manifest.yml +1 -1
  13. data/lib/samagotchi/compat.rb +8 -10
  14. data/lib/samagotchi/guardrails/approvals.rb +36 -9
  15. data/lib/samagotchi/plugin/sessions.rb +4 -1
  16. data/lib/samagotchi/reply_wait/poll.rb +4 -15
  17. data/lib/samagotchi/reply_wait.rb +0 -23
  18. data/lib/samagotchi/run_options.rb +1 -1
  19. data/lib/samagotchi/session_access/remote.rb +4 -19
  20. data/lib/samagotchi/session_inbox.rb +1 -1
  21. data/lib/samagotchi/tools/delegate.rb +2 -4
  22. data/lib/samagotchi/version.rb +1 -1
  23. data/lib/samagotchi/web/public/app.js +15 -8
  24. data/lib/samagotchi/web/public/auth_lost.js +3 -1
  25. data/lib/samagotchi/web/public/bar_fold.js +1 -1
  26. data/lib/samagotchi/web/public/chip_popover.js +5 -1
  27. data/lib/samagotchi/web/public/delivery_line.js +19 -4
  28. data/lib/samagotchi/web/public/index.html +122 -41
  29. data/lib/samagotchi/web/public/info_bar.js +1 -1
  30. data/lib/samagotchi/web/public/info_bar_model.js +6 -1
  31. data/lib/samagotchi/web/public/live_timing.js +3 -0
  32. data/lib/samagotchi/web/public/resync_reach.js +59 -0
  33. data/lib/samagotchi/web/public/session_fields.js +1 -0
  34. data/lib/samagotchi/web/public/session_state.js +5 -0
  35. data/lib/samagotchi/web/public/stage_frame.js +4 -2
  36. data/lib/samagotchi/web/public/stage_stall.js +134 -0
  37. data/lib/samagotchi/web/public/stage_view.js +75 -6
  38. data/lib/samagotchi/web/token.rb +2 -2
  39. metadata +3 -1
@@ -8,7 +8,11 @@
8
8
  <link rel="manifest" href="/manifest.webmanifest">
9
9
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
10
10
  <meta name="apple-mobile-web-app-title" content="Chi">
11
- <meta name="viewport" content="width=device-width,initial-scale=1">
11
+ <!-- viewport-fit=cover: the page runs under the notch and the home indicator; what must stay clear of them pads by --safe-* (below). -->
12
+ <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
13
+ <!-- The phone's status bar and Safari's toolbar take the page's own background (tokens.css --bg), per theme. -->
14
+ <meta name="theme-color" content="#0b0d11" media="(prefers-color-scheme: dark)">
15
+ <meta name="theme-color" content="#f5f6f8" media="(prefers-color-scheme: light)">
12
16
  <link rel="stylesheet" href="/assets/tokens.css">
13
17
  <link rel="stylesheet" href="/assets/verify_card.css">
14
18
  <link rel="stylesheet" href="/assets/annotate_bar.css">
@@ -19,10 +23,13 @@
19
23
  <style>
20
24
  /* Icon masks shared by the phone info bar and the all view's cards (the stroke only shapes the mask; the icon takes currentColor); the image icon is composer.css's. */
21
25
  :root{--icon-archive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M6.5 9h3'/%3E%3C/svg%3E");--icon-unarchive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M8 11.5V8.25M6.5 9.75 8 8.25l1.5 1.5'/%3E%3C/svg%3E")}
26
+ /* The phone's safe areas (the notch, the status bar, the home indicator; 0 elsewhere): main's padding, the bottom
27
+ sheets, the update sheet, the toast and the lightbox keep clear of them. One name per side, so the e2e can set them. */
28
+ :root{--safe-t:env(safe-area-inset-top,0px);--safe-r:env(safe-area-inset-right,0px);--safe-b:env(safe-area-inset-bottom,0px);--safe-l:env(safe-area-inset-left,0px)}
22
29
  *{box-sizing:border-box;margin:0;padding:0}
23
30
  /* No iOS text autosizing: it grows text in a box sized for the text as written (it clipped the session cards). */
24
31
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
25
- body{font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:radial-gradient(1100px 700px at 8% 0%,color-mix(in srgb,var(--accent) 13%,transparent),transparent 70%),var(--bg);background-attachment:fixed;color:var(--text);height:100vh;display:flex;flex-direction:column}
32
+ body{font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:radial-gradient(1100px 700px at 8% 0%,color-mix(in srgb,var(--accent) 13%,transparent),transparent 70%),var(--bg);background-attachment:fixed;color:var(--text);height:100vh;height:100dvh;display:flex;flex-direction:column}
26
33
  /* Glass: the composer card, the strip cards, the all-sessions cards and the question cards (by selector, so app.js is untouched). */
27
34
  .turn-stage,#topStrip .card,#allList .card,.bubble.question,.bubble.plugin-card{background:var(--glass-bg);-webkit-backdrop-filter:blur(18px) saturate(1.35);backdrop-filter:blur(18px) saturate(1.35);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-highlight),var(--glass-shadow)}
28
35
  @media(hover:hover){#topStrip .card:hover,#allList .card:hover{background:color-mix(in srgb,var(--bg-hover) 75%,transparent);border-color:var(--card-hover-border)}}
@@ -44,7 +51,10 @@ button{background:var(--primary);border:0;color:var(--on-solid);padding:8px 12px
44
51
  button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
45
52
  button.ghost{background:var(--bg-raised);color:var(--text-2)}
46
53
  button:disabled{opacity:.5;cursor:not-allowed}
47
- main{flex:1;display:flex;flex-direction:column;gap:16px;padding:16px;overflow:auto;background:transparent;min-height:0}
54
+ /* 16px, or the safe area where it is wider. At the bottom 16px less than it: the session's composer card floats 16px
55
+ above main's bottom (#dock bottom:16px), which puts it right on the home indicator's line (a phone's session has none:
56
+ its card is placed by --dock-bottom). */
57
+ main{flex:1;display:flex;flex-direction:column;gap:16px;padding:max(16px,var(--safe-t)) max(16px,var(--safe-r)) max(16px,calc(var(--safe-b) - 16px)) max(16px,var(--safe-l));overflow:auto;background:transparent;min-height:0}
48
58
  #topStrip{display:grid;grid-template-columns:repeat(var(--strip-cols,3),minmax(0,440px)) 150px;gap:12px;min-height:88px;align-content:start}
49
59
  #topStrip:empty{display:grid}
50
60
  #center{flex:1;display:flex;flex-direction:column;min-height:45vh;background:var(--bg-panel);border:1px solid var(--border);border-radius:12px;overflow:hidden}
@@ -662,19 +672,22 @@ body.has-session #center{background:color-mix(in srgb,var(--bg) 35%,transparent)
662
672
  body.has-session #stage,body.has-session #history{background:transparent}
663
673
  @media (prefers-reduced-transparency:reduce){body.has-session #center{background:var(--bg);border-color:var(--border)}}
664
674
  body.no-glass.has-session #center{background:var(--bg);border-color:var(--border)}
665
- body.has-session #dock{position:absolute;left:16px;right:16px;bottom:16px;margin:0;z-index:3}
666
- body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 32px)}
675
+ /* --dock-bottom: the card's offset from the panel's bottom (16px; a phone's is below). stage_frame.js fitCap reads it. */
676
+ body.has-session #dock{position:absolute;left:16px;right:16px;bottom:var(--dock-bottom,16px);margin:0;z-index:3}
677
+ body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 16px + var(--dock-bottom,16px))}
667
678
  /* A phone's session panel runs edge to edge: its sides, corners and bottom line go (main's 16px side padding is taken
668
679
  back), so only the message cards are framed and an answer gets the width. The history, the objectives' strip and the
669
- card keep 8px sides; the card's bottom offset (16px) and the history's bottom padding stay, so stage_frame.js's fitCap
670
- reads the same. */
680
+ card keep 8px sides. It runs to the screen's bottom too (main's bottom padding goes): the history scrolls on under
681
+ the card, which floats 16px over the bottom, or on the home indicator's line where that is higher (--dock-bottom). */
671
682
  @media(max-width:600px){
683
+ body.has-session main{padding-bottom:0}
684
+ body.has-session{--dock-bottom:max(16px,var(--safe-b))}
672
685
  body.has-session #center{margin:0 -16px;border-width:1px 0 0;border-radius:0}
673
686
  body.has-session #history{padding-left:8px;padding-right:8px}
674
687
  body.has-session #objectivesStrip{padding-left:8px;padding-right:8px}
675
688
  body.has-session #dock{left:8px;right:8px}
676
689
  }
677
- /* The delivery line (delivery_line.js): 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 gets the short text and chips. */
690
+ /* 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). */
678
691
  #deliveryLine{display:flex;align-items:center;gap:10px}
679
692
  #deliveryLine[hidden]{display:none}
680
693
  #deliveryLine .delivery-where{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@@ -693,6 +706,18 @@ body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 32px)}
693
706
  #deliveryLine .delivery-link{padding:0 8px;border:1px solid var(--accent-border);border-radius:999px;background:var(--accent-bg);line-height:16px}
694
707
  #deliveryLine .delivery-link:disabled{border-color:var(--border);background:transparent}
695
708
  #deliveryLine .delivery-link.armed{border-color:var(--accent-strong);background:var(--accent-strong)}
709
+ /* No row of its own: idle it is gone; running it is placed over the bar's first row (#composer is its box, the bar
710
+ right under it): the bar's phone padding (10px sides, 6px top, 8px bottom) and height, its right end clear of ⚙
711
+ (32px) and ⋯ (38px) with their gaps. The chips the line covers are hidden, unless the composer is folded away.
712
+ Running, it shows only while it matters, the bar's status, ctx and speed otherwise (a card waiting, a sent steer, a
713
+ message queued after the turn): the text field focused (the keyboard up) or holding text or images, or a choice
714
+ armed or an Apply turn held (delivery_line.js data-armed, data-held; not the queue chip's pressed look, which a
715
+ participant's turn draws with nothing armed). The two rules below share that list: change both. A chip's
716
+ mousedown keeps the focus in the text field, so tapping one doesn't hide the line under the finger. On a bare
717
+ stage an after-turn queued message isn't drawn and the line is hidden too: accepted. */
718
+ body.has-session #deliveryLine{display:none}
719
+ body.has-session #composer:has(:is(#prompt:focus,#prompt:not(:placeholder-shown),#chips:not([hidden]),#deliveryLine[data-armed="1"],#deliveryLine[data-held="1"])) #deliveryLine.running:not([hidden]){display:flex;position:absolute;left:10px;right:96px;top:100%;height:41px;padding:6px 0 8px;box-sizing:border-box;z-index:1}
720
+ body.has-session:not(.composer-folded) #dock:has(#deliveryLine.running:not([hidden])):has(:is(#prompt:focus,#prompt:not(:placeholder-shown),#chips:not([hidden]),#deliveryLine[data-armed="1"],#deliveryLine[data-held="1"])) #infoBar .meta :is(.status,.ctx,.speed){visibility:hidden}
696
721
  }
697
722
  /* A line queued for after the running turn: a dashed bubble, a turn of its own to come. */
698
723
  .bubble.user.queued[data-delivery="queue"]{border:1px dashed var(--accent-border);border-left:3px dashed var(--accent);background:transparent}
@@ -700,9 +725,10 @@ body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 32px)}
700
725
  .thumb{max-height:120px;max-width:200px;border-radius:6px;border:1px solid var(--border-strong);cursor:zoom-in;object-fit:contain;background:var(--bg)}
701
726
  .activity-row .thumbs{flex-basis:100%;margin-left:var(--row-gutter)}
702
727
  @media(max-width:600px){.activity-row .thumbs{margin-left:0}}
703
- #lightbox{position:fixed;inset:0;z-index:50;background:var(--backdrop);display:flex;align-items:center;justify-content:center;cursor:zoom-out}
728
+ /* The image keeps clear of the notch and the home indicator (its padding: the safe areas; 0 on a desktop). */
729
+ #lightbox{position:fixed;inset:0;z-index:50;background:var(--backdrop);display:flex;align-items:center;justify-content:center;cursor:zoom-out;padding:var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l)}
704
730
  #lightbox[hidden]{display:none}
705
- #lightbox img{max-width:96vw;max-height:94vh;border-radius:6px}
731
+ #lightbox img{max-width:min(96vw,100%);max-height:min(94vh,100%);border-radius:6px}
706
732
  /* The model picker (the start page, and a fresh chain link: start_page.js syncModelPick): reads as a label, "host:model ▾", left of Start; a button under a drawn caret that opens a searchable list (model_picker.js). Its name ellipsizes within max-width. */
707
733
  #composer .actions-col .model-pick{order:0;position:relative;display:inline-block;max-width:min(50%,380px);height:28px;min-height:28px;padding:0 22px 0 8px;border-radius:8px;overflow:hidden;background:transparent;color:var(--text-muted);font-size:12px;line-height:28px;text-align:left;text-overflow:ellipsis;transition:background .12s ease,color .12s ease}
708
734
  /* The start page's row stays one row (Start never wraps): the model name gives way first, down to its min-width, then the override chips ellipsize (100000x their shrink weight: at 1000x their share of the shrink was still a fraction of a pixel, enough for an ellipsis). Scoped off the session composer and a fresh link's button. */
@@ -855,6 +881,24 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
855
881
  .ts-tool{flex:none;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;font-weight:600;color:var(--accent)}
856
882
  .ts-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;color:var(--text-2)}
857
883
  .ts-title.quiet{font-family:inherit;font-style:italic;color:var(--text-faint)}
884
+ /* The quiet signal (stage_stall.js): a running turn silent for a while says so at the now row's right ("quiet 0:40"),
885
+ tinted by level; a running call shows its own clock there instead, plain. No transitions: it appears as it is. */
886
+ .ts-stall,.ts-tool-clock{margin-left:auto;flex:none;white-space:nowrap;font-size:12px;font-variant-numeric:tabular-nums}
887
+ .ts-tool-clock{color:var(--text-muted)}
888
+ .ts-tool-clock+button.task-stop{margin-left:0}
889
+ .ts-stall .short{display:none}
890
+ .ts-now[data-stall="1"]{background:color-mix(in srgb,var(--warn) 10%,transparent)}
891
+ .ts-now[data-stall="1"] .ts-stall{color:var(--warn-text)}
892
+ .ts-now[data-stall="2"]{background:var(--warn-bg);box-shadow:inset 0 0 0 1px var(--warn-border)}
893
+ .ts-now[data-stall="2"] .ts-stall{color:var(--warn-text);font-weight:600}
894
+ .ts-now[data-stall="net"]{background:var(--bg-hover)}
895
+ .ts-now[data-stall="net"] .ts-stall{color:var(--text-muted);font-style:italic}
896
+ /* Its short text in the status row, where the now row doesn't show: a collapsed stage, a plain turn's. */
897
+ .ts-stall-head{display:none;flex:none;font-variant-numeric:tabular-nums}
898
+ .turn-stage:is(.collapsed,.plain) .ts-stall-head:not(:empty){display:inline}
899
+ .turn-stage[data-stall="1"] .ts-stall-head,.turn-stage[data-stall="2"] .ts-stall-head{color:var(--warn-text)}
900
+ .turn-stage[data-stall="2"] .ts-stall-head{font-weight:600}
901
+ .turn-stage[data-stall="net"] .ts-stall-head{font-style:italic}
858
902
  .ts-trail{height:var(--ts-trail-h);display:flex;gap:10px;overflow:hidden;font-size:12px;line-height:18px;color:var(--text-faint);white-space:nowrap}
859
903
  .ts-trail-item{flex:none;max-width:36ch;overflow:hidden;text-overflow:ellipsis}
860
904
  .ts-trail-item:is(.error,.blocked){color:var(--danger-text)}
@@ -1111,6 +1155,10 @@ button.ws-row:hover:not(:disabled){filter:none}@media(hover:hover){button.ws-row
1111
1155
  .ts-defer{display:none}
1112
1156
  .ts-cancel{padding:1px 8px}
1113
1157
  .ts-trail-item{max-width:24ch}
1158
+ /* The quiet signal's short text on a phone; in the status row it takes the step's and the mini tool's room. */
1159
+ .ts-stall .long{display:none}
1160
+ .ts-stall .short{display:inline}
1161
+ .turn-stage.stalled:is(.collapsed,.plain) :is(.ts-step,.ts-mini){display:none}
1114
1162
  /* An approval's Submit in sight on a phone: its folder, reason and rows a little tighter. */
1115
1163
  .approval-where,.approval-why{line-height:1.35}
1116
1164
  .bubble.question.approval .question-option{padding:5px 8px}
@@ -1175,6 +1223,8 @@ button.ws-row:hover:not(:disabled){filter:none}@media(hover:hover){button.ws-row
1175
1223
  #infoBar[data-compact~="settings"] .meta .settings-chip .sc-own{display:none}
1176
1224
  #infoBar[data-compact~="settings"] .meta .settings-chip.own{padding-right:6px}
1177
1225
  #infoBar[data-compact~="settings"] .meta .settings-chip.own::after{content:"";position:absolute;top:3px;right:3px;width:5px;height:5px;border-radius:50%;background:var(--accent)}
1226
+ /* Compact, the dot says the session set its own: no accent border too (it comes back while the panel is open). */
1227
+ #infoBar[data-compact~="settings"] .meta .settings-chip.own:not([aria-expanded="true"]){border-color:transparent}
1178
1228
  /* The plain chips (spans, links) and the status take the button chips' 1px border, transparent and outside their tint, so every chip is one height: a chip wrapping onto a row of plain ones doesn't grow it. */
1179
1229
  #infoBar .meta :is(span,a).model,#infoBar .meta .status{border:1px solid transparent;background-clip:padding-box}
1180
1230
  /* The chips a running turn rewrites (the session clock each second, the last generation's speed, ctx): tabular digits in a reserved width, so a tick ("9.5s" → "10s" → "1m 00s") or a new number doesn't widen the line and move the chips after it. The speed and the clock show from the session's start, a muted placeholder until there is a number. */
@@ -1386,7 +1436,7 @@ body.has-session.composer-folded #infoBar{border-top-color:transparent}
1386
1436
  .us-detail{margin-top:4px;color:var(--text-muted);font-size:12px;overflow-wrap:anywhere}
1387
1437
  .us-kept{margin-top:6px;color:var(--warn-text);font-size:12px}
1388
1438
  .us-foot{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:10px}
1389
- @media(max-width:600px){#updateSheet{position:fixed;inset:auto 8px 8px;width:auto;max-width:none;max-height:min(80dvh,calc(100dvh - 16px));margin:0}}
1439
+ @media(max-width:600px){#updateSheet{position:fixed;inset:auto 8px calc(8px + var(--safe-b));width:auto;max-width:none;max-height:min(80dvh,calc(100dvh - 16px - var(--safe-t) - var(--safe-b)));margin:0}}
1390
1440
  .ctx-pop-kind{font-size:11px;color:var(--text-muted)}
1391
1441
  .ctx-pop-close{margin-left:auto;padding:0 6px;border:none;background:transparent;color:var(--text-muted);font-size:16px;line-height:1}
1392
1442
  @media(hover:hover){.ctx-pop-close:hover{color:var(--text)}}
@@ -1422,6 +1472,9 @@ body.has-session.composer-folded #infoBar{border-top-color:transparent}
1422
1472
  /* ⚙ and ⋯: bigger to the thumb than to the eye. 2 px of negative margin keep the row its height, and each one's ::before reaches the foot's edges for the tap. */
1423
1473
  #infoBar .meta .settings-chip{margin:-2px 0 -2px auto;min-width:32px;min-height:30px;justify-content:center}
1424
1474
  #infoBar .meta .settings-chip::before,#infoBar #infoMoreBtn::before{content:"";position:absolute;inset:-4px -3px -6px}
1475
+ /* ⚙ is in .info, which clips (the fold): its clip box reaches past ⚙'s outset box and its tap reach, so ⚙'s border
1476
+ and ::before are whole; the negative margin keeps the row its height. (⋯ is outside .info.) */
1477
+ #infoBar .info{padding:6px 0;margin:-6px 0}
1425
1478
  #infoBar #infoMoreBtn{width:38px;height:30px;margin:-2px 0;padding:0;font-size:16px}
1426
1479
  #infoBar #infoMoreBtn .more-count{display:none}
1427
1480
  #infoBar #infoMoreBtn[data-attention]::after{top:4px;right:4px}
@@ -1476,21 +1529,33 @@ body:not(.has-session) #dock{width:min(720px,calc(100% - 32px));margin:0 auto}
1476
1529
  body:not(.has-session) #infoBar{display:none}
1477
1530
  #notice{width:min(720px,calc(100% - 32px));margin:0 auto 12px;padding:8px 12px;border:1px solid var(--border-strong);border-radius:8px;color:var(--text-muted);font-size:13px;text-align:center}
1478
1531
  body.has-session #notice{display:none}
1479
- #topBar{display:flex;align-items:center;gap:12px;margin-bottom:-6px}
1480
- #newBtn.brand{background:transparent;border:0;padding:2px 4px;min-height:0;display:inline-flex;align-items:baseline;gap:10px;color:var(--text)}
1532
+ /* The top bar's words on one text line: "chi", "new session", the pills, "all" and the title share a baseline at every
1533
+ width; the bell and the all view's header (no text line of their own) are centred on the row. */
1534
+ #topBar{display:flex;align-items:baseline;gap:12px;margin-bottom:-6px}
1535
+ #newBtn.brand{background:transparent;border:0;padding:1px 4px 2px;min-height:0;display:inline-flex;align-items:baseline;gap:10px;color:var(--text)}
1481
1536
  #newBtn .brand-name{font-size:18px;font-weight:700;letter-spacing:.02em;color:var(--accent)}
1482
- #newBtn .brand-new{font-size:12px;color:var(--text-muted);display:none}
1537
+ #newBtn .brand-new{font-size:12px;color:var(--text-muted);display:none;white-space:nowrap}
1538
+ /* The plus is drawn, as the bell is: 10px beside "new session", 13px alone in a phone's round button. */
1539
+ #newBtn .brand-plus{width:10px;height:10px;vertical-align:-1px;margin-right:5px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round}
1483
1540
  body.has-session #newBtn .brand-new{display:inline}
1484
1541
  #newBtn:hover .brand-new{color:var(--text-2)}
1485
1542
  /* The scope chip: "<project> · all", or "all projects" and where a new session starts (start page only). */
1486
1543
  #scope{display:inline-flex;align-items:center;gap:8px;min-width:0;font-size:12px;color:var(--text-muted)}
1487
1544
  #scope[hidden]{display:none}
1488
- #scope .scope-name{display:inline-flex;align-items:center;flex-shrink:0;padding:2px 9px;border:1px solid var(--border-strong);border-radius:999px;background:transparent;color:var(--text-2);font:inherit;line-height:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:40vw;cursor:pointer;transition:none}
1545
+ #scope .scope-name{display:inline-flex;align-items:center;flex-shrink:0;min-height:28px;padding:0 9px;border:1px solid var(--border-strong);border-radius:999px;background:transparent;color:var(--text-2);font:inherit;line-height:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:40vw;cursor:pointer;transition:none}
1489
1546
  #scope .scope-name:hover:not(:disabled){filter:none}
1490
1547
  #scope .scope-name.error{color:var(--warn-text);border-color:var(--warn-border)}
1491
1548
  #scope .scope-all{color:var(--text-muted);text-decoration:none}
1492
1549
  #scope .scope-all:hover{color:var(--accent);text-decoration:underline}
1493
1550
  #scope .scope-where{display:inline-flex;gap:5px;min-width:0;white-space:nowrap;font-size:11px}
1551
+ /* A project view (and the error state): the project pill and "all" are one segmented control, at every width. The left
1552
+ segment opens the picker, the right one goes to all projects. No border on the left segment here: on touch its border is
1553
+ its ::before (the touch rules below), and the error state's is the warn one. */
1554
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)){gap:0}
1555
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-name{border-radius:999px 0 0 999px;background:var(--bg-raised)}
1556
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-all{display:inline-flex;align-items:center;height:28px;padding:0 8px;font-size:12px;border:1px solid var(--border-strong);border-left:0;border-radius:0 999px 999px 0;color:var(--text-muted)}
1557
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-all:hover{color:var(--text-2);text-decoration:none}
1558
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-all:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
1494
1559
  /* The path cuts on the left, so its last folders stay in view. */
1495
1560
  #scope .scope-where .path{overflow:hidden;text-overflow:ellipsis;direction:rtl;min-width:0;font-family:ui-monospace,monospace}
1496
1561
  #projectPicker{width:min(380px,calc(100vw - 32px))}
@@ -1531,15 +1596,13 @@ body.all-view #scope .scope-where{display:none}
1531
1596
  #topBar{gap:8px}
1532
1597
  #scope{gap:6px}
1533
1598
  #newBtn .brand-new-word{display:none}
1534
- #newBtn .brand-new,#scope .scope-back{white-space:nowrap}
1535
- #scope .scope-back{min-width:0;overflow:hidden;text-overflow:ellipsis}
1536
- #stripStatus{padding:3px 8px}
1537
- #newBtn .brand-new{font-size:16px}
1538
- /* In a session the brand gives its room to the bar: a bare "+", a 32px round button (the start page keeps "chi"); its extra 4px
1539
- taken back so the bar keeps its height. */
1599
+ #scope .scope-back{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1600
+ /* In a session the brand gives its room to the bar: a bare drawn plus, a 28px round button centred on the row, as the bell
1601
+ (the start page keeps "chi"). The plus is centred by flex, not by its line. */
1540
1602
  body.has-session #newBtn .brand-name{display:none}
1541
- body.has-session #newBtn.brand{width:32px;height:32px;margin:-2px 0;padding:0;justify-content:center;align-items:center;border-radius:999px;border:1px solid var(--border-strong)}
1542
- body.has-session #newBtn .brand-new{font-size:20px;line-height:1;color:var(--text-2)}
1603
+ body.has-session #newBtn.brand{align-self:center;width:28px;height:28px;padding:0;justify-content:center;align-items:center;border-radius:999px;border:1px solid var(--border-strong)}
1604
+ body.has-session #newBtn .brand-new{display:flex;color:var(--text-2)}
1605
+ body.has-session #newBtn .brand-plus{width:13px;height:13px;margin:0}
1543
1606
  }
1544
1607
  /* The bell (notifications): quiet at the top bar's right end; filled in the accent when on, struck through when the browser blocks it. */
1545
1608
  /* The open session's title, when no strip card in sight shows it (session_title.js): the bar's middle, cut with an ellipsis; the whole first message in its tooltip.
@@ -1562,12 +1625,13 @@ body.all-view #scope .scope-where{display:none}
1562
1625
  a wrapping line counts) and grow to their text, the pill first; the scope chip cuts with an ellipsis before the pill does.
1563
1626
  The pill drops its session count while it says live or waiting, so the scope chip keeps its words. */
1564
1627
  @media(max-width:600px){
1565
- #topBar{flex-wrap:wrap;row-gap:2px}
1628
+ #topBar{flex-wrap:wrap;row-gap:5px}
1566
1629
  #sessionTitleRow{flex-basis:100%;order:10}
1567
1630
  #sessionTitle{font-size:12px}
1568
1631
  .title-rename{font-size:12px;line-height:18px}
1569
1632
  #scope,#stripStatus{flex:1 1 0;min-width:0;max-width:max-content}
1570
- #stripStatus{flex-grow:1000;overflow:hidden;text-overflow:ellipsis}
1633
+ /* clip, not hidden: the ellipsis as before, and the touch tap box (its ::after) reaches out above and below. */
1634
+ #stripStatus{flex-grow:1000;overflow-x:clip;overflow-y:visible;text-overflow:ellipsis}
1571
1635
  /* A session page: the chip gives way to the pill. The start page has the "new session in …" path beside the chip:
1572
1636
  there the chip keeps its words and the path is what cuts. */
1573
1637
  body.has-session #scope .scope-name{flex-shrink:1;min-width:0}
@@ -1575,7 +1639,7 @@ body.all-view #scope .scope-where{display:none}
1575
1639
  body:not(.has-session) #scope .scope-where{flex:1 1 auto;min-width:0}
1576
1640
  #stripStatus:has(.live,.waiting) .pill-count{display:none}
1577
1641
  }
1578
- #notifyBtn{margin-left:auto;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;min-height:0;background:transparent;border:1px solid transparent;border-radius:999px;color:var(--text-muted)}
1642
+ #notifyBtn{margin-left:auto;align-self:center;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;min-height:0;background:transparent;border:1px solid transparent;border-radius:999px;color:var(--text-muted)}
1579
1643
  #notifyBtn[hidden]{display:none}
1580
1644
  @media(hover:hover){#notifyBtn:hover{color:var(--text-2);border-color:var(--border)}}
1581
1645
  #notifyBtn svg{fill:none;stroke:currentColor;stroke-width:1.3;stroke-linejoin:round;stroke-linecap:round}
@@ -1659,15 +1723,15 @@ body.no-glass :is(#familyPop,#chainPop){background:var(--bg-panel);-webkit-backd
1659
1723
  .scope-error{grid-column:1/-1;font-size:13px;color:var(--warn-text)}
1660
1724
  .strip-toggle{font-size:11px;padding:3px 10px;background:transparent;color:var(--text-muted);border:1px solid var(--border);border-radius:999px}
1661
1725
  .strip-toggle:hover{color:var(--text-2);border-color:var(--border-strong)}
1662
- #stripStatus{display:none;white-space:nowrap;flex-shrink:0}
1726
+ /* The sessions pill: the scope pill's twin (28px, the bell's height; 12px text), at every width. Sizes only on the bare id:
1727
+ a colour there would beat .strip-toggle[aria-pressed="true"], the all view's pressed look. */
1728
+ #stripStatus{display:none;align-self:center;height:28px;min-height:0;padding:0 10px;font-size:12px;line-height:26px;white-space:nowrap;flex-shrink:0}
1729
+ #stripStatus:not([aria-pressed="true"]){border-color:var(--border-strong)}
1730
+ #stripStatus:hover{filter:none}
1663
1731
  #stripStatus .live{color:var(--ok-text);white-space:nowrap}
1664
1732
  #stripStatus .live-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--ok);margin-right:4px;vertical-align:1px}
1665
1733
  #stripStatus .waiting{color:var(--warn-text);white-space:nowrap}
1666
1734
  #stripStatus .waiting-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--warn);margin-right:4px;vertical-align:1px}
1667
- /* A narrow window's strip scrolls sideways, and the grip's own target there is thin: the status pill gets a finger-sized one. */
1668
- @media(max-width:900px){
1669
- #stripStatus{min-height:30px;padding:4px 12px;font-size:12px}
1670
- }
1671
1735
  body.strip-hidden #stripStatus{display:block}
1672
1736
  body.strip-hidden #topStrip{display:none}
1673
1737
  /* In the all view the pill is the view's own button, pressed (app.js applyView), whatever the strip's state: a click goes
@@ -1708,9 +1772,11 @@ body.all-view #center, body.all-view #topStrip{display:none}
1708
1772
  /* All sessions' header sits in the top bar (before the bell, at its right end), shown in the all view alone: the search as a
1709
1773
  pill at chip height, the count, the archived toggle, Select. Its own auto margin pushes it right; the bell drops its own
1710
1774
  there (two auto margins would split the space). */
1711
- #allHead{display:none;margin-left:auto;gap:8px;align-items:center;min-width:0;flex-wrap:nowrap;justify-content:flex-end}
1775
+ #allHead{display:none;align-self:center;margin-left:auto;gap:8px;align-items:center;min-width:0;flex-wrap:nowrap;justify-content:flex-end}
1712
1776
  body.all-view #allHead{display:flex}
1713
1777
  @media(min-width:601px){body.all-view #notifyBtn{margin-left:0}}
1778
+ /* Nor does the header squeeze the scope chip there: its "all" segment would run under the sessions pill (800px). */
1779
+ @media(min-width:601px){body.all-view #scope{flex-shrink:0}}
1714
1780
  /* The search field is glass too (no shadow: it is a field, not a card); the focus ring below replaces the highlight. */
1715
1781
  #allHead input{flex:0 1 240px;width:240px;min-width:90px;box-sizing:border-box;height:24px;background:var(--glass-bg);-webkit-backdrop-filter:blur(18px) saturate(1.35);backdrop-filter:blur(18px) saturate(1.35);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-highlight);color:var(--text);padding:2px 11px;border-radius:999px;font-size:12px}
1716
1782
  #allHead input::placeholder{color:var(--text-faint)}
@@ -1739,8 +1805,9 @@ body.all-view #allHead{display:flex}
1739
1805
  .card.archived{opacity:.6}
1740
1806
  .card.archived:hover{opacity:.85}
1741
1807
  .card .archived-badge,.family-row .archived-badge{font-size:10px;padding:1px 6px;border-radius:6px;border:1px solid var(--border-strong);color:var(--text-muted)}
1742
- /* bottom: above the session's composer card when one shows (--toast-bottom, dock_reserve.js placeToast). */
1743
- #toast{position:fixed;left:50%;bottom:var(--toast-bottom,24px);transform:translateX(-50%);width:max-content;max-width:calc(100vw - 32px);box-sizing:border-box;z-index:50;display:flex;flex-direction:column;align-items:center;gap:8px}
1808
+ /* bottom: above the session's composer card when one shows (--toast-bottom, dock_reserve.js placeToast); else 24px, or
1809
+ 12px over the home indicator. */
1810
+ #toast{position:fixed;left:50%;bottom:var(--toast-bottom,max(24px,calc(var(--safe-b) + 12px)));transform:translateX(-50%);width:max-content;max-width:calc(100vw - 32px);box-sizing:border-box;z-index:50;display:flex;flex-direction:column;align-items:center;gap:8px}
1744
1811
  #toast[hidden]{display:none}
1745
1812
  #toast .toast-item{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;width:max-content;max-width:100%;box-sizing:border-box;padding:8px 14px;border-radius:10px;background:var(--bg-raised);color:var(--text);border:1px solid var(--border-strong);box-shadow:var(--toast-shadow);font-size:13px}
1746
1813
  #toast .toast-message{flex:1 1 180px;min-width:0;overflow-wrap:anywhere}
@@ -1805,6 +1872,9 @@ body.all-view #allHead{display:flex}
1805
1872
  .status.waiting{background:var(--warn-bg);color:var(--warn-text)}
1806
1873
  .status.completed{background:var(--accent-bg);color:var(--accent)}
1807
1874
  .status.error{background:var(--danger-bg-dim);color:var(--danger-text)}
1875
+ /* A re-read that can't reach chi web (resync_reach.js): the history stays, the chip says so. */
1876
+ .status.reconnecting{background:var(--warn-bg);color:var(--warn-text)}
1877
+ .status.offline{background:var(--danger-bg-dim);color:var(--danger-text)}
1808
1878
  .card .owner,.family-row .owner{font-size:11px;padding:2px 6px;border-radius:999px}
1809
1879
  .card .owner.worker,.family-row .owner.worker{background:var(--ok-bg);color:var(--ok-text)}
1810
1880
  .card .owner.tui,.family-row .owner.tui{background:var(--warn-bg);color:var(--warn-text)}
@@ -1828,20 +1898,31 @@ a{color:var(--accent)}
1828
1898
  .bubble.output>.copy-btn::before{inset:-15px -8px -2px -6px}
1829
1899
  .code-wrap>.copy-btn::before{inset:-5px -5px -12px -10px}
1830
1900
  .bubble.user>.copy-btn::before{inset:0 -2px -17px -13px}
1831
- /* The top bar. A phone's has two rows 2px apart (the scope pill over the title's ✎): the pill grows up only, the ✎
1832
- mostly down. */
1901
+ /* The top bar. A phone's has two rows 5px apart (the scope pill over the title's ✎): the pill grows up only, the ✎
1902
+ mostly down, its area ending at the pills' row. The sessions pill keeps a 30px tap box and a phone's round "+" a 32px
1903
+ one (the old sizes) with an invisible pseudo-element. */
1833
1904
  .title-rename{position:relative;z-index:1}
1834
1905
  .title-rename::after{content:"";position:absolute;inset:-5px -9px -16px}
1835
1906
  #notifyBtn{position:relative}
1836
1907
  #notifyBtn::after{content:"";position:absolute;inset:-7px}
1837
1908
  #scope .scope-all{position:relative}
1838
1909
  #scope .scope-all::after{content:"";position:absolute;inset:-14px -4px -11px -3px}
1839
- /* The pill: its box 40px tall and borderless, its border drawn at the box's bottom at the old height (21px) with the
1840
- text in its middle, the box's extra height above taken back by a negative margin so the row keeps its height; the box's
1910
+ #stripStatus{position:relative}
1911
+ #stripStatus::after{content:"";position:absolute;inset:-2px 0}
1912
+ #newBtn{position:relative}
1913
+ #newBtn::after{content:"";position:absolute;inset:-3px}
1914
+ /* The pill: its box 40px tall and borderless (no border at all: a transparent one would put the ::before 1px inside, a
1915
+ 26px pill beside the 28px "all"; the side padding takes its 1px), its border drawn at the box's bottom at the pill's
1916
+ height (28px) with the text in its middle, the box's extra height above taken back by a negative margin so the row keeps its height; the box's
1841
1917
  corners no rounder than the drawn pill's (overflow:hidden would clip them). */
1842
- #scope .scope-name,#scope .scope-name.error{position:relative;min-height:40px;margin:-19px 0 0;padding-top:21px;border-color:transparent;border-radius:11px}
1843
- #scope .scope-name::before{content:"";position:absolute;left:0;right:0;top:19px;bottom:0;border:1px solid var(--border-strong);border-radius:999px;pointer-events:none}
1918
+ #scope .scope-name,#scope .scope-name.error{position:relative;min-height:40px;margin:-12px 0 0;padding:12px 10px 0;border-width:0;border-radius:11px}
1919
+ #scope .scope-name::before{content:"";position:absolute;left:0;right:0;top:12px;bottom:0;border:1px solid var(--border-strong);border-radius:999px;pointer-events:none}
1844
1920
  #scope .scope-name.error::before{border-color:var(--warn-border)}
1921
+ /* The segmented control (project view): the left segment's fill on its drawn pill (::before, under the text), its box's
1922
+ left corners no rounder than the drawn pill's; "all"'s tap box 40px, as the left segment's, up from the row's bottom. */
1923
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-name{isolation:isolate;background:transparent;border-radius:11px 0 0 11px}
1924
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-name::before{z-index:-1;background:var(--bg-raised);border-radius:999px 0 0 999px}
1925
+ #scope:has(> .scope-name + .scope-all:not(.scope-back)) .scope-all::after{inset:-13px -4px -1px 0}
1845
1926
  /* The active strip card's ✎: inside the strip (overflow-x:auto clips), so its own box grows, into the card's padding. */
1846
1927
  #topStrip .card-rename{padding:9px 13px;margin:-9px -8px}
1847
1928
  /* 🖼 and Send at 36px; the one-line field's line centred on Send (the field is 27px: it sits 4.5px up). */
@@ -1862,7 +1943,7 @@ a{color:var(--accent)}
1862
1943
  <body>
1863
1944
  <main>
1864
1945
  <div id="topBar">
1865
- <button type="button" id="newBtn" class="brand" title="New session"><span class="brand-name">chi</span><span class="brand-new">+<span class="brand-new-word"> new session</span></span></button>
1946
+ <button type="button" id="newBtn" class="brand" title="New session" aria-label="New session"><span class="brand-name">chi</span><span class="brand-new"><svg class="brand-plus" viewBox="0 0 12 12" aria-hidden="true"><path d="M6 1.5v9M1.5 6h9"/></svg><span class="brand-new-word">new session</span></span></button>
1866
1947
  <div id="scope" hidden></div>
1867
1948
  <button type="button" class="strip-toggle" id="stripStatus" title="All sessions, with search"><span class="pill-count">sessions</span></button>
1868
1949
  <span id="sessionTitleRow" hidden><span id="sessionTitle"></span><button type="button" id="titleRenameBtn" class="title-rename" title="Rename this session" aria-label="Rename this session" hidden>✎</button></span>
@@ -107,7 +107,7 @@ export function infoBarHtml(bar) {
107
107
  if (!bar) return nothing;
108
108
  const memories = bar.memories || [];
109
109
  const sep = (group) => html`<span class=${`bar-sep sep-${group}`} aria-hidden="true"></span>`;
110
- const identity = html`<button type="button" class="id" title=${`Session id ${bar.id}: click to copy it`}>${String(bar.id).slice(0, 8)}</button><span class=${bar.status ? `status ${bar.status}` : "status"}><span>${bar.status || ""}</span></span><span class="model ctx" title=${bar.ctx.tip}>${bar.ctx.text}</span>${bar.speed ? html`<span class=${`model speed${bar.speed.empty ? " empty" : ""}`} title=${bar.speed.tip}>${bar.speed.text}</span>` : nothing}<span class=${`model session-time${bar.clock ? "" : " empty"}`} title=${bar.clock ? "This session's time: its turns, and the running one" : "This session's time: no turn yet"}>${bar.clock || CLOCK_NONE}</span>`;
110
+ const identity = html`<button type="button" class="id" title=${`Session id ${bar.id}: click to copy it`}>${String(bar.id).slice(0, 8)}</button><span class=${bar.status ? `status ${bar.status}` : "status"} title=${bar.statusTip || nothing}><span>${bar.statusText || bar.status || ""}</span></span><span class="model ctx" title=${bar.ctx.tip}>${bar.ctx.text}</span>${bar.speed ? html`<span class=${`model speed${bar.speed.empty ? " empty" : ""}`} title=${bar.speed.tip}>${bar.speed.text}</span>` : nothing}<span class=${`model session-time${bar.clock ? "" : " empty"}`} title=${bar.clock ? "This session's time: its turns, and the running one" : "This session's time: no turn yet"}>${bar.clock || CLOCK_NONE}</span>`;
111
111
  const setup = html`${settingsChip(bar.settings)}<span class=${`model model-name${bar.model.mismatch ? " served-mismatch" : ""}`} title=${bar.model.title}>${bar.model.text}</span>${toolkitChip(bar.toolkit)}${bar.notes ? html`<span class="model notes-chip" title=${bar.notes.title}>${bar.notes.text}</span>` : nothing}${bar.workingSet ? workingSetChipTemplate(bar.workingSet.chip) : memories.length ? html`<span class="model mem-chip" title=${memChipTitle(memories)}>${memChipText(memories)}</span>` : nothing}`;
112
112
  const pruned = !!bar.chain?.pruned && !bar.chain?.prev;
113
113
  const related = !!(bar.chain?.prev || bar.chain?.next || pruned || bar.parent || bar.kids || bar.participants);
@@ -9,6 +9,7 @@ import { ctxBarText, ctxBarTip, lastSpeedText, speedText } from "./ctx.js";
9
9
  import { formatDuration, sessionDurationNow } from "./timing.js";
10
10
  import { workerBadge } from "./update_notice.js";
11
11
  import { chipModel as settingsChipModel } from "./settings_chip.js";
12
+ import { REACH } from "./resync_reach.js";
12
13
 
13
14
  // Every chip and button of the session bar (#infoBar), one item per key:
14
15
  // {key, selector (its element in #infoBar), group (the .meta's identity,
@@ -151,10 +152,14 @@ export function infoBarModel({ id, state, sessions, chain, cardTitle, badge, res
151
152
  // link may not be listed yet: then neither, and its links show dates).
152
153
  const selfIso = state.createdAt || sessions.find((x) => x.id === id)?.created_at || null;
153
154
  const parentChip = delegatedBy(state.parentId, sessions.find((x) => x.id === state.parentId) || null);
155
+ const reach = REACH[state.reach] || null;
154
156
  return {
155
157
  id,
156
158
  // Its turn runs but a card blocks it: the word `chi sessions list` has for it.
157
- status: running && waiting ? "waiting" : state.status,
159
+ // A re-read that can't reach chi web says so in its place
160
+ // (resync_reach.js): +statusText+ and +statusTip+ then.
161
+ status: reach ? reach.status : running && waiting ? "waiting" : state.status,
162
+ ...(reach ? { statusText: reach.text, statusTip: reach.tip } : {}),
158
163
  model: modelLabel(state.model, ...(state.served || [])),
159
164
  // A link of a session chain: ← the previous link, → the next one (each
160
165
  // only while the list holds it).
@@ -102,6 +102,9 @@ export function createLiveTiming({
102
102
  get ended() { return ended; },
103
103
  set ended(n) { ended = n; },
104
104
  get ticking() { return ticker !== null; },
105
+ // What the running turn waits on ("": nothing; the stage's quiet signal
106
+ // says nothing while it waits on something named).
107
+ get note() { return note; },
105
108
 
106
109
  start(startedAt = new Date(now()).toISOString(), id = null) {
107
110
  stopTicker();
@@ -0,0 +1,59 @@
1
+ // A re-read of the open session (app.js resync) that could not reach chi web:
2
+ // the one rule for what the page does then. The history already drawn for
3
+ // this session stays as it is (the conversation is still right, only newer
4
+ // events are missing) and the info bar's status chip says the page is
5
+ // reconnecting, then, once the retries ran out, that it can't reach chi web;
6
+ // the next re-read that succeeds clears it (the hub's next event re-reads a
7
+ // session left in that state: needsReread). Only a first load (select()'s
8
+ // "Loading…", nothing of the session drawn yet) shows the error in the
9
+ // history, as there is nothing to keep.
10
+ // Its own module: new exports go in new modules (web-frontend.md).
11
+
12
+ // The status chip's word (its class), text and tooltip per state.
13
+ export const REACH = Object.freeze({
14
+ reconnecting: Object.freeze({
15
+ status: "reconnecting", text: "reconnecting…",
16
+ tip: "Can't reach chi web: trying again. The conversation shown is as it was; newer events show once it's back.",
17
+ }),
18
+ offline: Object.freeze({
19
+ status: "offline", text: "can't reach chi web",
20
+ tip: "Can't reach chi web. The conversation shown is as it was; the page reads it again once chi web is back.",
21
+ }),
22
+ });
23
+
24
+ // What a failed re-read does. +drawn+: the history shows this session's
25
+ // conversation; +retrying+: another try is scheduled.
26
+ // @return {{hint: boolean, reach: "reconnecting"|"offline"|null}}
27
+ // hint: replace the history with the error; reach: the store's field.
28
+ export function readFailed({ drawn, retrying }) {
29
+ if (!drawn) return { hint: true, reach: null };
30
+ return { hint: false, reach: retrying ? "reconnecting" : "offline" };
31
+ }
32
+
33
+ // The page side. +store+: the session store (its current.reach); +historyEl+,
34
+ // +errorHint+(message): the node a first load's failure shows.
35
+ export function createResyncReach({ store, historyEl, errorHint }) {
36
+ // The session whose conversation the history shows (null: a "Loading…"
37
+ // or error hint, the start page).
38
+ let drawnId = null;
39
+ return {
40
+ // select() put its "Loading…" hint in.
41
+ loading() {
42
+ drawnId = null;
43
+ },
44
+ // A re-read of +id+ drew it: the indicator goes.
45
+ drawn(id) {
46
+ drawnId = id;
47
+ if (store.current.reach) store.update({ current: { reach: null } });
48
+ },
49
+ // A re-read of +id+ (the open session) failed with +message+.
50
+ failed(id, message, { retrying }) {
51
+ const { hint, reach } = readFailed({ drawn: drawnId === id, retrying });
52
+ if (hint) historyEl.replaceChildren(errorHint(message));
53
+ if (reach !== store.current.reach) store.update({ current: { reach } });
54
+ },
55
+ // The session still shows a failed re-read: any sign of chi web (a hub
56
+ // event) is worth a re-read, not only a worker's bridge_up.
57
+ needsReread: () => !!store.current.reach,
58
+ };
59
+ }
@@ -110,6 +110,7 @@ export const FIELDS = {
110
110
  turnStarted: { redraws: ["composer", "infoBar"], writers: "setTurnRunning" },
111
111
  streamSeq: { redraws: [], writers: "resync" },
112
112
  streamFromGuess: { redraws: [], writers: "followWokenWorker, startStream, the stream's takeGuess" },
113
+ reach: { redraws: ["infoBar"], writers: "resync (resync_reach.js)" },
113
114
  };
114
115
 
115
116
  // The fields a hub card brings for the open session (followSelectedSession):
@@ -80,6 +80,11 @@ export function emptySessionState() {
80
80
  // The stream was opened from 0 (a wake with no cursor to go on) and no
81
81
  // new turn has started on it yet (app.js followWokenWorker).
82
82
  streamFromGuess: false,
83
+ // A re-read that couldn't reach chi web kept the drawn history
84
+ // (resync_reach.js): "reconnecting" while it retries, "offline" once
85
+ // the tries ran out; null otherwise. Never from a payload: the next
86
+ // re-read that draws the session clears it.
87
+ reach: null,
83
88
  };
84
89
  }
85
90
 
@@ -125,9 +125,11 @@ export function createStageFrame({ stage, scroller, status, cloud, queuedSlot, h
125
125
  function fitCap() {
126
126
  if (stage.hidden) return;
127
127
  // The composer card and the gap above it (the stage floats over them,
128
- // out of the dock's flow).
128
+ // out of the dock's flow), the card's offset from the panel's bottom
129
+ // (index.html --dock-bottom: 16 px, a phone's home indicator's line)
130
+ // and 16 px over the stage.
129
131
  const rest = dockEl.offsetHeight + STAGE_GAP;
130
- const room = centerEl.clientHeight - rest - 32;
132
+ const room = centerEl.clientHeight - rest - 16 - (parseFloat(getComputedStyle(dockEl).bottom) || 16);
131
133
  const share = window.innerHeight * (isRoomCap() ? ROOM_SHARE : isCloudOpen() ? CLOUD_SHARE : SHARE);
132
134
  const cap = Math.max(96, Math.round(Math.min(share, room)));
133
135
  const was = capPx();