create-pmos 0.608.0 → 0.610.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.
- package/package.json +33 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +2 -2
- package/workspace/briefing-premium-adddoc-test.js +2 -1
- package/workspace/briefing-premium-board-test.js +9 -9
- package/workspace/briefing-premium-initiative-test.js +7 -6
- package/workspace/briefing-premium-insights-test.js +10 -10
- package/workspace/briefing-premium-products-test.js +4 -2
- package/workspace/briefing-premium-sources-test.js +1 -1
- package/workspace/briefing-premium-test.js +4 -4
- package/workspace/briefing-premium-work-test.js +1 -1
- package/workspace/changelog.json +32 -0
- package/workspace/ev-everywhere-test.js +9 -9
- package/workspace/guide/home.md +1 -1
- package/workspace/guide/layout.md +32 -11
- package/workspace/home-other-product-test.js +2 -1
- package/workspace/home-railcard-test.js +2 -1
- package/workspace/lib/beside-page.js +15 -0
- package/workspace/lib/routes-lab.js +4 -1
- package/workspace/live-pill-round-test.js +3 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/panels-test.js +5 -4
- package/workspace/premium-chat-context-test.js +6 -6
- package/workspace/premium-chat-line-test.js +1 -1
- package/workspace/premium-chat-notes-test.js +1 -1
- package/workspace/premium-core-doc-issue-test.js +2 -1
- package/workspace/premium-vw-cal-test.js +1 -1
- package/workspace/premium-vw-doc-test.js +2 -1
- package/workspace/program-leave-test.js +2 -1
- package/workspace/program-panel-test.js +2 -2
- package/workspace/public/pm/bd-ini-panel.js +3 -1
- package/workspace/public/pm/bd-scroll.js +4 -2
- package/workspace/public/pm/cozy-board.css +3 -0
- package/workspace/public/pm/cozy-ev.css +51 -0
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-live-pill.js +2 -1
- package/workspace/public/pm/cozy-nav.js +70 -7
- package/workspace/public/pm/cozy-panels.js +1 -1
- package/workspace/public/pm/cozy-pick.css +3 -0
- package/workspace/public/pm/cozy-pick.js +6 -2
- package/workspace/public/pm/cozy-popup.css +113 -0
- package/workspace/public/pm/cozy-popup.js +408 -0
- package/workspace/public/pm/cozy-proto.js +3 -0
- package/workspace/public/pm/cozy-settings.js +10 -1
- package/workspace/public/pm/cozy-viewer.js +66 -18
- package/workspace/public/pm/home-app.js +11 -3
- package/workspace/public/pm/home-ini.js +4 -3
- package/workspace/public/pm/ini-agent.js +17 -4
- package/workspace/public/pm/ini-view.js +11 -0
- package/workspace/public/pm/page-chat.js +16 -4
- package/workspace/public/pm/pop-sessions.js +65 -0
- package/workspace/public/pm/premium-board.js +7 -3
- package/workspace/public/pm/premium-insights.js +14 -2
- package/workspace/public/pm/premium-shell.js +1 -1
- package/workspace/stage-card-tasks-test.js +2 -2
- package/workspace/task-card-test.js +2 -1
- package/workspace/task-delete-test.js +2 -1
- package/workspace/task-links-test.js +3 -2
- package/workspace/task-views-test.js +7 -7
- package/workspace/test-lists/one-popup.json +9 -0
- package/workspace/tk-tasks-test.js +2 -1
- package/workspace/viewer-trail-test.js +1 -1
- package/workspace/workflows-setup-test.js +1 -1
|
@@ -39,3 +39,6 @@
|
|
|
39
39
|
.ppk-menu.sheet .ppk-tk { width: 24px; height: 24px; border-radius: 8px; }
|
|
40
40
|
@media (prefers-reduced-motion: no-preference) { .ppk-menu.sheet { animation: ppk-up .18s ease-out; } }
|
|
41
41
|
@keyframes ppk-up { from { transform: translateY(24px); opacity: .6; } }
|
|
42
|
+
/* the chip with names (Work and Goals, slice 1): the full product name, then "+2" in grey */
|
|
43
|
+
.ppk-nmc { padding: 0 2px 0 9px; color: var(--cz-ink); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
|
|
44
|
+
.ppk-nmc em { font-style: normal; color: var(--cz-ink3); }
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* A saved pick fires pp:changed on the window (detail: the answer); each page follows it there
|
|
7
7
|
* tonesOf(products) → { [ws]: 0 | 1 | 2 }: a product's tint, by its place with the default workspace first (Home's groups use the same)
|
|
8
8
|
* codeOf(p) → the tile's letters: the workspace's own abbreviation, else two letters of its name
|
|
9
|
-
* chipHtml(P, o) → the chip: the ticked products' tiles, overlapped, +N past 3; the word All when every one is ticked
|
|
9
|
+
* chipHtml(P, o) → the chip: the ticked products' tiles, overlapped, +N past 3; the word All when every one is ticked.
|
|
10
|
+
* o.names: the full name instead ("pmos-idpf", "pmos-idpf +2", "All products"), as Work and Goals show it
|
|
10
11
|
* openPicker(chip, o) → the list under the chip (a sheet on a phone). o: { P, label, lines(ws), tones?, onApply(on), onAdd()?, note? };
|
|
11
12
|
* Add a product opens Settings › Workspaces (the add flow) unless the page gives its own onAdd
|
|
12
13
|
*
|
|
@@ -48,7 +49,10 @@ export function chipWords(P, label) {
|
|
|
48
49
|
}
|
|
49
50
|
export function chipHtml(P, o = {}) {
|
|
50
51
|
const T = o.tones || tonesOf(P ? P.products : []), on = P ? P.products.filter((p) => p.on) : [];
|
|
51
|
-
|
|
52
|
+
// o.names (Work and Goals, slice 1): the full name of the first ticked product, "+2" for the others, "All products" when every one is ticked
|
|
53
|
+
const first = on.slice().sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0))[0];
|
|
54
|
+
const inner = !P ? '' : o.names ? `<span class="ppk-all ppk-nmc">${isAll(P) ? 'All products' : first ? esc(first.name) + (on.length > 1 ? ` <em>+${on.length - 1}</em>` : '') : 'No product'}</span>`
|
|
55
|
+
: isAll(P) ? '<span class="ppk-all">All</span>'
|
|
52
56
|
: `<span class="ppk-stk">${on.slice(0, 3).map((p) => `<i class="ppk-t t${T[p.ws] || 0}">${esc(codeOf(p))}</i>`).join('')}${on.length > 3 ? `<i class="ppk-t ppk-n">+${on.length - 3}</i>` : ''}</span>`;
|
|
53
57
|
const words = chipWords(P, o.label || 'Products'), id = o.id || 'ppChip', open = !!cur && cur.id === id; // a page that draws again keeps the open state
|
|
54
58
|
return `<button type="button" class="ppk-chip${open ? ' open' : ''}" id="${esc(id)}"${o.attrs ? ' ' + o.attrs : ''} aria-haspopup="menu" aria-expanded="${open}" aria-label="${esc(words)}" title="${esc(words)}">${inner}${svg(open ? CHEV_U : CHEV_D, 14)}</button>`;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/* pm/cozy-popup.css — the one popup (slice 2 of the six-place navigation, boards 3, 7 and 23): the work on the left, Ask PMOS on the right. */
|
|
2
|
+
.cz-pop { position: fixed; inset: 0; z-index: 72; /* above the page and a floating Viewer (70), below the menus, pickers and toasts a press inside opens (74 and up) */ font-family: var(--cz-sans); color: var(--cz-ink); }
|
|
3
|
+
.cz-pop[hidden] { display: none; }
|
|
4
|
+
.cz-pop-sc { position: absolute; inset: 0; background: rgba(30, 34, 42, .28); }
|
|
5
|
+
.cz-pop-card { --pop-chat: 460px; position: absolute; inset: 16px 20px; display: flex; min-width: 0; overflow: hidden; border-radius: 28px;
|
|
6
|
+
background: var(--cz-card); box-shadow: 0 40px 100px -30px rgba(20, 24, 32, .6), 0 0 0 1px var(--cz-hair); }
|
|
7
|
+
.cz-pop-card:focus { outline: none; }
|
|
8
|
+
/* the left side: the page's Viewer, lifted in (cozy-viewer.js popInst) */
|
|
9
|
+
.cz-pop-l { flex: 1 1 auto; min-width: 480px; display: flex; min-height: 0; }
|
|
10
|
+
.cz-pop .cz-vw.cz-vw-pop { position: static !important; flex: 1 1 auto !important; width: auto !important; max-width: none !important; height: auto !important;
|
|
11
|
+
margin: 0 !important; transform: none !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
|
|
12
|
+
.cz-pop .cz-vw.cz-vw-pop > .cz-vw-grip { display: none; }
|
|
13
|
+
.cz-pop .cz-vw.cz-vw-pop .cz-vw-hd { border-bottom: 0; padding: 18px 20px 10px 22px; }
|
|
14
|
+
.cz-pop-card.chat-off .cz-vw.cz-vw-pop .cz-vw-hd { padding-right: 200px; }
|
|
15
|
+
.cz-vw-path { display: inline-flex; align-items: baseline; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 55%; overflow: hidden; white-space: nowrap; }
|
|
16
|
+
.cz-vw-path button { all: unset; cursor: pointer; font-size: var(--fs-meta); color: var(--cz-ink3); overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
|
|
17
|
+
.cz-vw-path button:hover { color: var(--cz-ink); text-decoration: underline; }
|
|
18
|
+
.cz-vw-path button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
19
|
+
.cz-vw-path span { color: var(--cz-ink3); font-size: var(--fs-meta); }
|
|
20
|
+
/* the grip: the line between the two sides, with its handle */
|
|
21
|
+
.cz-pop-grip { position: relative; flex: none; width: 1px; background: var(--cz-hair); cursor: col-resize; touch-action: none; }
|
|
22
|
+
.cz-pop-grip::before { content: ''; position: absolute; inset: 0 -6px; }
|
|
23
|
+
.cz-pop-grip i { position: absolute; left: -3px; top: 50%; width: 7px; height: 44px; margin-top: -22px; border-radius: 4px; background: var(--cz-card); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cz-ink3) 45%, transparent); }
|
|
24
|
+
.cz-pop-grip:hover i, .cz-pop-grip:focus-visible i { background: var(--cz-well); }
|
|
25
|
+
.cz-pop-grip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
26
|
+
body.cz-pop-drag, body.cz-pop-drag * { cursor: col-resize !important; user-select: none !important; }
|
|
27
|
+
/* the right side: Ask PMOS */
|
|
28
|
+
.cz-pop-r { position: relative; flex: 0 0 var(--pop-chat); width: var(--pop-chat); min-width: 360px; display: flex; flex-direction: column; min-height: 0; }
|
|
29
|
+
.cz-pop-card.chat-off .cz-pop-r, .cz-pop-card.chat-off .cz-pop-grip { display: none; }
|
|
30
|
+
.cz-pop-hd { flex: none; display: flex; align-items: center; gap: 8px; padding: 18px 16px 10px 18px; }
|
|
31
|
+
.cz-pop-tile { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cz-bluebg); color: var(--cz-blueink); }
|
|
32
|
+
.cz-pop-tile svg, .cz-pop-ib svg, .cz-pop-t svg, .cz-pop-f svg, .cz-pop-s svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
|
|
33
|
+
.cz-pop-t { all: unset; box-sizing: border-box; cursor: pointer; min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
|
|
34
|
+
background: var(--cz-well); font-size: var(--fs-row); font-weight: var(--fw-strong); color: var(--cz-ink); }
|
|
35
|
+
.cz-pop-t span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
36
|
+
.cz-pop-go:focus-visible, .cz-pop-t:focus-visible, .cz-pop-ib:focus-visible, .cz-pop-x:focus-visible, .cz-pop-sr:focus-visible, .cz-pop-f:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
37
|
+
.cz-pop-tw { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
|
|
38
|
+
.cz-pop-ib { all: unset; box-sizing: border-box; flex: none; cursor: pointer; width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; color: var(--cz-ink2); }
|
|
39
|
+
.cz-pop-ib:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
40
|
+
.cz-pop-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
|
41
|
+
.cz-pop-chat > .hm-chat { flex: 1 1 auto !important; min-height: 0 !important; width: auto !important; max-width: none !important; margin: 0 !important; border: 0 !important;
|
|
42
|
+
border-radius: 0 !important; box-shadow: none !important; background: transparent !important; position: relative !important; transform: none !important; display: flex; flex-direction: column; }
|
|
43
|
+
.cz-pop-chat .hm-chd, .cz-pop-chat .hm-reopen { display: none !important; } /* the popup's own top bar names the session */
|
|
44
|
+
.cz-pop-chat .ut-mic { all: unset; box-sizing: border-box; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--cz-ink2); }
|
|
45
|
+
.cz-pop-chat .ut-mic:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
46
|
+
/* the state of the session shown, on the chat's last line (board 7) */
|
|
47
|
+
.cz-pop-st { display: flex; align-items: center; gap: 8px; padding: 4px 22px 10px; font-size: var(--fs-meta); font-weight: var(--fw-strong); }
|
|
48
|
+
.cz-pop-st[hidden] { display: none; }
|
|
49
|
+
.cz-pop-st.wait { color: var(--cz-risk); }
|
|
50
|
+
.cz-pop-st.work { color: var(--cz-blueink); }
|
|
51
|
+
.cz-pop-st i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
|
|
52
|
+
.cz-pop-st button { all: unset; cursor: pointer; margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink2);
|
|
53
|
+
padding: 4px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--cz-hair); }
|
|
54
|
+
.cz-pop-st button b { width: 8px; height: 8px; border-radius: 2px; background: var(--cz-ink2); }
|
|
55
|
+
/* the session rows: the chooser and All sessions */
|
|
56
|
+
.cz-pop-sr { box-sizing: border-box; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto 28px; align-items: center; column-gap: 10px; padding: 9px 10px; border-radius: 10px;
|
|
57
|
+
cursor: pointer; width: 100%; text-align: left; }
|
|
58
|
+
.cz-pop-go { all: unset; box-sizing: border-box; min-width: 0; cursor: pointer; border-radius: 6px; }
|
|
59
|
+
.cz-pop-sr:hover, .cz-pop-sr.on { background: var(--cz-well); }
|
|
60
|
+
.cz-pop-sr b { display: block; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
61
|
+
.cz-pop-sr small { display: block; font-size: var(--fs-meta); color: var(--cz-ink3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
62
|
+
.cz-pop-sr em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); white-space: nowrap; }
|
|
63
|
+
.cz-pop-sr em.work { color: var(--cz-blueink); }
|
|
64
|
+
.cz-pop-sr em.wait { color: var(--cz-risk); }
|
|
65
|
+
.cz-pop-d { width: 8px; height: 8px; border-radius: 50%; justify-self: center; }
|
|
66
|
+
.cz-pop-d.work { background: var(--cz-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cz-blue) 20%, transparent); }
|
|
67
|
+
.cz-pop-d.wait { background: var(--cz-risk); }
|
|
68
|
+
.cz-pop-x { all: unset; box-sizing: border-box; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cz-card);
|
|
69
|
+
box-shadow: inset 0 0 0 1px var(--cz-hair); }
|
|
70
|
+
.cz-pop-x i { width: 9px; height: 9px; border-radius: 2px; background: var(--cz-ink2); }
|
|
71
|
+
.cz-pop-x:hover { box-shadow: inset 0 0 0 1px var(--cz-ink3); }
|
|
72
|
+
.cz-pop-m { position: absolute; z-index: 25; left: 12px; top: 62px; width: min(388px, calc(100% - 24px)); max-height: calc(100% - 80px); overflow: auto; box-sizing: border-box; padding: 8px;
|
|
73
|
+
border-radius: 16px; background: var(--cz-card); box-shadow: 0 18px 48px -12px rgba(30, 34, 42, .34), 0 0 0 1px var(--cz-hair); }
|
|
74
|
+
.cz-pop-m h6, .cz-pop-all h6 { margin: 6px 10px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
75
|
+
.cz-pop-m hr { border: 0; border-top: 1px solid var(--cz-hair); margin: 6px 4px; }
|
|
76
|
+
.cz-pop-f { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: var(--fs-body); font-weight: var(--fw-regular); color: var(--cz-ink2); }
|
|
77
|
+
.cz-pop-f:hover { background: var(--cz-well); color: var(--cz-ink); }
|
|
78
|
+
.cz-pop-f span { margin-left: auto; font-size: var(--fs-meta); color: var(--cz-ink3); }
|
|
79
|
+
/* All sessions (board 23): the full list on the chat side, or on the left when the session is about no work */
|
|
80
|
+
.cz-pop-all { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; top: 64px; box-sizing: border-box; display: flex; flex-direction: column; padding: 6px 16px 16px; background: var(--cz-card); }
|
|
81
|
+
.cz-pop-all[hidden] { display: none; }
|
|
82
|
+
.cz-pop-r.all-on .cz-pop-chat { visibility: hidden; } /* the card's colour is see-through: the chat under the list does not show */
|
|
83
|
+
.cz-pop-list { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
|
|
84
|
+
.cz-pop-scr { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
85
|
+
.cz-pop-s { flex: none; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--cz-well); color: var(--cz-ink3); margin: 0 0 6px; }
|
|
86
|
+
.cz-pop-s input:focus-visible { outline: none; }
|
|
87
|
+
.cz-pop-s:focus-within { box-shadow: inset 0 0 0 2px var(--cz-blue); }
|
|
88
|
+
.cz-pop-s input { all: unset; flex: 1; min-width: 0; font-size: var(--fs-body); color: var(--cz-ink); }
|
|
89
|
+
.cz-pop-s input::placeholder { color: var(--cz-ink3); }
|
|
90
|
+
.cz-pop-c { border-radius: 14px; box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; }
|
|
91
|
+
.cz-pop-c .cz-pop-sr { border-radius: 0; padding: 9px 12px; }
|
|
92
|
+
.cz-pop-c .cz-pop-sr + .cz-pop-sr { box-shadow: inset 0 1px 0 var(--cz-hair); }
|
|
93
|
+
.cz-pop-list h6 { margin: 14px 6px 4px; font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-ink3); }
|
|
94
|
+
.cz-pop-none { margin: 16px 6px; font-size: var(--fs-body); color: var(--cz-ink3); }
|
|
95
|
+
.cz-pop-n { all: unset; box-sizing: border-box; flex: none; cursor: pointer; margin-top: 12px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
|
|
96
|
+
font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); background: var(--cz-well); }
|
|
97
|
+
.cz-pop-n svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
|
|
98
|
+
.cz-pop-n:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
99
|
+
.cz-pop-l .cz-pop-list { padding: 4px 22px 22px; height: 100%; box-sizing: border-box; }
|
|
100
|
+
/* chat hidden: its way back and the close, at the top right of the work */
|
|
101
|
+
.cz-pop-tools { position: absolute; z-index: 6; top: 18px; right: 18px; display: flex; align-items: center; gap: 6px; }
|
|
102
|
+
.cz-pop-tools[hidden] { display: none; }
|
|
103
|
+
.cz-pop-ask { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: var(--fs-body); font-weight: var(--fw-strong);
|
|
104
|
+
color: var(--cz-ink); background: var(--cz-well); }
|
|
105
|
+
.cz-pop-ask svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
|
|
106
|
+
.cz-pop-ask:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
107
|
+
/* "Session ended · Undo" for a few seconds */
|
|
108
|
+
.cz-pop-toast { position: absolute; z-index: 30; left: 16px; right: 16px; bottom: 96px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
|
|
109
|
+
background: var(--cz-solid); color: var(--cz-onsolid); font-size: var(--fs-body); box-shadow: var(--cz-float); }
|
|
110
|
+
.cz-pop-toast[hidden] { display: none; }
|
|
111
|
+
.cz-pop-toast button { all: unset; cursor: pointer; margin-left: auto; font-weight: var(--fw-strong); text-decoration: underline; }
|
|
112
|
+
.cz-pop-toast button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
113
|
+
body.cz-pop-on { overflow: hidden; }
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/* pm/cozy-popup.js — the one popup (slice 2 of the six-place navigation; boards 3, 7 and 23 on Exploring 2, page "Navigation: Today, Work,
|
|
2
|
+
* Goals, Events, Library, Routine"; build plan /mnt/project-files/nav-structure/build-plan.md).
|
|
3
|
+
*
|
|
4
|
+
* One way to open work: a popup that covers almost the whole page, with a thin dimmed edge of the page around it. The thing is on the left, in
|
|
5
|
+
* the page's own Viewer (cozy-viewer.js lifts #czViewer into the popup, so every page's selectors still find it). Ask PMOS is on the right,
|
|
6
|
+
* already about that thing. Esc, × or a press on the edge closes it. The phone keeps today's layout (cozy-viewer.js never pops on a phone).
|
|
7
|
+
* The grip between the two sides resizes them: each side keeps a smallest width (the work 480 px, the chat 360 px), and PMOS remembers the
|
|
8
|
+
* chat's width (localStorage 'cz-pop-chat'). Double-click or Home resets it; ← and → move it 24 px. The chat's top bar hides the chat, and the
|
|
9
|
+
* work takes the full width; "Ask PMOS" at the top right brings it back.
|
|
10
|
+
* The chat's title is the session chooser: the newest sessions with the work each is about and its state (PMOS is working, Waits for you, or
|
|
11
|
+
* when it was last used), New session (about the work on the left), and All sessions (the full list on the chat side with a search box; the
|
|
12
|
+
* popup stays; ← goes back to the session you were in). Press one and the chat changes to it; the work on the left stays.
|
|
13
|
+
* Each live session has a stop button. One press ends it, with no question: "Session ended" shows with Undo for a few seconds, and only then
|
|
14
|
+
* is POST /api/session/remove sent. The session moves to Earlier at once. An ended chat opens again from Earlier; writing in it makes it live.
|
|
15
|
+
* The chat icon (window.czOpenChat, the rail of slice 1) opens the popup on the session that waits for you, or the newest. Left: the work that
|
|
16
|
+
* session is about; when it is about no work, the full list of sessions. Ask PMOS is not a page.
|
|
17
|
+
*
|
|
18
|
+
* A page opens a thing in the popup with cozy-viewer.js open({ …, pop: about }), about = { id, kind, title, ws } (the chat opens about it),
|
|
19
|
+
* { keep: true, … } (the page already put its chat on it: Home), { session: row }, or { target } (a chat target of home-chat.js).
|
|
20
|
+
* openWork({ about, open() }) does the same for a page whose opener does not know the popup (Intelligence opens premium-vw-item.js).
|
|
21
|
+
* useChat(provider) the page's own chat goes in the popup (Home: #hmChat, so there is never a second chat on the page). provider:
|
|
22
|
+
* { el, open(target), current() → target, focus(), sessionTarget?(row) → target }. Without it, page-chat.js's chat is used.
|
|
23
|
+
* setTitles(fn) fn(initiativeId) → its name, for the work a session is about. setOpener(fn) fn(initiativeId, row) opens it on the left.
|
|
24
|
+
* openChat() the chat icon. openCos(target) the chief-of-staff chat (search's "Ask PMOS: …"). chatTo(target) changes the chat.
|
|
25
|
+
* Reads GET /api/sessions while it shows (every 6 s). Writes only on a press: End (after its Undo moment). The look is cozy-popup.css. */
|
|
26
|
+
import * as VW from './cozy-viewer.js';
|
|
27
|
+
import { pmGet, pmPost } from './http.js';
|
|
28
|
+
import { sessionRows, pickSession, recent, nextKey } from './pop-sessions.js';
|
|
29
|
+
|
|
30
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
31
|
+
const svg = (d, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
|
|
32
|
+
const I = {
|
|
33
|
+
chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
|
|
34
|
+
hide: 'M4 5h16v14H4zM14.5 5v14M9 10l2 2-2 2', close: 'M6 6l12 12M18 6L6 18', down: 'M7 10l5 5 5-5', back: 'M15 6l-6 6 6 6',
|
|
35
|
+
plus: 'M12 5v14M5 12h14', list: 'M5 7h14M5 12h14M5 17h14', find: 'M11 4.5a6.5 6.5 0 1 0 0 13a6.5 6.5 0 1 0 0-13M16 16l4 4', flag: 'M5 21V4h11l-2 4 2 4H5',
|
|
36
|
+
side: 'M3.5 5h17v14h-17zM12 5v14',
|
|
37
|
+
};
|
|
38
|
+
const CLAUDE = { key: 'claude', name: 'PMOS', initial: 'P' };
|
|
39
|
+
const MIN_WORK = 480, MIN_CHAT = 360, DEF_CHAT = 460, POLL = 6000, UNDO = 6000, CHOOSER = 5;
|
|
40
|
+
const store = {
|
|
41
|
+
get(k) { try { return localStorage.getItem(k); } catch { return null; } },
|
|
42
|
+
set(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, String(v)); } catch { /* a private window */ } },
|
|
43
|
+
};
|
|
44
|
+
const isPhone = () => typeof innerWidth === 'number' && innerWidth <= 760;
|
|
45
|
+
const S = {
|
|
46
|
+
el: null, card: null, left: null, right: null, box: null, all: null, menu: null, toast: null, tools: null, title: null, st: null,
|
|
47
|
+
open: false, about: null, home: null, chat: null, back: null, raw: [], rows: { now: [], earlier: [], all: [] }, view: 'chat', q: '', prev: null,
|
|
48
|
+
ending: new Map(), timer: 0, toastT: 0, titles: null, opener: null, w: 0, seq: 0,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/* ── the page's hooks ── */
|
|
52
|
+
export function useChat(p) { S.home = p && p.el && typeof p.open === 'function' ? p : null; }
|
|
53
|
+
export function setTitles(fn) { S.titles = typeof fn === 'function' ? fn : null; }
|
|
54
|
+
export function setOpener(fn) { S.opener = typeof fn === 'function' ? fn : null; }
|
|
55
|
+
export const isOpen = () => S.open;
|
|
56
|
+
const pretty = (id) => String(id || '').replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
57
|
+
const titleOf = (id) => { try { return (S.titles && S.titles(id)) || pretty(id); } catch { return pretty(id); } };
|
|
58
|
+
|
|
59
|
+
/* ── the frame ── */
|
|
60
|
+
function sheet() {
|
|
61
|
+
if (document.getElementById('czPopCss')) return;
|
|
62
|
+
const l = document.createElement('link'); l.id = 'czPopCss'; l.rel = 'stylesheet';
|
|
63
|
+
try { l.href = new URL('./cozy-popup.css', import.meta.url).href; } catch { l.href = '/pm/cozy-popup.css'; }
|
|
64
|
+
document.head.appendChild(l);
|
|
65
|
+
}
|
|
66
|
+
const ib = (act, label, d) => `<button type="button" class="cz-pop-ib" data-pop="${act}" aria-label="${esc(label)}" title="${esc(label)}">${svg(d)}</button>`;
|
|
67
|
+
function frame() {
|
|
68
|
+
if (S.el) return;
|
|
69
|
+
sheet();
|
|
70
|
+
const el = document.createElement('div');
|
|
71
|
+
el.className = 'cz-pop'; el.hidden = true;
|
|
72
|
+
el.innerHTML = '<div class="cz-pop-sc" data-pop="close"></div>'
|
|
73
|
+
+ '<div class="cz-pop-card" role="dialog" aria-modal="true" aria-label="Work and Ask PMOS" tabindex="-1">'
|
|
74
|
+
+ '<div class="cz-pop-l"></div>'
|
|
75
|
+
+ '<div class="cz-pop-grip" role="separator" aria-orientation="vertical" tabindex="0" aria-label="Drag to change the width of the chat. Double-click to reset." title="Drag to change the width. Double-click to reset."><i></i></div>'
|
|
76
|
+
+ '<section class="cz-pop-r" aria-label="Ask PMOS">'
|
|
77
|
+
+ `<header class="cz-pop-hd"><span class="cz-pop-tile" aria-hidden="true">${svg(I.chat)}</span><div class="cz-pop-tw"></div>${ib('where', 'Open work beside the page', I.side)}${ib('hide', 'Hide the chat', I.hide)}${ib('close', 'Close', I.close)}</header>`
|
|
78
|
+
+ '<div class="cz-pop-chat"></div><div class="cz-pop-all" hidden></div><div class="cz-pop-toast" role="status" hidden></div></section>'
|
|
79
|
+
+ `<div class="cz-pop-tools" hidden><button type="button" class="cz-pop-ask" data-pop="ask" aria-label="Show Ask PMOS">${svg(I.chat, 16)}Ask PMOS</button>${ib('close', 'Close', I.close)}</div>`
|
|
80
|
+
+ '</div>';
|
|
81
|
+
document.body.appendChild(el);
|
|
82
|
+
Object.assign(S, { el, card: el.querySelector('.cz-pop-card'), left: el.querySelector('.cz-pop-l'), right: el.querySelector('.cz-pop-r'), box: el.querySelector('.cz-pop-chat'),
|
|
83
|
+
all: el.querySelector('.cz-pop-all'), toast: el.querySelector('.cz-pop-toast'), tools: el.querySelector('.cz-pop-tools'), title: el.querySelector('.cz-pop-tw') });
|
|
84
|
+
el.addEventListener('click', onClick);
|
|
85
|
+
el.addEventListener('input', (e) => { if (e.target.matches('[data-pop-q]')) { S.q = e.target.value; drawLists(); } });
|
|
86
|
+
grip(el.querySelector('.cz-pop-grip'));
|
|
87
|
+
addEventListener('resize', () => { if (S.open) width(S.w); });
|
|
88
|
+
}
|
|
89
|
+
/** The chat's width: within what leaves the work its least width. */
|
|
90
|
+
function width(px) {
|
|
91
|
+
if (!S.card) return;
|
|
92
|
+
const room = innerWidth - 40; // the card's inset is 20 px a side (cozy-popup.css), so its width is known before its sheet has loaded
|
|
93
|
+
const w = Math.max(MIN_CHAT, Math.min(Math.round(px || DEF_CHAT), room - MIN_WORK - 1));
|
|
94
|
+
S.w = w; S.card.style.setProperty('--pop-chat', w + 'px');
|
|
95
|
+
const g = S.el.querySelector('.cz-pop-grip'); g.setAttribute('aria-valuenow', String(w)); g.setAttribute('aria-valuemin', String(MIN_CHAT)); g.setAttribute('aria-valuemax', String(Math.max(MIN_CHAT, room - MIN_WORK - 1)));
|
|
96
|
+
}
|
|
97
|
+
function grip(g) {
|
|
98
|
+
g.addEventListener('pointerdown', (e) => {
|
|
99
|
+
if (e.button !== 0) return;
|
|
100
|
+
e.preventDefault(); g.setPointerCapture(e.pointerId); document.body.classList.add('cz-pop-drag');
|
|
101
|
+
const right = S.card.getBoundingClientRect().right;
|
|
102
|
+
const mv = (ev) => width(right - ev.clientX);
|
|
103
|
+
const up = () => { g.removeEventListener('pointermove', mv); g.removeEventListener('pointerup', up); g.removeEventListener('pointercancel', up); document.body.classList.remove('cz-pop-drag'); store.set('cz-pop-chat', S.w); };
|
|
104
|
+
g.addEventListener('pointermove', mv); g.addEventListener('pointerup', up); g.addEventListener('pointercancel', up);
|
|
105
|
+
});
|
|
106
|
+
g.addEventListener('dblclick', () => { store.set('cz-pop-chat', null); width(DEF_CHAT); });
|
|
107
|
+
g.addEventListener('keydown', (e) => {
|
|
108
|
+
const d = e.key === 'ArrowLeft' ? 24 : e.key === 'ArrowRight' ? -24 : 0;
|
|
109
|
+
if (d) { e.preventDefault(); width(S.w + d); store.set('cz-pop-chat', S.w); } else if (e.key === 'Home') { e.preventDefault(); store.set('cz-pop-chat', null); width(DEF_CHAT); }
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── open and close ── */
|
|
114
|
+
VW.popHook({ host: () => { frame(); return S.left; }, show });
|
|
115
|
+
VW.onChange((d) => { if (d && d.pop && d.shut && S.open) hide(); });
|
|
116
|
+
/** cozy-viewer.js calls this as an item goes into the popup. A popup already open keeps its chat: the work on the left changes, the chat stays. */
|
|
117
|
+
function show(pop) {
|
|
118
|
+
if (S.open) return;
|
|
119
|
+
frame();
|
|
120
|
+
S.open = true; S.view = 'chat'; S.q = ''; S.prev = null;
|
|
121
|
+
S.back = document.activeElement && document.activeElement !== document.body ? document.activeElement : null;
|
|
122
|
+
S.el.hidden = false; document.body.classList.add('cz-pop-on');
|
|
123
|
+
S.card.classList.remove('chat-off'); S.tools.hidden = true; S.all.hidden = true; closeMenu();
|
|
124
|
+
const p = pop && typeof pop === 'object' ? pop : {};
|
|
125
|
+
S.about = p.session ? (p.session.ini ? { id: p.session.ini, kind: 'initiative', title: p.session.work, ws: p.session.ws } : null) : p.id ? { id: p.id, kind: p.kind || 'initiative', title: p.title || '', ws: p.ws } : null;
|
|
126
|
+
width(parseInt(store.get('cz-pop-chat') || '', 10) || DEF_CHAT);
|
|
127
|
+
const want = p.keep ? null : p.target ? p.target : p.session ? null : S.about ? aboutTarget(S.about) : null;
|
|
128
|
+
drawWhere();
|
|
129
|
+
attach(want, p.session || null);
|
|
130
|
+
read();
|
|
131
|
+
tick();
|
|
132
|
+
setTimeout(() => { if (S.open && S.card && !S.card.contains(document.activeElement)) S.card.focus({ preventScroll: true }); }, 0);
|
|
133
|
+
}
|
|
134
|
+
function hide() {
|
|
135
|
+
S.open = false; clearTimeout(S.timer); closeMenu(); hideToast();
|
|
136
|
+
S.view = 'chat'; S.all.hidden = true; S.all.innerHTML = ''; S.right.classList.remove('all-on');
|
|
137
|
+
detach();
|
|
138
|
+
S.el.hidden = true; document.body.classList.remove('cz-pop-on');
|
|
139
|
+
const b = S.back; S.back = null;
|
|
140
|
+
if (b && b.isConnected) { try { b.focus({ preventScroll: true }); } catch { /* gone */ } }
|
|
141
|
+
}
|
|
142
|
+
/** Close the popup (×, the edge): the Viewer closes first, so an item with unsaved changes asks; its close hides the popup. */
|
|
143
|
+
/* ── where work opens: in this popup (the default) or beside the page (the panels). The ⧉ press in the header turns it over. ── */
|
|
144
|
+
const beside = () => store.get(VW.POP_WHERE) === 'beside';
|
|
145
|
+
function drawWhere() {
|
|
146
|
+
const b = S.card && S.card.querySelector('[data-pop="where"]'); if (!b) return;
|
|
147
|
+
const t = beside() ? 'Open work in this popup' : 'Open work beside the page';
|
|
148
|
+
b.setAttribute('aria-label', t); b.title = t; b.setAttribute('aria-pressed', String(beside()));
|
|
149
|
+
}
|
|
150
|
+
function where() {
|
|
151
|
+
if (beside()) { store.set(VW.POP_WHERE, null); drawWhere(); return; }
|
|
152
|
+
store.set(VW.POP_WHERE, 'beside');
|
|
153
|
+
const a = S.about; close();
|
|
154
|
+
if (a && a.id && a.kind === 'initiative') setTimeout(() => openIni(a.id, a), 0); // the same work, now beside the page
|
|
155
|
+
}
|
|
156
|
+
export function close() { if (VW.popOpen()) VW.closePop(); else if (S.open) hide(); }
|
|
157
|
+
|
|
158
|
+
/* ── the chat on the right ── */
|
|
159
|
+
let PC = null; // page-chat.js, read once
|
|
160
|
+
const pageChat = () => (PC = PC || import('./page-chat.js'));
|
|
161
|
+
async function provider() {
|
|
162
|
+
if (S.home) return S.home;
|
|
163
|
+
const M = await pageChat(), b = await M.box();
|
|
164
|
+
return { el: b.el, open: (t) => b.chat.open(t), current: () => (b.chat.current ? b.chat.current() : null), focus: () => b.chat.focus(), stop: () => b.chat.stop(), page: true };
|
|
165
|
+
}
|
|
166
|
+
/** The chat about a thing: page-chat.js's target (its conversation key is the one Home opens for it). */
|
|
167
|
+
function aboutTarget(a) {
|
|
168
|
+
if (!a) return null;
|
|
169
|
+
return { __about: a };
|
|
170
|
+
}
|
|
171
|
+
async function resolve(t) {
|
|
172
|
+
if (!t || !t.__about) return t;
|
|
173
|
+
const M = await pageChat(), a = t.__about;
|
|
174
|
+
return M.keyOf(a) ? M.targetOf(a, a.ws) : M.cosTarget(a.title || '', a.ws);
|
|
175
|
+
}
|
|
176
|
+
async function attach(want, row) {
|
|
177
|
+
const my = ++S.seq;
|
|
178
|
+
const P = await provider();
|
|
179
|
+
if (my !== S.seq || !S.open) return;
|
|
180
|
+
S.chat = P;
|
|
181
|
+
if (P.el.parentNode !== S.box) {
|
|
182
|
+
if (!P.page) S.restore = { parent: P.el.parentNode, next: P.el.nextSibling }; // the page's own chat goes back where it was
|
|
183
|
+
S.box.appendChild(P.el);
|
|
184
|
+
}
|
|
185
|
+
let t = want ? await resolve(want) : null;
|
|
186
|
+
if (!t && row) t = await rowTarget(row);
|
|
187
|
+
if (my !== S.seq || !S.open) return;
|
|
188
|
+
if (t) P.open(t); else if (P.page && !(P.current && P.current())) P.open((await pageChat()).cosTarget(''));
|
|
189
|
+
stateLine();
|
|
190
|
+
drawTitle();
|
|
191
|
+
}
|
|
192
|
+
function detach() {
|
|
193
|
+
S.seq++;
|
|
194
|
+
const P = S.chat; S.chat = null;
|
|
195
|
+
if (S.st) { S.st.remove(); S.st = null; }
|
|
196
|
+
if (!P) return;
|
|
197
|
+
if (P.page) { if (P.stop) P.stop(); P.el.remove(); return; }
|
|
198
|
+
const r = S.restore; S.restore = null;
|
|
199
|
+
if (r && r.parent) r.parent.insertBefore(P.el, r.next && r.next.parentNode === r.parent ? r.next : null);
|
|
200
|
+
}
|
|
201
|
+
/** A session's chat: its own conversation (a chat key), else its transcript (the session id). Home draws it its own way. */
|
|
202
|
+
async function rowTarget(r) {
|
|
203
|
+
if (S.home && typeof S.home.sessionTarget === 'function') { const t = S.home.sessionTarget(r); if (t) return t; }
|
|
204
|
+
if (r.key === 'chat:main') return (await pageChat()).cosTarget('', r.ws || undefined);
|
|
205
|
+
const base = { ws: r.ws || undefined, title: r.name, about: r.work, role: CLAUDE, rich: false, scope: { text: r.ini ? r.work : 'No work', icon: I.flag },
|
|
206
|
+
placeholder: 'Message PMOS', empty: 'Write to carry on with ' + r.name + '.' };
|
|
207
|
+
return r.key ? { ...base, key: r.key } : { ...base, sid: r.id };
|
|
208
|
+
}
|
|
209
|
+
/** Change the chat (page-chat.js openTarget while the popup shows, a session picked). The work on the left stays. */
|
|
210
|
+
export async function chatTo(t) {
|
|
211
|
+
if (!S.open) return false;
|
|
212
|
+
const P = S.chat || await provider();
|
|
213
|
+
const x = await resolve(t);
|
|
214
|
+
if (x) P.open(x);
|
|
215
|
+
S.view = 'chat'; S.all.hidden = true; S.right.classList.remove('all-on'); closeMenu(); drawTitle(); stateLine();
|
|
216
|
+
setTimeout(() => P.focus && P.focus(), 30);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* ── the sessions ── */
|
|
221
|
+
async function read() {
|
|
222
|
+
const r = await pmGet('/api/sessions').catch(() => null);
|
|
223
|
+
if (!S.open) return;
|
|
224
|
+
if (r && Array.isArray(r.sessions)) { S.raw = r.sessions; S.rows = sessionRows(S.raw, { titleOf }); }
|
|
225
|
+
drawTitle(); stateLine(); drawLists();
|
|
226
|
+
}
|
|
227
|
+
function tick() { clearTimeout(S.timer); S.timer = setTimeout(async () => { if (!S.open) return; if (!document.hidden) await read(); tick(); }, POLL); }
|
|
228
|
+
/** The rows with the sessions ended in this moment of Undo moved to Earlier. */
|
|
229
|
+
function rows() {
|
|
230
|
+
const end = (r) => (S.ending.has(r.id) ? { ...r, live: false, state: '', word: 'Ended' } : r);
|
|
231
|
+
const all = S.rows.all.map(end);
|
|
232
|
+
return { now: all.filter((r) => r.live), earlier: all.filter((r) => !r.live), all: all.filter((r) => r.live).concat(all.filter((r) => !r.live)) };
|
|
233
|
+
}
|
|
234
|
+
const curRow = () => {
|
|
235
|
+
const t = S.chat && S.chat.current ? S.chat.current() : null; if (!t) return null;
|
|
236
|
+
return rows().all.find((r) => (t.key && r.key === t.key) || (!t.key && t.sid && r.id === t.sid)) || null;
|
|
237
|
+
};
|
|
238
|
+
function rowHtml(r, sel) {
|
|
239
|
+
return `<div class="cz-pop-sr${sel ? ' on' : ''}" data-sid="${esc(r.id)}"><i class="cz-pop-d ${r.state}" aria-hidden="true"></i>`
|
|
240
|
+
+ `<button type="button" class="cz-pop-go" data-sid="${esc(r.id)}" aria-label="${esc(r.name + ', ' + r.work + ', ' + r.word)}"><b>${esc(r.name)}</b><small>${esc(r.work)}</small></button>`
|
|
241
|
+
+ `<em class="${r.state}">${esc(r.word)}</em>`
|
|
242
|
+
+ (r.live ? `<button type="button" class="cz-pop-x" data-end="${esc(r.id)}" aria-label="${esc('End ' + r.name)}" title="End this session"><i></i></button>` : '<span></span>') + '</div>';
|
|
243
|
+
}
|
|
244
|
+
function drawTitle() {
|
|
245
|
+
if (!S.title || !S.open) return;
|
|
246
|
+
if (S.view === 'all') {
|
|
247
|
+
S.title.innerHTML = `<button type="button" class="cz-pop-ib" data-pop="unall" aria-label="Back to the session you were in" title="Back to the session you were in">${svg(I.back)}</button><b class="t-row">All sessions</b>`;
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const r = curRow(), name = r ? r.name : 'Ask PMOS', on = !!S.menu;
|
|
251
|
+
S.title.innerHTML = `<button type="button" class="cz-pop-t" data-pop="pick" aria-haspopup="menu" aria-expanded="${on}" title="Change session" aria-label="${esc(name + '. Change session')}"><span>${esc(name)}</span>${svg(I.down, 16)}</button>`;
|
|
252
|
+
}
|
|
253
|
+
/** The chat's last line: the state of the session shown and End session (board 7). Nothing when it is not live and busy. */
|
|
254
|
+
function stateLine() {
|
|
255
|
+
const P = S.chat; if (!P || !S.open) return;
|
|
256
|
+
const foot = P.el.querySelector('.hm-foot');
|
|
257
|
+
if (!S.st) { S.st = document.createElement('div'); S.st.className = 'cz-pop-st'; S.st.setAttribute('role', 'status'); }
|
|
258
|
+
if (foot && S.st.nextSibling !== foot) foot.before(S.st);
|
|
259
|
+
const r = curRow();
|
|
260
|
+
if (!r || !r.live || !r.state) { S.st.hidden = true; S.st.innerHTML = ''; return; }
|
|
261
|
+
S.st.hidden = false; S.st.className = 'cz-pop-st ' + r.state;
|
|
262
|
+
S.st.innerHTML = `<i aria-hidden="true"></i>${esc(r.word)}<button type="button" data-end="${esc(r.id)}" aria-label="${esc('End ' + r.name)}"><b aria-hidden="true"></b>End session</button>`;
|
|
263
|
+
}
|
|
264
|
+
function openMenu() {
|
|
265
|
+
closeMenu();
|
|
266
|
+
const R = rows(), cur = curRow(), list = recent(R.all, CHOOSER);
|
|
267
|
+
const m = document.createElement('div');
|
|
268
|
+
m.className = 'cz-pop-m'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'Sessions'); m.dataset.escLayer = '1';
|
|
269
|
+
m.innerHTML = (list.length ? '<h6>Sessions</h6>' + list.map((r) => rowHtml(r, cur && cur.id === r.id)).join('') + '<hr>' : '')
|
|
270
|
+
+ `<button type="button" class="cz-pop-f" role="menuitem" data-pop="new">${svg(I.plus, 16)}New session</button>`
|
|
271
|
+
+ `<button type="button" class="cz-pop-f" role="menuitem" data-pop="all">${svg(I.list, 16)}All sessions<span>the full list</span></button>`;
|
|
272
|
+
S.right.appendChild(m); S.menu = m; drawTitle();
|
|
273
|
+
const f = m.querySelector('button'); if (f) f.focus();
|
|
274
|
+
setTimeout(() => document.addEventListener('pointerdown', away, true), 0);
|
|
275
|
+
}
|
|
276
|
+
function away(e) { if (S.menu && !S.menu.contains(e.target) && !e.target.closest('[data-pop="pick"]')) closeMenu(); }
|
|
277
|
+
function closeMenu() {
|
|
278
|
+
document.removeEventListener('pointerdown', away, true);
|
|
279
|
+
if (!S.menu) return;
|
|
280
|
+
S.menu.remove(); S.menu = null; drawTitle();
|
|
281
|
+
}
|
|
282
|
+
/** The full list: Now and Earlier, newest first, with a search box (board 23). */
|
|
283
|
+
function listHtml(where) {
|
|
284
|
+
const R = rows(), q = S.q.trim().toLowerCase(), cur = curRow();
|
|
285
|
+
const f = (r) => !q || (r.name + ' ' + r.work).toLowerCase().includes(q);
|
|
286
|
+
const now = R.now.filter(f), earlier = R.earlier.filter(f);
|
|
287
|
+
return `<div class="cz-pop-list" data-pop-list="${where}"><label class="cz-pop-s">${svg(I.find, 16)}<input type="search" data-pop-q placeholder="Find a session" aria-label="Find a session" value="${esc(S.q)}"></label><div class="cz-pop-scr">`
|
|
288
|
+
+ (now.length ? `<h6>Now · ${now.length}</h6><div class="cz-pop-c">${now.map((r) => rowHtml(r, cur && cur.id === r.id)).join('')}</div>` : '')
|
|
289
|
+
+ (earlier.length ? `<h6>Earlier</h6><div class="cz-pop-c">${earlier.map((r) => rowHtml(r, cur && cur.id === r.id)).join('')}</div>` : '')
|
|
290
|
+
+ (!now.length && !earlier.length ? `<p class="cz-pop-none">${q ? 'No session matches.' : 'No sessions yet. Write to PMOS to start one.'}</p>` : '')
|
|
291
|
+
+ `</div><button type="button" class="cz-pop-n" data-pop="new">${svg(I.plus, 16)}New session</button></div>`;
|
|
292
|
+
}
|
|
293
|
+
/** Draw the lists that show (the chat side's All sessions, the left side's list) again, keeping the search box's focus. */
|
|
294
|
+
function drawLists() {
|
|
295
|
+
const boxes = [];
|
|
296
|
+
if (S.view === 'all' && !S.all.hidden) boxes.push([S.all, 'right']);
|
|
297
|
+
const lb = VW.bodyOf('pop:sessions'); if (lb) boxes.push([lb, 'left']);
|
|
298
|
+
for (const [b, where] of boxes) {
|
|
299
|
+
const had = document.activeElement && b.contains(document.activeElement) && document.activeElement.matches('[data-pop-q]');
|
|
300
|
+
const at = had ? document.activeElement.selectionStart : 0;
|
|
301
|
+
const sc = b.querySelector('.cz-pop-scr'), top = sc ? sc.scrollTop : 0;
|
|
302
|
+
b.innerHTML = listHtml(where);
|
|
303
|
+
const s2 = b.querySelector('.cz-pop-scr'); if (s2) s2.scrollTop = top;
|
|
304
|
+
if (had) { const i = b.querySelector('[data-pop-q]'); i.focus(); try { i.setSelectionRange(at, at); } catch { /* search fields */ } }
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function showAll(on) {
|
|
308
|
+
S.view = on ? 'all' : 'chat'; closeMenu();
|
|
309
|
+
S.all.hidden = !on; S.right.classList.toggle('all-on', !!on);
|
|
310
|
+
if (on) { S.all.dataset.escLayer = '1'; S.all.innerHTML = listHtml('right'); const i = S.all.querySelector('[data-pop-q]'); if (i) i.focus(); read(); }
|
|
311
|
+
else { delete S.all.dataset.escLayer; S.all.innerHTML = ''; S.q = ''; if (S.chat && S.chat.focus) S.chat.focus(); }
|
|
312
|
+
drawTitle();
|
|
313
|
+
}
|
|
314
|
+
async function pick(id) {
|
|
315
|
+
const r = rows().all.find((x) => x.id === id); if (!r) return;
|
|
316
|
+
const t = await rowTarget(r);
|
|
317
|
+
await chatTo(t);
|
|
318
|
+
}
|
|
319
|
+
/** End a session: one press, no question; "Session ended" with Undo; the end is sent when the Undo moment has passed. */
|
|
320
|
+
function end(id) {
|
|
321
|
+
const r = rows().all.find((x) => x.id === id); if (!r || S.ending.has(id)) return;
|
|
322
|
+
const tm = setTimeout(async () => {
|
|
323
|
+
S.ending.delete(id);
|
|
324
|
+
const res = await pmPost('/api/session/remove', { id }).catch(() => null);
|
|
325
|
+
if (!(res && res.ok)) { if (S.open) showToast('“' + r.name + '” did not end: ' + ((res && res.error) || 'the server did not answer') + '.', null); }
|
|
326
|
+
if (S.open) read();
|
|
327
|
+
}, UNDO);
|
|
328
|
+
S.ending.set(id, tm);
|
|
329
|
+
showToast('Session ended', () => { clearTimeout(tm); S.ending.delete(id); redraw(); });
|
|
330
|
+
redraw();
|
|
331
|
+
}
|
|
332
|
+
function redraw() {
|
|
333
|
+
drawTitle(); stateLine(); drawLists();
|
|
334
|
+
if (S.menu) openMenu(); // the chooser shows the row in its new place
|
|
335
|
+
}
|
|
336
|
+
function showToast(text, undo) {
|
|
337
|
+
clearTimeout(S.toastT);
|
|
338
|
+
S.toast.innerHTML = `<span>${esc(text)}</span>` + (undo ? '<button type="button" data-pop="undo">Undo</button>' : '');
|
|
339
|
+
S.toast.hidden = false; S.toast._undo = undo;
|
|
340
|
+
S.toastT = setTimeout(hideToast, UNDO - 300);
|
|
341
|
+
}
|
|
342
|
+
function hideToast() { clearTimeout(S.toastT); if (S.toast) { S.toast.hidden = true; S.toast._undo = null; } }
|
|
343
|
+
async function newSession() {
|
|
344
|
+
const a = S.about, M = await pageChat();
|
|
345
|
+
let t;
|
|
346
|
+
if (a && M.keyOf(a)) {
|
|
347
|
+
const base = M.targetOf(a, a.ws);
|
|
348
|
+
t = { ...base, key: nextKey(base.key, S.raw), title: 'New session · ' + (a.title || 'this'), empty: 'A new session about ' + (a.title || 'this') + '. Say what it is for.' };
|
|
349
|
+
} else {
|
|
350
|
+
const d = new Date(), p = (x) => String(x).padStart(2, '0');
|
|
351
|
+
t = { key: 'chat:loose-' + d.getFullYear() + p(d.getMonth() + 1) + p(d.getDate()) + '-' + p(d.getHours()) + p(d.getMinutes()) + p(d.getSeconds()), title: 'New session', role: CLAUDE, rich: false,
|
|
352
|
+
scope: { text: 'No work', icon: I.flag }, placeholder: 'Message PMOS', empty: 'A new session. Say what it is for.' };
|
|
353
|
+
}
|
|
354
|
+
await chatTo(t);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function onClick(e) {
|
|
358
|
+
const end1 = e.target.closest('[data-end]'); if (end1) { e.preventDefault(); end(end1.dataset.end); return; }
|
|
359
|
+
const row = e.target.closest('[data-sid]'); if (row) { e.preventDefault(); pick(row.dataset.sid); return; }
|
|
360
|
+
const b = e.target.closest('[data-pop]'); if (!b) return;
|
|
361
|
+
const a = b.dataset.pop;
|
|
362
|
+
if (a === 'close') close();
|
|
363
|
+
else if (a === 'where') where();
|
|
364
|
+
else if (a === 'hide') { S.card.classList.add('chat-off'); S.tools.hidden = false; closeMenu(); const k = S.tools.querySelector('[data-pop="ask"]'); if (k) k.focus(); }
|
|
365
|
+
else if (a === 'ask') { S.card.classList.remove('chat-off'); S.tools.hidden = true; width(S.w); if (S.chat && S.chat.focus) S.chat.focus(); }
|
|
366
|
+
else if (a === 'pick') { if (S.menu) closeMenu(); else { openMenu(); read(); } }
|
|
367
|
+
else if (a === 'new') newSession();
|
|
368
|
+
else if (a === 'all') showAll(true);
|
|
369
|
+
else if (a === 'unall') showAll(false);
|
|
370
|
+
else if (a === 'undo') { const u = S.toast._undo; hideToast(); if (u) u(); }
|
|
371
|
+
}
|
|
372
|
+
// Esc: the chooser closes first, then All sessions goes back to the session; with neither, the Viewer's own Esc closes the popup
|
|
373
|
+
addEventListener('keydown', (e) => {
|
|
374
|
+
if (e.key !== 'Escape' || !S.open) return;
|
|
375
|
+
if (S.menu) { e.preventDefault(); e.stopImmediatePropagation(); closeMenu(); const t = S.title.querySelector('[data-pop="pick"]'); if (t) t.focus(); return; }
|
|
376
|
+
if (S.view === 'all') { e.preventDefault(); e.stopImmediatePropagation(); showAll(false); }
|
|
377
|
+
}, true);
|
|
378
|
+
|
|
379
|
+
/* ── the ways in ── */
|
|
380
|
+
const sessionsItem = (pop) => ({ pop: { ...pop, force: true }, id: 'pop:sessions', kind: 'Sessions', title: 'All sessions', icon: 'list', render: (b) => { b.innerHTML = listHtml('left'); } });
|
|
381
|
+
/** A page whose opener does not know the popup: the next Viewer open goes into the popup, with the chat about the thing. */
|
|
382
|
+
export function openWork({ about, open } = {}) {
|
|
383
|
+
if (!isPhone() && about) VW.popNext(about);
|
|
384
|
+
if (typeof open === 'function') open();
|
|
385
|
+
}
|
|
386
|
+
async function openIni(id, row) {
|
|
387
|
+
if (S.opener) { S.opener(id, row); return; }
|
|
388
|
+
const M = await import('./premium-vw-item.js');
|
|
389
|
+
M.openWorkItem({ kind: 'initiative', id, ws: (row && row.ws) || '', title: titleOf(id) });
|
|
390
|
+
}
|
|
391
|
+
/** The chat icon: the session that waits for you, else the newest. Left: its work, or the full list of sessions. */
|
|
392
|
+
export async function openChat() {
|
|
393
|
+
if (isPhone()) { const M = await pageChat(); return M.openCos({ here: '' }); }
|
|
394
|
+
const r = await pmGet('/api/sessions').catch(() => null);
|
|
395
|
+
const R = sessionRows(r && Array.isArray(r.sessions) ? r.sessions : [], { titleOf });
|
|
396
|
+
const row = pickSession(R.all);
|
|
397
|
+
if (S.open) { if (row) await pick(row.id); return true; }
|
|
398
|
+
VW.open(sessionsItem(row ? { session: row } : { target: (await pageChat()).cosTarget('') }));
|
|
399
|
+
if (row && row.ini) openIni(row.ini, row);
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
/** The chief-of-staff chat (search's "Ask PMOS: …", page-chat.js openCos): the popup with that chat and the list of sessions. */
|
|
403
|
+
export async function openCos(t) {
|
|
404
|
+
if (S.open) return chatTo(t);
|
|
405
|
+
VW.open(sessionsItem({ target: t }));
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
if (typeof window !== 'undefined') { window.czOpenChat = openChat; window.czPopup = { openChat, openCos, openWork, chatTo, close, isOpen, useChat, setTitles, setOpener }; }
|
|
@@ -612,9 +612,12 @@ async function delVersion(file) {
|
|
|
612
612
|
say(r.said, async () => {
|
|
613
613
|
const u = await pmPost('/api/lab/restore', { ws: at.ws, batch: r.batch }).catch(() => null);
|
|
614
614
|
if (!u || u.ok === false) { say((u && u.error) || 'It did not come back.'); return; }
|
|
615
|
+
fire('pmos:lab-version', { ini: c.ini });
|
|
615
616
|
if (V.H && V.H.reload) V.H.reload();
|
|
616
617
|
if (V.H && V.H.go && window.czViewer && window.czViewer.current() && window.czViewer.current().id === 'lab:cmp') V.H.go(u.back.id, u.back.key);
|
|
617
618
|
});
|
|
619
|
+
// the initiative page behind redraws its Specimens line and its Prototype & design fold, wherever the Viewer was opened from
|
|
620
|
+
fire('pmos:lab-version', { ini: c.ini });
|
|
618
621
|
if (V.H && V.H.reload) V.H.reload();
|
|
619
622
|
go(r.next);
|
|
620
623
|
}
|
|
@@ -108,7 +108,7 @@ function general() {
|
|
|
108
108
|
const upd = ready() ? `<div class="ev-card ev-upd">${adFace('needs-you')}<span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="updates">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
|
|
109
109
|
return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
|
|
110
110
|
+ trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
|
|
111
|
-
+ trow('Product', 'Which products
|
|
111
|
+
+ trow('Product', 'Which products Today, Work and Goals read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
|
|
112
112
|
+ trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
|
|
113
113
|
+ trow('Your impact', 'Adler’s sprout and your impact log. Only you see it. Nothing leaves PMOS.', sw(impactOn(), 'data-ev-impact', 'Your impact'))
|
|
114
114
|
+ trow('Agents write to Jira', 'Only after you press Commit. Never on their own.', (ready() ? '' : adFace('needs-you', 24)) + '<span class="ev-pill ok">Fixed</span>')
|
|
@@ -511,6 +511,7 @@ function draw() {
|
|
|
511
511
|
// the amber box sits on top of the other sections only: on Connectors the trouble row says it (say it once, CnA)
|
|
512
512
|
el.querySelector('.ev-st-main').innerHTML = (T.sec === 'connectors' ? '' : staleHtml()) + `<div class="ev-top"><h3 class="ev-h2" id="evStTitle">${esc(label)}</h3>${all}<button type="button" class="ev-ib" data-ev-close aria-label="Close settings" title="Close settings">${svg(ICON.close, 18)}</button></div>`
|
|
513
513
|
+ BODY[T.sec]() + `<p role="status"${T.msg && AD.moodOfText(T.msg) === 'honest' ? ' class="ev-say honest"' : ''}>${T.msg && AD.moodOfText(T.msg) === 'honest' ? AD.adler('honest', 24, { label: false }) : ''}${esc(T.msg)}</p>`;
|
|
514
|
+
cardRows(el.querySelector('.ev-st-main')); el.querySelectorAll('.ev-st-main .sc-w').forEach(cardRows);
|
|
514
515
|
if (disposeClaudeSetup) { disposeClaudeSetup(); disposeClaudeSetup = null; }
|
|
515
516
|
wfPanel(el);
|
|
516
517
|
const setup = el.querySelector('[data-claude-setup]');
|
|
@@ -518,6 +519,14 @@ function draw() {
|
|
|
518
519
|
const cur = el.querySelector('.ev-st-nav [aria-current="page"]'); if (cur && cur.scrollIntoView) cur.scrollIntoView({ block: 'nearest', inline: 'nearest' }); // on a phone the section row scrolls: keep the open one in view
|
|
519
520
|
if (had && !ae.isConnected) { const f = (key && el.querySelector(`[${key.name}="${CSS.escape(key.value)}"]`)) || el.querySelector('[aria-current="page"]'); if (f) f.focus(); }
|
|
520
521
|
}
|
|
522
|
+
/** One container (slice 1, board StSettings): rows that follow each other sit in one card with a thin border, never a card in a card. */
|
|
523
|
+
function cardRows(root) {
|
|
524
|
+
if (!root) return;
|
|
525
|
+
let run = [];
|
|
526
|
+
const flush = () => { if (run.length) { const c = document.createElement('div'); c.className = 'ev-tcard'; run[0].before(c); run.forEach((r) => c.appendChild(r)); run = []; } };
|
|
527
|
+
[...root.children].forEach((k) => { if (k.classList.contains('ev-trow')) run.push(k); else flush(); });
|
|
528
|
+
flush();
|
|
529
|
+
}
|
|
521
530
|
/** Workspaces › Workflows (UI grill U1): pm/wf-page.js draws into its host, the same node across redraws; leaving it lets it go. */
|
|
522
531
|
let WF = null, wfOpts = {};
|
|
523
532
|
function wfPanel(el) {
|