@alexgreensh/token-optimizer 5.13.70 → 5.13.72

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 (40) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/hooks/module_runner.py +3 -3
  4. package/hooks/sessionstart_runner.py +6 -0
  5. package/package.json +1 -1
  6. package/skills/token-optimizer/assets/dashboard.html +361 -289
  7. package/skills/token-optimizer/assets/savings_story.js +140 -36
  8. package/skills/token-optimizer/references/cli-reference.md +1 -1
  9. package/skills/token-optimizer/scripts/_measure/__init__.py +3 -3
  10. package/skills/token-optimizer/scripts/_measure/config_cache.py +63 -0
  11. package/skills/token-optimizer/scripts/_measure/context_reset_marker.py +3 -1
  12. package/skills/token-optimizer/scripts/_measure/counted_cap.py +4 -2
  13. package/skills/token-optimizer/scripts/_measure/coverage_report.py +11 -1
  14. package/skills/token-optimizer/scripts/_measure/dashboard.py +35 -64
  15. package/skills/token-optimizer/scripts/_measure/holdout_report.py +5 -1
  16. package/skills/token-optimizer/scripts/_measure/keepwarm_safety.py +4 -0
  17. package/skills/token-optimizer/scripts/_measure/lifecycle.py +6 -7
  18. package/skills/token-optimizer/scripts/_measure/quality_checkpoint.py +4 -3
  19. package/skills/token-optimizer/scripts/_measure/savings.py +11 -4
  20. package/skills/token-optimizer/scripts/_measure/savings_headline.py +130 -0
  21. package/skills/token-optimizer/scripts/_measure/sessions.py +7 -0
  22. package/skills/token-optimizer/scripts/_measure/setup_observation_cache.py +99 -0
  23. package/skills/token-optimizer/scripts/_measure/setup_step.py +4 -5
  24. package/skills/token-optimizer/scripts/_measure/status_bar_refresh.py +218 -0
  25. package/skills/token-optimizer/scripts/_measure/structural_report.py +25 -6
  26. package/skills/token-optimizer/scripts/_measure/structural_value.py +16 -10
  27. package/skills/token-optimizer/scripts/cloud_kit.py +1 -2
  28. package/skills/token-optimizer/scripts/codemap.py +33 -5
  29. package/skills/token-optimizer/scripts/codemap_hint.py +152 -11
  30. package/skills/token-optimizer/scripts/codemap_index.py +100 -11
  31. package/skills/token-optimizer/scripts/codemap_ledger.py +29 -0
  32. package/skills/token-optimizer/scripts/codex_doctor.py +3 -3
  33. package/skills/token-optimizer/scripts/hermes_doctor.py +3 -3
  34. package/skills/token-optimizer/scripts/hermes_install.py +3 -3
  35. package/skills/token-optimizer/scripts/statusline.js +157 -30
  36. package/skills/token-optimizer/scripts/_measure/keepwarm_fork.py +0 -140
  37. package/skills/token-optimizer/scripts/_measure/keepwarm_guard.py +0 -35
  38. package/skills/token-optimizer/scripts/_measure/keepwarm_guard_server.py +0 -85
  39. package/skills/token-optimizer/scripts/_measure/keepwarm_prefix.py +0 -143
  40. package/skills/token-optimizer/scripts/_measure/keepwarm_response_filter.py +0 -84
@@ -1712,9 +1712,35 @@ input:checked + .slider:before {
1712
1712
  Card titles are headings (no small-caps labels above them). Sans for words,
1713
1713
  mono only for standalone figures; numbers inside sentences use the sans face
1714
1714
  with tabular figures. Secondary lines stay in --c-text-main for readability. */
1715
- html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; } h1,h2,h3 { text-wrap: balance; } p,li { text-wrap: pretty; } .st-enter .st > * { animation: st-enter .32s ease-out both; } .st-enter .st > :nth-child(2) { animation-delay:90ms; } .st-enter .st > :nth-child(3) { animation-delay:180ms; } .st-enter .st > :nth-child(4) { animation-delay:270ms; } .st-enter .st > :nth-child(5) { animation-delay:360ms; } .st-enter .st > :nth-child(6) { animation-delay:450ms; } @keyframes st-enter { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } } @media (prefers-reduced-motion:reduce) { .st-enter .st > * { animation:none; } .fold__body { transition:none; } .fold > summary::before { transition:none; } } .st { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); } .st .card.wide { grid-column: auto; }
1715
+ html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; } em, i { font-style: normal; } h1,h2,h3 { text-wrap: balance; } p,li { text-wrap: pretty; } .st-enter .st > * { animation: st-enter .32s ease-out both; } .st-enter .st > :nth-child(2) { animation-delay:90ms; } .st-enter .st > :nth-child(3) { animation-delay:180ms; } .st-enter .st > :nth-child(4) { animation-delay:270ms; } .st-enter .st > :nth-child(5) { animation-delay:360ms; } .st-enter .st > :nth-child(6) { animation-delay:450ms; } @keyframes st-enter { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } } @media (prefers-reduced-motion:reduce) { .st-enter .st > * { animation:none; } .fold__body { transition:none; } .fold > summary::before { transition:none; } } .st { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); margin-bottom: var(--s-3); } .st .card.wide { grid-column: auto; }
1716
1716
  .st .card { padding: var(--s-4); border: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.09), 0 2px 6px rgba(0,0,0,.12); } [data-theme="light"] .st .card { box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 2px 5px rgba(0,0,0,.06); } .st .st-table { box-shadow: 0 0 0 1px rgba(251,191,36,.4), 0 0 44px rgba(251,191,36,.1); }
1717
- .st .st-limits-card { padding: 12px var(--s-4); } .st-limits__top { display:flex; align-items:baseline; flex-wrap:wrap; gap: 8px 24px; } .st-limits__bottom { display:flex; align-items:center; justify-content:space-between; gap:16px; font-size:14px; } .st-limits__bottom .fold { margin:0; } .st-transform .st-mega__item { gap:0; } .st-transform .st-lead { max-width:65ch; margin-top:8px; } .st-transform .fold, .st-hero .fold { margin-top:0; } .st-table__body > .st-mega__item { margin-top:0; } .st-reread__body { display:flex; align-items:center; gap:32px; } .st-reread__body .st-lead { margin:0; } .st-h { font: 600 20px/1.3 var(--font-sans); color: var(--c-text-main); display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) 12px; }
1717
+ .st .st-limits-card { padding: var(--s-4); display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s-4) var(--s-6, 48px); align-items: start; }
1718
+ .st-limits__mega { margin: var(--s-2) 0 0; }
1719
+ .st-limits__mega .st-mega { font-size: clamp(64px, 7vw, 104px); }
1720
+ .st-limits__body .fold { margin-top: var(--s-3); }
1721
+ .st-limitbar { margin-bottom: var(--s-4); }
1722
+ .st-limitbar__label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2) var(--s-4); flex-wrap: wrap; font: 500 15px/1.4 var(--font-sans); color: var(--c-text-main); margin-bottom: 6px; }
1723
+ .st-limitbar__val { color: var(--c-text-main); font-size: 14px; }
1724
+ .st-limitbar__track { position: relative; height: 14px; border-radius: 7px; overflow: hidden; background: var(--c-elev-3); box-shadow: inset 0 0 0 1px var(--c-border); }
1725
+ .st-limitbar__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--c-accent-cyan); box-shadow: 0 0 10px var(--c-accent-cyan); transition: width 600ms cubic-bezier(0.2, 0, 0, 1); }
1726
+ .st-limitbar__fill--ghost { background: repeating-linear-gradient(135deg, var(--c-warning-2) 0 3px, transparent 3px 7px); opacity: 0.75; box-shadow: none; }
1727
+ .st-fixcell { display: inline-flex; align-items: center; gap: var(--s-3); flex: none; }
1728
+ .st-fix { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--c-border-strong); background: var(--c-elev-2); color: var(--c-text-main); font: 600 14px/1 var(--font-sans); cursor: pointer; white-space: nowrap; }
1729
+ .st-fix:hover { border-color: var(--c-accent-cyan); color: var(--c-accent-cyan); }
1730
+ .st-fix:focus-visible { outline: 2px solid var(--c-accent-cyan); outline-offset: 2px; }
1731
+ .st-mega__item { position: relative; }
1732
+ .st-tip { font: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help; color: inherit; text-decoration: underline dotted var(--c-text-dim); text-decoration-thickness: 2px; text-underline-offset: 8px; }
1733
+ .st-tip:focus-visible { outline: 2px solid var(--c-accent-cyan); outline-offset: 4px; border-radius: 4px; }
1734
+ .st-tipcard { position: absolute; left: 0; top: calc(100% + 10px); z-index: 60; display: block; width: max-content; max-width: min(360px, calc(100vw - 32px)); padding: 14px 16px; background: var(--c-surface-hover); border: 0; border-radius: 12px; box-shadow: 0 0 0 1px var(--c-border-strong), 0 12px 32px rgba(0,0,0,.5); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .15s ease, transform .15s ease, visibility .15s; pointer-events: none; text-align: left; }
1735
+ [data-theme="light"] .st-tipcard { background: var(--c-surface); box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 12px 28px rgba(14,22,34,.18); }
1736
+ .st-mega__item:last-child .st-tipcard { left: auto; right: 0; }
1737
+ .st .card:hover, .st .card:focus-within, .st .card:has(.st-tip--open) { position: relative; z-index: 20; }
1738
+ .st-tipcard__t { display: block; font: 600 15px/1.4 var(--font-sans); color: var(--c-text-main); margin-bottom: 6px; }
1739
+ .st-tipcard__l { display: block; font: 400 14px/1.5 var(--font-sans); color: var(--c-text-main); margin-top: 4px; }
1740
+ .st-tipcard__note { color: var(--c-text-main); margin-top: 8px; }
1741
+ .st-mega__item:hover .st-tipcard, .st-tip:focus + .st-tipcard, .st-tipcard:hover, .st-tipcard:focus-within, .st-tip--open + .st-tipcard { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
1742
+ .st-flash { animation: st-flash 1.6s ease-out; }
1743
+ @keyframes st-flash { 0% { box-shadow: 0 0 0 3px var(--c-accent-cyan); } 100% { box-shadow: 0 0 0 0 transparent; } }
1718
1744
  .st-tag { font: 500 13px/1 var(--font-sans); letter-spacing: 0.01em; color: var(--c-text-main); border: 1px solid var(--c-border-strong); border-radius: 999px; padding: 5px 10px; }
1719
1745
  .st-num { font-family: var(--font-sans); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--c-accent-cyan); white-space: nowrap; }
1720
1746
  .st-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--c-text-main); text-align: right; white-space: nowrap; }
@@ -1752,8 +1778,8 @@ html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
1752
1778
  .st-mega__row--hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: var(--s-4); }
1753
1779
  .st-mega__row--hero .st-mega { font-size: clamp(60px, 6.2vw, 96px); }
1754
1780
  .st-mega__note { font: 600 17px/1.3 var(--font-sans); color: var(--c-savings); }
1781
+ .st-mega__note--worse { color: var(--c-waste); }
1755
1782
  .st-mega--route { color: var(--c-info); text-shadow: 0 0 26px rgba(96,165,250,0.36), 0 0 2px rgba(96,165,250,0.4); }
1756
- .st-mega--warm { color: var(--c-warning-2); text-shadow: 0 0 28px rgba(251,191,36,0.38), 0 0 2px rgba(251,191,36,0.45); }
1757
1783
  .st-table { border: 0; box-shadow: 0 0 0 1px rgba(251,191,36,0.35), 0 0 44px rgba(251,191,36,0.10); }
1758
1784
  [data-theme="light"] .st-table { box-shadow: 0 0 0 1px rgba(150,95,0,.3), 0 2px 5px rgba(0,0,0,.06); }
1759
1785
  .st-table__body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s-3) var(--s-5); align-items: center; }
@@ -1778,14 +1804,13 @@ html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
1778
1804
  .st-limit__ghost, .st-limit__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition-property: width; transition-duration: 600ms; transition-timing-function: cubic-bezier(0.2, 0, 0, 1); }
1779
1805
  .st-limit__ghost { background: repeating-linear-gradient(135deg, var(--c-warning-2) 0 3px, transparent 3px 7px); opacity: 0.7; }
1780
1806
  .st-limit__fill { background: var(--c-accent-cyan); box-shadow: 0 0 10px var(--c-accent-cyan); }
