diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-16 17:05:47 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-16 17:05:47 +0100 |
| commit | 835abc36ffd7bb79a1a7ed58ac365253b2d8be93 (patch) | |
| tree | 5daade272ecf32cdb11728297946b1d4d8ea69d7 /docs/superpowers/specs/2026-11-16-xbox-tab-design.md | |
| parent | c782f36b86d3c2aa357a7292f17bdad3322e46ad (diff) | |
| download | deck-it-835abc36ffd7bb79a1a7ed58ac365253b2d8be93.tar.gz deck-it-835abc36ffd7bb79a1a7ed58ac365253b2d8be93.zip | |
docs(spec): Xbox tab
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs/superpowers/specs/2026-11-16-xbox-tab-design.md')
| -rw-r--r-- | docs/superpowers/specs/2026-11-16-xbox-tab-design.md | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/docs/superpowers/specs/2026-11-16-xbox-tab-design.md b/docs/superpowers/specs/2026-11-16-xbox-tab-design.md new file mode 100644 index 0000000..49d8384 --- /dev/null +++ b/docs/superpowers/specs/2026-11-16-xbox-tab-design.md @@ -0,0 +1,123 @@ +# Xbox tab design + +A tab with the user's Xbox Live data (profile, presence, consoles, recent +games, achievements, friends) and the console's power and media control. +While a game runs on the Xbox the PC goes into keystone's presentation mode +and the tablet switches to the tab once. + +There is no local API on a retail console: everything goes through Xbox Live, +with the user's own Azure app registration (a public client, personal +Microsoft accounts, public client flows on). Standard library only, no +`xbox-webapi`, no third-party proxy such as OpenXBL. + +## Server: `deckit/modules/xbox.py` + +### Auth + +- `[xbox] client_id` is the Azure app's client id. Empty: `state()` is + `{offline: true, unconfigured: true}`. +- Device code flow on `login.microsoftonline.com/consumers`, scope + `XboxLive.signin offline_access`. The `login` action requests a code and + returns it; `state()` carries `{signed_in: false, login: {code, url, + expires}}` while a thread polls the token endpoint at the interval + Microsoft gives, until approved or expired. +- The refresh token is saved to `~/.config/deck-it/xbox-token.json`, mode + 0600, and replaced whenever Microsoft rotates it. +- Chain: MS access token → `user.auth.xboxlive.com` (`RpsTicket` `d=<token>`) + → `xsts.auth.xboxlive.com` (relying party `http://xboxlive.com`), giving + the XSTS token, user hash and xuid. Kept in memory; renewed before its + `NotAfter`, and once on a 401. A refresh that Microsoft rejects deletes the + file and gives `signed_in: false`. + +### Reads + +- Every 30s, in a thread (never on the request path): + - presence (`userpresence`): state, the title in the foreground on the + console (id, name, rich presence), last seen. + - consoles (`xccs` `lists/devices`, storage included): id, name, type, + power state (`On`, `ConnectedStandby`, `Off`), storage free and total. +- Every 10 min, and when the presence title changes: + - profile (`profile` settings): gamertag, gamerpic, gamerscore. + - recent titles (`titlehub` title history, achievement and image + decoration): name, cover, type, last played, achievements done/total, + gamerscore done/total; minutes played from `userstats` `MinutesPlayed`. + - last 10 unlocked achievements (`achievements`, ordered by unlock time): + name, description, icon, gamerscore, title, unlock time. + - friends (`peoplehub` social with presence detail): gamertag, gamerpic, + presence state and text, favourite. Online ones first. +- A network failure keeps the last state, marks it `offline` after the first + failed 30s read, and retries on the next tick. + +### Playing + +- Playing is the foreground title being a Game in titlehub's `type`, not an + App (YouTube, Netflix, the home screen). A title's type is looked up once + and cached. +- `state.playing` is that title, `state.session` the time playing started + (set on the not-playing to playing edge, cleared on the other). +- `$XDG_RUNTIME_DIR/status.xbox` gets `1` while playing, `0` otherwise and on + module `stop`, written atomically (temp file + rename) only on change. + +### Actions + +Each console action takes `{console}`, which must be an id the last state +listed, else `ModuleError`. + +- `login`: start the device code flow (above). +- `wake`, `off`: power on and off through `xccs` `commands`. +- `play`, `pause`, `vol_up`, `vol_down`, `mute`: media and volume commands + through `xccs`. + +The command bodies (type, command, parameters, headers) are not documented by +Microsoft; they are taken from xbox-webapi's source and checked live on the +console. A command's error message becomes the `ModuleError`, shown on the +tab. + +## Panel: `static/modules/xbox.js`, tab "Xbox" + +- Not configured / network down: `offline.js`'s card. +- Signed out: a "Sign in" button; then the code, large, and + `microsoft.com/devicelogin`, until signed in or expired. +- Header: gamerpic, gamertag, gamerscore, presence line. +- Console card per console: name, power pill, storage bar, power button (tap + wakes, hold turns off, through `hold.js`), and while on the media row + (play/pause, volume down/up, mute). Nerd Font glyphs. +- Now playing (while playing): cover, title, rich presence, session time, the + title's achievement progress. +- Recent games: a grid of covers with a progress bar, gamerscore and hours. +- Recent achievements and friends as lists. +- Images (gamerpics, covers, achievement icons) are loaded by the tablet + straight from Microsoft's CDN, as K1C's camera is from the printer. +- `peek(st)` returns `Infinity` once per new `st.session`; the last one seen + is kept in `localStorage`, so a reload mid-session does not switch again. +- `app.js`: `peekTab` treats a non-finite duration as "show the tab and do not + go back". + +## Keystone (quickshell repo) + +- `shared/Status.qml`: a `status.xbox` ModeFile, ORed into `presentation` + with `gaming`. Like `gaming`, it is not a mode `statusctl` exposes. +- `Modules.js`: `xbox` in `TABS`, `xbox: "Xbox"` in `NAMES`. + +## Config + +```toml +[xbox] +# The Azure app's client id (a public client for personal Microsoft +# accounts). Empty: the Xbox tab says it is not configured. +client_id = "" +``` + +`[modules] xbox = true`. + +## Skipped + +Captures (screenshots and clips), sending messages, friend management, the +store, a Dashboard chip (the auto-switch replaces it), a CLI login. + +## Tests + +`tests/test_xbox.py` with a fake HTTP function: the token chain and its +refresh and failure, device code polling, presence parsing, game vs app, +session edges, the status file, action validation. `node --check +static/modules/xbox.js`. |
