diff --git a/changelog.d/1549-cockpit-phone-utility-row.md b/changelog.d/1549-cockpit-phone-utility-row.md new file mode 100644 index 0000000000..e3e59d6ea6 --- /dev/null +++ b/changelog.d/1549-cockpit-phone-utility-row.md @@ -0,0 +1,9 @@ +- Keep the phone Cockpit's Display and Radio launchers off the flight + instruments. In the phone layout (720 px wide and below), the collapsed row + of the flight and bridge views now sits centred on the Reset/Exit axis + above the reticle, clear of the destination cue, instead of right-anchored + over the ground speed and altitude readouts. On short landscape phones it + stays on screen and tappable below the vision controls, though it may cover + the top of the readouts. Very short or narrow split-screen windows keep + the old place above Reset/Exit. The first-visit Stories announcement waits until + Cockpit closes (Denis Groshev, @ZloyS, #1549). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index fb90e23b51..9a78ce4007 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -5162,9 +5162,20 @@ down | auth-failed` (plus the unchanged `missing-key`/`unsupported`) with > stacking. Narrow mobile Cockpit > viewports suppress the legacy layer stack, peripheral HUD, and secondary > Context/briefing panes so the flight instruments and primary controls remain -> unobstructed. Outside Cockpit, Radio starts collapsed while off and lives -> only in its section inside Context; the detailed panel's normal accordion -> control owns its disclosure and its Enable/Disable action owns power. +> unobstructed. In the phone layout (720 px wide and below) the flight and +> bridge views put the collapsed Display and Radio launchers in one row +> centred on the Reset/Exit axis, above the reticle and clear of the +> destination cue: below the roll arc in portrait, over the arc's lower tick +> ends in landscape. On short landscape screens the row stays +> on screen and tappable below the vision controls but may cover the top of +> the speed and altitude readouts. Windows under 240 px tall, and those under +> 390 px wide and 450 px tall, keep the row above Reset/Exit at the right. +> Satellite and provider views keep the row +> above Reset/Exit at the right, where their own layouts expect it. The +> first-visit Stories announcement waits, unread, until Cockpit closes. +> Outside Cockpit, Radio starts collapsed while off and lives only in its +> section inside Context; the detailed panel's normal accordion control +> owns its disclosure and its Enable/Disable action owns power. > Radio volume in the full and Cockpit surfaces, plus Space Mission > replay speed, use Display / Sharpen's muted 3px rail, circular cyan thumb, > glow, and mono value treatment. Their larger transparent hit areas, keyboard diff --git a/scripts/qa-cockpit-utility.mjs b/scripts/qa-cockpit-utility.mjs index 3ca0e81773..157592d398 100644 --- a/scripts/qa-cockpit-utility.mjs +++ b/scripts/qa-cockpit-utility.mjs @@ -2050,6 +2050,151 @@ try { JSON.stringify(narrowViewActions), ); + // A fresh profile has not seen the Stories announcement: Cockpit keeps + // it unread and off the phone row until it closes. + const storiesPopupDisplay = () => { + const popup = document.getElementById('hPop'); + return popup ? getComputedStyle(popup).display : null; + }; + const storiesPopupInCockpit = await page.evaluate(storiesPopupDisplay); + check('the unread Stories announcement waits while Cockpit is open', + storiesPopupInCockpit === 'none', String(storiesPopupInCockpit)); + + // Windows too short for the centred row keep it above Reset/Exit. + for (const [width, height] of [[360, 370], [320, 360], [568, 188], [667, 190]]) { + await page.setViewport({ width, height, deviceScaleFactor: 1 }); + const glyphHits = await page.evaluate(async () => { + const manager = window.__godsEyeView.styleManager; + manager._setCockpitDisclosure('display', false); + manager._setCockpitDisclosure('radio', false); + await new Promise(requestAnimationFrame); + await new Promise(requestAnimationFrame); + return [...document.querySelectorAll( + '#cockpit-utility-controls .cockpit-utility-glyph', + )].map((glyph) => { + const box = glyph.getBoundingClientRect(); + const target = document.elementFromPoint( + box.left + box.width / 2, + box.top + box.height / 2, + ); + return target && glyph.contains(target) ? 'ok' : target?.closest('[id]')?.id || null; + }); + }); + check( + `${width}×${height} Cockpit Display/Radio glyph centres reach their own launchers`, + glyphHits.length === 2 && glyphHits.every((hit) => hit === 'ok'), + JSON.stringify(glyphHits), + ); + } + + // The phone row's place in each room: centred on Reset/Exit, on screen, + // tappable, and clear of what that room has space to clear. + for (const [width, height, room] of [ + [360, 740, 'portrait'], + [720, 360, 'landscape'], + [667, 240, 'short'], + [390, 844, 'portrait'], + ]) { + await page.setViewport({ width, height, deviceScaleFactor: 1 }); + const phoneRow = await page.evaluate(async () => { + const manager = window.__godsEyeView.styleManager; + manager._setCockpitDisclosure('display', false); + manager._setCockpitDisclosure('radio', false); + await new Promise(requestAnimationFrame); + manager.cockpitView.syncSignalLayout(); + await new Promise(requestAnimationFrame); + const rect = (element) => element?.getBoundingClientRect().toJSON() || null; + const hud = (selector) => document.querySelector(`#cockpit-hud ${selector}`); + const route = document.getElementById('cockpit-route-direction'); + // A live flight may have no route, which hides the DEST cue. Show it while + // measuring so the clearance check always has a cue to clear. + const wasHidden = route.hidden; + try { + route.hidden = false; + const controls = [...document.querySelectorAll( + '#cockpit-utility-controls .cockpit-utility-control', + )]; + const launchers = controls.map(rect); + const rowLeft = Math.min(...launchers.map((launcher) => launcher.left)); + const rowRight = Math.max(...launchers.map((launcher) => launcher.right)); + // Taps beside the row reach what is under it. + const besideHits = []; + if (launchers.length) { + const middle = launchers[0].top + launchers[0].height / 2; + for (const x of [rowLeft - 8, rowRight + 8]) { + const target = document.elementFromPoint(x, middle); + besideHits.push(Boolean(target?.closest('#cockpit-utility-controls'))); + } + } + return { + launchers, + rowLeft, + rowRight, + besideHits, + hits: controls.map((control) => { + const glyph = control.querySelector('.cockpit-utility-glyph'); + const box = glyph?.getBoundingClientRect(); + const target = box && document.elementFromPoint( + box.left + box.width / 2, + box.top + box.height / 2, + ); + return Boolean(target && glyph.contains(target)); + }), + speed: rect(hud('.cockpit-speed')), + altitude: rect(hud('.cockpit-altitude')), + route: rect(route), + chevron: rect(route.querySelector('.cockpit-route-chevron')), + reticle: rect(hud('.cockpit-reticle')), + rollArc: rect(hud('.cockpit-roll-arc')), + vision: rect(hud('.cockpit-vision-controls')), + switcher: rect(document.getElementById('view-switcher')), + viewport: { width: innerWidth, height: innerHeight }, + }; + } finally { + route.hidden = wasHidden; + } + }); + const obstacles = { + portrait: ['speed', 'altitude', 'route', 'chevron', 'reticle', 'rollArc', 'vision'], + // The row covers the roll arc's lower tick ends; ticks and labels stay readable. + landscape: ['speed', 'altitude', 'route', 'chevron', 'reticle', 'vision'], + // No free band between the instruments: only the vision controls. + short: ['vision'], + }[room]; + const overlaps = (a, b) => Boolean(a && b) + && a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom; + const { rowLeft, rowRight } = phoneRow; + const switcherCentre = (phoneRow.switcher?.left + phoneRow.switcher?.right) / 2; + const [first, second] = phoneRow.launchers; + check( + `${width}×${height} Cockpit Display/Radio row is centred in one line, on screen, tappable and clear of ${obstacles.join(', ')}`, + phoneRow.launchers.length === 2 + && phoneRow.launchers.every((launcher) => launcher.width > 0) + && phoneRow.speed?.width > 0 + && phoneRow.altitude?.width > 0 + && (room === 'short' || (phoneRow.route?.width > 0 && phoneRow.chevron?.width > 0)) + && phoneRow.hits.every(Boolean) + && phoneRow.besideHits.every((inside) => !inside) + && Math.abs((first?.top + first?.bottom) / 2 - (second?.top + second?.bottom) / 2) <= 1 + && phoneRow.launchers.every((launcher) => obstacles.every( + (name) => !overlaps(launcher, phoneRow[name]), + )) + && Math.abs((rowLeft + rowRight) / 2 - switcherCentre) <= 2 + && rowLeft >= 0 + && rowRight <= phoneRow.viewport.width + && phoneRow.launchers.every((launcher) => ( + launcher.top >= 0 && launcher.bottom <= phoneRow.viewport.height + )), + JSON.stringify(phoneRow), + ); + } + + // A Stories tap that Cockpit refuses leaves the announcement unread. + await page.evaluate(() => document.getElementById('hStories').click()); + await page.waitForFunction( + () => document.querySelector('#toast.visible')?.textContent === 'Exit cockpit to open Stories', + ); + const resetResult = await page.evaluate(() => { // Both the UI and compatibility facade delegate to this navigation owner. const manager = window.__godsEyeView.styleManager._locationNavigation; @@ -2121,6 +2266,9 @@ try { && resetState.visionRestored, JSON.stringify(resetState), ); + const storiesPopupAfterReset = await page.evaluate(storiesPopupDisplay); + check('the Stories announcement returns once Cockpit closes', + storiesPopupAfterReset !== null && storiesPopupAfterReset !== 'none', String(storiesPopupAfterReset)); check('runtime console remains clean', consoleErrors.length === 0 && localHttpErrors.length === 0, [...localHttpErrors, ...consoleErrors].slice(0, 6).join(' | ')); } finally { diff --git a/src/cockpitMarkup.test.mjs b/src/cockpitMarkup.test.mjs index f8232a2f47..616bfd2c18 100644 --- a/src/cockpitMarkup.test.mjs +++ b/src/cockpitMarkup.test.mjs @@ -1157,6 +1157,15 @@ test('mobile Cockpit prioritizes flight instruments and collision-safe controls' mobileCockpit[1], /body\.cockpit-mode \.cockpit-utility-controls[\s\S]*?bottom:\s*152px;/, ); + assert.match( + mobileCockpit[1], + /body\.cockpit-mode\.mobile-shell[^{]*?\.cockpit-utility-controls \{[^}]*?top:[^;]*?var\(--cockpit-visor-top\)/, + ); + assert.match( + mobileCockpit[1], + /@media \(min-width: 390px\) and \(min-height: 240px\),\s*\(min-height: 450px\) \{\s*body\.cockpit-mode\.mobile-shell/, + ); + assert.match(css, /\.cockpit-visor-shell \{[^}]*?inset:\s*var\(--cockpit-visor-top\)/); assert.match( mobileCockpit[1], /body\.cockpit-mode \.cockpit-utility-control\.is-expanded[\s\S]*?top:\s*96px;/, @@ -1175,6 +1184,15 @@ test('mobile Cockpit prioritizes flight instruments and collision-safe controls' ); }); +test('the unread Stories announcement waits until Cockpit closes', () => { + assert.match(css, /body\.cockpit-mode #gev-stories #hPop \{\s*display:\s*none;\s*\}/); + const storiesView = fs.readFileSync(path.join(ROOT, 'src', 'ui', 'views', 'StoriesView.vue'), 'utf8'); + assert.match( + storiesView, + /async function openExplore\(\) \{[^}]*?if \(await store\.controller\.open\(\)\) markPopSeen\(\);/, + ); +}); + test('cockpit route direction uses self-contained vector artwork, not a font ligature', () => { const match = html.match(/