1781
- .st-limit__stat { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
1782
- .st-limit__stat--over { color: var(--c-warning-2); font-weight: 600; }
1807
+ .st-limit__stat { display: inline-flex; align-items: baseline; gap: 6px; white-space: normal; }
1783
1808
  @media (max-width: 720px) { .st-limit { grid-template-columns: 1fr max-content max-content; } .st-limit__meter { grid-column: 1 / -1; grid-row: 2; } }
1784
1809
  .st-mega__per { font: 500 clamp(20px, 2vw, 26px)/1 var(--font-sans); letter-spacing: 0; text-shadow: none; color: var(--c-text-main); }
1785
1810
  .st-limit__used, .st-limit__num { font: 500 24px/1 var(--font-mono); font-variant-numeric: tabular-nums; text-shadow: 0 0 18px currentColor; } .st-limit__used { color: var(--c-accent-cyan); }
1786
- .st-limit__num { color: var(--c-warning-2); }
1811
+ .st-limit__num { color: var(--c-text-main); }
1787
1812
  @media (max-width: 900px) {
1788
- .st-grid, .st-bands, .st-mega__row--hero, .st-table__body, .st-cols { grid-template-columns: 1fr; }
1813
+ .st-grid, .st-bands, .st-mega__row--hero, .st-table__body, .st-cols, .st-limits-card { grid-template-columns: 1fr; }
1789
1814
  .st-grid > :last-child:nth-child(odd) { grid-column: auto; }
1790
1815
  .st-mega__row--hero .st-mega { font-size: 72px; }
1791
1816
  }
@@ -1858,11 +1883,7 @@ html { -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
1858
1883
  .hook-command-pre { white-space: pre-wrap; word-break: break-word; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 8px; padding: 12px; color: var(--c-accent-cyan); font-family: var(--font-mono); font-size: 13px; line-height: 1.5; margin: 10px 0 12px; }
1859
1884
  .hook-command-meta { color: var(--c-text-dim); font-size: 13px; line-height: 1.45; }
1860
1885
 
1861
- /* ========== SESSION QUALITY OVERLAY (v2.6) ========== */
1862
- .quality-good { border-left: 4px solid var(--c-savings-strong, #22c55e) !important; }
1863
- .quality-fair { border-left: 4px solid transparent !important; }
1864
- .quality-needs-work { border-left: 4px solid var(--c-warning-yellow, #eab308) !important; }
1865
- .quality-poor { border-left: 4px solid var(--c-waste-strong, #ef4444) !important; }
1886
+ /* Section 6: quality rows carry a badge, not a left accent stripe. */
1866
1887
  .quality-badge {
1867
1888
  display: inline-block;
1868
1889
  font-family: var(--font-mono);
@@ -1955,7 +1976,7 @@ tr.token-spike td {
1955
1976
  background: var(--c-warning-fill-2, rgba(251, 146, 60, 0.08)) !important;
1956
1977
  }
1957
1978
  tr.token-spike td:first-child {
1958
- border-left: 3px solid var(--c-warning-soft, #fb923c);
1979
+ border-left: none;
1959
1980
  }
1960
1981
 
1961
1982
  /* ========== PROMPT PREVIEW MODAL ========== */
@@ -2147,8 +2168,8 @@ window.__TOKEN_DATA__ = null;
2147
2168
  <div>
2148
2169
  <div class="brand"><span></span> Token Optimizer <small id="brand-meta" style="display:block;margin-left:27px;margin-top:2px;font-size:11px;letter-spacing:.18em;text-transform:uppercase;color:var(--c-text-dim);font-weight:600;"></small></div>
2149
2170
  <div class="nav-menu">
2150
- <a class="nav-item active" data-view="overview">Overview</a>
2151
- <a class="nav-item" data-view="savings">Savings</a>
2171
+ <a class="nav-item active" data-view="savings">Savings</a>
2172
+ <a class="nav-item" data-view="overview">Overview</a>
2152
2173
  <a class="nav-item" data-view="quick">Quick Wins <span class="nav-badge" id="badge-quick"></span></a>
2153
2174
  <a class="nav-item" data-view="medium">Medium <span class="nav-badge" id="badge-medium"></span></a>
2154
2175
  <a class="nav-item" data-view="deep">Deep <span class="nav-badge" id="badge-deep"></span></a>
@@ -2161,15 +2182,13 @@ window.__TOKEN_DATA__ = null;
2161
2182
  <a class="nav-item" data-view="manage">Manage</a>
2162
2183
  </div>
2163
2184
  </div>
2164
- <div class="user-profile">workspace: <i id="nav-date"></i></div>
2165
2185
  </nav>
2166
2186
 
2167
2187
  <!-- MAIN -->
2168
2188
  <main class="main-col">
2169
2189
  <!-- Overview View -->
2170
- <div class="view active" id="view-overview">
2190
+ <div class="view" id="view-overview">
2171
2191
  <header class="header">
2172
- <div class="label">Token Overhead Analysis <span id="overview-version-badge" style="opacity:.7;margin-left:.5rem;font-family:var(--font-mono);font-size:12px;"></span></div>
2173
2192
  <h1>Overview</h1>
2174
2193
  <p>Your current config overhead, measured against your detected context window. <span id="overview-view-source" style="color:var(--c-text-dim);font-size:13px;"></span></p>
2175
2194
  </header>
@@ -2209,7 +2228,7 @@ window.__TOKEN_DATA__ = null;
2209
2228
  </div>
2210
2229
 
2211
2230
  <!-- Savings View -->
2212
- <div class="view" id="view-savings"></div>
2231
+ <div class="view active" id="view-savings"></div>
2213
2232
  <!-- Quick Wins View -->
2214
2233
  <div class="view" id="view-quick"></div>
2215
2234
  <!-- Medium View -->
@@ -2229,6 +2248,8 @@ window.__TOKEN_DATA__ = null;
2229
2248
  <div class="view" id="view-manage"></div>
2230
2249
 
2231
2250
  <div class="main-footer">
2251
+ <span class="footer-version" id="footer-version"></span>
2252
+ <span class="footer-updated" id="footer-updated"></span>
2232
2253
  <span class="footer-byline">Built by <a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener">Alex Greenshpun</a></span>
2233
2254
  <a class="gh-star" href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="Star Token Optimizer on GitHub">
2234
2255
  <svg class="gh-star-icon" width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.5l2.9 6.06 6.6.59-5 4.38 1.5 6.47L12 16.98 5.99 20.5l1.5-6.47-5-4.38 6.6-.59L12 2.5z"/></svg>
@@ -2260,29 +2281,10 @@ window.__TOKEN_DATA__ = null;
2260
2281
  </div>
2261
2282
 
2262
2283
  <div class="section-title">Notes</div>
2263
- <textarea class="notes-area" id="notes-input" placeholder="Keep gsd, skip n8n cluster..."></textarea>
2284
+ <textarea class="notes-area" id="notes-input" placeholder="Anything to keep or skip?"></textarea>
2264
2285
 
2265
2286
  <button class="apply-btn" id="copy-btn" disabled>Preview &amp; Copy</button>
2266
2287
 
2267
- <div class="version-footer">
2268
- <div class="footer-byline">Built by <a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener">Alex Greenshpun</a></div>
2269
- <a class="gh-star" href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="Star Token Optimizer on GitHub">
2270
- <svg class="gh-star-icon" width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2.5l2.9 6.06 6.6.59-5 4.38 1.5 6.47L12 16.98 5.99 20.5l1.5-6.47-5-4.38 6.6-.59L12 2.5z"/></svg>
2271
- <span>Star on GitHub</span>
2272
- <span class="gh-star-count" data-gh-stars hidden></span>
2273
- </a>
2274
- <div class="social-icons">
2275
- <a href="https://github.com/alexgreensh/token-optimizer" target="_blank" rel="noopener" title="GitHub" class="social-link">
2276
- <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg>
2277
- </a>
2278
- <a href="https://x.com/alexgreensh" target="_blank" rel="noopener" title="X (Twitter)" class="social-link">
2279
- <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24h-6.66l-5.214-6.817-5.97 6.817H1.673l7.73-8.835L1.254 2.25h6.83l4.713 6.231 5.447-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117l11.966 15.644z"/></svg>
2280
- </a>
2281
- <a href="https://linkedin.com/in/alexgreensh" target="_blank" rel="noopener" title="LinkedIn" class="social-link">
2282
- <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
2283
- </a>
2284
- </div>
2285
- </div>
2286
2288
  </aside>
2287
2289
  </div>
2288
2290
 
@@ -2817,6 +2819,17 @@ var DB = (function() {
2817
2819
  safeRender('RightPanel', null, updateRightPanel);
2818
2820
  safeRender('EventBinding', null, bind);
2819
2821
 
2822
+ // Deep links: a hash naming a view opens that view; with no usable hash,
2823
+ // open Savings when the story payload is present, else Overview. The
2824
+ // replaceState write keeps the landing URL bookmarkable without adding a
2825
+ // history entry.
2826
+ var initialView = viewFromHash();
2827
+ if (initialView) {
2828
+ showView(initialView, { skipHash: true });
2829
+ } else {
2830
+ showView((typeof savingsStoryOn === 'function' && savingsStoryOn(data)) ? 'savings' : 'overview', { replace: true });
2831
+ }
2832
+
2820
2833
  // Kill stale session buttons (v2.6)
2821
2834
  var killStaleBtn = document.getElementById('kill-stale-btn');
2822
2835
  if (killStaleBtn) {
@@ -2876,21 +2889,33 @@ var DB = (function() {
2876
2889
  hasAnyItems = true;
2877
2890
  }
2878
2891
  });
2879
- // Default to Trends tab (analytics are always relevant for standalone)
2880
- var trendsNav = document.querySelector('.nav-item[data-view="trends"]');
2881
- if (trendsNav) trendsNav.click();
2892
+ // Standalone files still open on Savings/Overview per the initial
2893
+ // showView() above; the F4 default is not overridden here.
2882
2894
  }
2883
2895
  }
2884
2896
 
2897
+ // Section 5 cuts: habits items that say "no action needed" or give generic
2898
+ // advice with no figure from this user's data are not rendered (see
2899
+ // renderSectionViews) and do not count toward the nav badge.
2900
+ function habitsItemCut(it) {
2901
+ var t = (it.title || '') + ' ' + (it.shortDesc || '');
2902
+ return /effortLevel/i.test(t) || /Use \/clear/i.test(t) || /Batch related/i.test(t);
2903
+ }
2904
+
2885
2905
  function renderNav() {
2886
2906
  var counts = { quick: 0, medium: 0, deep: 0, habits: 0 };
2887
- items.forEach(function(it) { if (counts[it.section] !== undefined) counts[it.section]++; });
2907
+ items.forEach(function(it) {
2908
+ if (counts[it.section] === undefined) return;
2909
+ if (it.section === 'habits' && habitsItemCut(it)) return;
2910
+ counts[it.section]++;
2911
+ });
2888
2912
  for (var k in counts) {
2889
2913
  var el = document.getElementById('badge-' + k);
2890
2914
  if (el) el.textContent = counts[k] || '';
2891
2915
  }
2892
2916
  var ts = data.generated_at || new Date().toISOString();
2893
- document.getElementById('nav-date').textContent = ts.slice(0,10);
2917
+ var navDate = document.getElementById('nav-date');
2918
+ if (navDate) navDate.textContent = ts.slice(0,10);
2894
2919
  }
2895
2920
 
2896
2921
  // v5.4.18: v5 feature metadata mirrors V5_FEATURES in measure.py. Used as a
@@ -3087,11 +3112,10 @@ var DB = (function() {
3087
3112
  }
3088
3113
 
3089
3114
  // Hero card
3090
- var remaining = Math.max(0, ctxWindow - total);
3091
3115
  document.getElementById('hero-tag').textContent = fn(total) + ' tokens';
3092
3116
  document.getElementById('hero-total').textContent = fn(total);
3093
3117
  document.getElementById('hero-sub').innerHTML =
3094
- 'tokens loaded before you type a word (' + ctxLabel + ' window). You start every session with only <span>' + fn(remaining) + '</span> left for actual conversation.';
3118
+ 'tokens loaded before you type a word (' + ctxLabel + ' window).';
3095
3119
 
3096
3120
  // v5 Active Compression recommendation card. v5.4.18: fall back to
3097
3121
  // client-side synthesis when the dashboard has no real data yet so a
@@ -3134,7 +3158,7 @@ var DB = (function() {
3134
3158
  var recBadge = f.recommended
3135
3159
  ? '<span style="background:var(--c-badge-savings);color:#000;font-size:11px;padding:2px 7px;border-radius:3px;margin-left:8px;font-weight:700;">RECOMMENDED</span>'
3136
3160
  : '<span style="background:var(--c-border);color:var(--c-text-dim);font-size:11px;padding:2px 7px;border-radius:3px;margin-left:8px;">OPT-IN</span>';
3137
- cardHtml += '<div style="padding:14px;background:var(--c-bg);border-radius:6px;border-left:4px solid ' + riskColor + ';">' +
3161
+ cardHtml += '<div style="padding:14px;background:var(--c-bg);border-radius:6px;">' +
3138
3162
  '<div style="display:flex;justify-content:space-between;align-items:baseline;margin-bottom:6px;">' +
3139
3163
  '<div style="font-size:17px;font-weight:600;">' + esc(f.label) + recBadge + '</div>' +
3140
3164
  '<div style="font-size:20px;font-weight:700;color:var(--c-accent-cyan);">+' + f.impact_pct + '%</div>' +
@@ -3154,13 +3178,9 @@ var DB = (function() {
3154
3178
  cardHtml += '</div></div>';
3155
3179
  v5card.innerHTML = cardHtml;
3156
3180
  } else {
3157
- // All features enabled - show success state
3158
- v5card.innerHTML = '<div class="card wide" style="border: 2px solid var(--c-savings);margin-bottom:var(--s-3);">' +
3159
- '<div class="card-header"><span style="font-size:20px;">Active Compression (v5)</span>' +
3160
- '<span class="label" style="background:var(--c-badge-savings);color:#000;padding:4px 10px;border-radius:4px;font-weight:700;font-size:13px;">MAXED OUT</span></div>' +
3161
- '<div style="padding: var(--s-2) var(--s-3);font-size:17px;">' +
3162
- '<span style="font-size:24px;">\u2713</span> ' + esc(v5rec.recommendation) +
3163
- '</div></div>';
3181
+ // All features enabled: one line, the detail lives in Manage.
3182
+ v5card.innerHTML = '<div style="font-size:15px;color:var(--c-text-dim);margin:0 0 var(--s-3);">' +
3183
+ '\u2713 All compression features are on.</div>';
3164
3184
  }
3165
3185
  }
3166
3186
 
@@ -3168,8 +3188,7 @@ var DB = (function() {
3168
3188
  var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
3169
3189
  var staleMinutes = data.generated_at ? Math.round((Date.now() - new Date(data.generated_at).getTime()) / 60000) : 0;
3170
3190
  var isStale = staleMinutes > 60;
3171
- var refreshHint = data.runtime === 'codex' ? 'run the Codex dashboard refresh command' : isNoInstructionHost(data) ? 'regenerate the dashboard' : 'run /token-optimizer';
3172
- var staleWarning = isStale ? ' <span style="color:var(--c-warning, #ff9f43);font-weight:500;">(data is ' + (staleMinutes > 1440 ? Math.round(staleMinutes / 1440) + 'd' : Math.round(staleMinutes / 60) + 'h') + ' old — ' + refreshHint + ' to refresh)</span>' : '';
3191
+ var staleWarning = isStale ? ' <span style="color:var(--c-text-dim);font-weight:500;">(updated ' + (staleMinutes > 1440 ? Math.round(staleMinutes / 1440) + ' days' : Math.round(staleMinutes / 60) + ' hours') + ' ago)</span>' : '';
3173
3192
  var headerEl = document.querySelector('#view-overview .header');
3174
3193
  if (headerEl) {
3175
3194
  var existingTs = headerEl.querySelector('.last-updated');
@@ -3263,21 +3282,8 @@ var DB = (function() {
3263
3282
  isCodexOverview
3264
3283
  ? 'Bars show % of the logged Codex context window each component uses. Core System is fixed by Codex. AGENTS.md, memories, skills/plugins, MCP, and hooks are yours to tune.'
3265
3284
  : 'Bars show % of context window each component uses. Core System is fixed by ' + (data.runtime_label || 'Claude Code') + '. Everything else is yours to trim.';
3266
- var caveatEl = document.getElementById('sat-caveat');
3267
- if (!caveatEl) {
3268
- caveatEl = document.createElement('div');
3269
- caveatEl.id = 'sat-caveat';
3270
- caveatEl.style.cssText = 'font-size:11px;color:var(--c-text-dim);margin-top:6px;font-style:italic;';
3271
- document.getElementById('sat-desc').parentNode.appendChild(caveatEl);
3272
- }
3273
- var cal = data.snapshot.calibration;
3274
- if (cal && cal.has_data && cal.significant) {
3275
- caveatEl.textContent = 'Note: real session baseline averages ' + fn(cal.avg_real_baseline) +
3276
- ' tokens (' + (cal.gap_pct > 0 ? '+' : '') + cal.gap_pct + '% vs estimate). ' +
3277
- 'Gap is from unmeasured system overhead (XML framing, MCP instructions).';
3278
- } else {
3279
- caveatEl.textContent = 'Estimate based on file sizes. Actual overhead includes XML framing and system wrappers not measured here.';
3280
- }
3285
+ // The italic calibration footnote is cut (section 5): the headline now
3286
+ // carries the measured number, and an 11px dim aside only repeated it.
3281
3287
 
3282
3288
  // What You'd Save card
3283
3289
  var planTokens = Math.min(
@@ -3341,24 +3347,11 @@ var DB = (function() {
3341
3347
  gridEl.className = 'component-cards';
3342
3348
  gridEl.innerHTML = cardsHtml;
3343
3349
 
3344
- // Health cards: runtime instruction files + memory files
3350
+ // Health cards: runtime memory files. The instruction-file (CLAUDE.md /
3351
+ // AGENTS.md) health card is cut (section 5): its one number is already in
3352
+ // the component breakdown above.
3345
3353
  var healthCardsHtml = '<div style="display:grid;grid-template-columns:1fr 1fr;gap:var(--s-3);margin-top:var(--s-3);">';
3346
3354
 
3347
- // Instruction-file health card
3348
- var cmh = data.claude_md_health;
3349
- if (cmh) {
3350
- var instructionLabel = isCodexOverview ? 'AGENTS.md Health' : 'CLAUDE.md Health';
3351
- var cmColor = cmh.status === 'good' ? 'var(--c-accent-cyan)' : cmh.status === 'warning' ? 'var(--c-warning, #ff9f43)' : 'var(--c-text-dim, #7d8ca3)';
3352
- healthCardsHtml += '<div class="card"><div class="card-header"><span>' + instructionLabel + '</span></div>' +
3353
- '<div style="text-align:center;padding:var(--s-3) 0;">' +
3354
- '<div style="font-size:28px;font-weight:700;font-family:var(--font-mono);color:' + cmColor + ';">' + fn(cmh.tokens) + '</div>' +
3355
- '<div style="font-size:13px;color:var(--c-text-dim);">tokens (' + cmh.pct + '% of context)</div>' +
3356
- '</div>' +
3357
- '<div style="text-align:center;padding:0 0 var(--s-3) 0;font-size:13px;color:' + cmColor + ';">' +
3358
- (cmh.status === 'good' ? 'Lean and efficient' : cmh.status === 'warning' ? 'Consider restructuring' : 'Growing') +
3359
- '</div></div>';
3360
- }
3361
-
3362
3355
  // Memory health card
3363
3356
  var mr = data.memory_review;
3364
3357
  if (mr && !mr.error && mr.codex) {
@@ -3395,20 +3388,15 @@ var DB = (function() {
3395
3388
  healthCardsHtml += '</div>';
3396
3389
  gridEl.insertAdjacentHTML('afterend', healthCardsHtml);
3397
3390
 
3398
- // Standalone mode: CTA or auto-recommendations banner
3399
- if (data.standalone) {
3391
+ // Standalone mode: CTA when there is nothing auto-detected. The
3392
+ // "Auto-Detected Recommendations" card is cut (section 5): its whole body
3393
+ // was "browse them in the tabs on the left".
3394
+ if (data.standalone && !(data.auto_plan && items.length > 0)) {
3400
3395
  var ctaEl = document.createElement('div');
3401
3396
  ctaEl.className = 'card wide';
3402
- if (data.auto_plan && items.length > 0) {
3403
- ctaEl.innerHTML = '<div class="card-header"><span>Auto-Detected Recommendations</span></div>' +
3404
- '<div class="empty-state" style="text-align:left;color:var(--c-text-dim);font-size:14px;">' +
3405
- 'These recommendations are auto-generated from your config. Browse them in the tabs on the left.<br>' +
3406
- (isCodexOverview ? 'For deeper analysis, refresh the Codex dashboard after a few real turns so quality and continuity signals are available.' : isHostOverview ? '' : 'For deeper analysis (semantic duplication, content quality), run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full LLM-powered audit.') + '</div>';
3407
- } else {
3408
- ctaEl.innerHTML = '<div class="card-header"><span>Optimization Recommendations</span></div>' +
3409
- '<div class="empty-state">No auto-detected issues. Your setup looks clean.<br>' +
3410
- (isCodexOverview ? 'Refresh the Codex dashboard after live usage for deeper quality analysis.' : isHostOverview ? '' : 'Run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full audit with deeper analysis.') + '</div>';
3411
- }
3397
+ ctaEl.innerHTML = '<div class="card-header"><span>Optimization Recommendations</span></div>' +
3398
+ '<div class="empty-state">No auto-detected issues. Your setup looks clean.<br>' +
3399
+ (isCodexOverview ? 'Refresh the Codex dashboard after live usage for deeper quality analysis.' : isHostOverview ? '' : 'Run <code style="color:var(--c-accent-cyan)">/token-optimizer</code> for a full audit with deeper analysis.') + '</div>';
3412
3400
  gridEl.parentNode.insertBefore(ctaEl, gridEl.nextSibling);
3413
3401
  }
3414
3402
 
@@ -3462,24 +3450,20 @@ var DB = (function() {
3462
3450
  if (!el) return;
3463
3451
  var secItems = items.filter(function(it) { return it.section === sec; });
3464
3452
  var isHabits = (sec === 'habits');
3453
+ if (isHabits) {
3454
+ // Section 5 cuts: the FYI effortLevel card says "no action needed" and
3455
+ // the two generic advice items cite no number from this user's data.
3456
+ secItems = secItems.filter(function(it) { return !habitsItemCut(it); });
3457
+ }
3465
3458
 
3466
- var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
3467
3459
  var html = '<div class="section-header">' +
3468
- '<div class="label">' + (isHabits ? 'Recommendations' : 'Optimization Plan') + '</div>' +
3469
3460
  '<h1>' + (groupLabels[sec] || sec) + '</h1>' +
3470
3461
  '<p>' + (groupDescs[sec] || '') + '</p>' +
3471
3462
  '</div>';
3472
3463
 
3473
- if (data.auto_plan) {
3474
- html += '<div class="last-updated">Last updated: ' + esc(ts) +
3475
- (data.runtime === 'codex' ? ' · Auto-detected from Codex local config and logs.</div>' : (isNoInstructionHost(data) ? ' · Auto-detected from local config and logs.</div>' : ' · Auto-detected. Run <span class="update-cmd">/token-optimizer</span> for deeper LLM-powered analysis.</div>'));
3476
- } else if (data.standalone) {
3477
- html += '<div class="last-updated">Last updated: ' + esc(ts) +
3478
- (data.runtime === 'codex' ? ' · Optimization data is limited until Codex session logs are collected.</div>' : (isNoInstructionHost(data) ? ' · Optimization data is limited in standalone mode.</div>' : ' · Optimization data not available in standalone mode. Run <span class="update-cmd">/token-optimizer</span> for a full audit with recommendations.</div>'));
3479
- } else {
3480
- html += '<div class="last-updated">Last updated: ' + esc(ts) +
3481
- (data.runtime === 'codex' ? ' · To refresh, use the Codex dashboard refresh command.</div>' : (isNoInstructionHost(data) ? ' · To refresh, run ' + hostRefreshHtml(data) + '.</div>' : ' · To refresh, run <span class="update-cmd">/token-optimizer</span> again.</div>'));
3482
- }
3464
+ // The "Last updated … Auto-detected" line is cut (section 5): freshness
3465
+ // lives once in the footer, and the auto-detect note repeated on all
3466
+ // four tabs.
3483
3467
 
3484
3468
  if (secItems.length === 0) {
3485
3469
  if (!data.plan && !data.auto_plan) {
@@ -3563,7 +3547,7 @@ var DB = (function() {
3563
3547
  return [{ heading: 'Details', text: detail }];
3564
3548
  }
3565
3549
 
3566
- var analyticsViews = { savings: true, trends: true, health: true, hooks: true, manage: true };
3550
+ var analyticsViews = { savings: true, trends: true, health: true, hooks: true, manage: true, overview: true, coach: true };
3567
3551
 
3568
3552
  // Emits the per-model note + stacked bar + legend (the existing USAGE
3569
3553
  // breakdown). Hoisted to module scope so the Tokens Saved card (in BOTH
@@ -3638,7 +3622,6 @@ var DB = (function() {
3638
3622
  // Share the Savings story calculation and period, including its eligibility rules.
3639
3623
  function tokensSavedCardHtml(savings) {
3640
3624
  var s = savings || {};
3641
- var storyAvailable = typeof savingsStoryOn === 'function' && savingsStoryOn(data);
3642
3625
  var bands = typeof savingsStoryBands === 'function' ? savingsStoryBands(data) : null;
3643
3626
  var total = bands ? bands.totalTok : Number((s.token_headline || {}).total_tokens) || 0;
3644
3627
  if (total <= 0) return '';
@@ -3662,10 +3645,26 @@ var DB = (function() {
3662
3645
  out += '<div class="ts-divider"></div><h3 class="ts-section-label">Model usage</h3>';
3663
3646
  out += modelMixBodyHtml(mix, data.runtime === 'codex', spent > 0 ? spent : modelTotal);
3664
3647
  }
3665
- out += '<div class="ts-foot">' + (storyAvailable ? 'Same figure as the Savings card.<br>' : '') + formatTokens(removed) + ' tokens removed once.</div></div>';
3648
+ out += '<div class="ts-foot">' + formatTokens(removed) + ' tokens removed once.</div></div>';
3666
3649
  return out;
3667
3650
  }
3668
3651
 
3652
+ // Trends keeps only the model-usage bar from the old Tokens Saved card
3653
+ // (section 5): the savings figures live on the Savings tab now, and the
3654
+ // "Your limits go further" twin is removed (F8).
3655
+ function trendsModelMixCardHtml() {
3656
+ var t = data.trends || {};
3657
+ var mix = t.model_mix || {};
3658
+ var modelTotal = 0;
3659
+ for (var m in mix) { modelTotal += Number(mix[m]) || 0; }
3660
+ if (modelTotal <= 0) return '';
3661
+ var spent = Object.prototype.hasOwnProperty.call(t, 'total_tokens') ? Math.max(0, Number(t.total_tokens) || 0) : modelTotal;
3662
+ var days = Number(t.period_days) || 30;
3663
+ return '<div class="card wide"><div class="card-header"><span>Model usage</span></div>' +
3664
+ '<div style="font-size:13px;color:var(--c-text-dim);margin:0 0 var(--s-2);">Share of logged tokens by model, last ' + days + ' days.</div>' +
3665
+ modelMixBodyHtml(mix, data.runtime === 'codex', spent > modelTotal ? spent : modelTotal) + '</div>';
3666
+ }
3667
+
3669
3668
  function renderTrends() {
3670
3669
  var el = document.getElementById('view-trends');
3671
3670
  if (!el) return;
@@ -3675,13 +3674,15 @@ var DB = (function() {
3675
3674
 
3676
3675
  var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
3677
3676
  var html = '<div class="section-header">' +
3678
- '<div class="label">Analytics</div>' +
3679
3677
  '<h1>Usage Trends</h1>' +
3680
3678
  '<p>How you use ' + esc(runtimeLabel) + ' across sessions.</p>' +
3681
3679
  '</div>' +
3682
3680
  '<div class="last-updated">Last updated: ' + esc(ts) + '</div>';
3683
3681
 
3684
- html += tokensSavedCardHtml(data.savings || {}) + runwayCardHtml();
3682
+ // The Tokens Saved card and the "Your limits go further" twin are cut
3683
+ // (sections 5 and F8): savings figures live on the Savings tab. Only the
3684
+ // model-usage bar was new information here.
3685
+ html += trendsModelMixCardHtml();
3685
3686
  // Context before the first message is not a saving: it lives here, not on Savings.
3686
3687
  if (typeof firstCallContextHtml === 'function') html += firstCallContextHtml((t || {}).first_call_context);
3687
3688
 
@@ -3713,32 +3714,16 @@ var DB = (function() {
3713
3714
  html += '</select><span class="pricing-tier-badge">costs reflect this tier</span></div>';
3714
3715
  }
3715
3716
 
3716
- // Compute global cache hit rate + cache write TTL mix
3717
+ // Compute global cache hit rate
3717
3718
  var globalCacheRead = 0, globalCacheTotal = 0;
3718
- var globalTtl1h = 0, globalTtl5m = 0;
3719
- var globalMixedSessions = 0, globalFiveOnlySessions = 0;
3720
3719
  (t.daily || []).forEach(function(dd) {
3721
3720
  (dd.session_details || []).forEach(function(sd) {
3722
3721
  if (sd.continuation) return; // multi-day session: count it once
3723
3722
  var chr = sd.cache_hit_rate || 0;
3724
3723
  if (chr > 0) { globalCacheRead += chr; globalCacheTotal++; }
3725
- var ttl1h = sd.cache_create_1h_tokens || 0;
3726
- var ttl5m = sd.cache_create_5m_tokens || 0;
3727
- globalTtl1h += ttl1h;
3728
- globalTtl5m += ttl5m;
3729
- if (ttl1h && ttl5m) globalMixedSessions += 1;
3730
- else if (ttl5m && !ttl1h) globalFiveOnlySessions += 1;
3731
3724
  });
3732
3725
  });
3733
3726
  var avgCacheHit = globalCacheTotal > 0 ? (globalCacheRead / globalCacheTotal * 100).toFixed(0) : 'N/A';
3734
- var globalTtlMix = ttlMixLabel(globalTtl1h, globalTtl5m);
3735
- var globalTtlSessionLabel = (globalMixedSessions || globalFiveOnlySessions)
3736
- ? ('Mixed sessions: ' + globalMixedSessions + ' | 5m-only: ' + globalFiveOnlySessions)
3737
- : 'Recent main sessions were 1h-only';
3738
- var ttlPeriodSummary = (data.ttl_period_summary || [])
3739
- .map(function(item) { return item && item.label ? item.label : ''; })
3740
- .filter(function(label) { return !!label; })
3741
- .join(' | ');
3742
3727
 
3743
3728
  var tokenLabel = isCodex ? 'Measured/Estimated Tokens' : 'Deduplicated Fresh Input + Output';
3744
3729
  var tokenNote = isCodex
@@ -3753,14 +3738,8 @@ var DB = (function() {
3753
3738
  var avgCacheDisplay = cacheOverall ? (overallCacheHit * 100).toFixed(1).replace(/\.0$/, '')
3754
3739
  : (Number.isFinite(eligibleCacheHit) && pop.cache_eligible_main_sessions ? Math.round(eligibleCacheHit * 100) : avgCacheHit);
3755
3740
  var cacheLabel = isCodex ? 'Cached Input Share' : (cacheOverall ? 'Cache hit rate (all tokens)' : 'Main-work cache hit rate');
3756
- var cacheSessionLines = cacheOverall
3757
- ? (pop.cache_eligible_main_sessions ? '<div style="font-size:12px;color:var(--c-text-main);margin-top:6px">Average session, 20+ messages: ' + Math.round((Number(pop.cache_eligible_main_hit_rate) || 0) * 100) + '%</div>' : '') +
3758
- (pop.cache_ineligible_sessions ? '<div style="font-size:12px;color:var(--c-text-main);margin-top:2px">Average short or delegated session: ' + Math.round((Number(pop.cache_ineligible_hit_rate) || 0) * 100) + '%</div>' : '') +
3759
- '<div style="font-size:11px;color:var(--c-text-dim);margin-top:2px">Session lines average each session&rsquo;s own rate; the big number weights every token.</div>'
3760
- : '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + (pop.cache_eligible_main_sessions || 0) + ' cache-building main-work sessions · ' + (pop.cache_ineligible_sessions || 0) + ' short/delegated sessions at ' + Math.round((Number(pop.cache_ineligible_hit_rate) || 0) * 100) + '%</div>';
3761
- var cacheNote = isCodex
3762
- ? 'Share of logged input tokens Codex says were cached_input_tokens. Similar to a cache hit rate, but Codex does not expose cache-write TTL or write-size fields.'
3763
- : (cacheOverall ? '' : 'Main-work sessions with 20+ messages.');
3741
+ // The six grey sub-lines under the cache number are cut (section 5):
3742
+ // session-mix and TTL debug output. The number and its label stand alone.
3764
3743
  var tokenBreakdownNote = isCodex
3765
3744
  ? 'fresh:' + fn(t.total_fresh_input || 0) + ' · cached input:' + fn(t.total_cache_read || 0) + ' · out:' + fn(t.total_output_tokens || 0)
3766
3745
  : 'raw fresh:' + fn(t.total_fresh_input || 0) + ' · cache-write:' + fn(t.total_cache_create || 0) + ' · out:' + fn(t.total_output_tokens || 0);
@@ -3775,10 +3754,6 @@ var DB = (function() {
3775
3754
  codexCostNote += '<div style="font-size:10px;color:var(--c-warning);margin-top:2px">' + esc(t.cost_note) + '</div>';
3776
3755
  }
3777
3756
  }
3778
- var cacheExtra = isCodex
3779
- ? '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + cacheNote + '</div>'
3780
- : '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">Cache writes: ' + esc(globalTtlMix) + '</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + esc(globalTtlSessionLabel) + '</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + esc(ttlPeriodSummary || 'TTL period summary unavailable') + '</div>' + (cacheNote ? '<div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + cacheNote + '</div>' : '');
3781
-
3782
3757
  html += '<div class="stat-row" style="grid-template-columns:repeat(3,1fr);margin-bottom:var(--s-3)">' +
3783
3758
  '<div class="stat-card"><div class="stat-card-value">' + t.session_count + '</div><div class="stat-card-label">All logged sessions (' + t.period_days + 'd)</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + (pop.main_work_sessions || 0) + ' main-work · ' + (pop.delegated_sessions || 0) + ' delegated/subagent</div></div>' +
3784
3759
  '<div class="stat-card"><div class="stat-card-value">' + fn(t.total_tokens || 0) + '</div><div class="stat-card-label">' + tokenLabel + ', all logged (' + t.period_days + 'd)</div><div style="font-size:11px;color:var(--c-text-dim);margin-top:4px">' + tokenNote + '</div><div style="font-size:10px;color:var(--c-text-dim);margin-top:2px">' + tokenBreakdownNote + '</div>' + codexCostNote + '</div>' +
@@ -3787,7 +3762,7 @@ var DB = (function() {
3787
3762
  '<div class="stat-row" style="grid-template-columns:repeat(3,1fr)">' +
3788
3763
  '<div class="stat-card"><div class="stat-card-value">' + Math.round(t.avg_duration_minutes || 0) + 'm</div><div class="stat-card-label">Avg duration, all logged</div></div>' +
3789
3764
  '<div class="stat-card"><div class="stat-card-value">' + fn((t.avg_input_tokens || 0) + (t.avg_output_tokens || 0)) + '</div><div class="stat-card-label">Avg tokens, all logged sessions</div></div>' +
3790
- (avgCacheDisplay === 'N/A' ? '' : '<div class="stat-card"><div class="stat-card-value" style="color:var(--c-savings-strong, #22c55e)">' + avgCacheDisplay + '%</div><div class="stat-card-label">' + cacheLabel + '</div>' + cacheSessionLines + cacheExtra + '</div>') +
3765
+ (avgCacheDisplay === 'N/A' ? '' : '<div class="stat-card"><div class="stat-card-value" style="color:var(--c-savings-strong, #22c55e)">' + avgCacheDisplay + '%</div><div class="stat-card-label">' + cacheLabel + '</div></div>') +
3791
3766
  '</div>';
3792
3767
 
3793
3768
  var skillsDetail = (data.snapshot && data.snapshot.components && data.snapshot.components.skills_detail) || {};
@@ -3877,7 +3852,7 @@ var DB = (function() {
3877
3852
  row += '</div>';
3878
3853
  }
3879
3854
  } else {
3880
- row += '<div class="skill-desc" style="font-style:italic;">No detail available</div>';
3855
+ row += '<div class="skill-desc">No detail available</div>';
3881
3856
  }
3882
3857
  row += '</div></div></div>';
3883
3858
  return row;
@@ -4705,17 +4680,59 @@ var DB = (function() {
4705
4680
  var routingAltShare = mr.measured_baseline_opus_share;
4706
4681
  var routingAltMo = mr.measured_baseline_realized_cost_usd != null ? mo(mr.measured_baseline_realized_cost_usd) : null;
4707
4682
  var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
4683
+ var storyOn = (typeof savingsStoryOn === 'function') && savingsStoryOn(data);
4684
+
4685
+ // ---- SAVE MORE: suggestions, promoted right under the hero ----
4686
+ // Built before the story render: in story mode they fold into "Still on
4687
+ // the table" ("More changes you could make") so the two never contradict;
4688
+ // in legacy mode they feed the "Money on the table" card below.
4689
+ var parts = [];
4690
+ if ((Number(sp.cost_saved_usd) || 0) > 0 && unusedSkills > 0) {
4691
+ parts.push('Review ' + unusedSkills + ' skill' + (unusedSkills === 1 ? '' : 's') + ' not invoked in this window.');
4692
+ }
4693
+ if ((Number(recl.cost_usd) || 0) > 0) {
4694
+ parts.push('Avoid re-reading files that have not changed, or add them to .contextignore. ' + (Number(recl.tokens) || 0).toLocaleString() + ' tokens of stale re-reads across ' + (Number(recl.sessions) || 0).toLocaleString() + ' sessions are worth about ' + moneyCents(oppCents.reclaimable) + per + '.');
4695
+ }
4696
+ if (!storyOn && (Number(mr.potential_cost_usd) || 0) > 0) {
4697
+ parts.push('Route routine work to lighter models and keep Opus for the work that needs it. The routing line above shows the size of that assumption.');
4698
+ }
4699
+ if (cdTokensMo > 0) {
4700
+ parts.push(cdResume + ', or batch related work before stepping away. ' + (Number(cd.drop_sessions) || 0) + ' of your sessions idled past ' + cdCacheName + ' and re-wrote the prefix' + (cdRebuilds > 0 ? ' ' + cdRebuilds.toLocaleString() + ' time' + (cdRebuilds === 1 ? '' : 's') : '') + ', about ' + cdTokensMo.toLocaleString() + ' tokens' + per + (cdCostMo > 0 ? ', worth about ' + money(cdCostMo) + per + ' at API rates' : '') + '.');
4701
+ }
4702
+ if ((Number(ow.cost_saved_usd) || 0) > 0) {
4703
+ parts.push('Favor targeted Edits over full-file Writes. About ' + (Number(ow.avoidable_writes) || 0) + ' of your Writes could have been Edits, worth about ' + moneyCents(oppCents.output) + per + ' in output.');
4704
+ }
4705
+
4708
4706
  // U9: the savings story leads when the payload carries session_effect;
4709
4707
  // older payloads (or a template without the inlined module) keep the
4710
- // previous layout unchanged.
4708
+ // previous layout unchanged. extras carries the "Still on the table" fix
4709
+ // targets and the merged "More changes you could make" parts.
4711
4710
  var story = '';
4712
- try { story = (typeof savingsStoryHtml === 'function') ? savingsStoryHtml(data) : ''; } catch (e) { story = ''; }
4711
+ if (storyOn) {
4712
+ try {
4713
+ story = (typeof savingsStoryHtml === 'function') ? savingsStoryHtml(data, {
4714
+ fixes: (typeof savingsOnTableFixes === 'function') ? savingsOnTableFixes() : {},
4715
+ parts: parts,
4716
+ optimizerHint: data.runtime !== 'cursor' && data.runtime !== 'antigravity'
4717
+ }) : '';
4718
+ } catch (e) { story = ''; }
4719
+ }
4720
+
4721
+ // F13: "Updated today at 8:33 PM", not a raw locale timestamp.
4722
+ var updTxt = 'unknown';
4723
+ var updDate = data.generated_at ? new Date(data.generated_at) : null;
4724
+ if (updDate && !isNaN(updDate.getTime())) {
4725
+ var updNow = new Date();
4726
+ var updDay = Math.floor((new Date(updNow.getFullYear(), updNow.getMonth(), updNow.getDate()) - new Date(updDate.getFullYear(), updDate.getMonth(), updDate.getDate())) / 86400000);
4727
+ var updWhen = updDate.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' });
4728
+ updTxt = (updDay <= 0 ? 'today' : updDay === 1 ? 'yesterday' : updDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })) + ' at ' + updWhen;
4729
+ }
4713
4730
 
4714
4731
  var html = '<div class="section-header">' +
4715
4732
  (story ? '<h1>Savings</h1>' : '<div class="label">Value</div><h1>Savings</h1>' +
4716
4733
  '<p>Your savings, with the time period and method shown for each total.</p>') +
4717
4734
  '</div>' +
4718
- '<div class="last-updated">Updated ' + esc(ts) + ' &middot; refreshes after every session</div>';
4735
+ '<div class="last-updated">Updated ' + esc(updTxt) + ' &middot; refreshes after every session</div>';
4719
4736
 
4720
4737
  html += story || runwayCardHtml();
4721
4738
  var storyHead = html; html = '';
@@ -4908,37 +4925,26 @@ var DB = (function() {
4908
4925
  var ledgerHtml = html;
4909
4926
  html = storyHead + (story ? '' : ledgerHtml);
4910
4927
 
4911
- // ---- SAVE MORE: suggestions, promoted right under the hero ----
4912
- var parts = [];
4913
- if ((Number(sp.cost_saved_usd) || 0) > 0 && unusedSkills > 0) {
4914
- parts.push('Review ' + unusedSkills + ' skill' + (unusedSkills === 1 ? '' : 's') + ' not invoked in this window.');
4915
- }
4916
- if ((Number(recl.cost_usd) || 0) > 0) {
4917
- parts.push('Avoid re-reading files that have not changed, or add them to .contextignore. ' + (Number(recl.tokens) || 0).toLocaleString() + ' tokens of stale re-reads across ' + (Number(recl.sessions) || 0).toLocaleString() + ' sessions are worth about ' + moneyCents(oppCents.reclaimable) + per + '.');
4918
- }
4919
- if (!story && (Number(mr.potential_cost_usd) || 0) > 0) {
4920
- parts.push('Route routine work to lighter models and keep Opus for the work that needs it. The routing line above shows the size of that assumption.');
4921
- }
4922
- if (cdTokensMo > 0) {
4923
- parts.push(cdResume + ', or batch related work before stepping away. ' + (Number(cd.drop_sessions) || 0) + ' of your sessions idled past ' + cdCacheName + ' and re-wrote the prefix' + (cdRebuilds > 0 ? ' ' + cdRebuilds.toLocaleString() + ' time' + (cdRebuilds === 1 ? '' : 's') : '') + ', about ' + cdTokensMo.toLocaleString() + ' tokens' + per + (cdCostMo > 0 ? ', worth about ' + money(cdCostMo) + per + ' at API rates' : '') + '.');
4924
- }
4925
- if ((Number(ow.cost_saved_usd) || 0) > 0) {
4926
- parts.push('Favor targeted Edits over full-file Writes. About ' + (Number(ow.avoidable_writes) || 0) + ' of your Writes could have been Edits, worth about ' + moneyCents(oppCents.output) + per + ' in output.');
4927
- }
4928
+ // ---- SAVE MORE: the parts list was built before the story render (see
4929
+ // above); story mode already folded it into "Still on the table". ----
4928
4930
  var moreFolds = [];
4929
4931
  if (story) {
4930
- // U9: nothing else on the tab. Opportunity, coverage detail, the previous
4931
- // cards and diagnostics sit in one row of folds at the bottom; the
4932
+ // U9: nothing else on the tab. Coverage detail, the previous cards and
4933
+ // diagnostics sit in one row of folds at the bottom; the
4932
4934
  // whole-workload comparison is no longer shown here.
4933
- if (parts.length > 0) {
4934
- moreFolds.push('<details class="fold"><summary>Room to save more</summary><div class="fold__body">' +
4935
- '<p>More changes you could make to your setup or habits, beyond Still on the table. None of this is in any total above.</p>' +
4935
+ var covFold = (typeof savingsCoverageFold === 'function') ? savingsCoverageFold(data) : '';
4936
+ if (covFold) moreFolds.push(covFold);
4937
+ // F13 merged "Room to save more" into the Still-on-the-table fold. When
4938
+ // that card does not render (nothing sized), the parts still need a home:
4939
+ // keep them as their own fold rather than dropping the copy entirely.
4940
+ if (parts.length > 0 && story.indexOf('st-table') === -1) {
4941
+ moreFolds.push('<details class="fold"><summary>More changes you could make</summary><div class="fold__body">' +
4942
+ '<p>More changes to your setup or habits. None of this is in any total above.</p>' +
4936
4943
  parts.map(function(p) { return '<p>' + esc(p) + '</p>'; }).join('') +
4937
- (data.runtime !== 'cursor' && data.runtime !== 'antigravity' ? '<p>Run <strong>/token-optimizer</strong> and follow its suggestions to claim it.</p>' : '') +
4944
+ (data.runtime !== 'cursor' && data.runtime !== 'antigravity'
4945
+ ? '<p>Run <strong>/token-optimizer</strong> and follow its suggestions to claim it.</p>' : '') +
4938
4946
  '</div></details>');
4939
4947
  }
4940
- var covFold = (typeof savingsCoverageFold === 'function') ? savingsCoverageFold(data) : '';
4941
- if (covFold) moreFolds.push(covFold);
4942
4948
  // The previous action-savings, since-install and Tokens Saved cards are not
4943
4949
  // shown in story mode: they still add routing to their totals and count
4944
4950
  // tokens on another basis, so they would contradict the hero.
@@ -4949,10 +4955,10 @@ var DB = (function() {
4949
4955
  moreFolds.push('<details class="fold"><summary>Full ledger and history</summary><div class="fold__body">' + ledgerBody + '</div></details>');
4950
4956
  } else if (parts.length > 0) {
4951
4957
  html += '<div class="card wide" style="padding:var(--s-5) var(--s-4);margin-bottom:var(--s-3);border:1px solid var(--c-amber);box-shadow:0 0 0 1px rgba(217,164,65,0.18), 0 0 44px rgba(217,164,65,0.12);">';
4952
- html += '<div class="label" style="margin-bottom:var(--s-2);color:var(--c-amber);letter-spacing:0.08em;">Money on the table &middot; opportunity</div>';
4958
+ html += '<div class="label" style="margin-bottom:var(--s-2);color:var(--c-text-dim);">Money on the table &middot; opportunity</div>';
4953
4959
  if (opportunityMo > 0) {
4954
4960
  html += '<div style="display:flex;align-items:baseline;gap:var(--s-2);flex-wrap:wrap;">' +
4955
- '<span style="font-family:var(--font-mono);font-weight:300;font-size:76px;line-height:0.9;color:var(--c-amber);text-shadow:0 0 30px rgba(217,164,65,0.5);letter-spacing:-0.02em;">' + moneyCents(oppCents.total) + '</span>' +
4961
+ '<span style="font-family:var(--font-mono);font-weight:300;font-size:76px;line-height:0.9;color:var(--c-text-main);text-shadow:0 0 30px rgba(217,164,65,0.5);letter-spacing:-0.02em;">' + moneyCents(oppCents.total) + '</span>' +
4956
4962
  '<span style="font-size:23px;color:var(--c-text-dim);font-family:var(--font-mono);">' + per + ' still on the table</span>' +
4957
4963
  '</div>';
4958
4964
  html += '<div class="lede" style="margin-top:var(--s-2);">Potential savings if you change your setup or habits. Excluded from the totals above.</div>';
@@ -4962,7 +4968,7 @@ var DB = (function() {
4962
4968
  if (cdTokensMo > 0) {
4963
4969
  html += '<div class="cache-drop-opportunity" style="margin-top:var(--s-3);font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);max-width:820px;">' +
4964
4970
  'Cache drops (an opportunity, not a measurement): ' + (Number(cd.drop_sessions) || 0) + ' sessions idled past ' + cdCacheName + ' and re-wrote ~' + fmtTok(cdTokensMo) + ' tokens' + esc(per) + ' of prefix' +
4965
- (cdCostMo > 0 ? ', about <span style="color:var(--c-amber);">' + money(cdCostMo) + esc(per) + '</span> at API rates' : '') + '.' +
4971
+ (cdCostMo > 0 ? ', about <span style="color:var(--c-text-main);font-weight:600;">' + money(cdCostMo) + esc(per) + '</span> at API rates' : '') + '.' +
4966
4972
  '</div>';
4967
4973
  html += '<div class="plain-line">Not part of the savings number above.</div>';
4968
4974
  html += fold('How the cache drop figure is priced', '<p>Each rebuild is the prefix the cache had held before the gap, priced at its own cache write rate (1 hour or 5 minutes) minus the cache read it would have cost, at the models you ran and at API rates. It is not part of the number above.</p>' + ((Number(cd.unscanned_large_sessions) || 0) > 0 ? '<p>' + Number(cd.unscanned_large_sessions) + ' very large session' + (Number(cd.unscanned_large_sessions) === 1 ? ' was' : 's were') + ' not scanned; savings there are understated.</p>' : ''));
@@ -4970,7 +4976,7 @@ var DB = (function() {
4970
4976
  if (routingPotentialMo > 0) {
4971
4977
  html += '<div class="routing-assumption" style="margin-top:var(--s-3);font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);max-width:820px;">' +
4972
4978
  'Routing (an assumption, not a measurement): if about ' + routingFracPct + '% of your Opus work (grunt tasks) ran on ' + esc(routingTarget) + ': new input and output only' +
4973
- (mo(mr.potential_unsplit_excluded_tokens) > 0 ? ' (~' + fmtTok(mo(mr.potential_unsplit_excluded_tokens)) + ' Opus tokens' + esc(per) + ' without a class split are left out)' : '') + ', about <span style="color:var(--c-amber);">' + money(routingPotentialMo) + esc(per) + '</span> at API rates.' +
4979
+ (mo(mr.potential_unsplit_excluded_tokens) > 0 ? ' (~' + fmtTok(mo(mr.potential_unsplit_excluded_tokens)) + ' Opus tokens' + esc(per) + ' without a class split are left out)' : '') + ', about <span style="color:var(--c-text-main);font-weight:600;">' + money(routingPotentialMo) + esc(per) + '</span> at API rates.' +
4974
4980
  (routingTokensMo > 0 ? ' ~' + fmtTok(routingTokensMo) + ' tokens' + esc(per) + '.' : '') +
4975
4981
  '</div>';
4976
4982
  html += '<div class="plain-line">An assumption about your own work, not a measured saving, and not part of the number above.</div>';
@@ -4995,11 +5001,11 @@ var DB = (function() {
4995
5001
  html += '<p>' + billingCaption + '</p>';
4996
5002
  parts.forEach(function(p, i){
4997
5003
  html += '<div style="display:flex;gap:var(--s-3);align-items:flex-start;">' +
4998
- '<div style="flex-shrink:0;width:34px;height:34px;border-radius:50%;border:1.5px solid var(--c-amber);background:rgba(217,164,65,0.08);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:16px;color:var(--c-amber);margin-top:2px;">' + (i+1) + '</div>' +
5004
+ '<div style="flex-shrink:0;width:34px;height:34px;border-radius:50%;border:1.5px solid var(--c-amber);background:rgba(217,164,65,0.08);display:flex;align-items:center;justify-content:center;font-family:var(--font-mono);font-size:16px;color:var(--c-text-main);margin-top:2px;">' + (i+1) + '</div>' +
4999
5005
  '<div style="font-size:18px;color:var(--c-text-main);line-height:1.7;max-width:760px;">' + esc(p) + '</div></div>';
5000
5006
  });
5001
5007
  html += '</div>';
5002
- if (data.runtime !== 'cursor' && data.runtime !== 'antigravity') html += '<div style="margin-top:var(--s-5);padding:var(--s-4);background:rgba(217,164,65,0.07);border:1px solid var(--c-amber);border-radius:10px;font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);font-weight:500;">Run <span style="color:var(--c-amber);">/token-optimizer</span> and follow its suggestions to claim the rest &rarr;</div>';
5008
+ if (data.runtime !== 'cursor' && data.runtime !== 'antigravity') html += '<div style="margin-top:var(--s-5);padding:var(--s-4);background:rgba(217,164,65,0.07);border:1px solid var(--c-amber);border-radius:10px;font-family:var(--font-mono);font-size:17px;line-height:1.6;color:var(--c-text-main);font-weight:500;">Run <span style="color:var(--c-accent-cyan);">/token-optimizer</span> and follow its suggestions to claim the rest &rarr;</div>';
5003
5009
  html += '</details></div>';
5004
5010
  }
5005
5011
 
@@ -5190,27 +5196,30 @@ var DB = (function() {
5190
5196
 
5191
5197
  var ts = data.generated_at ? new Date(data.generated_at).toLocaleString() : 'unknown';
5192
5198
  var html = '<div class="section-header">' +
5193
- '<div class="label">Analytics</div>' +
5194
5199
  '<h1>Session Health</h1>' +
5195
- '<p>Running sessions, version status, and automated processes.</p>' +
5200
+ '<p>Running sessions and context quality.</p>' +
5196
5201
  '</div>' +
5197
5202
  '<div class="last-updated">Last updated: ' + esc(ts) + '</div>';
5198
5203
 
5199
- if (typeof keepwarmHealthHtml === 'function') html += keepwarmHealthHtml(data);
5204
+ // The keep-warm card is cut from Health (section 5): its paused-state
5205
+ // detail lives as one line in Manage. The coverage funnel renders only
5206
+ // when the counters were actually read — a card that says it has nothing
5207
+ // to say is hidden.
5200
5208
  if (!h) {
5201
5209
  html += '<div class="empty-state">No health data available. This usually means no ' + esc(data.runtime_label || 'Claude Code') + ' processes are currently running.</div>';
5202
5210
  try { if (typeof featureHealthHtml === 'function') html += featureHealthHtml(data); } catch (e) {}
5203
- try { if (typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data); } catch (e) {}
5211
+ try {
5212
+ var cfData = data.coverage_funnel;
5213
+ if (cfData && cfData.available && typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data);
5214
+ } catch (e) {}
5204
5215
  try { if (typeof holdoutHtml === 'function') html += holdoutHtml(data); } catch (e) {}
5205
5216
  el.innerHTML = html;
5206
5217
  return;
5207
5218
  }
5208
5219
 
5209
- if (!isCodex) {
5210
- html += '<div class="card wide"><div class="card-header"><span>Installed Version</span></div>' +
5211
- '<div class="version-hero">' + esc(h.installed_version || 'unknown') + '</div>' +
5212
- '<div class="label">' + esc(data.runtime_label || 'Claude Code') + '</div></div>';
5213
- } else {
5220
+ // The "Installed Version" card is cut (section 5): one line in the
5221
+ // sessions context is enough; the version lives in the footer.
5222
+ if (isCodex) {
5214
5223
  html += '<div class="card wide"><div class="card-header"><span>Codex Health</span><span class="label">local session logs</span></div>' +
5215
5224
  '<p style="font-size:13px;color:var(--c-text-dim);margin-bottom:0;">Codex process version comparison is not exposed reliably in local session data, so version/outdated rows are hidden. This tab focuses on running sessions, hook health, and context quality.</p></div>';
5216
5225
  }
@@ -5300,49 +5309,47 @@ var DB = (function() {
5300
5309
  }
5301
5310
  html += '</div>';
5302
5311
 
5303
- // Automated processes
5312
+ // The "Automated Processes" card is cut (section 5): two launchd labels
5313
+ // with a zero in front, no reader, no action.
5304
5314
  var automated = h.automated || [];
5305
- if (automated.length > 0) {
5306
- html += '<div class="card wide"><div class="card-header"><span>Automated Processes</span><span class="label">' + automated.length + ' found</span></div>';
5307
- automated.forEach(function(proc) {
5308
- html += '<div style="font-family:var(--font-mono);font-size:13px;color:var(--c-text-dim);padding:4px 0;border-bottom:1px solid var(--c-border);">' + esc(proc) + '</div>';
5309
- });
5310
- html += '</div>';
5311
- }
5312
5315
 
5313
5316
  // Context Quality Gauge (v2.0)
5314
5317
  var q = data.quality;
5315
5318
  if (q && typeof q.score === 'number') {
5316
5319
  var qs = q.score;
5317
5320
  var qColor = qs >= 85 ? 'var(--c-accent-cyan)' : qs >= 70 ? 'var(--c-chart-teal, #4ecdc4)' : qs >= 50 ? 'var(--c-warning, #ff9f43)' : 'var(--c-chart-coral, #ff6b6b)';
5321
+ // Section 6: warm colour stays on non-text marks; score, band and drag
5322
+ // labels are ink.
5323
+ var qInk = 'var(--c-text-main)';
5318
5324
  var qBand = qs >= 85 ? 'Excellent' : qs >= 70 ? 'Good' : qs >= 50 ? 'Degraded' : 'Critical';
5319
5325
  var sessionFile = q.session_file ? q.session_file.replace(/.*\//, '') : null;
5320
5326
  var runtimeLabel = q.runtime_label || data.runtime_label || 'Claude Code';
5321
5327
  var estimateNote = q.estimated ? ' Some Codex quality signals are inferred from local session events and should be read as an operational estimate, not model self-evaluation.' : '';
5322
5328
  html += '<div class="card wide"><div class="card-header"><span>Context quality &middot; latest session</span><span class="label">v2.0</span></div>' +
5323
- '<div style="padding:8px var(--s-3) 0;font-size:12px;color:var(--c-text-dim);">This score measures your most recently active ' + esc(runtimeLabel) + ' session, not an average across sessions. It reflects context quality based on 7 signals.' + estimateNote + ' <em>For the rolling cross-session average, see the Savings tab.</em></div>' +
5329
+ '<div style="padding:8px var(--s-3) 0;font-size:12px;color:var(--c-text-dim);">This score measures your most recently active ' + esc(runtimeLabel) + ' session, not an average across sessions. It reflects context quality based on 7 signals.' + estimateNote + ' For the rolling cross-session average, see the Savings tab.</div>' +
5324
5330
  (sessionFile ? '<div style="padding:4px var(--s-3) 0;font-size:13px;color:var(--c-text-dim);">Session: <code style="font-family:var(--font-mono);color:var(--c-text-main);">' + esc(sessionFile) + '</code><span style="margin-left:8px;color:var(--c-text-dim);font-size:12px;">(most recently active)</span></div>' : '') +
5325
5331
  '<div style="text-align:center;padding:var(--s-3) 0;">' +
5326
- '<div style="font-size:56px;font-weight:700;font-family:var(--font-mono);color:' + qColor + ';text-shadow:0 0 15px ' + qColor + ';">' + qs + '</div>' +
5327
- '<div class="label" style="font-size:16px;color:' + qColor + ';">' + qBand + '</div>' +
5332
+ '<div style="font-size:56px;font-weight:700;font-family:var(--font-mono);color:' + qInk + ';text-shadow:0 0 15px ' + qColor + '55;">' + qs + '</div>' +
5333
+ '<div class="label" style="font-size:16px;color:' + qInk + ';">' + qBand + '</div>' +
5328
5334
  '</div>' +
5329
5335
  // Biggest drag: the actual weighted deficit (fill / compactions /
5330
5336
  // dominant waste), computed upstream — not inferred from waste keys.
5331
5337
  (q.top_drag && q.top_drag.label
5332
- ? '<div style="text-align:center;padding:0 var(--s-3) var(--s-2);font-size:13px;color:var(--c-text-dim);">Biggest drag: <strong style="color:' + qColor + ';">' + esc(q.top_drag.label) + '</strong>' +
5338
+ ? '<div style="text-align:center;padding:0 var(--s-3) var(--s-2);font-size:13px;color:var(--c-text-dim);">Biggest drag: <strong style="color:' + qInk + ';">' + esc(q.top_drag.label) + '</strong>' +
5333
5339
  (typeof q.top_drag.points === 'number' ? ' <span style="font-family:var(--font-mono);font-size:12px;">(-' + esc(String(q.top_drag.points)) + ' pts)</span>' : '') +
5334
5340
  '</div>'
5335
5341
  : '');
5336
5342
 
5337
5343
  // Breakdown bars
5338
5344
  var bd = q.breakdown || {};
5345
+ // Section 6: no emoji — the labels carry the meaning.
5339
5346
  var signals = [
5340
- { key: 'context_fill_degradation', label: 'Context Fill', icon: '\uD83D\uDCCA', tip: 'How full the active context is. Higher fill raises degradation risk.' },
5341
- { key: 'stale_reads', label: 'Stale Reads', icon: '\uD83D\uDCC4', tip: 'Files read earlier that have since changed. The model may be working with outdated content.' },
5342
- { key: 'bloated_results', label: 'Bloated Results', icon: '\uD83D\uDCE6', tip: 'Tool outputs sitting in context that were never referenced. Wasted space.' },
5343
- { key: 'duplicates', label: 'Duplicates', icon: '\uD83D\uDD04', tip: 'Same system reminders or content injected multiple times. Pure waste.' },
5344
- { key: 'decision_density', label: 'Decision Density', icon: '\uD83C\uDFAF', tip: 'Ratio of actual decisions and work vs overhead and boilerplate.' },
5345
- { key: 'agent_efficiency', label: 'Agent Efficiency', icon: '\u2699\uFE0F', tip: 'Whether dispatched agents produced useful output relative to their token cost.' }
5347
+ { key: 'context_fill_degradation', label: 'Context Fill', tip: 'How full the active context is. Higher fill raises degradation risk.' },
5348
+ { key: 'stale_reads', label: 'Stale Reads', tip: 'Files read earlier that have since changed. The model may be working with outdated content.' },
5349
+ { key: 'bloated_results', label: 'Bloated Results', tip: 'Tool outputs sitting in context that were never referenced. Wasted space.' },
5350
+ { key: 'duplicates', label: 'Duplicates', tip: 'Same system reminders or content injected multiple times. Pure waste.' },
5351
+ { key: 'decision_density', label: 'Decision Density', tip: 'Ratio of actual decisions and work vs overhead and boilerplate.' },
5352
+ { key: 'agent_efficiency', label: 'Agent Efficiency', tip: 'Whether dispatched agents produced useful output relative to their token cost.' }
5346
5353
  ];
5347
5354
  html += '<div style="padding:0 var(--s-3) var(--s-3);">';
5348
5355
  // Compactions are metadata, with no health bar or fixed loss claim.
@@ -5365,7 +5372,7 @@ var DB = (function() {
5365
5372
  else if (d.ratio !== undefined) detail = d.ratio;
5366
5373
  else if (d.detail) detail = d.detail;
5367
5374
  html += '<div style="display:flex;align-items:center;gap:var(--s-2);margin-bottom:10px;font-size:15px;" title="' + esc(sig.tip) + '">' +
5368
- '<span style="width:165px;color:var(--c-text-main);font-weight:500;cursor:help;">' + sig.icon + ' ' + sig.label + '</span>' +
5375
+ '<span style="width:165px;color:var(--c-text-main);font-weight:500;cursor:help;">' + sig.label + '</span>' +
5369
5376
  '<div style="flex:1;height:10px;background:var(--c-surface);border-radius:5px;overflow:hidden;">' +
5370
5377
  '<div style="width:' + sigScore + '%;height:100%;background:' + barColor + ';border-radius:5px;transition:width 0.3s;"></div>' +
5371
5378
  '</div>' +
@@ -5377,7 +5384,7 @@ var DB = (function() {
5377
5384
  var waste = bd.total_estimated_waste_tokens;
5378
5385
  if (waste && waste > 0) {
5379
5386
  html += '<div style="margin-top:var(--s-2);padding:var(--s-2);background:var(--c-surface);border-radius:8px;font-size:13px;color:var(--c-text-dim);">' +
5380
- '<strong style="color:' + qColor + ';">' + waste.toLocaleString() + ' tokens</strong> of estimated waste. ' +
5387
+ '<strong style="color:' + qInk + ';">' + waste.toLocaleString() + ' tokens</strong> of estimated waste. ' +
5381
5388
  (qs < 70 ? 'Consider <code>/compact</code> to reclaim.' : 'Minor bloat, manageable.') +
5382
5389
  '</div>';
5383
5390
  }
@@ -5399,7 +5406,7 @@ var DB = (function() {
5399
5406
  var latestAvg = last7[last7.length - 1].avg_quality;
5400
5407
  var trendColor = latestAvg >= 80 ? 'var(--c-accent-cyan)' : latestAvg >= 60 ? 'var(--c-chart-teal, #4ecdc4)' : latestAvg >= 50 ? 'var(--c-warning, #ff9f43)' : 'var(--c-chart-coral, #ff6b6b)';
5401
5408
 
5402
- html += '<div class="card wide"><div class="card-header"><span>Quality Trend</span><span class="label">' + last7.length + '-day</span></div>' +
5409
+ html += '<div class="card wide"><div class="card-header"><span>Quality Trend</span><span class="label">last ' + last7.length + ' days</span></div>' +
5403
5410
  '<div style="padding:var(--s-2) var(--s-3);font-size:12px;color:var(--c-text-dim);">Rolling daily average quality score across sessions. Dashed line shows daily minimum.</div>' +
5404
5411
  '<div style="padding:0 var(--s-3) var(--s-3);overflow-x:auto;">' +
5405
5412
  '<svg viewBox="0 0 ' + chartW + ' ' + chartH + '" style="width:100%;max-width:' + chartW + 'px;height:auto;">' +
@@ -5430,7 +5437,10 @@ var DB = (function() {
5430
5437
  // U9: context quality and hook time limits moved here from the Savings tab.
5431
5438
  try { if (typeof healthNotesHtml === 'function') html += healthNotesHtml(data); } catch (e) {}
5432
5439
  try { if (typeof featureHealthHtml === 'function') html += featureHealthHtml(data); } catch (e) {}
5433
- try { if (typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data); } catch (e) {}
5440
+ try {
5441
+ var cfData2 = data.coverage_funnel;
5442
+ if (cfData2 && cfData2.available && typeof coverageFunnelHtml === 'function') html += coverageFunnelHtml(data);
5443
+ } catch (e) {}
5434
5444
  try { if (typeof holdoutHtml === 'function') html += holdoutHtml(data); } catch (e) {}
5435
5445
 
5436
5446
  el.innerHTML = html;
@@ -5444,7 +5454,6 @@ var DB = (function() {
5444
5454
  var isCodex = data.runtime === 'codex';
5445
5455
 
5446
5456
  var html = '<div class="section-header">' +
5447
- '<div class="label">Advisory</div>' +
5448
5457
  '<h1>Token Coach</h1>' +
5449
5458
  '<p>Health score, pattern analysis, and coaching prompts for your setup.</p>' +
5450
5459
  '</div>';
@@ -5523,64 +5532,38 @@ var DB = (function() {
5523
5532
  '<div style="font-size:28px;font-weight:500;font-family:var(--font-mono);color:' + scoreColor + ';">' + esc(score) + '/100</div>' +
5524
5533
  '</div></div>';
5525
5534
 
5526
- // Snapshot summary
5535
+ // The "Startup Overhead" and "Usable context" tiles are cut (section 5):
5536
+ // they repeat Overview. The snapshot numbers stay available in the
5537
+ // health-score description above.
5527
5538
  var snap = c.snapshot || {};
5528
5539
  var instructionLabel = snap.instruction_label || (isCodex ? 'AGENTS.md' : isNoInstructionHost(data) ? 'agent instructions' : 'CLAUDE.md');
5529
- html += '<div class="dashboard-grid">' +
5530
- '<div class="card"><div class="card-header"><span>Startup Overhead</span></div>' +
5531
- '<div style="font-size:11px;color:var(--c-text-dim);padding:0 0 4px 0;">Tokens loaded before you type. Includes ' + esc(instructionLabel) + ', skills/plugin metadata, MCP tools, and system prompt.</div>' +
5532
- '<div class="mini-stat">' + fn(snap.total_overhead || 0) + '</div>' +
5533
- '<div class="label">' + esc(snap.overhead_pct || 0) + '% of ' + ((snap.context_window || data.snapshot.context_window || 1000000) >= 1000000 ? ((snap.context_window || data.snapshot.context_window || 1000000) / 1000000) + 'M' : ((snap.context_window || data.snapshot.context_window || 1000000) / 1000) + 'K') + '</div></div>' +
5534
- '<div class="card"><div class="card-header"><span>Usable Context</span></div>' +
5535
- '<div style="font-size:11px;color:var(--c-text-dim);padding:0 0 4px 0;">Context window minus startup overhead and ~33K autocompact buffer. This is how much room you actually have for conversation.</div>' +
5536
- '<div class="mini-stat" style="color:var(--c-accent-cyan);">~' + fn(snap.usable_tokens || 0) + '</div>' +
5537
- '<div class="label">After overhead + autocompact buffer</div></div>' +
5538
- '</div>';
5539
5540
 
5540
5541
  // Pattern cards
5541
5542
  var bad = c.patterns_bad || [];
5542
5543
  var good = c.patterns_good || [];
5543
5544
 
5544
5545
  if (bad.length > 0) {
5546
+ // Section 6: no left stripes, no orange type. Severity is a small dot
5547
+ // before the title; the title itself is ink.
5545
5548
  html += '<div class="card wide"><div class="card-header"><span>Issues Detected</span><span class="label">' + bad.length + ' found</span></div>';
5546
5549
  bad.forEach(function(p) {
5547
5550
  var sevColor = p.severity === 'high' ? 'var(--c-chart-coral, #ff6b6b)' : p.severity === 'medium' ? 'var(--c-warning, #ff9f43)' : 'var(--c-text-dim, #7d8ca3)';
5548
- html += '<div style="border-left:3px solid ' + sevColor + ';padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(255,255,255,0.02);border-radius:0 6px 6px 0;">' +
5549
- '<div style="font-weight:500;color:' + sevColor + ';">' + esc(p.name) + '</div>' +
5551
+ html += '<div style="padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(255,255,255,0.02);border-radius:8px;">' +
5552
+ '<div style="font-weight:500;color:var(--c-text-main);"><span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:' + sevColor + ';margin-right:8px;"></span>' + esc(p.name) + '</div>' +
5550
5553
  '<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
5551
5554
  '<div style="font-size:13px;margin-top:4px;"><span style="color:var(--c-accent-cyan);">Fix:</span> ' + esc(p.fix) + '</div>' +
5552
- '<div style="font-size:13px;color:var(--c-text-dim);">Savings: ' + esc(p.savings) + '</div>' +
5555
+ // Section 6: only a real figure is a savings claim; "Not estimated"
5556
+ // and friends are not shown as savings.
5557
+ (/\d/.test(p.savings || '')
5558
+ ? '<div style="font-size:13px;color:var(--c-text-dim);">Savings: ' + esc(p.savings) + '</div>'
5559
+ : '') +
5553
5560
  '</div>';
5554
5561
  });
5555
5562
  html += '</div>';
5556
5563
  }
5557
5564
 
5558
- if (good.length > 0) {
5559
- var earned = good.filter(function(p) { return p.earned; });
5560
- var neutral = good.filter(function(p) { return !p.earned; });
5561
-
5562
- if (earned.length > 0) {
5563
- html += '<div class="card wide"><div class="card-header"><span>Working Well</span></div>';
5564
- earned.forEach(function(p) {
5565
- html += '<div style="border-left:3px solid var(--c-accent-cyan);padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(0,240,255,0.02);border-radius:0 6px 6px 0;">' +
5566
- '<div style="font-weight:500;color:var(--c-accent-cyan);">' + esc(p.name) + '</div>' +
5567
- '<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
5568
- '</div>';
5569
- });
5570
- html += '</div>';
5571
- }
5572
-
5573
- if (neutral.length > 0) {
5574
- html += '<div class="card wide"><div class="card-header"><span>Setup Summary</span></div>';
5575
- neutral.forEach(function(p) {
5576
- html += '<div style="border-left:3px solid var(--c-border);padding:var(--s-3);margin-bottom:var(--s-2);background:rgba(255,255,255,0.015);border-radius:0 6px 6px 0;">' +
5577
- '<div style="font-weight:500;color:var(--c-text-main);">' + esc(p.name) + '</div>' +
5578
- '<div style="color:var(--c-text-dim);font-size:14px;margin-top:4px;">' + esc(p.detail) + '</div>' +
5579
- '</div>';
5580
- });
5581
- html += '</div>';
5582
- }
5583
- }
5565
+ // "Working well" and "Setup summary" are cut (section 5): five rows
5566
+ // restating Overview.
5584
5567
 
5585
5568
  // Compaction timing guide
5586
5569
  var cg = c.compaction_guide;
@@ -5590,12 +5573,12 @@ var DB = (function() {
5590
5573
  '<div>' +
5591
5574
  '<div style="font-weight:500;color:var(--c-accent-cyan);margin-bottom:var(--s-2);">Compact after</div>';
5592
5575
  (cg.compact_after || []).forEach(function(item) {
5593
- html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">\u2705 ' + esc(item) + '</div>';
5576
+ html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">' + esc(item) + '</div>';
5594
5577
  });
5595
5578
  html += '</div><div>' +
5596
5579
  '<div style="font-weight:500;color:var(--c-chart-coral, #ff6b6b);margin-bottom:var(--s-2);">Avoid during</div>';
5597
5580
  (cg.avoid_during || []).forEach(function(item) {
5598
- html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">\u274C ' + esc(item) + '</div>';
5581
+ html += '<div style="font-size:14px;color:var(--c-text-dim);padding:4px 0;">' + esc(item) + '</div>';
5599
5582
  });
5600
5583
  html += '</div></div></div>';
5601
5584
  }
@@ -5640,21 +5623,13 @@ var DB = (function() {
5640
5623
  html += '<div style="padding:10px var(--s-3);border-bottom:1px solid var(--c-border);">' +
5641
5624
  '<div style="display:flex;justify-content:space-between;margin-bottom:4px;">' +
5642
5625
  '<span style="font-size:13px;color:var(--c-text-dim);">#' + (i + 1) + ' (' + breakdown + ')</span>' +
5643
- '<span style="font-family:var(--font-mono);font-weight:500;color:' + (p.cost_usd > 1 ? 'var(--c-chart-coral, #ff6b6b)' : p.cost_usd > 0.5 ? 'var(--c-warning, #ff9f43)' : 'var(--c-text-main)') + ';">$' + p.cost_usd.toFixed(4) + '</span></div>' +
5644
- '<div style="font-size:14px;color:var(--c-text-dim);font-style:italic;">"' + esc(preview) + '..."</div></div>';
5626
+ '<span style="font-family:var(--font-mono);font-weight:500;color:var(--c-text-main);">$' + p.cost_usd.toFixed(2) + '</span></div>' +
5627
+ '<div style="font-size:14px;color:var(--c-text-dim);">"' + esc(preview) + '..."</div></div>';
5645
5628
  });
5646
5629
  html += '</div>';
5647
5630
  }
5648
5631
 
5649
- // Coaching questions
5650
- var questions = c.questions || [];
5651
- if (questions.length > 0) {
5652
- html += '<div class="card wide"><div class="card-header"><span>Coaching Questions</span></div>';
5653
- questions.forEach(function(q) {
5654
- html += '<div style="padding:var(--s-2) var(--s-3);color:var(--c-text-dim);font-size:14px;border-bottom:1px solid var(--c-border);">' + esc(q) + '</div>';
5655
- });
5656
- html += '</div>';
5657
- }
5632
+ // "Coaching Questions" is cut (section 5): one generic question.
5658
5633
 
5659
5634
  // Ask Coach prompt
5660
5635
  html += '<div class="card wide">' +
@@ -5713,7 +5688,6 @@ var DB = (function() {
5713
5688
  : tcli('python3 measure.py dashboard --user');
5714
5689
 
5715
5690
  var html = '<div class="section-header">' +
5716
- '<div class="label">Configuration</div>' +
5717
5691
  '<h1>Hooks</h1>' +
5718
5692
  '<p>' + (isCodex
5719
5693
  ? 'Codex hooks collect real local telemetry. Balanced mode is the default; per-tool hooks are opt-in because Codex Desktop shows hook rows.'
@@ -5963,7 +5937,6 @@ var DB = (function() {
5963
5937
  }
5964
5938
 
5965
5939
  var html = '<div class="section-header">' +
5966
- '<div class="label">Control Panel</div>' +
5967
5940
  '<h1>Manage</h1>' +
5968
5941
  '<p id="manage-mode-desc">' +
5969
5942
  (isCodex
@@ -5977,7 +5950,7 @@ var DB = (function() {
5977
5950
  '</div>';
5978
5951
 
5979
5952
  if (v5Synthesized) {
5980
- html += '<div style="padding:12px var(--s-3);margin-bottom:var(--s-2);background:var(--c-bg);border-left:3px solid var(--c-accent-cyan);border-radius:4px;font-size:14px;color:var(--c-text-dim);">' +
5953
+ html += '<div style="padding:12px var(--s-3);margin-bottom:var(--s-2);background:var(--c-bg);border:1px solid var(--c-border);border-radius:8px;font-size:14px;color:var(--c-text-dim);">' +
5981
5954
  (isCodex
5982
5955
  ? 'Showing default Codex feature state. Run a Codex dashboard refresh to reflect your actual config.'
5983
5956
  : isNoInstructionHost(data) ? 'Showing default feature state.'
@@ -6041,10 +6014,8 @@ var DB = (function() {
6041
6014
  : unavailable
6042
6015
  ? '<span style="font-size:12px;color:var(--c-text-dim);margin-left:10px;">(shown for parity; not toggleable in Codex yet)</span>'
6043
6016
  : '';
6044
- var impactPct = f.impact_pct > 0 ? '+' + f.impact_pct + '%' : '';
6045
- var impactBadge = impactPct
6046
- ? '<span style="font-size:20px;font-weight:800;color:var(--c-accent-cyan);margin-left:auto;">' + impactPct + '</span>'
6047
- : '';
6017
+ // Section 5: the "+N%" badge was a percent with no noun; it is cut.
6018
+ var impactBadge = '';
6048
6019
 
6049
6020
  html += '<div class="hook-row" style="padding:20px var(--s-3);align-items:flex-start;border-top:1px solid var(--c-border);">' +
6050
6021
  '<label class="hook-toggle" style="margin-top:4px;transform:scale(1.2);transform-origin:left top;">' +
@@ -6068,7 +6039,7 @@ var DB = (function() {
6068
6039
  '</div>' +
6069
6040
  '<div style="margin-top:12px;display:inline-block;padding:6px 12px;background:' + riskBg + ';color:#000;font-size:13px;font-weight:700;border-radius:4px;">' +
6070
6041
  riskLabel + '</div>' +
6071
- '<div style="font-size:14px;color:var(--c-text-dim);margin-top:8px;line-height:1.6;font-style:italic;">' +
6042
+ '<div style="font-size:14px;color:var(--c-text-dim);margin-top:8px;line-height:1.6;">' +
6072
6043
  esc(f.risk) +
6073
6044
  '</div>' +
6074
6045
  '</div></div>';
@@ -6693,28 +6664,96 @@ var DB = (function() {
6693
6664
  document.getElementById('prompt-modal-overlay').classList.remove('visible');
6694
6665
  }
6695
6666
 
6667
+ // ---- View switching with deep links (F4) ----
6668
+ // location.hash names the view (#savings, #quick, ...). showView is the one
6669
+ // place that activates a view, syncs the nav, the right rail and the hash.
6670
+ function viewFromHash() {
6671
+ var h = (window.location.hash || '').replace(/^#/, '');
6672
+ if (h.indexOf('view-') === 0) h = h.slice(5);
6673
+ return h && document.querySelector('.nav-item[data-view="' + h + '"]') ? h : null;
6674
+ }
6675
+ function showView(v, opts) {
6676
+ opts = opts || {};
6677
+ var target = document.getElementById('view-' + v);
6678
+ var nav = document.querySelector('.nav-item[data-view="' + v + '"]');
6679
+ if (!target || !nav) return false;
6680
+ document.querySelectorAll('.view').forEach(function(el) { el.classList.remove('active'); });
6681
+ document.querySelectorAll('.nav-item').forEach(function(n) { n.classList.remove('active'); });
6682
+ target.classList.add('active');
6683
+ nav.classList.add('active');
6684
+ var layout = document.querySelector('.layout');
6685
+ if (layout) layout.classList.toggle('panel-hidden', !!analyticsViews[v]);
6686
+ var mc = document.querySelector('.main-col');
6687
+ if (mc) mc.scrollTop = 0;
6688
+ if (!opts.skipHash) {
6689
+ try {
6690
+ if (opts.replace) history.replaceState(null, '', '#' + v);
6691
+ else if (window.location.hash !== '#' + v) window.location.hash = v;
6692
+ } catch (e) { /* file:// or locked history: leave the hash alone */ }
6693
+ }
6694
+ return true;
6695
+ }
6696
+
6697
+ // ---- "Still on the table" fix buttons (F5) ----
6698
+ // Each row's button lands on the exact plan item that fixes it: the tab it
6699
+ // lives on plus the item, expanded and highlighted.
6700
+ function savingsOnTableFixes() {
6701
+ function find(patterns, fallback) {
6702
+ for (var i = 0; i < items.length; i++) {
6703
+ var it = items[i];
6704
+ var hay = (it.title || '') + ' ' + (it.shortDesc || '') + ' ' + (it.detail || '');
6705
+ for (var p = 0; p < patterns.length; p++) {
6706
+ if (patterns[p].test(hay)) return { view: it.section || 'quick', idx: it._i };
6707
+ }
6708
+ }
6709
+ return { view: fallback };
6710
+ }
6711
+ return {
6712
+ routing: find([/hardcoded model/i, /route subagents/i, /model.{0,20}(routing|mix|task)/i, /lighter model/i], 'quick'),
6713
+ skills: find([/skills? not invoked/i, /skill.{0,40}(archive|budget|listing|inventory|trim|unused)/i, /unused skills?/i], 'manage')
6714
+ };
6715
+ }
6716
+ function gotoFix(view, idx) {
6717
+ if (!showView(view)) return;
6718
+ if (idx == null || idx === '') return;
6719
+ var scope = document.getElementById('view-' + view);
6720
+ var target = scope && scope.querySelector('[data-idx="' + idx + '"]');
6721
+ if (!target) return;
6722
+ var row = target.classList.contains('setting-row') ? target : target.closest('.setting-row');
6723
+ if (row && !row.classList.contains('expanded')) {
6724
+ row.classList.add('expanded');
6725
+ var detail = scope.querySelector('[data-detail-for="' + idx + '"]');
6726
+ if (detail) detail.style.maxHeight = detail.scrollHeight + 'px';
6727
+ }
6728
+ target.scrollIntoView({ behavior: 'smooth', block: 'center' });
6729
+ target.classList.remove('st-flash');
6730
+ void target.offsetWidth;
6731
+ target.classList.add('st-flash');
6732
+ setTimeout(function() { target.classList.remove('st-flash'); }, 1700);
6733
+ }
6734
+
6696
6735
  function bind() {
6697
6736
  // Nav clicks
6698
6737
  document.querySelectorAll('.nav-item[data-view]').forEach(function(lnk) {
6699
6738
  lnk.addEventListener('click', function(e) {
6700
6739
  e.preventDefault();
6701
- var v = this.getAttribute('data-view');
6702
- document.querySelectorAll('.view').forEach(function(el) { el.classList.remove('active'); });
6703
- document.querySelectorAll('.nav-item').forEach(function(n) { n.classList.remove('active'); });
6704
- document.getElementById('view-' + v).classList.add('active');
6705
- this.classList.add('active');
6706
- // Toggle panel visibility for analytics views
6707
- var layout = document.querySelector('.layout');
6708
- if (analyticsViews[v]) {
6709
- layout.classList.add('panel-hidden');
6710
- } else {
6711
- layout.classList.remove('panel-hidden');
6712
- }
6713
- document.querySelector('.main-col').scrollTop = 0;
6740
+ showView(this.getAttribute('data-view'));
6714
6741
  });
6715
6742
  });
6716
6743
 
6744
+ // Back/forward and hand-edited hashes switch the view too.
6745
+ window.addEventListener('hashchange', function() {
6746
+ var v = viewFromHash();
6747
+ if (v) showView(v, { skipHash: true });
6748
+ });
6749
+
6717
6750
  // Individual toggles (delegated)
6751
+ document.addEventListener('keydown', function(e) {
6752
+ if (e.key === 'Escape') {
6753
+ var any = document.querySelector('.st-tip--open');
6754
+ if (any) { any.classList.remove('st-tip--open'); any.blur(); }
6755
+ }
6756
+ });
6718
6757
  document.addEventListener('change', function(e) {
6719
6758
  var toggleLabel = e.target.closest('[data-toggle]');
6720
6759
  if (toggleLabel) {
@@ -6747,7 +6786,7 @@ var DB = (function() {
6747
6786
  var td = document.createElement('td');
6748
6787
  td.colSpan = 12;
6749
6788
  td.style.padding = '0';
6750
- var html = '<div style="background:var(--c-bg);padding:var(--s-2) var(--s-3);margin:2px 0;border-left:2px solid var(--c-accent-cyan);">' +
6789
+ var html = '<div style="background:var(--c-bg);padding:var(--s-2) var(--s-3);margin:2px 0;border:1px solid var(--c-border);border-radius:8px;">' +
6751
6790
  '<div style="font-size:12px;font-family:var(--font-mono);color:var(--c-accent-cyan);margin-bottom:6px;">Per-Turn Breakdown (' + turns.length + ' API calls)</div>' +
6752
6791
  '<table class="session-table" style="margin:0;font-size:12px;"><thead><tr>' +
6753
6792
  '<th title="Assistant API call number inside this session." style="cursor:help">#</th>' +
@@ -6850,6 +6889,27 @@ var DB = (function() {
6850
6889
  // Stop propagation on toggle clicks so expand doesn't fire
6851
6890
  if (e.target.closest('.toggle')) return;
6852
6891
 
6892
+ // Savings hero hover cards: tap toggles the card open on touch; a
6893
+ // click anywhere else closes it. Hover and focus are pure CSS.
6894
+ var tipBtn = e.target.closest('.st-tip');
6895
+ if (tipBtn) {
6896
+ var wasOpen = tipBtn.classList.contains('st-tip--open');
6897
+ document.querySelectorAll('.st-tip--open').forEach(function(b) { b.classList.remove('st-tip--open'); });
6898
+ if (!wasOpen) tipBtn.classList.add('st-tip--open');
6899
+ return;
6900
+ }
6901
+ if (!e.target.closest('.st-mega__item')) {
6902
+ document.querySelectorAll('.st-tip--open').forEach(function(b) { b.classList.remove('st-tip--open'); });
6903
+ }
6904
+
6905
+ // "Still on the table" fix buttons: jump to the exact fix (tab + item).
6906
+ var fixBtn = e.target.closest('.st-fix[data-goto-view]');
6907
+ if (fixBtn) {
6908
+ e.preventDefault();
6909
+ gotoFix(fixBtn.getAttribute('data-goto-view'), fixBtn.getAttribute('data-goto-idx'));
6910
+ return;
6911
+ }
6912
+
6853
6913
  // Setting row expand/collapse
6854
6914
  var row = e.target.closest('.setting-row[data-idx]');
6855
6915
  if (row) {
@@ -7401,10 +7461,22 @@ document.addEventListener('DOMContentLoaded', function() {
7401
7461
  var brandMeta = document.getElementById('brand-meta');
7402
7462
  if (brandMeta) {
7403
7463
  var brandParts = [];
7404
- if (data.version) brandParts.push('v' + data.version);
7405
7464
  if (data.runtime === 'codex') brandParts.push('Codex');
7406
7465
  brandMeta.textContent = brandParts.join(' \u00b7 ');
7407
7466
  }
7467
+ // Version and freshness live once, in the footer.
7468
+ var footerVersion = document.getElementById('footer-version');
7469
+ if (footerVersion && data.version) footerVersion.textContent = 'v' + data.version;
7470
+ var footerUpdated = document.getElementById('footer-updated');
7471
+ if (footerUpdated && data.generated_at) {
7472
+ var fuDate = new Date(data.generated_at);
7473
+ if (!isNaN(fuDate.getTime())) {
7474
+ var fuNow = new Date();
7475
+ var fuDay = Math.floor((new Date(fuNow.getFullYear(), fuNow.getMonth(), fuNow.getDate()) - new Date(fuDate.getFullYear(), fuDate.getMonth(), fuDate.getDate())) / 86400000);
7476
+ var fuDayTxt = fuDay <= 0 ? 'today' : fuDay === 1 ? 'yesterday' : fuDate.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: fuDate.getFullYear() === fuNow.getFullYear() ? undefined : 'numeric' });
7477
+ footerUpdated.textContent = 'Updated ' + fuDayTxt + ' at ' + fuDate.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' });
7478
+ }
7479
+ }
7408
7480
 
7409
7481
  function startApp() {
7410
7482
  DB.init(data); refreshSavingsLive();