Skip to content

Open-source Xbox-inspired desktop launcher for Xodus on Linux

TypeScript

Fix compact profile controls and directional search access

domsvoboda6e497e4ea000
diff --git a/scripts/ui/issue455-smoke.cjs b/scripts/ui/issue455-smoke.cjs
new file mode 100644
index 0000000..168acbc
--- /dev/null
+++ b/scripts/ui/issue455-smoke.cjs
@@ -0,0 +1,135 @@
+// Run with Electron. Exercises top-left hit targets and actual controller focus.
+// XODUS_UI_SMOKE_OUTPUT must be a new private directory. Optional
+// XODUS_UI_SMOKE_SOURCE selects a built checkout (defaults to this checkout).
+// English-only synthetic account screenshots.
+const {app,session,ipcMain} = require('electron');
+const fs = require('node:fs/promises');
+const path = require('node:path');
+const {pathToFileURL} = require('node:url');
+const source = path.resolve(process.env.XODUS_UI_SMOKE_SOURCE || path.join(__dirname,'../..'));
+const output = process.env.XODUS_UI_SMOKE_OUTPUT;
+if (!output || !path.isAbsolute(output)) throw Error('Set XODUS_UI_SMOKE_OUTPUT to a new absolute private directory');
+if (process.argv.some(value=>value==='--launch-game'||value==='--nexus-profile')) throw Error('Demo fixture does not accept game or profile arguments');
+process.env.XODUS_DEMO = '1';
+app.disableHardwareAcceleration();
+const language='en-US';
+app.commandLine.appendSwitch('lang',language);
+// Never inherit another capture action or a developer server from the caller.
+for (const name of ['VITE_DEV_SERVER_URL','XODUS_DEMO_CAPTURE_DIR','XODUS_DEMO_TOUR','XODUS_NEXUS_SMOKE_SCREENSHOT','XODUS_NEXUS_SMOKE_STORE','XODUS_NEXUS_SMOKE_STORE_QUERY','XODUS_NEXUS_FONTCONFIG','XODUS_NEXUS_FONTCONFIG_ORIGINAL','XODUS_NEXUS_FONTCONFIG_ORIGINAL_SET']) delete process.env[name];
+// Block both main-process Store requests and renderer artwork. This fixture
+// needs no network and cannot accidentally fall through to live account APIs.
+globalThis.fetch = async () => { throw Error('Network disabled by demo UI fixture'); };
+let completed = false;
+const timer = setTimeout(()=>{console.error('Demo Store eligibility smoke timed out');app.exit(1);},90000);
+const evaluate = (window, fn, ...args) => window.webContents.executeJavaScript(`(${fn.toString()})(...${JSON.stringify(args)})`);
+const ready = async (window, selector) => evaluate(window, async selector => {
+ const deadline=Date.now()+6000;
+ while(!document.querySelector(selector)) {
+ if(Date.now()>deadline)throw Error('Missing demo element: '+selector);
+ await new Promise(resolve=>setTimeout(resolve,30));
+ }
+},selector);
+const settle = window => evaluate(window,async()=>{
+ await new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)));
+ await Promise.race([Promise.all(document.getAnimations().filter(animation=>Number.isFinite(animation.effect?.getTiming().iterations)).map(animation=>animation.finished.catch(()=>{}))),new Promise(resolve=>setTimeout(resolve,500))]);
+});
+async function capture(window) {
+ const results=[];
+ const initial=await evaluate(window,()=>window.launcher.getSnapshot());
+ if(initial.auth.username!=='[email protected]')throw Error('Expected isolated sample account');
+ await evaluate(window,()=>{
+ window.__smokePad={index:0,id:'isolated standard fixture',connected:true,mapping:'standard',buttons:Array.from({length:17},()=>({pressed:false,value:0})),axes:[0,0,0,0]};
+ Object.defineProperty(navigator,'getGamepads',{configurable:true,value:()=>[window.__smokePad]});
+ document.hasFocus=()=>true;
+ });
+ const press=button=>evaluate(window,async button=>{
+ const frames=async()=>{await new Promise(requestAnimationFrame);await new Promise(requestAnimationFrame);};
+ window.__smokePad.buttons[button]={pressed:true,value:1};await frames();
+ window.__smokePad.buttons[button]={pressed:false,value:0};await frames();
+ },button);
+ await evaluate(window,async()=>{await new Promise(requestAnimationFrame);await new Promise(requestAnimationFrame);});
+ const keyboardRequests=[];ipcMain.removeHandler('show-touch-keyboard');ipcMain.handle('show-touch-keyboard',(_event,field)=>{keyboardRequests.push(field);return false;});
+ const requireFixed=process.env.XODUS_UI_SMOKE_REQUIRE_FIXED!=='0';
+ for(const [width,height] of [[1280,800],[800,600]])for(const mode of ['single','expanded']){
+ window.setContentSize(width,height);window.webContents.send('launcher-page','settings');await ready(window,'.settings-page');await settle(window);
+ const fixture=structuredClone(initial);fixture.settings.interfaceLanguage='en';fixture.settings.firstRunCompleted=true;fixture.auth.gamertag='SyntheticPlayer';fixture.settings.multiAccountEnabled=mode==='expanded';fixture.auth.savedAccountsEnabled=mode==='expanded';fixture.auth.saved=['[email protected]','[email protected]'];if(mode==='expanded'){fixture.backend.capabilities.savedAccounts=true;fixture.backend.capabilities.playerAccount=true;fixture.auth.player='[email protected]';}window.webContents.send('snapshot',fixture);await settle(window);
+ await evaluate(window,()=>{
+ document.querySelectorAll('.settings-page details').forEach(el=>el.open=true);
+ const elements=[...document.querySelectorAll('.settings-page button,.settings-page input,.settings-page select,.settings-page textarea,.settings-page summary,.search-box input')].filter(el=>!el.matches(':disabled,[aria-disabled="true"]')&&el.tabIndex>=0&&el.getClientRects().length&&getComputedStyle(el).visibility!=='hidden');
+ elements.forEach((el,i)=>el.dataset.smokeFocusKey='field-'+i);
+ window.__smokeFields=elements.map(el=>({key:el.dataset.smokeFocusKey,tag:el.tagName,type:el.type,label:el.getAttribute('aria-label')||el.closest('label')?.textContent?.slice(0,100)||el.textContent?.slice(0,100),search:el.matches('.search-box input')}));
+ });
+ await press(2);
+ const fields=await evaluate(window,()=>window.__smokeFields),edges={};
+ for(const field of fields.filter(field=>!field.search)){
+ edges[field.key]={};
+ for(const [direction,button] of [['up',12],['down',13],['left',14],['right',15]]){
+ await evaluate(window,key=>document.querySelector(`[data-smoke-focus-key="${key}"]`).focus({preventScroll:true}),field.key);await press(button);
+ edges[field.key][direction]=await evaluate(window,()=>document.activeElement?.dataset.smokeFocusKey||document.activeElement?.className||document.activeElement?.tagName);
+ }
+ }
+ const geometry=await evaluate(window,()=>{
+ document.querySelector('.page-scroll').scrollTop=0;
+ const box=selector=>{const r=document.querySelector(selector).getBoundingClientRect();return {left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height};};
+ const hit=selector=>{const el=document.querySelector(selector),r=el.getBoundingClientRect();return el.contains(document.elementFromPoint(r.left+r.width/2,r.top+r.height/2));};
+ return {language:document.documentElement.lang,documentWidth:document.documentElement.scrollWidth,account:box('.account-summary'),bell:box('.notification-bell'),avatar:box('.account-avatar'),accountHit:hit('.account-summary'),bellHit:hit('.notification-bell')};
+ });
+ const top=await evaluate(window,()=>[...document.querySelectorAll('.settings-page [data-smoke-focus-key]')].filter(el=>el.getClientRects().length&&!el.matches(':disabled,[aria-disabled="true"]')).sort((a,b)=>a.getBoundingClientRect().top-b.getBoundingClientRect().top)[0].dataset.smokeFocusKey);
+ await evaluate(window,key=>document.querySelector(`[data-smoke-focus-key="${key}"]`).focus({preventScroll:true}),top);await press(12);
+ const topUp=await evaluate(window,()=>({key:document.activeElement?.dataset.smokeFocusKey,search:document.activeElement?.matches('.search-box input')}));
+ const keys=new Set(fields.map(field=>field.key)),reached=new Set([top]),queue=[top];
+ while(queue.length)for(const target of Object.values(edges[queue.pop()]??{}))if(keys.has(target)&&!reached.has(target)){reached.add(target);queue.push(target);}
+ const unreachable=fields.filter(field=>!reached.has(field.key));
+ const a=geometry.account,b=geometry.bell,v=geometry.avatar;
+ const overlap=(a,b)=>Math.max(0,Math.min(a.right,b.right)-Math.max(a.left,b.left))*Math.max(0,Math.min(a.bottom,b.bottom)-Math.max(a.top,b.top));
+ const hits=geometry.accountHit&&geometry.bellHit&&a.width>=44&&a.height>=44&&b.width>=44&&b.height>=44&&!overlap(a,b)&&!overlap(v,b)&&v.left>=a.left&&v.right<=a.right;
+ const beforeKeyboard=keyboardRequests.length;await press(0);await settle(window);
+ const acceptKeyboard=keyboardRequests.length===beforeKeyboard+1&&keyboardRequests.at(-1)?.mode===0;
+ await fs.writeFile(path.join(output,`search-${mode}-${width}x${height}.png`),(await window.webContents.capturePage()).toPNG());
+ await press(13);const downReturn=await evaluate(window,key=>document.activeElement?.dataset.smokeFocusKey===key,top);
+ await settle(window);await fs.writeFile(path.join(output,`settings-${mode}-${width}x${height}.png`),(await window.webContents.capturePage()).toPNG());
+ const beforeY=keyboardRequests.length;await press(3);await settle(window);
+ const ySearch=await evaluate(window,()=>document.activeElement?.matches('.search-box input'));
+ const yKeyboard=ySearch&&keyboardRequests.length===beforeY+1;
+ if(mode==='expanded'){
+ await evaluate(window,()=>document.querySelector('.saved-accounts')?.scrollIntoView({block:'center'}));await settle(window);
+ await fs.writeFile(path.join(output,`accounts-${mode}-${width}x${height}.png`),(await window.webContents.capturePage()).toPNG());
+ }
+ await evaluate(window,()=>document.querySelector('.account-summary').focus({preventScroll:true}));
+ window.webContents.sendInputEvent({type:'keyDown',keyCode:'TAB'});window.webContents.sendInputEvent({type:'keyUp',keyCode:'TAB'});await settle(window);
+ const tabBell=await evaluate(window,()=>document.activeElement?.matches('.notification-bell'));
+ await evaluate(window,()=>document.querySelector('.account-summary').focus({preventScroll:true}));await press(2);await press(width<=1100?13:15);
+ const padBell=await evaluate(window,()=>document.activeElement?.matches('.notification-bell'));
+ if(requireFixed&&(!tabBell||!padBell))throw Error('Profile/bell keyboard or controller route failed');
+ let bellModal=false,bellReturn=false;
+ if(padBell){
+ await press(0);await ready(window,'.notification-panel');await press(12);
+ bellModal=await evaluate(window,()=>Boolean(document.activeElement?.closest('.notification-panel')));
+ await fs.writeFile(path.join(output,`notifications-${mode}-${width}x${height}.png`),(await window.webContents.capturePage()).toPNG());
+ await press(1);bellReturn=await evaluate(window,()=>!document.querySelector('.notification-panel')&&document.activeElement?.matches('.notification-bell'));
+ }
+ if(requireFixed&&(!bellModal||!bellReturn))throw Error('Notification modal controller containment/return failed');
+ if(requireFixed&&(!topUp.search||!downReturn||!acceptKeyboard||!yKeyboard||!hits||unreachable.length||geometry.language!=='en'||geometry.documentWidth>width))throw Error('Issue455 check failed: '+JSON.stringify({width,height,mode,topUp,downReturn,acceptKeyboard,yKeyboard,hits,unreachable,geometry}));
+ results.push({width,height,mode,fields,edges,geometry,top,topUp,downReturn,acceptKeyboard,yKeyboard,hits,unreachable,tabBell,padBell,bellModal,bellReturn});
+ }
+ await fs.writeFile(path.join(output,'issue455-results.json'),JSON.stringify({source,scope:'Actual English demo with synthetic standard controller; network blocked. Directional focus and intercepted synthetic keyboard IPC only, no settings saved/accounts/games/backend/Steam actions.',results},null,2)+'\n');
+ completed=true;clearTimeout(timer);app.exit(0);
+}
+
+(async()=>{
+ // Refuse an existing directory, so no saved profile or prior result is reused.
+ await fs.mkdir(output,{mode:0o700});
+ const profile=path.join(output,'profile');await fs.mkdir(profile,{mode:0o700});
+ app.setPath('userData',profile);
+ app.on('browser-window-created',(_event,window)=>{
+ window.show=()=>{};window.hide();window.webContents.setBackgroundThrottling(false);
+ window.webContents.once('did-finish-load',()=>void capture(window).catch(error=>{console.error(error);app.exit(1);}));
+ });
+ await app.whenReady();
+ session.defaultSession.webRequest.onBeforeRequest({urls:['http://*/*','https://*/*','ws://*/*','wss://*/*']},(_details,callback)=>callback({cancel:true}));
+ // Use the built-in offscreen smoke surface, while this fixture owns exit.
+ process.env.XODUS_NEXUS_SMOKE_SCREENSHOT=path.join(output,'built-in-smoke.png');
+ app.quit=()=>{};
+ await import(pathToFileURL(path.join(source,'dist-electron/main/index.js')).href);
+})().catch(error=>{console.error(error);clearTimeout(timer);app.exit(1);});
+app.on('will-quit',()=>{if(!completed)clearTimeout(timer);});
diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx
index 084edbd..7b026a5 100644
--- a/src/renderer/App.tsx
+++ b/src/renderer/App.tsx
@@ -105,7 +105,7 @@ function NavItem({ active, icon, label, badge, onClick, autoSelect = false }: {
export function Sidebar({ data, page, go, openGame, openProfile, notifications, inert = false }: { data: AppSnapshot; page: Page; go: (page: Page) => void; openGame?: (id: string) => void; openProfile?: () => void; notifications?: React.ReactNode; inert?: boolean }) {
const account = data.auth.gamertag ?? data.auth.player ?? data.auth.username ?? (data.auth.stored === true ? ui("ui.microsoft_account_6c2b1f2") : ui("ui.sign_in_bfd402b"));
return <aside className="sidebar" ref={inertRef(inert)}>
- <div className="account-header" data-gamepad-action-row><button className="account-summary" onClick={() => openProfile ? openProfile() : go('settings')}><AccountAvatar auth={data.auth} /><span><strong>{account}</strong><AccountMembership auth={data.auth} /></span></button>{notifications}</div>
+ <div className="account-header" data-gamepad-action-row><button className="account-summary" aria-label={account} onClick={() => openProfile ? openProfile() : go('settings')}><AccountAvatar auth={data.auth} /><span><strong>{account}</strong><AccountMembership auth={data.auth} /></span></button>{notifications}</div>
<nav><NavItem autoSelect active={page === 'home'} icon={<Home />} label={ui("ui.home_3a78695")} onClick={() => go('home')} /><NavItem autoSelect active={page === 'library'} icon={<Library />} label={ui("ui.my_library_d931dba")} onClick={() => go('library')} /><NavItem autoSelect active={page === 'store'} icon={<Store />} label={ui("ui.store_ee7da93")} onClick={() => go('store')} /></nav>
{data.games.length > 0 ? <div className="recents"><span>{ui("ui.most_recent_7459b86")}</span>{data.games.slice(0, 5).map(game => <button key={game.id} onClick={() => openGame ? openGame(game.id) : go('library')}><Cover game={game} /><GameTitle title={game.title} /></button>)}</div> : null}
<div className="sidebar-bottom"><NavItem active={page === 'settings'} icon={<Cog />} label={ui("ui.settings_74a883a")} onClick={() => go('settings')} /><InstallQueueShortcut downloads={data.downloads} games={data.games} active={page === 'downloads'} openQueue={() => go('downloads')} /></div>
diff --git a/src/renderer/gamepad-navigation.ts b/src/renderer/gamepad-navigation.ts
index 7a2acf2..03f7df9 100644
--- a/src/renderer/gamepad-navigation.ts
+++ b/src/renderer/gamepad-navigation.ts
@@ -516,6 +516,18 @@ export function installGamepadNavigation(win: Window, options: Options): () => v
// leaving a game detail must not reselect/reset its Library page.
focus(target);
};
+ /** Up crosses a nested region to higher page controls before global search.
+ * Only the true page edge reaches search, without leaving a modal scope.
+ * The existing topbar Down exit restores this page's remembered field. */
+ const toTopbar = (element: HTMLElement, direction: Direction) => {
+ if (scope !== doc || direction !== 'up' || !element.closest('.page-scroll')) return;
+ const content = element.closest<HTMLElement>('.page-scroll')!;
+ const above = gridNavigationTarget(focusBox(element).getBoundingClientRect(), candidates(content).filter(target => target !== element)
+ .map(target => ({ value: target, rect: focusBox(target).getBoundingClientRect() })), direction);
+ if (above) return above;
+ const search = doc.querySelector<HTMLElement>('.topbar .search-box input');
+ return search && focusable(search) ? search : undefined;
+ };
/** Explicit exits first, then the beam, then region fallbacks in priority order. */
const move = (element: HTMLElement, direction: Direction) => {
const exit = fromTopbar(element, direction) ?? fromSidebar(element, direction);
@@ -524,6 +536,7 @@ export function installGamepadNavigation(win: Window, options: Options): () => v
const target = beam.choose(beam.region)
?? crossStoreRegions(element, direction, beam)
?? crossLibraryRows(element, direction, beam)
+ ?? toTopbar(element, direction)
?? toSocialToggle(element, direction);
if (target) focus(target, true);
else toSidebar(element, direction);
diff --git a/src/renderer/issue455-navigation.test.ts b/src/renderer/issue455-navigation.test.ts
new file mode 100644
index 0000000..54617c6
--- /dev/null
+++ b/src/renderer/issue455-navigation.test.ts
@@ -0,0 +1,36 @@
+// @vitest-environment jsdom
+import {afterEach,beforeEach,expect,it,vi} from 'vitest';
+import {installGamepadNavigation} from './gamepad-navigation';
+import {gamepadHarness} from './gamepad-test-harness';
+let stop:()=>void,h:ReturnType<typeof gamepadHarness>,keyboard:ReturnType<typeof vi.fn>,search:ReturnType<typeof vi.fn>;
+const get=(id:string)=>document.getElementById(id)!;
+beforeEach(()=>{
+ document.body.innerHTML='<aside class="sidebar"><button class="nav-item active">Settings</button></aside><section class="content-shell"><header class="topbar"><div class="search-box"><input id="search" type="search" data-test-rect="300,10,300,40"></div></header><div class="page-scroll" data-gamepad-page="settings"><main class="settings-page"><input id="first" data-test-rect="300,120,300,40"><input id="middle" type="number" data-test-rect="300,200,300,40"><select id="last" data-test-rect="300,280,300,40"><option>One</option></select></main></div></section>';
+ h=gamepadHarness();keyboard=vi.fn(async()=>false);search=vi.fn(()=>get('search').focus());
+ stop=installGamepadNavigation(window,{mode:vi.fn(),back:vi.fn(),page:vi.fn(),keyboard,search});h.step();get('first').focus();h.press(2);
+});
+afterEach(()=>{stop();vi.restoreAllMocks();document.body.innerHTML='';});
+it('reaches top search from the page edge and Down returns to the remembered Settings field',()=>{
+ h.press(12);expect(document.activeElement).toBe(get('search'));expect(keyboard).not.toHaveBeenCalled();
+ h.press(0);expect(keyboard).toHaveBeenCalledOnce();h.press(13);expect(document.activeElement).toBe(get('first'));
+});
+it('keeps Up within the current page while another field is available',()=>{
+ get('middle').focus();h.press(12);expect(document.activeElement).toBe(get('first'));expect(search).not.toHaveBeenCalled();
+});
+it('never escapes a modal scope into the top search',()=>{
+ document.body.insertAdjacentHTML('beforeend','<section role="dialog" aria-modal="true"><input id="modal" data-gamepad-initial data-test-rect="300,120,300,40"></section>');
+ h.step();get('modal').focus();h.press(12);expect(document.activeElement).toBe(get('modal'));expect(search).not.toHaveBeenCalled();
+});
+it('retains the explicit Y search shortcut',()=>{
+ get('middle').focus();h.press(3);expect(search).toHaveBeenCalledOnce();expect(document.activeElement).toBe(get('search'));
+});
+it('retains access to number and select fields without opening the keyboard during navigation',()=>{
+ h.press(13);expect(document.activeElement).toBe(get('middle'));expect(keyboard).not.toHaveBeenCalled();
+ h.press(0);expect(keyboard).toHaveBeenCalledWith(expect.objectContaining({mode:3}));h.press(13);expect(document.activeElement).toBe(get('last'));
+});
+it('leaves a nested grid for a higher page action before reaching global search',()=>{
+ const page=document.querySelector('.page-scroll')!;page.setAttribute('data-gamepad-page','home');
+ page.innerHTML='<main class="home-page"><button id="spotlight" data-test-rect="700,100,180,44">Spotlight action</button><div data-gamepad-grid><button id="nested" data-test-rect="300,220,180,100">First grid row</button></div></main>';
+ get('nested').focus();h.press(12);expect(document.activeElement).toBe(get('spotlight'));
+ h.press(12);expect(document.activeElement).toBe(get('search'));
+});
diff --git a/src/renderer/notifications.css b/src/renderer/notifications.css
index 3b2bf0f..ce35ee5 100644
--- a/src/renderer/notifications.css
+++ b/src/renderer/notifications.css
@@ -1,7 +1,7 @@
-.account-header { display: flex; align-items: center; gap: 2px; position: relative; }
-.account-header .account-summary { flex: 1; min-width: 0; grid-template-columns: 36px minmax(0,1fr); gap: 8px; }
-.notifications { flex: 0 0 36px; }
-.notification-bell { width: 36px; height: 38px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; position: relative; display: grid; place-items: center; }
+.account-header { display: flex; align-items: center; gap: 4px; position: relative; margin-bottom: 13px; }
+.account-header .account-summary { flex: 1; min-width: 0; margin-bottom: 0; grid-template-columns: 36px minmax(0,1fr); gap: 8px; }
+.notifications { flex: 0 0 44px; }
+.notification-bell { width: 44px; height: 44px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; position: relative; display: grid; place-items: center; }
.notification-bell:hover, .notification-bell[aria-expanded="true"] { background: #3a3e44; }
.notification-bell > svg { width: 19px; height: 19px; }
.notification-badge { position: absolute; top: 1px; right: 0; min-width: 15px; padding: 1px 3px; border-radius: 4px; background: #378a39; border: 1px solid #272a30; color: white; font-size: 10px; font-weight: 700; line-height: 13px; }
@@ -23,3 +23,11 @@
.notification-panel strong { font-size: 13px; overflow-wrap: anywhere; }
.notification-panel small { font-size: 11px; color: #bac0c7; }
.notification-panel i { width: 6px; height: 6px; border-radius: 50%; background: #83cc6b; flex: 0 0 6px; }
+
+/* Keep both profile and notifications at the top of the compact sidebar,
+ with separate touch targets instead of shrinking the avatar underneath the bell. */
+@media (max-width: 1100px) {
+ .account-header { flex-direction: column; gap: 4px; }
+ .account-header .account-summary { flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; padding: 4px; grid-template-columns: 1fr; justify-items: center; }
+ .account-header .notifications { flex: 0 0 44px; }
+}