diff --git a/changelog.d/added-15829-activity-monitor-popout.md b/changelog.d/added-15829-activity-monitor-popout.md new file mode 100644 index 0000000000..b0821fdfc1 --- /dev/null +++ b/changelog.d/added-15829-activity-monitor-popout.md @@ -0,0 +1 @@ +- The Hive activity monitor can now be popped out into its own browser window (⧉ on the card header, `?popout=1`, same sign-in, tracker-only layout for a second monitor, ⤶ Return to dashboard) or taken full screen (⛶ / the `f` key, Esc exits) ([#15829](https://github.com/hivecommons/hive/issues/15829)). diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index 398c45bfa3..5e2e47b9b0 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -121,6 +121,15 @@ The monospace **engine enforce · N anomalies** strip describes the [central sta ### Monitor controls and detailed reference +#### Pop out and full screen (⧉ / ⛶ on the card header) + +Two buttons sit beside the ⚙ gear on the card header for working with the monitor on its own ([#15829](https://github.com/hivecommons/hive/issues/15829)): + +- **⧉ Pop out** opens the dashboard in a new browser window named `hive-activity-monitor` (1600×900 by default; drag it to another monitor). The window loads `?popout=1#section-activity-monitor-section`: no sidebar, topbar, notices, chat or other sections — just the tracker filling the viewport, with live updates, toasts, sounds, the Merged bee and the ⚙ settings all working. It uses the same saved sign-in as the main window, so there is no second login; its title is `Hive · Activity Monitor · `; and reloading it keeps the layout because the flag lives in the URL. The small **⤶ Return to dashboard** pill brings the main window forward and closes the pop-out (a tab you opened by hand on that URL navigates back to the full dashboard instead). If the browser blocks the popup, a toast says so — allow pop-ups for the dashboard's origin and try again. +- **⛶ Full screen** puts the page into the browser's full-screen mode with the same tracker-only layout; the button reads **⛶ Exit full screen** while active, and **Esc** leaves as usual. With focus inside the monitor (or anywhere in a pop-out) the **f** key toggles it too; it is ignored while typing in a field or with a modifier held. + +Neither mode changes any saved preference. Kiosk mode (`?kiosk=1`, [Streaming the activity monitor](../streaming-the-activity-monitor.md)) is the unattended cousin of pop-out: same layout, no cursor, no controls. + #### Filter chips (Needs human / On hold / labels) The label row under the toolbar starts with two synthetic chips, then one chip per label the listed items carry. **🙋 Needs human** means a person's decision or action is the *only* thing that advances the row: an issue at `015` triage-needed, `045` or `085` needs-decision, a PR at `090` ready-for-human-merge, a PR at `071`/`072` whose author is a human, or any row wearing a `needs human` / `needs human decision` / `unauthorized` pill. diff --git a/src/pkg/dashboard/stage_tracker_popout.test.js b/src/pkg/dashboard/stage_tracker_popout.test.js new file mode 100644 index 0000000000..3f5521c5fb --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_popout.test.js @@ -0,0 +1,197 @@ +// Pop out & full screen for the Hive activity monitor (hivecommons/hive#15829): +// the ⧉ header button opens the SPA in a named popup on +// `?popout=1#section-activity-monitor-section`, boot.js flags the body before +// first paint so the chrome never shows, and ⛶ toggles the Fullscreen API on +// the document with a body class that shares the pop-out layout. The +// functions are lifted out of index.html so this runs against the shipped +// source. +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8'); + +function pick(re, what) { + const m = html.match(re); + assert.ok(m, what + ' not found in index.html'); + return m[0]; +} + +function fakeEl(id) { + const attrs = {}; + const classes = new Set(); + return { + id, textContent: '', title: '', attrs, + classList: { add: c => classes.add(c), remove: c => classes.delete(c), contains: c => classes.has(c), toggle(c, on) { on ? classes.add(c) : classes.delete(c); } }, + setAttribute(k, v) { attrs[k] = v; }, getAttribute(k) { return attrs[k]; }, + contains(n) { return n === this || (n && n.parent === this); }, + }; +} + +function load(env) { + const src = [ + 'var toasts = [];', + 'function showToast(msg, type) { toasts.push({ msg, type }); }', + pick(/const STAGE_TRACKER_POPOUT_PARAM = [^\n]*\n/, 'POPOUT_PARAM'), + pick(/const STAGE_TRACKER_POPOUT_WINDOW_NAME = [^\n]*\n/, 'WINDOW_NAME'), + pick(/const STAGE_TRACKER_POPOUT_FEATURES = [^\n]*\n/, 'FEATURES'), + pick(/const STAGE_TRACKER_POPOUT_HASH = [^\n]*\n/, 'HASH'), + pick(/const STAGE_TRACKER_POPOUT_TITLE = [^\n]*\n/, 'TITLE'), + pick(/const STAGE_TRACKER_FULLSCREEN_KEY = [^\n]*\n/, 'FULLSCREEN_KEY'), + pick(/const STAGE_TRACKER_FULLSCREEN_LABELS = \{[\s\S]*?\n \};\n/, 'FULLSCREEN_LABELS'), + 'var _stageTrackerPopoutHiveId = "";', + pick(/function stageTrackerPopoutUrl\(href\) \{[\s\S]*?\n \}\n/, 'stageTrackerPopoutUrl'), + pick(/function stageTrackerDashboardUrl\(href\) \{[\s\S]*?\n \}\n/, 'stageTrackerDashboardUrl'), + pick(/function stageTrackerPopoutTitle\(hiveId\) \{[\s\S]*?\n \}\n/, 'stageTrackerPopoutTitle'), + pick(/function stageTrackerPopoutMode\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerPopoutMode'), + pick(/function stageTrackerPopoutSyncTitle\(hiveId\) \{[\s\S]*?\n \}\n/, 'stageTrackerPopoutSyncTitle'), + pick(/function openStageTrackerPopout\(\) \{[\s\S]*?\n \}\n/, 'openStageTrackerPopout'), + pick(/function stageTrackerReturnToDashboard\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerReturnToDashboard'), + pick(/function stageTrackerFullscreenTarget\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerFullscreenTarget'), + pick(/function stageTrackerFullscreenButton\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerFullscreenButton'), + pick(/function stageTrackerIsFullscreen\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerIsFullscreen'), + pick(/function stageTrackerFullscreenLabel\(isFull\) \{[\s\S]*?\n \}\n/, 'stageTrackerFullscreenLabel'), + pick(/function stageTrackerRenderFullscreenButton\(\) \{[\s\S]*?\n \}\n/, 'stageTrackerRenderFullscreenButton'), + pick(/function toggleStageTrackerFullscreen\(\) \{[\s\S]*?\n \}\n/, 'toggleStageTrackerFullscreen'), + pick(/function stageTrackerFullscreenHotkey\(ev, inTracker, typing, popout\) \{[\s\S]*?\n \}\n/, 'stageTrackerFullscreenHotkey'), + 'return { stageTrackerPopoutUrl, stageTrackerDashboardUrl, stageTrackerPopoutTitle, stageTrackerPopoutSyncTitle, openStageTrackerPopout, stageTrackerReturnToDashboard, stageTrackerRenderFullscreenButton, toggleStageTrackerFullscreen, stageTrackerFullscreenHotkey, stageTrackerIsFullscreen, toasts };', + ].join('\n'); + const body = fakeEl('body'); + const root = { requestFullscreen: null, calls: [] }; + root.requestFullscreen = function() { root.calls.push('request'); document.fullscreenElement = root; return Promise.resolve(); }; + const btn = fakeEl('activity-monitor-fullscreen'); + const document = { + body, documentElement: root, fullscreenElement: null, title: '', + exitFullscreen() { root.calls.push('exit'); document.fullscreenElement = null; return Promise.resolve(); }, + getElementById(id) { return id === 'activity-monitor-fullscreen' ? btn : null; }, + }; + const window = Object.assign({ location: { href: 'http://127.0.0.1:8099/?theme=light#section-agents-section' }, closed: false, opened: [], hivePopoutMode: () => false }, env || {}); + window.open = window.open || function(url, name, features) { window.opened.push({ url, name, features }); return { focus() { window.focusedChild = true; } }; }; + const api = new Function('window', 'document', 'URL', src)(window, document, URL); + return { api, window, document, body, root, btn }; +} + +// Scenario (c): popout URL building. +test('pop-out URL keeps origin/query, adds popout=1, drops kiosk/filter, lands on the tracker', () => { + const { api } = load(); + const u = new URL(api.stageTrackerPopoutUrl('http://127.0.0.1:8099/?theme=light&kiosk=1&filter=waiting-on-you#section-agents-section')); + assert.strictEqual(u.origin + u.pathname, 'http://127.0.0.1:8099/'); + assert.strictEqual(u.searchParams.get('popout'), '1'); + assert.strictEqual(u.searchParams.get('theme'), 'light'); + assert.strictEqual(u.searchParams.get('kiosk'), null); + assert.strictEqual(u.searchParams.get('filter'), null); + assert.strictEqual(u.hash, '#section-activity-monitor-section'); + assert.strictEqual(api.stageTrackerPopoutUrl('not a url'), ''); + const back = new URL(api.stageTrackerDashboardUrl(u.toString())); + assert.strictEqual(back.searchParams.get('popout'), null, 'return URL drops popout'); + assert.strictEqual(back.searchParams.get('theme'), 'light'); +}); + +test('⧉ opens one named popup window with the popup features and focuses it; a blocked popup toasts', () => { + const { api, window } = load(); + const win = api.openStageTrackerPopout(); + assert.ok(win); + assert.strictEqual(window.opened.length, 1); + assert.strictEqual(window.opened[0].name, 'hive-activity-monitor'); + assert.strictEqual(window.opened[0].features, 'popup,width=1600,height=900'); + assert.ok(window.opened[0].url.includes('popout=1')); + assert.strictEqual(window.focusedChild, true); + const blocked = load({ open: () => null }); + assert.strictEqual(blocked.api.openStageTrackerPopout(), null); + assert.strictEqual(blocked.api.toasts.length, 1); + assert.match(blocked.api.toasts[0].msg, /blocked/); +}); + +// Scenario (a): popout mode hides the chrome and renders only the tracker. +test('popout mode: boot flags the body before paint and the CSS removes every piece of chrome', () => { + assert.ok(html.includes("popout=u.searchParams.get('popout')==='1'"), 'boot.js reads ?popout=1'); + assert.ok(html.includes("window.hivePopoutMode=function(){ return !!window.HIVE_POPOUT; };")); + assert.ok(html.includes("document.body.classList.add('popout-mode');")); + assert.ok(html.includes("if(kiosk||window.HIVE_POPOUT){\n if(!location.hash) history.replaceState(null,'',location.pathname+location.search+'#section-activity-monitor-section');"), 'popout lands on the tracker section'); + for (const rule of [ + 'body.popout-mode .oc-sidebar, body.popout-mode .oc-sidebar-resize, body.popout-mode .oc-topbar,', + 'html body.popout-mode #oc-topbar[id], html body.ham-fullscreen #oc-topbar[id] { display: none !important; }', + 'body.popout-mode #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section),', + 'body.ham-fullscreen #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section) { display: none !important; }', + 'body.popout-mode .ham-popout-return { display: inline-flex; align-items: center; }', + 'body.popout-mode .ham-popout-btn, body.ham-fullscreen .ham-popout-btn,', + ]) assert.ok(html.includes(rule), 'missing CSS rule: ' + rule); + // Header tools render next to the gear, dispatch through data-action and + // never collapse the section (data-stop). + assert.match(html, /id="activity-monitor-popout" data-action="openStageTrackerPopout" data-stop="1"/); + assert.match(html, /id="activity-monitor-fullscreen" data-action="toggleStageTrackerFullscreen" data-stop="1" aria-pressed="false"/); + assert.match(html, /id="activity-monitor-return" data-action="stageTrackerReturnToDashboard" data-stop="1"/); + // The welcome tour and NPS card stay in the main window; the title is the monitor's. + assert.ok(html.includes('if (window.hivePopoutMode && window.hivePopoutMode()) return;')); + assert.ok(html.includes('if (!(window.hivePopoutMode && window.hivePopoutMode())) document.title = "Hive Dashboard for " + repoDisplay;')); + assert.ok(html.includes("if (typeof stageTrackerPopoutSyncTitle === 'function') stageTrackerPopoutSyncTitle(hiveId);")); + // Nothing is persisted for the layout: the flag lives in the URL only. + assert.ok(!html.includes("localStorage.setItem('hive-popout")); +}); + +test('popout window title carries the hive id once status delivers it; the main window is untouched', () => { + const main = load(); + main.api.stageTrackerPopoutSyncTitle('hive-abc'); + assert.strictEqual(main.document.title, '', 'main window keeps its own title'); + const pop = load({ hivePopoutMode: () => true }); + pop.api.stageTrackerPopoutSyncTitle(); + assert.strictEqual(pop.document.title, 'Hive · Activity Monitor'); + pop.api.stageTrackerPopoutSyncTitle('hive-abc'); + assert.strictEqual(pop.document.title, 'Hive · Activity Monitor · hive-abc'); + assert.strictEqual(pop.api.stageTrackerPopoutTitle(' '), 'Hive · Activity Monitor'); +}); + +test('⤶ Return focuses the opener and closes; a hand-opened tab navigates back instead', () => { + let focused = false, closed = false, assigned = null; + const popup = load({ opener: { closed: false, focus() { focused = true; } }, close() { closed = true; this.closed = true; } }); + popup.api.stageTrackerReturnToDashboard(); + assert.ok(focused && closed); + const tab = load({ opener: null, close() {}, location: { href: 'http://h/?popout=1#section-activity-monitor-section', assign(u) { assigned = u; } } }); + tab.api.stageTrackerReturnToDashboard(); + assert.ok(assigned && !assigned.includes('popout=1') && assigned.includes('#section-activity-monitor-section')); +}); + +// Scenario (b): fullscreen toggle calls requestFullscreen on the wrapper and flips the label. +test('⛶ requests full screen on the document, sets body.ham-fullscreen and flips the label; a second press exits', async () => { + const { api, root, body, btn, document } = load(); + api.stageTrackerRenderFullscreenButton(); + assert.strictEqual(btn.textContent, '⛶'); + assert.strictEqual(btn.attrs['aria-pressed'], 'false'); + assert.strictEqual(await api.toggleStageTrackerFullscreen(), true); + assert.deepStrictEqual(root.calls, ['request']); + assert.ok(body.classList.contains('ham-fullscreen')); + assert.strictEqual(btn.textContent, '⛶ Exit full screen'); + assert.strictEqual(btn.attrs['aria-pressed'], 'true'); + assert.match(btn.title, /^Exit full screen/); + assert.strictEqual(await api.toggleStageTrackerFullscreen(), true); + assert.deepStrictEqual(root.calls, ['request', 'exit']); + assert.ok(!body.classList.contains('ham-fullscreen')); + assert.strictEqual(btn.textContent, '⛶'); + assert.strictEqual(btn.attrs['aria-pressed'], 'false'); + // Esc (native exit) fires fullscreenchange with no fullscreenElement: the layout drops. + body.classList.add('ham-fullscreen'); + document.fullscreenElement = null; + api.stageTrackerRenderFullscreenButton(); + assert.ok(!body.classList.contains('ham-fullscreen')); +}); + +test('a refused requestFullscreen rolls the layout back and toasts', async () => { + const { api, body, root } = load(); + root.requestFullscreen = () => Promise.reject(new Error('denied')); + assert.strictEqual(await api.toggleStageTrackerFullscreen(), false); + assert.ok(!body.classList.contains('ham-fullscreen')); + assert.match(api.toasts[0].msg, /denied/); +}); + +test('`f` toggles only as a bare key with focus in the tracker (or anywhere in a pop-out), never while typing', () => { + const { api } = load(); + const f = (extra) => Object.assign({ key: 'f', ctrlKey: false, metaKey: false, altKey: false, shiftKey: false }, extra || {}); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f(), true, false, false), true); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f(), false, false, false), false, 'focus outside the tracker'); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f(), false, false, true), true, 'pop-out: the page is the tracker'); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f(), true, true, true), false, 'typing in the search box'); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f({ metaKey: true }), true, false, false), false, '⌘F is find'); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f({ key: 'F', shiftKey: true }), true, false, false), false); + assert.strictEqual(api.stageTrackerFullscreenHotkey(f({ key: 'g' }), true, false, false), false); +}); diff --git a/src/pkg/dashboard/static-src/css/popout.css b/src/pkg/dashboard/static-src/css/popout.css new file mode 100644 index 0000000000..4e20d56b25 --- /dev/null +++ b/src/pkg/dashboard/static-src/css/popout.css @@ -0,0 +1,54 @@ +/* ---- pop-out & full screen: the activity monitor on its own (#15829) ---- + `?popout=1` (see js/boot.js) is what the ⧉ header button opens in a + named popup window so an operator can park the tracker on a second + monitor. Same chrome-less layout as kiosk — no sidebar, topbar, avatar + menu, chat FAB or notices, every other section out of flow — but attended: + the cursor stays, the gear works, and a ⤶ Return link goes back to the + opener. The ⛶ button puts the document into the Fullscreen API and sets + body.ham-fullscreen, which shares every rule below — the document rather + than the section so the body-level toasts (waiting on you, merges) stay + visible while full screen. */ + body.popout-mode, body.ham-fullscreen { padding: var(--sp-5) var(--sp-7) var(--sp-7) var(--sp-7); --navbar-sticky-height: 0px; } + body.popout-mode .oc-sidebar, body.popout-mode .oc-sidebar-resize, body.popout-mode .oc-topbar, + body.popout-mode #dash-notices, body.popout-mode #oc-agent-detail, body.popout-mode .hive-chat-fab, + body.popout-mode .hive-chat-panel, body.popout-mode #welcome-overlay, body.popout-mode .nps-card, + body.ham-fullscreen .oc-sidebar, body.ham-fullscreen .oc-sidebar-resize, body.ham-fullscreen .oc-topbar, + body.ham-fullscreen #dash-notices, body.ham-fullscreen #oc-agent-detail, body.ham-fullscreen .hive-chat-fab, + body.ham-fullscreen .hive-chat-panel { display: none !important; } + /* /api/theme.css (theme/theme.go layoutGuardCSS) forces the topbar to + display:grid!important with id specificity; beat it with (1,2,2). */ + html body.popout-mode #oc-topbar[id], html body.ham-fullscreen #oc-topbar[id] { display: none !important; } + body.popout-mode #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section), + body.ham-fullscreen #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section) { display: none !important; } + body.popout-mode #activity-monitor-section .dashboard-grip, body.popout-mode #activity-monitor-section .section-chevron, + body.ham-fullscreen #activity-monitor-section .dashboard-grip, body.ham-fullscreen #activity-monitor-section .section-chevron { display: none !important; } + /* The header cannot collapse the only section on the page, but its + gear, full-screen and return buttons must still take clicks. */ + body.popout-mode #activity-monitor-section .section-header-toggle, + body.ham-fullscreen #activity-monitor-section .section-header-toggle { pointer-events: none; } + body.popout-mode #activity-monitor-section .section-header-toggle button, + body.popout-mode #activity-monitor-section .section-header-toggle .config-info, + body.ham-fullscreen #activity-monitor-section .section-header-toggle button, + body.ham-fullscreen #activity-monitor-section .section-header-toggle .config-info { pointer-events: auto; } + /* A collapsed state saved from the main window would leave an empty + page with a header that cannot be clicked: always show the body. */ + body.popout-mode #activity-monitor-section .section-body.collapsed, + body.ham-fullscreen #activity-monitor-section .section-body.collapsed { max-height: none !important; opacity: 1; pointer-events: auto; } + body.popout-mode #activity-monitor-section .dash-card.collapsed .dash-card-actions, + body.ham-fullscreen #activity-monitor-section .dash-card.collapsed .dash-card-actions { display: inline-flex; } + body.popout-mode #activity-monitor-section .dash-card.collapsed .dash-card-summary, + body.ham-fullscreen #activity-monitor-section .dash-card.collapsed .dash-card-summary { display: none; } + body.popout-mode .ham-sticky, body.ham-fullscreen .ham-sticky { top: 0; } + body.popout-mode .ham-cols, body.ham-fullscreen .ham-cols { top: var(--ham-sticky-bar-h); } + + /* Header tools: ⧉ pop out and ⛶ full screen sit beside the gear and + share its chip styling; the return link is a pop-out-only text pill. */ + .ham-header-tool { width: auto; min-width: 15px; padding: 0 var(--sp-1); font-size: var(--fs-2xs); line-height: 1; color: var(--muted); white-space: nowrap; } + .ham-header-tool[aria-pressed="true"] { color: var(--blue); border-color: var(--blue); } + .ham-popout-return { display: none; margin-left: var(--sp-2); padding: 0 var(--sp-2); height: 15px; border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--blue) 60%, transparent); background: color-mix(in srgb, var(--blue) 18%, var(--panel)); color: var(--blue); font: inherit; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0; line-height: 1; white-space: nowrap; cursor: pointer; } + .ham-popout-return:hover, .ham-popout-return:focus-visible { background: var(--blue); color: var(--bg); outline: none; } + body.popout-mode .ham-popout-return { display: inline-flex; align-items: center; } + /* A window that already is the tracker has nothing to pop out, and a + kiosk has no one to click. */ + body.popout-mode .ham-popout-btn, body.ham-fullscreen .ham-popout-btn, + body.kiosk-mode .ham-header-tool, body.kiosk-mode .ham-popout-return { display: none !important; } diff --git a/src/pkg/dashboard/static-src/js/boot.js b/src/pkg/dashboard/static-src/js/boot.js index 73bf0d531c..8fea9461a2 100644 --- a/src/pkg/dashboard/static-src/js/boot.js +++ b/src/pkg/dashboard/static-src/js/boot.js @@ -14,15 +14,27 @@ // The class is set here, before first paint, so the chrome never flashes. // Tracker sounds are on by default in kiosk mode (the streamer captures them // through a PulseAudio null sink); `&sound=off` keeps the display silent. +// Pop-out mode (#15829): `?popout=1` is the same chrome-less, tracker-only +// layout for an operator's second monitor — opened by the ⧉ button in the +// activity monitor header via window.open. Unlike kiosk it is attended: the +// cursor stays, the settings gear works, preferences persist as usual, and a +// "Return to dashboard" link focuses the opener. Reloading keeps the layout +// because the flag lives in the URL. (function(){ - var kiosk=false, sound=true; - try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} + var kiosk=false, popout=false, sound=true; + try { var u=new URL(window.location.href); kiosk=u.searchParams.get('kiosk')==='1'; popout=u.searchParams.get('popout')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} window.HIVE_KIOSK=kiosk; + window.HIVE_POPOUT=popout&&!kiosk; window.HIVE_KIOSK_SOUND=kiosk&&sound; window.hiveKioskMode=function(){ return !!window.HIVE_KIOSK; }; + window.hivePopoutMode=function(){ return !!window.HIVE_POPOUT; }; window.hiveKioskSoundOn=function(){ return !!window.HIVE_KIOSK_SOUND; }; if(kiosk){ document.body.classList.add('kiosk-mode'); + }else if(window.HIVE_POPOUT){ + document.body.classList.add('popout-mode'); + } + if(kiosk||window.HIVE_POPOUT){ if(!location.hash) history.replaceState(null,'',location.pathname+location.search+'#section-activity-monitor-section'); } })(); diff --git a/src/pkg/dashboard/static-src/js/nps.js b/src/pkg/dashboard/static-src/js/nps.js index 98551e541a..247b350560 100644 --- a/src/pkg/dashboard/static-src/js/nps.js +++ b/src/pkg/dashboard/static-src/js/nps.js @@ -237,6 +237,7 @@ function showNPSSurvey(status) { if (_npsShownThisLoad || _npsCard) return; if (window.hiveKioskMode && window.hiveKioskMode()) return; + if (window.hivePopoutMode && window.hivePopoutMode()) return; _npsShownThisLoad = true; const maxChars = Number(status && status.max_feedback_chars) || 0; let selected = null; diff --git a/src/pkg/dashboard/static-src/js/refresh.js b/src/pkg/dashboard/static-src/js/refresh.js index cd85642335..492fddb47b 100644 --- a/src/pkg/dashboard/static-src/js/refresh.js +++ b/src/pkg/dashboard/static-src/js/refresh.js @@ -523,6 +523,7 @@ if (hiveIdBadge) hiveIdBadge.textContent = hiveId; const ocHiveId = document.getElementById('oc-hive-id'); if (ocHiveId) ocHiveId.textContent = hiveId; + if (typeof stageTrackerPopoutSyncTitle === 'function') stageTrackerPopoutSyncTitle(hiveId); // Update Light health badge with hover detail renderNavbarHealthBadge(document.getElementById('oc-health'), data); renderProviderStrip(document.getElementById('oc-providers'), data.providers); diff --git a/src/pkg/dashboard/static-src/js/sections.js b/src/pkg/dashboard/static-src/js/sections.js index 766a990101..b4930fba24 100644 --- a/src/pkg/dashboard/static-src/js/sections.js +++ b/src/pkg/dashboard/static-src/js/sections.js @@ -74,6 +74,12 @@ return ``; } + // Pop out / full screen / return (hivecommons/hive#15829), rendered next to + // the activity monitor's gear; handlers live in js/tracker-popout.js and + // css/popout.css decides which of the three show in which mode. + const STAGE_TRACKER_HEADER_TOOLS_HTML = '' + + '' + + ''; const DASHBOARD_SECTION_CARD_CONFIG = Object.freeze({ 'overview-section': { title: '🍩 Overview', summary: 'overview', actionIds: ['overview-chart-settings'], settingsHtml: sectionSettingsGear('Overview', 'toggleOverviewChartSettings', 'Configure Overview chart types, carousel timing, and transitions', ' aria-haspopup="true" aria-expanded="false" aria-controls="overview-chart-settings"') }, 'governor': { title: '🚦 Governor', summary: 'idle', settingsHtml: sectionSettingsGear('Governor', 'openConfigDialog', 'Open Governor configuration — manage agents, thresholds, budget, notifications, health checks, and sensing patterns', ' data-arg0="governor"') }, @@ -101,7 +107,7 @@ 'logs-section': { title: '📋 Agent Logs', summary: 'logs' }, 'agents-section': { title: '🤖 Agents', summary: '0 running / 0 total' }, 'agent-activity-section': { title: '📡 Agent activity', summary: '0 working / 0 total' }, - 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') }, + 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML }, 'faq-section': { title: '❓ FAQ', summary: 'questions' }, }); // Section help marks (#10915). Each entry's help sentence is word for word diff --git a/src/pkg/dashboard/static-src/js/sse-bootstrap.js b/src/pkg/dashboard/static-src/js/sse-bootstrap.js index 0c9e735833..5c98d043fd 100644 --- a/src/pkg/dashboard/static-src/js/sse-bootstrap.js +++ b/src/pkg/dashboard/static-src/js/sse-bootstrap.js @@ -169,7 +169,7 @@ const el = document.getElementById("project-name"); if (el && repoDisplay) { el.textContent = "for " + repoDisplay; - document.title = "Hive Dashboard for " + repoDisplay; + if (!(window.hivePopoutMode && window.hivePopoutMode())) document.title = "Hive Dashboard for " + repoDisplay; } const ocEl = document.getElementById("oc-project-name"); if (ocEl && repoDisplay) ocEl.textContent = repoDisplay; diff --git a/src/pkg/dashboard/static-src/js/tracker-popout.js b/src/pkg/dashboard/static-src/js/tracker-popout.js new file mode 100644 index 0000000000..5d7af4b796 --- /dev/null +++ b/src/pkg/dashboard/static-src/js/tracker-popout.js @@ -0,0 +1,158 @@ + /* ---- Pop out & full screen ------------------------------------------- + Two header buttons next to the settings gear (hivecommons/hive#15829) + for an operator who wants the activity monitor on another monitor + while they do other work. ⧉ opens the SPA in a named popup window on + `?popout=1#section-activity-monitor-section`; boot.js reads the flag + before first paint and css/popout.css hides every piece of chrome and + every other section, so the new window is the tracker and nothing + else. The bearer token is in localStorage, so the popup is already + signed in. ⛶ toggles the Fullscreen API on the section itself (and + `f` does the same while focus is inside the tracker); Esc exits + natively and the label flips through the fullscreenchange event. + Nothing is persisted: the only state is the URL of the popup. */ + const STAGE_TRACKER_POPOUT_PARAM = 'popout'; + const STAGE_TRACKER_POPOUT_WINDOW_NAME = 'hive-activity-monitor'; + const STAGE_TRACKER_POPOUT_FEATURES = 'popup,width=1600,height=900'; + const STAGE_TRACKER_POPOUT_HASH = '#section-activity-monitor-section'; + const STAGE_TRACKER_POPOUT_TITLE = 'Hive · Activity Monitor'; + const STAGE_TRACKER_FULLSCREEN_KEY = 'f'; + const STAGE_TRACKER_FULLSCREEN_LABELS = { + enter: { text: '⛶', title: 'Full screen — fill the screen with the activity monitor (f, Esc exits)' }, + exit: { text: '⛶ Exit full screen', title: 'Exit full screen (Esc or f)' }, + }; + var _stageTrackerPopoutHiveId = ''; + + // Pure: the pop-out URL for the window the operator is on. Keeps the + // origin, path and any other query (theme, style…), drops kiosk so the + // attended layout wins, and lands on the activity monitor section. + function stageTrackerPopoutUrl(href) { + let url; + try { url = new URL(href); } catch { return ''; } + url.searchParams.set(STAGE_TRACKER_POPOUT_PARAM, '1'); + url.searchParams.delete('kiosk'); + url.searchParams.delete('filter'); + url.hash = STAGE_TRACKER_POPOUT_HASH; + return url.toString(); + } + // Pure: the main-dashboard URL a pop-out falls back to when the browser + // refuses to close it (a tab the operator opened directly, not a popup). + function stageTrackerDashboardUrl(href) { + let url; + try { url = new URL(href); } catch { return ''; } + url.searchParams.delete(STAGE_TRACKER_POPOUT_PARAM); + url.hash = STAGE_TRACKER_POPOUT_HASH; + return url.toString(); + } + // Pure: the pop-out window title; the hive id joins once /api/status + // has delivered it. + function stageTrackerPopoutTitle(hiveId) { + const id = String(hiveId || '').trim(); + return id ? STAGE_TRACKER_POPOUT_TITLE + ' · ' + id : STAGE_TRACKER_POPOUT_TITLE; + } + function stageTrackerPopoutMode() { + return !!(window.hivePopoutMode && window.hivePopoutMode()); + } + function stageTrackerPopoutSyncTitle(hiveId) { + if (hiveId !== undefined) _stageTrackerPopoutHiveId = hiveId || ''; + if (!stageTrackerPopoutMode()) return; + document.title = stageTrackerPopoutTitle(_stageTrackerPopoutHiveId); + } + function openStageTrackerPopout() { + const url = stageTrackerPopoutUrl(window.location.href); + if (!url) return null; + let win = null; + try { win = window.open(url, STAGE_TRACKER_POPOUT_WINDOW_NAME, STAGE_TRACKER_POPOUT_FEATURES); } catch { win = null; } + if (!win) { + if (typeof showToast === 'function') showToast('The browser blocked the pop-out window — allow pop-ups for this site and try again.', 'error'); + return null; + } + try { win.focus(); } catch {} + return win; + } + // ⤶ Return to dashboard: bring the opener forward and close this + // pop-out. A window the operator navigated to by hand cannot be + // closed by script, so it navigates back to the full dashboard instead. + function stageTrackerReturnToDashboard() { + try { if (window.opener && !window.opener.closed) window.opener.focus(); } catch {} + try { window.close(); } catch {} + if (!window.closed) { + const url = stageTrackerDashboardUrl(window.location.href); + if (url) window.location.assign(url); + } + } + + // The whole document goes full screen (not the section) so the + // body-level toasts — waiting on you, merge celebrations — stay + // visible; body.ham-fullscreen then applies the pop-out layout. + function stageTrackerFullscreenTarget() { + return document.documentElement; + } + function stageTrackerFullscreenButton() { + return document.getElementById('activity-monitor-fullscreen'); + } + function stageTrackerIsFullscreen() { + return !!(document.fullscreenElement && document.fullscreenElement === stageTrackerFullscreenTarget()) && document.body.classList.contains('ham-fullscreen'); + } + // Pure: label + title for the ⛶ button given the current state. + function stageTrackerFullscreenLabel(isFull) { + return isFull ? STAGE_TRACKER_FULLSCREEN_LABELS.exit : STAGE_TRACKER_FULLSCREEN_LABELS.enter; + } + function stageTrackerRenderFullscreenButton() { + // Esc (or the browser) leaving full screen must drop the layout too. + if (!document.fullscreenElement) document.body.classList.remove('ham-fullscreen'); + const full = stageTrackerIsFullscreen(); + const btn = stageTrackerFullscreenButton(); + if (!btn) return; + const label = stageTrackerFullscreenLabel(full); + btn.textContent = label.text; + btn.title = label.title; + btn.setAttribute('aria-label', label.title); + btn.setAttribute('aria-pressed', full ? 'true' : 'false'); + } + function toggleStageTrackerFullscreen() { + const target = stageTrackerFullscreenTarget(); + if (!target) return Promise.resolve(false); + let p; + if (stageTrackerIsFullscreen()) { + document.body.classList.remove('ham-fullscreen'); + p = document.exitFullscreen ? document.exitFullscreen() : Promise.resolve(); + } else if (target.requestFullscreen) { + document.body.classList.add('ham-fullscreen'); + p = target.requestFullscreen(); + } else { + if (typeof showToast === 'function') showToast('This browser does not support full screen here.', 'error'); + return Promise.resolve(false); + } + return Promise.resolve(p).then(() => { stageTrackerRenderFullscreenButton(); return true; }, (err) => { + document.body.classList.remove('ham-fullscreen'); + stageTrackerRenderFullscreenButton(); + if (typeof showToast === 'function') showToast('Full screen was refused: ' + ((err && err.message) || err), 'error'); + return false; + }); + } + // Pure: should this keydown toggle full screen? Only a bare `f` with + // focus inside the tracker (or anywhere, in a pop-out — the whole page + // is the tracker), never while typing in a field. + function stageTrackerFullscreenHotkey(ev, inTracker, typing, popout) { + if (!ev || ev.key !== STAGE_TRACKER_FULLSCREEN_KEY) return false; + if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.shiftKey) return false; + if (typing) return false; + return !!(inTracker || popout); + } + document.addEventListener('keydown', function(e) { + const t = e.target; + const tag = ((t && t.tagName) || '').toLowerCase(); + const typing = tag === 'input' || tag === 'textarea' || tag === 'select' || !!(t && t.isContentEditable); + const section = document.getElementById('activity-monitor-section'); + const inTracker = !!(section && t && t.nodeType === 1 && section.contains(t)) || stageTrackerIsFullscreen(); + if (!stageTrackerFullscreenHotkey(e, inTracker, typing, stageTrackerPopoutMode())) return; + const overlay = document.getElementById('activity-monitor-settings-overlay'); + if (overlay && !overlay.classList.contains('hidden')) return; + e.preventDefault(); + toggleStageTrackerFullscreen(); + }); + document.addEventListener('fullscreenchange', stageTrackerRenderFullscreenButton); + document.addEventListener('DOMContentLoaded', function() { + stageTrackerRenderFullscreenButton(); + stageTrackerPopoutSyncTitle(); + }); diff --git a/src/pkg/dashboard/static-src/js/welcome.js b/src/pkg/dashboard/static-src/js/welcome.js index bcf200f4ab..cf61ad8a3e 100644 --- a/src/pkg/dashboard/static-src/js/welcome.js +++ b/src/pkg/dashboard/static-src/js/welcome.js @@ -45,6 +45,8 @@ const topBtn = document.getElementById('welcome-topbar-btn'); if (topBtn) topBtn.style.display = ''; // Kiosk displays (#15594) are unattended: nothing can dismiss a dialog. + // A pop-out (#15829) is the tracker alone; the welcome tour belongs to the main window. + if (window.hivePopoutMode && window.hivePopoutMode()) return; if (!_welcomeState.dismissed && !(window.hiveKioskMode && window.hiveKioskMode())) openWelcomeDialog(); } diff --git a/src/pkg/dashboard/static-src/manifest.txt b/src/pkg/dashboard/static-src/manifest.txt index 2a7cd02568..53ea46d019 100644 --- a/src/pkg/dashboard/static-src/manifest.txt +++ b/src/pkg/dashboard/static-src/manifest.txt @@ -31,6 +31,7 @@ css/recipes-utilities.css css/welcome.css css/review-campaigns.css css/kiosk.css +css/popout.css css/variables.css glue/style-close-body-open.html js/boot.js @@ -78,6 +79,7 @@ js/tracker-merged.js js/tracker-queue.js js/tracker-sound.js js/tracker-waiting.js +js/tracker-popout.js js/agent-cards.js js/banners.js js/governor-view.js diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index c14ecd8ad1..36416d8bae 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -6728,6 +6728,60 @@ body.kiosk-mode #activity-monitor-section > .section-label { pointer-events: none; } body.kiosk-mode .ham-sticky { top: 0; } body.kiosk-mode .ham-cols { top: var(--ham-sticky-bar-h); } +/* ---- pop-out & full screen: the activity monitor on its own (#15829) ---- + `?popout=1` (see js/boot.js) is what the ⧉ header button opens in a + named popup window so an operator can park the tracker on a second + monitor. Same chrome-less layout as kiosk — no sidebar, topbar, avatar + menu, chat FAB or notices, every other section out of flow — but attended: + the cursor stays, the gear works, and a ⤶ Return link goes back to the + opener. The ⛶ button puts the document into the Fullscreen API and sets + body.ham-fullscreen, which shares every rule below — the document rather + than the section so the body-level toasts (waiting on you, merges) stay + visible while full screen. */ + body.popout-mode, body.ham-fullscreen { padding: var(--sp-5) var(--sp-7) var(--sp-7) var(--sp-7); --navbar-sticky-height: 0px; } + body.popout-mode .oc-sidebar, body.popout-mode .oc-sidebar-resize, body.popout-mode .oc-topbar, + body.popout-mode #dash-notices, body.popout-mode #oc-agent-detail, body.popout-mode .hive-chat-fab, + body.popout-mode .hive-chat-panel, body.popout-mode #welcome-overlay, body.popout-mode .nps-card, + body.ham-fullscreen .oc-sidebar, body.ham-fullscreen .oc-sidebar-resize, body.ham-fullscreen .oc-topbar, + body.ham-fullscreen #dash-notices, body.ham-fullscreen #oc-agent-detail, body.ham-fullscreen .hive-chat-fab, + body.ham-fullscreen .hive-chat-panel { display: none !important; } + /* /api/theme.css (theme/theme.go layoutGuardCSS) forces the topbar to + display:grid!important with id specificity; beat it with (1,2,2). */ + html body.popout-mode #oc-topbar[id], html body.ham-fullscreen #oc-topbar[id] { display: none !important; } + body.popout-mode #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section), + body.ham-fullscreen #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section) { display: none !important; } + body.popout-mode #activity-monitor-section .dashboard-grip, body.popout-mode #activity-monitor-section .section-chevron, + body.ham-fullscreen #activity-monitor-section .dashboard-grip, body.ham-fullscreen #activity-monitor-section .section-chevron { display: none !important; } + /* The header cannot collapse the only section on the page, but its + gear, full-screen and return buttons must still take clicks. */ + body.popout-mode #activity-monitor-section .section-header-toggle, + body.ham-fullscreen #activity-monitor-section .section-header-toggle { pointer-events: none; } + body.popout-mode #activity-monitor-section .section-header-toggle button, + body.popout-mode #activity-monitor-section .section-header-toggle .config-info, + body.ham-fullscreen #activity-monitor-section .section-header-toggle button, + body.ham-fullscreen #activity-monitor-section .section-header-toggle .config-info { pointer-events: auto; } + /* A collapsed state saved from the main window would leave an empty + page with a header that cannot be clicked: always show the body. */ + body.popout-mode #activity-monitor-section .section-body.collapsed, + body.ham-fullscreen #activity-monitor-section .section-body.collapsed { max-height: none !important; opacity: 1; pointer-events: auto; } + body.popout-mode #activity-monitor-section .dash-card.collapsed .dash-card-actions, + body.ham-fullscreen #activity-monitor-section .dash-card.collapsed .dash-card-actions { display: inline-flex; } + body.popout-mode #activity-monitor-section .dash-card.collapsed .dash-card-summary, + body.ham-fullscreen #activity-monitor-section .dash-card.collapsed .dash-card-summary { display: none; } + body.popout-mode .ham-sticky, body.ham-fullscreen .ham-sticky { top: 0; } + body.popout-mode .ham-cols, body.ham-fullscreen .ham-cols { top: var(--ham-sticky-bar-h); } + + /* Header tools: ⧉ pop out and ⛶ full screen sit beside the gear and + share its chip styling; the return link is a pop-out-only text pill. */ + .ham-header-tool { width: auto; min-width: 15px; padding: 0 var(--sp-1); font-size: var(--fs-2xs); line-height: 1; color: var(--muted); white-space: nowrap; } + .ham-header-tool[aria-pressed="true"] { color: var(--blue); border-color: var(--blue); } + .ham-popout-return { display: none; margin-left: var(--sp-2); padding: 0 var(--sp-2); height: 15px; border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--blue) 60%, transparent); background: color-mix(in srgb, var(--blue) 18%, var(--panel)); color: var(--blue); font: inherit; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0; line-height: 1; white-space: nowrap; cursor: pointer; } + .ham-popout-return:hover, .ham-popout-return:focus-visible { background: var(--blue); color: var(--bg); outline: none; } + body.popout-mode .ham-popout-return { display: inline-flex; align-items: center; } + /* A window that already is the tracker has nothing to pop out, and a + kiosk has no one to click. */ + body.popout-mode .ham-popout-btn, body.ham-fullscreen .ham-popout-btn, + body.kiosk-mode .ham-header-tool, body.kiosk-mode .ham-popout-return { display: none !important; } .var-empty{color:var(--muted);font-size:var(--fs-sm);padding:var(--sp-2) var(--sp-0)} .var-section{margin-top:var(--sp-6);border-top:1px solid var(--border);padding-top:var(--sp-5)} .var-heading{font-weight:600;font-size:var(--fs-sm);margin-bottom:var(--sp-4)} @@ -6761,15 +6815,27 @@ // The class is set here, before first paint, so the chrome never flashes. // Tracker sounds are on by default in kiosk mode (the streamer captures them // through a PulseAudio null sink); `&sound=off` keeps the display silent. +// Pop-out mode (#15829): `?popout=1` is the same chrome-less, tracker-only +// layout for an operator's second monitor — opened by the ⧉ button in the +// activity monitor header via window.open. Unlike kiosk it is attended: the +// cursor stays, the settings gear works, preferences persist as usual, and a +// "Return to dashboard" link focuses the opener. Reloading keeps the layout +// because the flag lives in the URL. (function(){ - var kiosk=false, sound=true; - try { kiosk=new URL(window.location.href).searchParams.get('kiosk')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} + var kiosk=false, popout=false, sound=true; + try { var u=new URL(window.location.href); kiosk=u.searchParams.get('kiosk')==='1'; popout=u.searchParams.get('popout')==='1'; sound=new URL(window.location.href).searchParams.get('sound')!=='off'; } catch(e) {} window.HIVE_KIOSK=kiosk; + window.HIVE_POPOUT=popout&&!kiosk; window.HIVE_KIOSK_SOUND=kiosk&&sound; window.hiveKioskMode=function(){ return !!window.HIVE_KIOSK; }; + window.hivePopoutMode=function(){ return !!window.HIVE_POPOUT; }; window.hiveKioskSoundOn=function(){ return !!window.HIVE_KIOSK_SOUND; }; if(kiosk){ document.body.classList.add('kiosk-mode'); + }else if(window.HIVE_POPOUT){ + document.body.classList.add('popout-mode'); + } + if(kiosk||window.HIVE_POPOUT){ if(!location.hash) history.replaceState(null,'',location.pathname+location.search+'#section-activity-monitor-section'); } })(); @@ -8840,6 +8906,12 @@

Where to get help

return ``; } + // Pop out / full screen / return (hivecommons/hive#15829), rendered next to + // the activity monitor's gear; handlers live in js/tracker-popout.js and + // css/popout.css decides which of the three show in which mode. + const STAGE_TRACKER_HEADER_TOOLS_HTML = '' + + '' + + ''; const DASHBOARD_SECTION_CARD_CONFIG = Object.freeze({ 'overview-section': { title: '🍩 Overview', summary: 'overview', actionIds: ['overview-chart-settings'], settingsHtml: sectionSettingsGear('Overview', 'toggleOverviewChartSettings', 'Configure Overview chart types, carousel timing, and transitions', ' aria-haspopup="true" aria-expanded="false" aria-controls="overview-chart-settings"') }, 'governor': { title: '🚦 Governor', summary: 'idle', settingsHtml: sectionSettingsGear('Governor', 'openConfigDialog', 'Open Governor configuration — manage agents, thresholds, budget, notifications, health checks, and sensing patterns', ' data-arg0="governor"') }, @@ -8867,7 +8939,7 @@

Where to get help

'logs-section': { title: '📋 Agent Logs', summary: 'logs' }, 'agents-section': { title: '🤖 Agents', summary: '0 running / 0 total' }, 'agent-activity-section': { title: '📡 Agent activity', summary: '0 working / 0 total' }, - 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') }, + 'activity-monitor-section': { title: '📍 Hive activity monitor', summary: '0 items', actionIds: ['activity-monitor-settings'], settingsHtml: sectionSettingsGear('Hive activity monitor', 'toggleStageTrackerSettings', 'Configure Hive activity monitor sounds — open buzz, merge zap, your own WAV files, volume', ' aria-haspopup="true" aria-expanded="false" aria-controls="activity-monitor-settings"') + STAGE_TRACKER_HEADER_TOOLS_HTML }, 'faq-section': { title: '❓ FAQ', summary: 'questions' }, }); // Section help marks (#10915). Each entry's help sentence is word for word @@ -23501,6 +23573,164 @@

All labels

stageTrackerSaveFilter(); return true; } + /* ---- Pop out & full screen ------------------------------------------- + Two header buttons next to the settings gear (hivecommons/hive#15829) + for an operator who wants the activity monitor on another monitor + while they do other work. ⧉ opens the SPA in a named popup window on + `?popout=1#section-activity-monitor-section`; boot.js reads the flag + before first paint and css/popout.css hides every piece of chrome and + every other section, so the new window is the tracker and nothing + else. The bearer token is in localStorage, so the popup is already + signed in. ⛶ toggles the Fullscreen API on the section itself (and + `f` does the same while focus is inside the tracker); Esc exits + natively and the label flips through the fullscreenchange event. + Nothing is persisted: the only state is the URL of the popup. */ + const STAGE_TRACKER_POPOUT_PARAM = 'popout'; + const STAGE_TRACKER_POPOUT_WINDOW_NAME = 'hive-activity-monitor'; + const STAGE_TRACKER_POPOUT_FEATURES = 'popup,width=1600,height=900'; + const STAGE_TRACKER_POPOUT_HASH = '#section-activity-monitor-section'; + const STAGE_TRACKER_POPOUT_TITLE = 'Hive · Activity Monitor'; + const STAGE_TRACKER_FULLSCREEN_KEY = 'f'; + const STAGE_TRACKER_FULLSCREEN_LABELS = { + enter: { text: '⛶', title: 'Full screen — fill the screen with the activity monitor (f, Esc exits)' }, + exit: { text: '⛶ Exit full screen', title: 'Exit full screen (Esc or f)' }, + }; + var _stageTrackerPopoutHiveId = ''; + + // Pure: the pop-out URL for the window the operator is on. Keeps the + // origin, path and any other query (theme, style…), drops kiosk so the + // attended layout wins, and lands on the activity monitor section. + function stageTrackerPopoutUrl(href) { + let url; + try { url = new URL(href); } catch { return ''; } + url.searchParams.set(STAGE_TRACKER_POPOUT_PARAM, '1'); + url.searchParams.delete('kiosk'); + url.searchParams.delete('filter'); + url.hash = STAGE_TRACKER_POPOUT_HASH; + return url.toString(); + } + // Pure: the main-dashboard URL a pop-out falls back to when the browser + // refuses to close it (a tab the operator opened directly, not a popup). + function stageTrackerDashboardUrl(href) { + let url; + try { url = new URL(href); } catch { return ''; } + url.searchParams.delete(STAGE_TRACKER_POPOUT_PARAM); + url.hash = STAGE_TRACKER_POPOUT_HASH; + return url.toString(); + } + // Pure: the pop-out window title; the hive id joins once /api/status + // has delivered it. + function stageTrackerPopoutTitle(hiveId) { + const id = String(hiveId || '').trim(); + return id ? STAGE_TRACKER_POPOUT_TITLE + ' · ' + id : STAGE_TRACKER_POPOUT_TITLE; + } + function stageTrackerPopoutMode() { + return !!(window.hivePopoutMode && window.hivePopoutMode()); + } + function stageTrackerPopoutSyncTitle(hiveId) { + if (hiveId !== undefined) _stageTrackerPopoutHiveId = hiveId || ''; + if (!stageTrackerPopoutMode()) return; + document.title = stageTrackerPopoutTitle(_stageTrackerPopoutHiveId); + } + function openStageTrackerPopout() { + const url = stageTrackerPopoutUrl(window.location.href); + if (!url) return null; + let win = null; + try { win = window.open(url, STAGE_TRACKER_POPOUT_WINDOW_NAME, STAGE_TRACKER_POPOUT_FEATURES); } catch { win = null; } + if (!win) { + if (typeof showToast === 'function') showToast('The browser blocked the pop-out window — allow pop-ups for this site and try again.', 'error'); + return null; + } + try { win.focus(); } catch {} + return win; + } + // ⤶ Return to dashboard: bring the opener forward and close this + // pop-out. A window the operator navigated to by hand cannot be + // closed by script, so it navigates back to the full dashboard instead. + function stageTrackerReturnToDashboard() { + try { if (window.opener && !window.opener.closed) window.opener.focus(); } catch {} + try { window.close(); } catch {} + if (!window.closed) { + const url = stageTrackerDashboardUrl(window.location.href); + if (url) window.location.assign(url); + } + } + + // The whole document goes full screen (not the section) so the + // body-level toasts — waiting on you, merge celebrations — stay + // visible; body.ham-fullscreen then applies the pop-out layout. + function stageTrackerFullscreenTarget() { + return document.documentElement; + } + function stageTrackerFullscreenButton() { + return document.getElementById('activity-monitor-fullscreen'); + } + function stageTrackerIsFullscreen() { + return !!(document.fullscreenElement && document.fullscreenElement === stageTrackerFullscreenTarget()) && document.body.classList.contains('ham-fullscreen'); + } + // Pure: label + title for the ⛶ button given the current state. + function stageTrackerFullscreenLabel(isFull) { + return isFull ? STAGE_TRACKER_FULLSCREEN_LABELS.exit : STAGE_TRACKER_FULLSCREEN_LABELS.enter; + } + function stageTrackerRenderFullscreenButton() { + // Esc (or the browser) leaving full screen must drop the layout too. + if (!document.fullscreenElement) document.body.classList.remove('ham-fullscreen'); + const full = stageTrackerIsFullscreen(); + const btn = stageTrackerFullscreenButton(); + if (!btn) return; + const label = stageTrackerFullscreenLabel(full); + btn.textContent = label.text; + btn.title = label.title; + btn.setAttribute('aria-label', label.title); + btn.setAttribute('aria-pressed', full ? 'true' : 'false'); + } + function toggleStageTrackerFullscreen() { + const target = stageTrackerFullscreenTarget(); + if (!target) return Promise.resolve(false); + let p; + if (stageTrackerIsFullscreen()) { + document.body.classList.remove('ham-fullscreen'); + p = document.exitFullscreen ? document.exitFullscreen() : Promise.resolve(); + } else if (target.requestFullscreen) { + document.body.classList.add('ham-fullscreen'); + p = target.requestFullscreen(); + } else { + if (typeof showToast === 'function') showToast('This browser does not support full screen here.', 'error'); + return Promise.resolve(false); + } + return Promise.resolve(p).then(() => { stageTrackerRenderFullscreenButton(); return true; }, (err) => { + document.body.classList.remove('ham-fullscreen'); + stageTrackerRenderFullscreenButton(); + if (typeof showToast === 'function') showToast('Full screen was refused: ' + ((err && err.message) || err), 'error'); + return false; + }); + } + // Pure: should this keydown toggle full screen? Only a bare `f` with + // focus inside the tracker (or anywhere, in a pop-out — the whole page + // is the tracker), never while typing in a field. + function stageTrackerFullscreenHotkey(ev, inTracker, typing, popout) { + if (!ev || ev.key !== STAGE_TRACKER_FULLSCREEN_KEY) return false; + if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.shiftKey) return false; + if (typing) return false; + return !!(inTracker || popout); + } + document.addEventListener('keydown', function(e) { + const t = e.target; + const tag = ((t && t.tagName) || '').toLowerCase(); + const typing = tag === 'input' || tag === 'textarea' || tag === 'select' || !!(t && t.isContentEditable); + const section = document.getElementById('activity-monitor-section'); + const inTracker = !!(section && t && t.nodeType === 1 && section.contains(t)) || stageTrackerIsFullscreen(); + if (!stageTrackerFullscreenHotkey(e, inTracker, typing, stageTrackerPopoutMode())) return; + const overlay = document.getElementById('activity-monitor-settings-overlay'); + if (overlay && !overlay.classList.contains('hidden')) return; + e.preventDefault(); + toggleStageTrackerFullscreen(); + }); + document.addEventListener('fullscreenchange', stageTrackerRenderFullscreenButton); + document.addEventListener('DOMContentLoaded', function() { + stageTrackerRenderFullscreenButton(); + stageTrackerPopoutSyncTitle(); + }); function parseCadenceMinutes(cadence) { if (!cadence || cadence === 'paused' || cadence === 'off' || cadence === 'on demand') return 0; const m = cadence.match(/^(\d+)(m|h)$/); @@ -41055,6 +41285,7 @@ if (hiveIdBadge) hiveIdBadge.textContent = hiveId; const ocHiveId = document.getElementById('oc-hive-id'); if (ocHiveId) ocHiveId.textContent = hiveId; + if (typeof stageTrackerPopoutSyncTitle === 'function') stageTrackerPopoutSyncTitle(hiveId); // Update Light health badge with hover detail renderNavbarHealthBadge(document.getElementById('oc-health'), data); renderProviderStrip(document.getElementById('oc-providers'), data.providers); @@ -47305,7 +47536,7 @@

