create-pmos 0.388.0 → 0.390.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-insights-test.js +22 -27
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/guide/briefing-premium.md +38 -19
  10. package/workspace/lib/briefing-premium-agent.js +3 -0
  11. package/workspace/lib/insights-premium.js +10 -8
  12. package/workspace/lib/report-chat.js +37 -0
  13. package/workspace/lib/routes-insights-premium.js +3 -1
  14. package/workspace/package-lock.json +2 -2
  15. package/workspace/package.json +1 -1
  16. package/workspace/premium-chat-chart-tab-test.js +150 -0
  17. package/workspace/premium-chat-report-tab-test.js +127 -0
  18. package/workspace/premium-report-read-test.js +99 -59
  19. package/workspace/premium-vw-slides-test.js +17 -19
  20. package/workspace/public/pm/goal-chat.js +2 -1
  21. package/workspace/public/pm/premium-chart-draw.js +58 -0
  22. package/workspace/public/pm/premium-chart-tab.js +157 -0
  23. package/workspace/public/pm/premium-chat.js +8 -2
  24. package/workspace/public/pm/premium-insights.js +39 -85
  25. package/workspace/public/pm/premium-report-brief.js +132 -0
  26. package/workspace/public/pm/premium-report-read.js +276 -103
  27. package/workspace/public/pm/premium-report-tab.js +235 -0
  28. package/workspace/public/pm/premium-shell.js +35 -3
  29. package/workspace/public/pm/premium-vw-doc.js +9 -1
  30. package/workspace/public/pm/premium-vw-report.css +60 -0
  31. package/workspace/public/pm/premium-vw-slides.js +14 -5
  32. package/workspace/public/pm/premium.css +71 -122
  33. package/workspace/public/pm/report-chat.js +89 -0
  34. package/workspace/test-lists/premium-chat-chart-tab.json +12 -0
  35. package/workspace/test-lists/premium-chat-report-tab.json +12 -0
  36. package/workspace/premium-studio-chart-test.js +0 -193
  37. package/workspace/premium-studio-report-test.js +0 -277
  38. package/workspace/premium-studio-test.js +0 -185
  39. package/workspace/public/pm/premium-studio-design.js +0 -298
  40. package/workspace/public/pm/premium-studio-report.js +0 -291
  41. package/workspace/public/pm/premium-studio.js +0 -453
  42. package/workspace/test-lists/premium-studio-chart.json +0 -13
  43. package/workspace/test-lists/premium-studio-report.json +0 -9
  44. package/workspace/test-lists/premium-studio.json +0 -9
@@ -915,90 +915,7 @@ button.pst{border:0;font:inherit;color:inherit;text-align:left;cursor:pointer}bu
915
915
  .addf .cact{display:flex;flex-wrap:wrap;gap:10px}.addf .note[role="status"]{margin:0;min-height:1.2em}
916
916
  @media (max-width:760px){.inirw>.ini2{padding-right:48px}.baiact .dmcta,.lifeb .dmcta,.baa .dmcta{height:44px}.baa .baact .dmcta{flex:1;justify-content:center}.bapl button{min-height:44px}}
917
917
 
