fix(sharing): drop per-branch rows from the shared payload

sanitizeForSharing spread current and emptied only topProjects and
topSessions, so the per-branch rows added with the payload block went out
verbatim: a branch such as exp/extraction-arms reached a peer device as
typed. Branch names encode ticket ids, customer names and feature
codenames, so they get what project and session rows get and leave the
payload entirely. Pseudonymizing was the alternative, but a branch-a1b2c3
row means nothing on another device's dashboard, and no shared surface
reads the block today.

Refs #1321, #1325
This commit is contained in:
ozymandiashh 2026-09-13 01:42:28 +03:00
parent e04ff869b4
commit d8f39cc2db
3 changed files with 26 additions and 6 deletions

View file

@ -12,6 +12,7 @@
- **The Capacity Dock gauge can report the short usage window instead of the weekly one, without expanding the dock.** The resting rail shows one number per provider, and that number was always the weekly (else monthly) billing window. Clicking the provider already resting in the rail now switches its gauge to the provider's short rolling window — Claude's 5-hour limit, Codex's 5-hour or daily window, any `Hourly`, `Daily` or session row an adapter reports — and clicking again switches back. The choice is stored per provider under `CodeBurnCapacityDockGlanceWindows`, so Claude can sit on its 5-hour window while Codex stays weekly, and it survives relaunch. A per-model row such as `Weekly · Opus` is never read as a short window, a provider that reports only one window keeps the plain click-to-pin behaviour, and a stored horizon the provider stops reporting falls back to the window it does report rather than blanking the gauge to `--`. The rail's geometry is untouched, VoiceOver and keyboard users get the switch as a named action on the provider cell with the window named in the cell's value, and Escape or a click outside still unpins the dock. (#1243)
### Fixed
- **Shared and MCP-redacted payloads no longer carry git branch names or the working directory of a session.** Two identities were riding along in `current`: the `topSessions` rows added in #1316 carry `projectKey`, a dash-encoded absolute path such as `-Users-<user>-Projects-<repo>`, which `redactProjectNames` left verbatim even when an MCP client asked not to see project names, and the per-branch rows added in #788 carry the raw branch, which both `sanitizeForSharing` and the MCP pass let through, so a branch such as `exp/extraction-arms` reached a shared payload as typed. The MCP pass now hashes `projectKey` with the same salted pseudonym it already applies to `topProjects[].id`, hashes the drill-through `sessionId` on both `topSessions` and `topProjects[].sessionDetails` (a Codex id embeds the rollout timestamp the pass blanks out of `date`), and gives each distinct branch a stable `branch-xxxxxx` pseudonym, keeping the cost, calls and session counts untouched; a `null` branch stays null, because unbranched spend is not a name. Sharing drops the per-branch block outright, the way it already drops the project and session rows, since a pseudonymized branch tells a peer device nothing anyway. Nothing changes for the local menubar, the desktop app or the web dashboard, which read the unsanitized payload, and nothing changes for an MCP caller that passes `include_project_names: true` — it still gets every name as recorded. (#1325, #1321)
- **The menubar second row's quota line now names the provider the flame is warning about.** "Quota remaining" picked each provider's *headline* window — weekly, else monthly, and only then the busiest one — which is the Capacity Dock's billing horizon, not a warning: on a machine with Cursor's API window at 100% and Claude's 5-hour window at 18%, the row reported Monthly 9.5% and Weekly 5% and read as if nothing were near a limit. Each provider now contributes its worst window, per-model rows included, which is exactly what the menu-bar flame already tints by, so the two surfaces agree. A provider backing off after a failed fetch keeps its last-known window instead of dropping out, so the row no longer vanishes — resizing the status item — for the length of a retry, matching what the dock shows dimmed. The row is also capped at 24 characters, shortening a long provider name ("GitHub Copilot 12% left · 6d 3h") rather than letting the second line more than double the item's width, and the two-line title now carries a VoiceOver label that reads as one phrase instead of a string with a newline in it. With the setting off nothing changed: the snapshot that feeds the row is no longer even built on a refresh, and the title is the single-row composition it has always been. (#1310)
- **Every Copilot credential rung now follows its own GitHub host, not just the two read from files.** #1286 taught `hosts.json` and `apps.json` to carry the host their token came from, but the rungs that carried none — `COPILOT_GITHUB_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN`, `gh auth token`, and a token pasted into Settings — were still sent to `api.github.com`, so a user whose only Copilot credential is a GitHub Enterprise Cloud login got a 401 and a terminal failure with no way out. The environment rung now reads `GH_HOST` from the same environment as the token; the `gh` rung resolves the host from gh's own `hosts.yml` (`GH_CONFIG_DIR`, then `XDG_CONFIG_HOME/gh`, then `~/.config/gh`), picking it the way gh picks the host for `gh auth token` and without a second subprocess; and macOS Settings gains a GitHub host field next to the pasted token, defaulting to `github.com` and saved in the same Keychain record as the token so the two can never drift apart. Settings refuses a host no endpoint can be derived from at the field rather than storing it, the connection row no longer promises `api.github.com` before anything has been fetched, and every one of these new host sources is character-validated before a URL is built, so a crafted value such as `evil.com?.ghe.com` fails closed with no request instead of pointing the Authorization header at a host of its own choosing. `codeburn quota` is unchanged: it still reads only the editor-plugin files, which already carry their host. (#1306)
- **Copilot live quota works for GitHub Enterprise Cloud enterprises on a `*.ghe.com` host.** Both readers hardcoded `https://api.github.com/copilot_internal/user` and threw away the host their credential came from, so a data-residency enterprise signed in on `<tenant>.ghe.com` could only ever report `available: false` with "Temporarily unavailable". A discovered credential now carries its host — `hosts.json` is keyed by host and newer `apps.json` files key by `<host>:<app id>` — and the request follows it: `api.github.com` for `github.com` and for any rung that carries no host of its own (an app-name `apps.json` key, `COPILOT_GITHUB_TOKEN` / `GH_TOKEN` / `GITHUB_TOKEN`, `gh auth token`, a pasted token), and `https://api.<tenant>.ghe.com/copilot_internal/user` for an enterprise host. The token and the host always come from the same entry, with `github.com` preferred when several hosts are signed in and otherwise the first `.ghe.com` tenant in sorted order; a host neither rule can address, such as a self-hosted GitHub Enterprise Server install, fails with a message naming that host instead of sending the credential to dotcom, and unreachable-host and HTTP failures name the host that was tried. The macOS Settings connection row now says which host answered. (#1286)

View file

@ -1,10 +1,10 @@
import type { MenubarPayload } from '../menubar-json.js'
// Strip identifying detail before usage leaves the device. We never share
// project names, file paths, or per-session detail (the strongest signal of
// "what you are working on"). We DO share aggregate numbers plus model, tool,
// task, subagent, skill, and MCP-server usage, since the dashboard surfaces
// those per device. If a user names a subagent/skill after a client, that name
// project names, branch names, file paths, or per-session detail (the strongest
// signal of "what you are working on"). We DO share aggregate numbers plus
// model, tool, task, subagent, skill, and MCP-server usage, since the dashboard
// surfaces those per device. If a user names a subagent/skill after a client, that name
// would travel; revisit if that becomes a concern.
export function sanitizeForSharing(payload: MenubarPayload): MenubarPayload {
// Older peers may predate the history field even though current producers
@ -13,10 +13,14 @@ export function sanitizeForSharing(payload: MenubarPayload): MenubarPayload {
// Live sessions name the project and branch in flight, the most identifying
// block of all.
const { liveSessions: _liveSessions, ...rest } = payload
// Per-branch rows are keyed by the raw git branch, which encodes ticket ids,
// customer names and feature codenames as readily as a project name does, so
// they leave with the project and session rows rather than travelling verbatim.
const { byBranch: _byBranch, ...current } = payload.current
return {
...rest,
current: {
...payload.current,
...current,
topProjects: [],
topSessions: [],
},

View file

@ -23,7 +23,11 @@ function fixture(): MenubarPayload {
{ name: 'secret-project', cost: 100, savingsUSD: 0, sessions: 2, avgCostPerSession: 50, sessionDetails: [] },
],
tools: [{ name: 'Bash', calls: 9 }],
topSessions: [{ project: 'secret-project', cost: 100, savingsUSD: 0, calls: 5, date: '2026-06-01' }],
topSessions: [{ project: 'secret-project', cost: 100, savingsUSD: 0, calls: 5, date: '2026-06-01', projectKey: '-Users-me-Projects-secret-project' }],
byBranch: [
{ branch: 'exp/extraction-arms', cost: 60, calls: 3, sessions: 1 },
{ branch: null, cost: 40, calls: 2, sessions: 1 },
],
},
history: {
daily: [],
@ -62,6 +66,17 @@ describe('sanitizeForSharing', () => {
expect(JSON.stringify(clean)).not.toContain('secret-project')
})
it('drops the per-branch rows: branch names encode tickets, customers and codenames', () => {
const clean = sanitizeForSharing(fixture())
expect(clean.current.byBranch).toBeUndefined()
expect(JSON.stringify(clean)).not.toContain('exp/extraction-arms')
})
it('leaks no working-directory key from the session rows', () => {
const clean = sanitizeForSharing(fixture())
expect(JSON.stringify(clean)).not.toContain('-Users-me-Projects-secret-project')
})
it('drops the live-session block, which names the project and branch in flight', () => {
const withSessions = {
...fixture(),