Configure LiteLLM

const el = document.getElementById("project-name"); if (el && repoDisplay) { el.textContent = "for " + repoDisplay; - document.title = "Hive Dashboard for " + repoDisplay; + if (!(window.hivePopoutMode && window.hivePopoutMode())) document.title = "Hive Dashboard for " + repoDisplay; } const ocEl = document.getElementById("oc-project-name"); if (ocEl && repoDisplay) ocEl.textContent = repoDisplay; @@ -62549,6 +62780,7 @@

${esc(s.title)}

function showNPSSurvey(status) { if (_npsShownThisLoad || _npsCard) return; if (window.hiveKioskMode && window.hiveKioskMode()) return; + if (window.hivePopoutMode && window.hivePopoutMode()) return; _npsShownThisLoad = true; const maxChars = Number(status && status.max_feedback_chars) || 0; let selected = null; @@ -62695,6 +62927,8 @@

${esc(s.title)}

const topBtn = document.getElementById('welcome-topbar-btn'); if (topBtn) topBtn.style.display = ''; // Kiosk displays (#15594) are unattended: nothing can dismiss a dialog. + // A pop-out (#15829) is the tracker alone; the welcome tour belongs to the main window. + if (window.hivePopoutMode && window.hivePopoutMode()) return; if (!_welcomeState.dismissed && !(window.hiveKioskMode && window.hiveKioskMode())) openWelcomeDialog(); }