918
- /* ── Insight Studio (initiative premium-studio-dashboard): the mockup's Dashboard mode; brief, tray, library, preview, checks and footer ── */
919
- #dlg.stud .p-out .obody{padding-bottom:0}
920
- .stu{display:grid;gap:12px;min-width:0}
921
- .stt{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
922
- #dlg.stud #askF,#dlg.stud #askNote{display:none}
923
- .stx{display:flex;align-items:center;gap:12px}
924
- .stx .lk,.stlh .lk,.stdone{min-height:44px;padding:0 10px;font-size:var(--fs-2)}
925
- .stsug{margin:0;font-size:var(--fs-3);color:var(--ink-2);line-height:1.5;padding:0 2px}
926
- .stbr{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px}
927
- .suc{display:grid;gap:2px;align-content:center;min-height:52px;padding:8px 12px;border-radius:14px;background:var(--well);box-shadow:inset 0 0 0 1px var(--hair);max-width:100%;text-align:left;transition:background .2s}
928
- .suc em{font-style:normal;font-size:var(--fs-1);font-weight:600;color:var(--ink-3);white-space:nowrap}
929
- .suc b{font-size:var(--fs-3);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}
930
- .suc.on{background:var(--solid);color:var(--on-solid)}
931
- .suc.on em{color:color-mix(in oklab,var(--on-solid) 70%,transparent)}
932
- .suc.req{box-shadow:inset 0 0 0 1.5px color-mix(in oklab,var(--ember) 60%,transparent)}
933
- .sup{padding:14px;border-radius:18px;background:var(--well);display:grid;gap:10px}
934
- .stdone{justify-self:end}
935
- .sol{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:8px}
936
- .sto{display:grid;gap:2px;text-align:left;padding:10px 12px;border-radius:14px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);align-content:start;min-height:44px}
937
- .sto b{font-size:var(--fs-3)}
938
- .sto small{font-size:var(--fs-2);color:var(--ink-3);line-height:1.35}
939
- .sto[aria-pressed="true"]{box-shadow:inset 0 0 0 2px var(--ink)}
940
- .sti{width:100%;height:44px;border-radius:12px;border:1px solid var(--hair);background:var(--card-solid);padding:0 12px;font:inherit;font-size:var(--fs-3);color:var(--ink)}
941
- .sti:focus{outline:2px solid var(--ember);outline-offset:1px}
942
- .sul{list-style:none;margin:0;padding:0;display:grid;gap:6px}
943
- .sul li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-radius:12px;background:var(--card-solid)}
944
- .sul small{display:block;color:var(--ink-3);font-size:var(--fs-2)}
945
- .stlc{display:flex;gap:4px;flex:none}
946
- .stlc button{min-width:44px;height:44px;border-radius:10px;background:var(--well);display:grid;place-items:center;padding:0 10px}
947
- .stlc svg{width:15px;height:15px}
948
- .stlc button:disabled{opacity:.35}
949
- .stlib{padding:14px;border-radius:18px;background:var(--well)}
950
- .stlh{display:flex;align-items:center;gap:10px}
951
- .stlh small{color:var(--ink-3);margin-right:auto}
952
- .stlib .label{margin:10px 0 0}
953
- .stlg{display:grid;gap:6px;margin-top:6px}
954
- .stli{display:grid;grid-template-columns:96px minmax(0,1fr) auto;gap:12px;align-items:center;text-align:left;padding:8px 12px;border-radius:12px;background:var(--card-solid);min-height:44px}
955
- .stli .spk{width:96px;height:30px}
956
- .stli .spk path{fill:none;stroke:var(--ink-2);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
957
- .stli b{font-size:var(--fs-3)}
958
- .stli small{display:block;color:var(--ink-3);font-size:var(--fs-2)}
959
- .stli em{font-style:normal;font-size:var(--fs-2);font-weight:600;color:var(--ink-2)}
960
- .stli:disabled{opacity:.5}
961
- .stlic{display:grid;place-items:center;width:96px}
962
- .stlic svg{width:22px;height:22px;color:var(--ink-3)}
963
- .stpvw{padding:16px;border-radius:18px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);min-width:0}
964
- .stpvw .ndt{margin:0;font-size:var(--fs-4);font-weight:600;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
965
- .stpvw .npin2{font-size:var(--fs-1);font-weight:600;padding:3px 9px;border-radius:999px;background:var(--well);color:var(--ink-2)}
966
- .stpvw .stuse{margin:4px 0 10px;font-size:var(--fs-3)}
967
- .stgone{margin:4px 0 0}
968
- .suck{border-radius:16px;background:var(--well);overflow:hidden}
969
- .suckb{display:flex;align-items:center;gap:10px;width:100%;min-height:48px;padding:10px 14px;text-align:left}
970
- .suckb svg{width:18px;height:18px;flex:none}
971
- .suckb b{font-size:var(--fs-3);white-space:nowrap}
972
- .suckb span{font-size:var(--fs-2);color:var(--ink-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}
973
- .suckb svg:last-child{margin-left:auto;transition:transform .2s}
974
- .suckb[aria-expanded="true"] svg:last-child{transform:rotate(180deg)}
975
- .suck.bad .suckb>svg:first-child{color:var(--ember-ink)}
976
- .stbar{margin:0 14px 12px;width:auto}
977
- .stbar b{width:0}.stbar[data-n="1"] b{width:16.67%}.stbar[data-n="2"] b{width:33.33%}.stbar[data-n="3"] b{width:50.0%}.stbar[data-n="4"] b{width:66.67%}.stbar[data-n="5"] b{width:83.33%}.stbar[data-n="6"] b{width:100.0%}
978
- .sucl{list-style:none;margin:0;padding:0 14px 12px;display:grid;gap:8px}
979
- .sucl li{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center}
980
- .sucl li svg{width:16px;height:16px}
981
- .sucl li.bad svg{color:var(--ember-ink)}
982
- .sucl b{font-size:var(--fs-2);display:block}
983
- .sucl small{font-size:var(--fs-2);color:var(--ink-3)}
984
- .stmsg{min-height:1.2em;margin:0;color:var(--ember-ink)}
985
- .stft{display:flex;gap:8px;align-items:center;flex-wrap:wrap;position:sticky;bottom:0;padding:10px 0 12px;background:linear-gradient(to top,var(--card-solid) 70%,transparent)}
986
- .stft .sp{flex:1}
987
- .stft .dmcta{height:44px}
988
- @media (max-width:700px){.sol{grid-template-columns:minmax(0,1fr)}.stli{grid-template-columns:72px minmax(0,1fr)}.stli .spk,.stlic{width:72px}.stli em{grid-column:2}.stt{gap:8px}.sucl li{grid-template-columns:18px minmax(0,1fr)}.sucl li .dmcta{grid-column:2;justify-self:start}}
989
- /* ── Insight Studio, Chart mode (initiative premium-studio-chart): the mode switch, More, and the four chart forms the page and the Studio share ── */
990
- .stt{justify-content:space-between}
991
- .stmd{display:inline-flex;gap:4px;padding:4px;border-radius:999px;background:var(--well)}
992
- .stmd button{min-height:44px;padding:0 16px;border-radius:999px;font-size:var(--fs-3);font-weight:600;color:var(--ink-2)}
993
- .stmd button[aria-pressed="true"]{background:var(--card-solid);color:var(--ink);box-shadow:0 1px 2px color-mix(in oklab,var(--ink) 18%,transparent)}
994
- .stmd button:focus-visible{outline:2px solid var(--ember);outline-offset:1px}
995
- .suc.stmore{background:transparent;box-shadow:inset 0 0 0 1px var(--hair);border-style:dashed}
996
- .sor{display:flex;gap:8px;flex-wrap:wrap}.sor .dmcta{height:44px}
997
- .stbar[data-t="5"][data-n="1"] b{width:20%}.stbar[data-t="5"][data-n="2"] b{width:40%}.stbar[data-t="5"][data-n="3"] b{width:60%}.stbar[data-t="5"][data-n="4"] b{width:80%}.stbar[data-t="5"][data-n="5"] b{width:100%}
998
- .stu{grid-template-columns:minmax(0,1fr)}
999
- .stpvw>.mt1{grid-template-columns:minmax(0,1fr)}
1000
- .stvt{margin-top:8px;font-size:var(--fs-2)}.stvt summary{cursor:pointer;color:var(--ink-2);min-height:44px;display:flex;align-items:center}
1001
- .stsrc{margin:8px 0 0;font-size:var(--fs-2);color:var(--ink-3)}
918
+ /* ── a chart in its four forms (initiative premium-studio-chart C3): the Insights page and the Chart tab beside a chat share them (premium-chart-draw.js) ── */
1002
919
  .mfm .mval{font-size:var(--fs-5)}
1003
920
  .mfm .mhero{font-size:var(--fs-6);line-height:1;letter-spacing:-.03em}
1004
921
  .mfm .nspk{width:100%;height:auto;display:block;margin-top:8px;overflow:visible}
@@ -1017,13 +934,6 @@ button.pst{border:0;font:inherit;color:inherit;text-align:left;cursor:pointer}bu
1017
934
  .mnote{margin:6px 0 0 4px;font-size:var(--fs-2);color:var(--ink-2)}
1018
935
  .mt1 .mwhy{font-size:var(--fs-2);color:var(--ink-3);margin-top:4px}
1019
936
  .ntf .lk+.lk{margin-left:4px}
1020
- /* ── Insight Studio, Report mode (initiative premium-studio-report): the report's sections in the preview ── */
1021
- .stsec{padding:10px 0;border-top:1px solid var(--hair)}
1022
- .stsec:first-of-type{margin-top:12px}
1023
- .stsec h4{margin:0;font-size:var(--fs-3);font-weight:600;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
1024
- .stsec .mut{margin:3px 0 0;font-size:var(--fs-2);line-height:1.4}
1025
- .stlc small{font-size:var(--fs-2);color:var(--ink-3);white-space:nowrap;align-self:center}
1026
- .stlc button{font-size:var(--fs-2);font-weight:600}
1027
937
  /* ── a report read on the page (initiative premium-report-read): the deck, the page, the menus, the design row and Present. From the mockup's report sheet ── */
1028
938
  #dlg.rdrd:not(.rdiss) #askF,#dlg.rdrd:not(.rdiss) #askNote{display:none}
1029
939
  .rdr{display:grid;gap:12px;min-width:0}
@@ -1892,13 +1802,6 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
1892
1802
  .phstats b{font-size:var(--t-lead,20px);font-weight:600;color:var(--ink)}
1893
1803
  .phstats span{font-size:var(--t-small);color:var(--ink-3)}
1894
1804
  }
1895
- .stsub{grid-column:1/-1;flex:0 0 100%;justify-self:start;margin-bottom:4px}
1896
- .dzbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin-bottom:10px}
1897
- .dzth{align-items:flex-start}
1898
- .dzth button{position:relative;flex:0 0 132px;padding:6px}
1899
- .dzth .rdfc{border-radius:10px}
1900
- .dzth i{position:absolute;right:10px;bottom:8px;font:600 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-3)}
1901
- .stlk{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.stlk .sti{flex:1 1 200px}
1902
1805
  /* initiative page: Tasks paging and the about-popup of a document with no file */
1903
1806
  .tkpg{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:12px}.tkpg>span{display:flex;align-items:center;gap:10px}.tkpg small{color:var(--ink-2)}
1904
1807
  .tkpg .dmcta:disabled{opacity:.45;cursor:default}
@@ -2009,8 +1912,76 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2009
1912
  @media (max-width:700px){#dsOlItems{display:flex;flex-wrap:wrap;gap:6px}.dso button{display:inline-flex;width:auto}.dso .l2,.dso .l3{padding-left:10px}.dso{max-height:none}}
2010
1913
  .dsbody .dsat{display:flex;align-items:center;gap:6px;margin:-2px 0 8px;font-size:var(--fs-2);color:var(--ink-3)}
2011
1914
  .dsbody .dsat i{width:18px;height:18px;border-radius:50%;background:var(--well);display:grid;place-items:center;font:600 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-2)}
2012
- .rdbar .rdsp{margin-left:auto;display:flex;gap:8px;flex-wrap:wrap}
2013
- .rdbar .dsvw:last-child .dsmn,.rdbar .rdsp .dsmn{left:auto;right:0}
1915
+ /* one bar for a report, one row, icons only (PM 2026-10-22): Slides | Page, Brief, state, schedule, then Edit, Present, Share, Issue and ⋯ */
1916
+ .rdbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 12px}
1917
+ .rdbar .rdsp{flex:1 1 0;min-width:0;margin:0}
1918
+ .rdib{display:grid;place-items:center;flex:none;width:44px;height:44px;border-radius:10px;background:var(--well);color:var(--ink)}
1919
+ .rdib svg{width:18px;height:18px}
1920
+ .rdib:disabled{opacity:.5;cursor:not-allowed}
1921
+ .rdib.pri{background:var(--ink);color:var(--card-solid)}
1922
+ .rdib[data-rr="mo"] svg{fill:currentColor;stroke:none}
1923
+ @media (hover:hover){.rdib:hover{background:color-mix(in oklab,var(--ink) 9%,transparent)}.rdib.pri:hover{background:var(--ink);opacity:.9}}
1924
+ .rdvw{display:inline-flex;gap:2px;padding:2px;border-radius:12px;background:var(--well)}
1925
+ .rdvw .rdib{background:none;color:var(--ink-3)}
1926
+ .rdvw .rdib[aria-pressed="true"]{background:var(--card-solid);color:var(--ink);box-shadow:0 0 0 1px var(--hair)}
1927
+ .rdst{padding:4px 10px;font-size:var(--fs-2);gap:6px;font-weight:600}
1928
+ .rdbar .chp.rdsch{min-height:44px;padding:0 12px;border:0;cursor:pointer;font:600 var(--fs-2) var(--mono);gap:6px;background:var(--well);color:var(--ink-2)}
1929
+ .rdsch svg{width:15px;height:15px}
1930
+ .rdsch b{font-weight:600;color:var(--ink)}
1931
+ .rdbar .dsmn{top:50px}
1932
+ .rdbar .dsvw:last-child .dsmn{left:auto;right:0}
1933
+ .dsmn.rdmo,.dsmn.rdsm,.dsmn.rdcm{min-width:min(300px,86vw);max-height:min(70vh,560px);overflow:auto}
1934
+ .dsmn.rdmo button,.dsmn.rdmo a,.dsmn.rdsm button,.dsmn.rdsm a,.dsmn.rdcm button{height:auto;min-height:44px;align-items:flex-start;padding:9px 12px}
1935
+ .dsmn.rdmo hr,.dsmn.rdsm hr{border:0;border-top:1px solid var(--hair);margin:4px 6px;width:auto}
1936
+ .dsmn .rdbad,.dsmn .rdbad svg{color:var(--bad)}
1937
+ .rdfile{margin:6px 12px 2px;font:500 var(--fs-2) var(--mono);color:var(--ink-3);overflow-wrap:anywhere}
1938
+ .rdsd{display:flex;gap:4px;flex-wrap:wrap;padding:6px 8px}
1939
+ .dsmn .rdsd button{min-height:44px;height:auto;padding:6px 12px;border-radius:999px;background:var(--well)}
1940
+ .dsmn .rdsd button[aria-pressed="true"]{background:var(--ink);color:var(--card-solid)}
1941
+ .dsmn.rdsm a span{flex:1}
1942
+ .rdedn{margin:0;align-self:center}
1943
+ .rded{min-height:420px}
1944
+ .rdlook{margin:0 0 12px}
1945
+ /* the report's cycles, under its name */
1946
+ #dSub .rdcw{display:inline-flex;z-index:60}
1947
+ #dSub .chp.rdcyc{min-height:32px;padding:2px 10px;border:0;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2);gap:4px;cursor:pointer}
1948
+ #dSub .rdcyc svg{width:15px;height:15px}
1949
+ .dsmn.rdcm{top:38px}
1950
+ .dsmn.rdcm .label{margin:8px 12px 2px}
1951
+ .dsmn.rdcm button{flex-wrap:wrap}
1952
+ .dsmn.rdcm small{display:block;width:100%;font:400 var(--fs-2) var(--mono);color:var(--ink-3)}
1953
+ .dsmn.rdcm button svg{margin-left:auto}
1954
+ /* the samples above the chat box, and its clip */
1955
+ .rdsmp{display:flex;flex-wrap:wrap;align-items:center;gap:2px 0;margin-top:10px}
1956
+ .rdsmp .label{margin:0 8px 0 0}
1957
+ #rdF .rdclip{background:var(--well);color:var(--ink-2)}
1958
+ @media (pointer:coarse){#dSub .chp.rdcyc{min-height:44px}}
1959
+ /* the Brief, in its own viewer tab: how the report is made, not part of it */
1960
+ .rbrief{padding:4px 4px 24px;display:grid;gap:14px}
1961
+ .rbhd{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
1962
+ .rbhd>span:first-child{flex:1;min-width:0;display:grid;gap:2px}
1963
+ .rbhd small{font-size:var(--fs-2);color:var(--ink-3)}
1964
+ .rbto{padding:4px 10px;border-radius:999px;background:var(--warn-bg,var(--well));color:var(--warn,var(--ink));font:600 var(--fs-2) var(--mono)}
1965
+ .rbhd .dmcta{min-height:44px}
1966
+ .rbtoc{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px}
1967
+ .rbtoc button{flex:none;min-height:44px;padding:0 12px;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
1968
+ .rbs{padding:14px 16px;border-radius:14px;background:var(--well);scroll-margin-top:12px}
1969
+ .rbs h4{display:flex;align-items:center;gap:8px;margin:0 0 8px;font-size:var(--fs-4)}
1970
+ .rbs p,.rbs li{font-size:var(--fs-3);line-height:1.5;color:var(--ink-2)}
1971
+ .rbs ul,.rbs ol{margin:0;padding-left:20px;display:grid;gap:4px}
1972
+ .rbs p{margin:0 0 6px}
1973
+ .rbfix{margin-left:auto;min-height:44px;padding:0 12px;border-radius:10px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
1974
+ .rbs li .rbfix{margin-left:6px;vertical-align:middle}
1975
+ .rbkv{display:grid;grid-template-columns:max-content 1fr;gap:6px 14px;margin:0;font-size:var(--fs-3)}
1976
+ .rbkv dt{color:var(--ink-3)}
1977
+ .rbkv dd{margin:0;color:var(--ink)}
1978
+ .rbcalc{padding:10px 12px;border-radius:10px;background:var(--card-solid);margin:0 0 8px}
1979
+ .rbcalc p{margin:2px 0 0}
1980
+ .rbsub{color:var(--ink-3)}
1981
+ .rbrief .tag{display:inline-block;padding:1px 8px;border-radius:999px;font:600 var(--fs-1) var(--mono);background:var(--card-solid);color:var(--ink-3);box-shadow:inset 0 0 0 1px var(--hair)}
1982
+ .rbrief .tag.ok{color:var(--ok)}
1983
+ .rbrief .tag.no,.rbrief .tag.as{color:var(--warn,var(--bad))}
1984
+ @media (max-width:520px){.rbkv{grid-template-columns:1fr}.rbkv dd{margin-bottom:6px}.rdbar{gap:4px}}
2014
1985
  .dsrel{display:grid;gap:6px}
2015
1986
  .dsrr{display:flex;align-items:center;gap:10px;justify-content:space-between;padding:6px 10px;border-radius:10px;background:var(--well)}
2016
1987
  .dsrr button,.dsrr>span:first-child{display:grid;gap:2px;text-align:left;min-height:44px;align-content:center;color:var(--ink)}
@@ -2053,30 +2024,8 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2053
2024
  .lgdf{margin-top:6px;white-space:pre-wrap;overflow-wrap:anywhere}.lgdf del{color:var(--bad);text-decoration:line-through}
2054
2025
  .evl .hsr .lk{grid-column:2;justify-self:start;min-height:44px;display:inline-flex;align-items:center}.evl .hsr .dsdf{grid-column:2}
2055
2026
 
2056
- /* The Studio's size (Normal, Half, 3/4, Whole). Whole is .full. Half is the Studio's two parts as tabs, as on a narrow window. Not shown on a phone. */
2057
- .stsz{display:none;gap:2px}
2058
2027
  @media (min-width:1000px){.stsz{display:inline-flex}}
2059
- .stsz .lk[aria-pressed="true"]{background:var(--well);border-radius:999px;font-weight:600;color:var(--ink)}
2060
- @media (min-width:1000px){
2061
- .dlg.stud.sz-half:not(.full){width:50vw;min-width:560px;height:min(90vh,860px)}
2062
- .dlg.stud.sz-three-quarters:not(.full){width:75vw;height:min(90vh,860px)}
2063
- .dlg.stud.sz-half[data-mode="split"] #dTabs{display:flex}
2064
- .dlg.stud.sz-half[data-mode="split"] .dgrid{grid-template-columns:minmax(0,1fr)}
2065
- .dlg.stud.sz-half[data-mode="split"] .dgrid[data-tab="chat"] .p-out,.dlg.stud.sz-half[data-mode="split"] .dgrid[data-tab="out"] .p-work{display:none}
2066
- }
2067
- .dzact{display:inline-flex;gap:8px;flex-wrap:wrap;margin-left:auto}
2068
- .dzact .dmcta[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
2069
- .dzbig{position:relative;cursor:crosshair}
2070
- .dzpin{position:absolute;left:var(--rp-pinx,0);top:var(--rp-piny,0);transform:translate(-50%,-50%);min-width:24px;height:24px;padding:0 6px;border-radius:999px;background:var(--ember);color:var(--on-solid);font:600 var(--fs-2) var(--mono);display:grid;place-items:center;box-shadow:0 1px 4px color-mix(in oklab,var(--ink) 30%,transparent);pointer-events:none}
2071
- .dzsay{margin-top:12px;padding:12px;border-radius:14px;background:var(--well)}
2072
- .dzsh{display:flex;align-items:center;justify-content:space-between;gap:8px}
2073
- .dzon{display:inline-flex;align-items:center;gap:6px;min-height:44px;font-size:var(--fs-2)}
2074
- .dzsay .sul li{display:flex;align-items:center;gap:8px}
2075
- .dzsay .sul .sti{flex:1 1 auto;min-width:0}
2076
- .dzpn{flex:0 0 auto;min-width:24px;height:24px;border-radius:999px;background:var(--ember);color:var(--on-solid);font:600 var(--fs-2) var(--mono);display:grid;place-items:center}
2077
- .dzcg{display:grid;grid-template-columns:1fr 1fr;gap:12px}
2078
2028
  @media (max-width:700px){.dzcg{grid-template-columns:1fr}}
2079
- .dzch{margin-bottom:6px}
2080
2029
  /* board Metrics card: the lead line's inline "open Insights" link, as the mockup draws it */
2081
2030
  .mhint .lk{display:inline;font-size:var(--fs-2);font-weight:600;color:var(--ink);text-decoration:underline;text-underline-offset:2px;padding:0}
2082
2031
  .mhint .lk:hover{color:var(--ember-ink)}
@@ -0,0 +1,89 @@
1
+ /* report-chat — the page's half of reports, charts and dashboards from chat (initiative premium-reports-from-chat, slices B and C; PRD R1–R4, C1–C3).
2
+ * Pure: no DOM, so Node tests it. Claude ends an answer about a report, a chart or a dashboard with a fenced `pmos-report` JSON block
3
+ * (lib/report-chat.js writes the rule into the message). This module splits the block off the words, checks its shape, and draws the chip under the
4
+ * answer that opens the Report or Chart tab. */
5
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
6
+ const ID_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
7
+ const REF_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,119}$/; // a KR metric id, a saved chart id (pc-…) or a dashboard id (lib/premium-charts.js ID_RE)
8
+ const FORMS = ['line', 'bars', 'number', 'meter'];
9
+ const OUTPUTS = ['google-doc', 'google-slides', 'google-sheets', 'confluence', 'pdf'];
10
+ const CADENCES = ['daily', 'weekly', 'bi-weekly', 'monthly'];
11
+ const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
12
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
13
+
14
+ /** A schedule as the routes take it, 'off', or null (none said, or not a schedule). */
15
+ export function cleanSchedule(x) {
16
+ if (x === 'off' || (x && x.cadence === 'off')) return 'off';
17
+ if (!x || typeof x !== 'object' || !CADENCES.includes(x.cadence)) return null;
18
+ const out = { cadence: x.cadence, time: /^\d{1,2}:\d{2}$/.test(String(x.time || '')) ? String(x.time) : '09:00' };
19
+ if (x.cadence === 'weekly' || x.cadence === 'bi-weekly') out.day = DAYS.includes(x.day) ? x.day : 'Mon';
20
+ if (x.cadence === 'monthly') out.dayOfMonth = Number.isInteger(+x.dayOfMonth) && +x.dayOfMonth >= 1 && +x.dayOfMonth <= 28 ? +x.dayOfMonth : 1;
21
+ return out;
22
+ }
23
+
24
+ /** A chart as the premium-charts route takes it, or null without a measure. */
25
+ function cleanChart(p) {
26
+ if (!p || typeof p !== 'object' || !REF_RE.test(String(p.measure || ''))) return null;
27
+ const tg = p.target === null || p.target === undefined || p.target === '' || !Number.isFinite(+p.target) ? null : +p.target;
28
+ const rg = Number.isInteger(+p.range) && +p.range >= 2 && +p.range <= 500 ? +p.range : null;
29
+ return { measure: p.measure, title: clip(p.title, 60), question: clip(p.question, 100), form: FORMS.includes(p.form) ? p.form : 'line', range: rg, target: tg,
30
+ better: p.better === 'lower' ? 'lower' : 'higher', note: clip(p.note, 200) };
31
+ }
32
+ /** A chart or a dashboard: { kind, id?, proposal? }. id names a saved one; proposal is what Claude proposes (new, or the change to that one). */
33
+ function cleanChartBlock(b) {
34
+ const id = typeof b.id === 'string' && REF_RE.test(b.id) ? b.id : null;
35
+ let proposal = null;
36
+ if (b.kind === 'chart') proposal = cleanChart(b.proposal);
37
+ else if (b.proposal && typeof b.proposal === 'object') {
38
+ const charts = (Array.isArray(b.proposal.charts) ? b.proposal.charts : []).map(String).filter((x) => REF_RE.test(x)).filter((x, i, a) => a.indexOf(x) === i).slice(0, 12);
39
+ if (clip(b.proposal.name, 60) && charts.length) proposal = { name: clip(b.proposal.name, 60), purpose: clip(b.proposal.purpose, 200), charts };
40
+ }
41
+ if (!id && !proposal) return null;
42
+ const out = { kind: b.kind }; if (id) out.id = id; if (proposal) out.proposal = proposal;
43
+ return out;
44
+ }
45
+
46
+ /** The block as the tab uses it, or null when it is not a block. Unknown keys are dropped; text is clipped. */
47
+ export function cleanBlock(b) {
48
+ if (b && typeof b === 'object' && (b.kind === 'chart' || b.kind === 'dashboard')) return cleanChartBlock(b);
49
+ if (!b || typeof b !== 'object' || b.kind !== 'report') return null;
50
+ if (typeof b.id === 'string' && ID_RE.test(b.id)) {
51
+ const out = { kind: 'report', id: b.id };
52
+ if (b.schedule !== undefined) { const s = cleanSchedule(b.schedule); if (s) out.schedule = s; }
53
+ for (const k of ['structure', 'design']) { const v = clip(b[k], 600); if (v) out[k] = v; }
54
+ return out;
55
+ }
56
+ const p = b.proposal && typeof b.proposal === 'object' ? b.proposal : null;
57
+ if (!p || !clip(p.name, 80)) return null;
58
+ return { kind: 'report', proposal: {
59
+ name: clip(p.name, 80), purpose: clip(p.purpose, 400), audience: clip(p.audience, 120) || 'The team',
60
+ output: OUTPUTS.includes(p.output) ? p.output : 'google-doc', schedule: cleanSchedule(p.schedule) === 'off' ? null : cleanSchedule(p.schedule),
61
+ sources: (Array.isArray(p.sources) ? p.sources : []).map((x) => clip(x, 160)).filter(Boolean).slice(0, 8),
62
+ } };
63
+ }
64
+
65
+ /** { text, block }: the words with the last `pmos-report` block taken out, and that block checked (null when there is none or it does not parse). */
66
+ export function splitReport(text) {
67
+ const t = String(text == null ? '' : text);
68
+ const re = /```pmos-report[^\n]*\n([\s\S]*?)```/g;
69
+ let m, last = null;
70
+ while ((m = re.exec(t))) last = m;
71
+ if (!last) return { text: t, block: null };
72
+ let block = null; try { block = cleanBlock(JSON.parse(last[1])); } catch { block = null; }
73
+ return { text: (t.slice(0, last.index) + t.slice(last.index + last[0].length)).trim(), block };
74
+ }
75
+
76
+ /** A stable key for a block, so the same answer opens the tab once. */
77
+ export const blockSig = (b) => (b ? JSON.stringify(b) : '');
78
+
79
+ /** The chip under Claude's answer: it opens the Report tab with this block. `i` is the message's index in the conversation. */
80
+ export function reportChipHtml(block, i) {
81
+ if (!block) return '';
82
+ const k = block.kind, P = block.proposal;
83
+ const name = k === 'report' ? (P ? P.name : block.id) : P ? (k === 'chart' ? P.title || P.measure : P.name) : block.id;
84
+ const noun = k === 'report' ? 'report' : k;
85
+ const what = k === 'report' && !P ? (block.schedule ? 'Schedule change' : block.structure || block.design ? 'Report change' : 'Report')
86
+ : P && !block.id ? 'New ' + noun : P ? noun[0].toUpperCase() + noun.slice(1) + ' change' : noun[0].toUpperCase() + noun.slice(1);
87
+ const tab = k === 'report' ? 'Report' : k === 'chart' ? 'Chart' : 'Dashboard';
88
+ return `<div class="ctxc"><button type="button" class="ctxchip lead" data-report-open="${i}"><span><b>${esc(name)}</b><em>${esc(what)} · View in the ${tab} tab</em></span></button></div>`;
89
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "_comment": "Initiative premium-reports-from-chat, slice C: charts and dashboards from any chat (the Chart and Dashboard tabs) and the Insight Studio removed, against the real server on a scratch repository's KR metric records.",
3
+ "modules": [
4
+ "premium-charts.test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-chat-chart-tab-test.js": 60
8
+ },
9
+ "panels": [
10
+ "premium-chat-chart-tab-test.js"
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "_comment": "Initiative premium-reports-from-chat, slice B: reports from any chat. The block helpers (unit) and the Report tab beside a chat, against the real server on a scratch repository.",
3
+ "modules": [
4
+ "report-chat.test.js"
5
+ ],
6
+ "seconds": {
7
+ "premium-chat-report-tab-test.js": 60
8
+ },
9
+ "panels": [
10
+ "premium-chat-report-tab-test.js"
11
+ ]
12
+ }
@@ -1,193 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* premium-studio-chart-test.js — the Insight Studio's Chart mode on the premium Insights page (initiative premium-studio-chart;
4
- * planning/prd/premium-studio-chart-prd.md C1 to C12). A real server on a scratch repository whose KR metric records hold two measures with a series and
5
- * one without. The real page presses the real save routes:
6
- * O opening · C the conversation · D the four forms · K the checks · U Undo · B the brief · S save, add to a dashboard, edit and remove · P the POST allow-list · F floors */
7
- const fs = require('fs');
8
- const os = require('os');
9
- const path = require('path');
10
- const { spawn } = require('child_process');
11
- const { findBrowser } = require('./lib/find-browser');
12
- const T = require('./test-run').configure({ name: 'premium-studio-chart' });
13
- const PC = require('./lib/premium-charts.js');
14
-
15
- const BASE = T.BASE;
16
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
- const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
18
- const results = [];
19
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
20
- let srv = null, browser = null;
21
- const finish = async (code) => {
22
- if (browser) await browser.close().catch(() => {});
23
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
24
- T.killTmux();
25
- const bad = results.filter((x) => !x.cond).length;
26
- console.log(`\n${results.length - bad}/${results.length} premium-studio-chart assertions passed`);
27
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
28
- };
29
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
-
31
- /* the scratch repository: Partner activation (5 readings), Time to first call (2 readings), Lonely (1 reading, no series) */
32
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-chart-repo-'));
33
- const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-chart-state-'));
34
- fs.mkdirSync(path.join(dir, 'planning', 'records'), { recursive: true });
35
- const rd = (id, rid, at, value) => ({ id, kind: 'reading', rid, fields: { at, value } });
36
- const L = [
37
- { id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
38
- rd('2', 'krm-a', '2026-06-01', 20), rd('3', 'krm-a', '2026-07-01', 24), rd('4', 'krm-a', '2026-08-01', 30), rd('5', 'krm-a', '2026-09-01', 28), rd('6', 'krm-a', '2026-10-01', 33),
39
- { id: '7', kind: 'add', rid: 'krm-t', fields: { metric: 'Time to first call', baseline: 10, target: 4, by: '2026-12-31', pillar: 'Growth', unit: ' days' } },
40
- rd('8', 'krm-t', '2026-08-01', 9), rd('9', 'krm-t', '2026-10-01', 7),
41
- { id: '10', kind: 'add', rid: 'krm-l', fields: { metric: 'Lonely', baseline: 1, target: 2, by: '2026-12-31' } }, rd('11', 'krm-l', '2026-10-01', 1),
42
- ];
43
- fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), L.map((x) => JSON.stringify(x)).join('\n') + '\n');
44
- const model = async () => (await (await fetch(BASE + '/api/insights-premium')).json()).model;
45
-
46
- (async () => {
47
- const exe = findBrowser();
48
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
49
- let chromium;
50
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
51
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir }) });
52
- await T.waitForServer(BASE);
53
- browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
54
-
55
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
56
- p.on('pageerror', (e) => errs.push(String(e)));
57
- p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
58
- await p.goto(BASE + '/premium-insights.html');
59
- await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch') && !!document.querySelector('#pcNew')));
60
- const M0 = await model(), board = M0.board.id;
61
- const ledger = () => PC.list(dir, board);
62
- const say = async (t) => { await p.fill('#stIn', t); await p.press('#stIn', 'Enter'); await sleep(150); return p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; }); };
63
- const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
64
- const pv = () => p.evaluate(() => { const t = document.querySelector('#stPv .mt1'); return t ? { cls: t.className, title: t.querySelector('.mlab').firstChild.textContent, val: (t.querySelector('.mval') || {}).textContent, bars: [...t.querySelectorAll('.bw i')].map((i) => parseFloat(i.style.height)), foot: (t.querySelector('.mfoot') || {}).textContent || '' } : null; });
65
- const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
66
- const tap = (sel) => p.$eval(sel, (b) => b.click());
67
- const open = async (sel) => { if (sel === '#pdNew' || sel === '#repNew') await p.click('#listNew'); if (['#pdEdit', '#pcNew', '#pdPin', '#pdBack'].includes(sel) && await p.locator('#dashBar').isHidden()) await p.click('#dashMore'); await p.click(sel); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu'))); await sleep(300); };
68
- const mode = () => p.evaluate(() => (document.querySelector('#oMain .stmd [aria-pressed="true"]') || {}).textContent || '');
69
-
70
- /* O: New chart opens the Studio in Chart mode */
71
- await open('#pcNew');
72
- ok('O1 New chart opens the Studio in Chart mode, with the brief of the mockup', await mode() === 'Chart' && await chipv('q') === 'Not set' && ['Partner activation', 'Time to first call'].includes(await chipv('measure')) && await chipv('form') === 'Line', await mode() + ' ' + await chipv('measure'));
73
- await tap('#oMain [data-st="lib"]'); await sleep(100);
74
- const lib = await p.evaluate(() => [...document.querySelectorAll('#stLb .stli')].map((b) => b.querySelector('b').textContent + ':' + (b.disabled ? 'off' : 'on')));
75
- ok('O2 the library lists the measures of the records, and one with no series cannot start a chart', lib.join() === 'Partner activation:on,Time to first call:on,Lonely:off', lib.join());
76
- await tap('#stLb [data-st="libm|krm-a"]'); await sleep(100);
77
- ok('O3 a measure from the library starts the draft, with the record\'s own target', await chipv('measure') === 'Partner activation' && await chipv('target') === '50' && await chipv('range') === 'All 5 readings', await chipv('target'));
78
- await tap('#oMain [data-st="lib"]');
79
-
80
- /* C and D: the conversation and the forms */
81
- let a = await say('Is partner activation on track to reach its target?');
82
- ok('C1 a question sets the Question chip and suggests a meter, and says why', await chipv('q') === 'Is partner activation on track to reach its target?' && await chipv('form') === 'Meter' && /a meter, because/i.test(a), a);
83
- let t = await pv();
84
- ok('D1 the meter draws the latest reading against the target, in words', /\bprg\b/.test(t.cls) && t.val === '33%' && /target 50%/.test(t.foot), JSON.stringify(t));
85
- a = await say('show it as bars, last 4 readings, target 35');
86
- t = await pv();
87
- ok('C2 one turn sets the form, the range and the target', await chipv('form') === 'Bars' && await chipv('range') === 'Last 4 readings' && await chipv('target') === '35', a);
88
- ok('D2 bars start at zero: four bars, each as tall as its reading against the highest of the readings and the target', t && t.bars.length === 4 && Math.abs(t.bars[3] - 33 / 35 * 84) < 0.2 && Math.abs(t.bars[0] - 24 / 35 * 84) < 0.2, JSON.stringify(t));
89
- a = await say('make it a pie chart');
90
- ok('C3 a pie is declined with the reason, and nothing changes', /^I changed nothing: no pie/.test(a) && await chipv('form') === 'Bars', a);
91
- a = await say('call it Activation check');
92
- ok('C4 "call it" names the chart on the preview', (await pv()).title === 'Activation check', a);
93
- a = await say('show the number');
94
- t = await pv();
95
- ok('D3 the number form draws the latest value and its change', /\bnum\b/.test(t.cls) && t.val === '33%', JSON.stringify(t));
96
- await say('show it as a line');
97
- ok('D4 the line form is the page\'s own line chart', /\bmch\b/.test((await pv()).cls));
98
- ok('C5 no turn posted anything', posts.length === 0, posts.join());
99
-
100
- /* K and U: the checks, a fix, and Undo */
101
- await say('bars');
102
- ok('K1 with a question, a target, four readings and a form that fits, 5 of 5 checks pass', await checksTxt() === '5 of 5 checks pass', await checksTxt());
103
- a = await say('question: How has activation moved over time?');
104
- ok('K2 a question about movement with bars fails "The form fits the question"', await checksTxt() === '4 of 5 checks pass', a + ' ' + await checksTxt());
105
- await tap('#oMain [data-st="ck"]'); await sleep(100);
106
- const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
107
- ok('K3 the failing check offers its fix', fix.join() === 'Use a line', fix.join());
108
- await tap('#stCk .sucl li.bad button'); await sleep(150);
109
- ok('K4 the fix sets the line, and the checks pass', await chipv('form') === 'Line' && await checksTxt() === '5 of 5 checks pass');
110
- await tap('#oMain [data-st="undo"]'); await sleep(150);
111
- ok('U1 Undo steps back one change (the form)', await chipv('form') === 'Bars');
112
- await say('line');
113
-
114
- /* B: the brief and its tray */
115
- await tap('#oMain [data-st="chip|range"]'); await sleep(100);
116
- await tap('#stTr [data-st="set|range|"]'); await sleep(100);
117
- ok('B1 the Range tray sets every reading', await chipv('range') === 'All 5 readings');
118
- await tap('#oMain [data-st="chip|target"]'); await sleep(100);
119
- await p.fill('#stI', '40'); await sleep(150);
120
- ok('B2 the Target field sets the target as it is typed', await chipv('target') === '40' && /target 40%/.test((await p.evaluate(() => document.querySelector('#stPv .mwk').textContent))));
121
- await p.press('#stI', 'Enter'); await sleep(100);
122
- await tap('#oMain [data-st="more"]'); await sleep(100);
123
- ok('B3 More shows Title, Better when, Note and Add to', await chipv('title') === 'Activation check' && await chipv('better') === 'Higher' && await chipv('note') === 'None' && await chipv('addTo') === 'No dashboard');
124
- await say('note: From the partner records');
125
- ok('B4 a note is set in words and drawn under the chart', await p.evaluate(() => (document.querySelector('#stPv .mnote') || {}).textContent) === 'From the partner records');
126
-
127
- /* S: save, see it on the page, add it to a dashboard, edit, remove */
128
- await tap('#oMain [data-st="save"]');
129
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
130
- let Y = ledger();
131
- ok('S1 Save writes one chart line with what the brief shows', Y.length === 1 && Y[0].title === 'Activation check' && Y[0].form === 'line' && Y[0].range === null && Y[0].target === 40 && Y[0].measure === 'krm-a' && Y[0].note === 'From the partner records' && Y[0].question === 'How has activation moved over time?', JSON.stringify(Y));
132
- const cid = Y[0] && Y[0].id;
133
- ok('S2 the page lists it under Your charts, drawn, with Edit', await until(() => p.evaluate((id) => [...document.querySelectorAll('#dashBody .ntw')].some((w) => /Activation check/.test(w.textContent) && !!w.querySelector(`[data-ced="${id}"]`)), cid)));
134
- await open('#pdNew');
135
- await say('add Time to first call'); await say('call it Weekly'); await say('it is for the Monday review');
136
- await tap('#oMain [data-st="save"]');
137
- await until(async () => (await model()).dashboards.some((d) => d.saved && d.name === 'Weekly'));
138
- // the Studio has closed and the page has drawn the new dashboard; Your charts is under All measures
139
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.querySelector('#hDash').textContent === 'Weekly' && !!document.querySelector('#repBody [data-d="all"]')));
140
- await p.$eval('#repBody [data-d="all"]', (b) => b.click());
141
- await until(() => p.evaluate((id) => !!document.querySelector(`#dashBody [data-ced="${id}"]`), cid));
142
- await p.$eval(`#dashBody [data-ced="${cid}"]`, (b) => b.click());
143
- await until(async () => await mode() === 'Chart');
144
- await sleep(200);
145
- ok('S3 Edit opens the saved chart in Chart mode', await mode() === 'Chart' && await chipv('q') === 'How has activation moved over time?' && await chipv('target') === '40');
146
- a = await say('last 3 readings and add it to Weekly');
147
- ok('S4 "add it to" names the dashboard for Save', /it will be added to Weekly on Save/.test(a) && await chipv('range') === 'Last 3 readings', a);
148
- await tap('#oMain [data-st="save"]');
149
- await until(async () => { const d = (await model()).dashboards.find((x) => x.name === 'Weekly'); return d && d.charts.includes(cid); });
150
- const W = (await model()).dashboards.find((x) => x.name === 'Weekly');
151
- ok('S5 the chart is saved and appended to the dashboard, which draws it', ledger()[0].range === 3 && W.charts.join() === 'krm-t,' + cid && W.keys.join() === 'ins:krm-t,mine:' + cid, JSON.stringify(W));
152
- const onPage = await until(() => p.evaluate(() => [...document.querySelectorAll('#dashBody .mt1 .mlab')].map((e) => e.firstChild.textContent).join()));
153
- ok('S6 the page shows Weekly with the saved chart after the measure', onPage === 'Time to first call,Activation check', onPage);
154
- await until(() => p.evaluate((id) => !document.querySelector('#dlg').classList.contains('on') && !!document.querySelector(`#dashBody [data-ced="${id}"]`), cid));
155
- await p.$eval(`#dashBody [data-ced="${cid}"]`, (b) => b.click());
156
- await until(async () => await mode() === 'Chart'); await sleep(200);
157
- await tap('#oMain [data-st="del"]'); await sleep(100);
158
- const armed = await p.evaluate(() => ({ b: document.querySelector('#oMain [data-st="del"]').textContent, m: document.querySelector('#stMsg').textContent }));
159
- ok('S7 Remove asks for a second press and says what stays', armed.b === 'Press again to remove it' && /measure and its record stay/.test(armed.m), JSON.stringify(armed));
160
- await tap('#oMain [data-st="del"]');
161
- await until(() => ledger().length === 0);
162
- const W2 = await until(async () => { const d = (await model()).dashboards.find((x) => x.name === 'Weekly'); return d && d.gone.length ? d : null; });
163
- ok('S8 the second press removes the chart, and the dashboard says it was removed', ledger().length === 0 && W2 && /was removed/.test(W2.gone[0].why), JSON.stringify(W2 && W2.gone));
164
-
165
- /* P: the POST allow-list and the guard */
166
- const allowed = new Set(['/api/premium-charts/save', '/api/premium-dashboards/save']);
167
- ok('P1 the page posted only to the two save routes', posts.length === 5 && posts.every((x) => allowed.has(x)), posts.join());
168
- const H = await T.pressHeaders(BASE), body = JSON.stringify({ ws: M0.board.ws, board, measure: 'krm-a', title: 'From an agent' });
169
- const asAgent = await fetch(BASE + '/api/premium-charts/save', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body }).then((x) => x.status);
170
- const noNonce = await fetch(BASE + '/api/premium-charts/save', { method: 'POST', headers: { 'content-type': 'application/json' }, body }).then((x) => x.status);
171
- ok('P2 an agent session and a request without the page press are refused, and nothing is written', asAgent === 403 && noNonce >= 400 && ledger().length === 0, asAgent + ' ' + noNonce);
172
- ok('P3 no script error', errs.length === 0, errs.join(' | '));
173
- await ctx.close();
174
-
175
- /* F: floors at 390 px, both themes */
176
- for (const theme of ['light', 'dark']) {
177
- const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, colorScheme: theme }), q = await c2.newPage();
178
- await q.goto(BASE + '/premium-insights.html');
179
- await until(() => q.evaluate(() => !!document.querySelector('#pcNew')));
180
- await (async (pg, sel) => { if (await pg.locator('#dashBar').isHidden()) await pg.click('#dashMore'); await pg.click(sel); })(q, '#pcNew'); await until(() => q.evaluate(() => !!document.querySelector('#oMain .stu'))); await sleep(400);
181
- await q.$eval('#oMain [data-st="more"]', (b) => b.click()); await sleep(100);
182
- await q.$eval('#oMain [data-st="chip|form"]', (b) => b.click()); await sleep(100);
183
- const measure = () => q.evaluate(() => {
184
- const sm = [...document.querySelectorAll('#oMain .stu button')].filter((b) => b.offsetParent).filter((b) => { const r = b.getBoundingClientRect(); return r.height < 44 || r.width < 44; }).map((b) => (b.dataset.st || b.textContent) + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height));
185
- const pane = document.querySelector('#dOut'); return { small: sm.length, which: sm, side: pane.scrollWidth - pane.clientWidth, doc: document.documentElement.scrollWidth - innerWidth };
186
- });
187
- await until(async () => (await measure()).small === 0, 4000);
188
- const f = await measure();
189
- ok(`F1 at 390 px (${theme}) every Chart mode target is 44 px or more and nothing scrolls sideways`, f.small === 0 && f.side <= 1 && f.doc <= 1, JSON.stringify(f));
190
- await c2.close();
191
- }
192
- finish();
193
- })().catch((e) => { console.error(e); finish(1); });