Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ agent's in-flight work. Say where the worktree is, and remove it once the work h
`unauthorized`, `unconfigured`, …) instead of an empty one, retry sooner after a failure, and
validate every command payload with zod. Commands that run a program use `execFile` with an
argument list, never a shell, and only accept what a closed list or a strict schema allows.
An account provider never publishes the account's e-mail unless `privacy.showAccountEmail` is
on: build the snapshot with `withAccountEmail()` from `server/src/privacy.ts`, pass every
snapshot it returns — the error path's `{ ...last, error }` included — through
`gateAccountEmail()`, applied to the object that carries `email` when it is nested, and set `publishesAccountEmail: true` (see `docs/connections.md`).
- **Config schema** changes go through `server/src/config/schema.ts` with a migration in the
same commit and a test; the store never rewrites a file it could not migrate.
- **Commits**: small, one concern each — a native fix noticed *while I was in there* is its own
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Anything that changes what the dashboard, the admin or a widget can do gets a li
- **Local Docker and AI models.** Registry widgets can show up to 200 local containers and observed Ollama or MLX models. Fremkit refuses remote Docker contexts, distinguishes a missing CLI from a stopped daemon, and keeps the container list when stats fail.
- **The Uptime tile shows time since boot.** The reading comes from macOS and remains unavailable when the system cannot provide it.
- **Borrow the Edge display.** Hide or show the dashboard from the helper menu without quitting it. Hidden state survives display rearrangements, and the mouse fence pauses while the Edge is borrowed. Touch and data collection continue; the dashboard reappears after a helper restart.
- **Account e-mail stays private.** A new box in **/admin → Screen → Privacy**, *Show the account
e-mail address*, off by default. Until you tick it, a widget that shows an account gets its plan
and how you signed in, never its e-mail address: the server does not send it, so no widget —
one from the marketplace included — can show it or pass it on.
- **Claude sessions: go to the session.** Touch a card and its window comes forward — the
exact Orca pane, the Terminal.app or iTerm2 tab, the VS Code window on that folder, or at
least the application — for every session, hooked or merely found running. The card also says which application the session lives in, which is what tells two panes of the
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ The list is short and it is all of it.
| The Dock's badge counts and the icons of installed applications | the `notifications` and `shortcuts` widgets, through the helper | whenever one of those widgets is on the dashboard |
| The volume, the battery, the disks, the processes, the network | those widgets, through `pmset`, `df`, `ps` and friends | whenever one of them is on the dashboard |

A widget that shows an account — its plan, how you signed in — never gets the account's e-mail
address unless you tick **/admin → Screen → Privacy → Show the account e-mail address**. It is off
by default, and the server leaves the address out of what it sends, so no widget can show it or
pass it on. Once on, every widget that reads that account's channel receives it, one installed
from the marketplace included, and it is on the screen.

Everything else Fremkit knows, you typed into it: the connections of the table above, whose
secrets live in the macOS keychain (see [docs/connections.md](docs/connections.md)). Nothing is
sent to any server other than the ones you configured, there is no telemetry, and the server
Expand Down
5 changes: 5 additions & 0 deletions docs/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ macOS keychain (the item "Claude Code-credentials") every 5 minutes and calls th
endpoint for per-model weekly limits. The token is never stored or logged and is sent only to
`api.anthropic.com`. macOS may ask once to allow keychain access. The endpoint is undocumented and
may change without notice.

Nothing the Claude providers publish carries the account's e-mail address. Should one ever do so,
it is held to the rule every account provider is: the address is left out unless **/admin →
Screen → Privacy → Show the account e-mail address** is ticked (see
[connections.md](connections.md#the-accounts-e-mail-address)).
56 changes: 56 additions & 0 deletions docs/connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,62 @@ are reduced to a phrase rather than passed through, because a network error can
the URL can carry the organisation or the calendar address. Deleting a connection a widget still
points at is refused with a 409 naming the widgets.

## The account's e-mail address

A provider that signs in to an account — Claude, Codex, any service whose API answers with a
profile — **never publishes the account's e-mail address unless `privacy.showAccountEmail` is
on**, and it is off by default. The check belongs to the provider, on the server, not to the
widget: whatever lands on a channel reaches every widget subscribed to it, a third-party widget
from the marketplace with network access included, and that widget's consent dialog said "reads
channel X", not "reads your e-mail". A widget that hides the field has already received it.

Build the snapshot with `withAccountEmail()` from `server/src/privacy.ts`, and read the setting
on every poll rather than once, so the admin's toggle takes effect without a restart:

```ts
// server/src/app.ts
registry.register(createExampleAccountProvider({
showAccountEmail: () => store.get().privacy.showAccountEmail,
})) // the provider object sets publishesAccountEmail: true

// in the provider's poll()
return { plan: profile.plan, authMode, ...withAccountEmail(profile.email, opts.showAccountEmail()) }
```

Every snapshot the provider returns goes through `gateAccountEmail()` as well — the error path
above all. A provider that answers a failure with its last good snapshot would otherwise go on
publishing an address fetched while the box was ticked, after the user has unticked it:

```ts
return gateAccountEmail({ ...last, error: 'offline' }, opts.showAccountEmail())
```

`gateAccountEmail()` looks only at the top level of what it is given: apply it to **the object
that carries `email`**, on the fresh path, the error path and any stale answer alike. A snapshot
that holds the account under a key gates that object, not the snapshot around it:

```ts
const show = opts.showAccountEmail()
return {
...last,
error: 'offline',
account: { ...last.account, data: gateAccountEmail(last.account.data, show) },
}
```

Set `publishesAccountEmail: true` on the provider. Toggling the setting then drops the hub's
cached value of its channel and polls it again at once instead of at its next tick, and an answer
from a poll that was already in flight is thrown away, since it may have read the old setting.
The address therefore leaves the screen when the box is unticked rather than five minutes later.
The flag needs a `poll()` — the registry refuses it otherwise — because a poll is the only way
anything reaches a channel. A provider whose endpoint is rate-limited should answer that extra poll from its last
snapshot, gated, rather than fetch again.

Off, the snapshot has no `email` key at all — not an empty string, not a masked address. The plan
(Pro, Max, …) and the sign-in method are not covered by the setting and are published either way.
No provider built into Fremkit publishes an address today; this is the contract the first one is
held to.

## Local Network

macOS 15 and later gate LAN access per application. The server runs inside whatever launched it —
Expand Down
5 changes: 5 additions & 0 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,13 @@ export async function buildApp(opts: AppOptions): Promise<FastifyInstance> {
retainCameras(store.get())

hub.broadcast('config', store.get())
let showAccountEmail = store.get().privacy.showAccountEmail
store.onChange((cfg) => {
setServerLocale(cfg.locale)
if (cfg.privacy.showAccountEmail !== showAccountEmail) {
showAccountEmail = cfg.privacy.showAccountEmail
registry.reconsiderAccountEmail()
}
syncDeclared()
hub.broadcast('config', cfg)
// Fire and forget: a failed sync must not break the save that triggered it.
Expand Down
5 changes: 4 additions & 1 deletion server/src/config/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export function placesClaudeUsage(config: Config): boolean {
* working, and an upgrade that silently blanked them would be a regression rather than a choice —
* so that case starts enabled, and the admin's toggle is where it is turned back off. A config
* that already carries the field is left exactly as written.
*
* `showAccountEmail` needs no such inference: no release ever published an account's e-mail, so
* an older config is read as off by the schema's default, which is what it always meant.
*/
function adoptPrivacy(config: Config, raw: unknown): Config {
const stated = (raw as { privacy?: unknown } | null)?.privacy
Expand Down Expand Up @@ -149,7 +152,7 @@ export function migrateConfig(raw: unknown): Config {
connections: [],
secrets: { backend: defaultSecretsBackend() },
locale: defaultLocale(),
privacy: { claudeAccountUsage: false },
privacy: { claudeAccountUsage: false, showAccountEmail: false },
// A v1 config predates the marketplace by a long way; nothing can have been installed.
marketplace: { installed: {} },
pages: v1.pages.map((p) => ({
Expand Down
10 changes: 9 additions & 1 deletion server/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ const PrivacySchema = z.object({
* undocumented and may disappear.
*/
claudeAccountUsage: z.boolean().default(false),
/**
* Let an account provider (Claude, Codex, …) put the account's e-mail address in what it
* publishes. Off, the field is never in the snapshot: anything on a channel reaches every
* widget subscribed to it, a third-party one with network access included, and the Edge sits
* on a desk. The plan and the sign-in method are published either way. Providers read it with
* `withAccountEmail()` from `privacy.ts` on every poll.
*/
showAccountEmail: z.boolean().default(false),
}).prefault({})

/**
Expand Down Expand Up @@ -341,7 +349,7 @@ export const DEFAULT_CONFIG: Config = {
connections: [],
secrets: { backend: defaultSecretsBackend() },
locale: defaultLocale(),
privacy: { claudeAccountUsage: false },
privacy: { claudeAccountUsage: false, showAccountEmail: false },
marketplace: { installed: {} },
pages: [
{
Expand Down
35 changes: 35 additions & 0 deletions server/src/privacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* The one way an account provider puts the account's e-mail address in a snapshot.
*
* Whatever a provider publishes reaches every widget subscribed to its channel — a third-party
* widget from the marketplace with network access included, whose consent dialog said "reads
* channel X", not "reads your e-mail" — and whatever a widget shows is on a screen on a desk. So
* the address is left out unless the user turned `privacy.showAccountEmail` on, and the check is
* made here, on the server, not by the widget that would display it.
*
* Spread the result into the snapshot: `{ plan, authMode, ...withAccountEmail(email, show()) }`.
* Pass `show` as `() => store.get().privacy.showAccountEmail` and call it on every poll rather
* than capturing it, so the admin's toggle takes effect without a restart. The plan and the
* sign-in method are not covered by the setting and are published either way.
*/
export function withAccountEmail(email: string | null | undefined, show: boolean): { email?: string } {
return show && email ? { email } : {}
}

/**
* The same rule for a snapshot that already exists: the address is dropped unless `show` is on.
*
* A provider that answers a failure with its last good snapshot — `{ ...last, error }` — would
* otherwise go on publishing an address the user has hidden since it was fetched. So every
* snapshot a provider returns goes through this, the error path and a cached answer included:
* `return gateAccountEmail({ ...last, error: 'offline' }, opts.showAccountEmail())`.
*
* It looks at the top level of the object it is given, nothing deeper: apply it to the object
* that carries `email`. A snapshot holding the account under a key gates that object —
* `{ ...last, account: { ...last.account, data: gateAccountEmail(last.account.data, show) } }`.
*/
export function gateAccountEmail<T extends object>(snapshot: T, show: boolean): T {
if (show || !('email' in snapshot)) return snapshot
const { email: _email, ...rest } = snapshot as T & { email?: unknown }
return rest as T
}
38 changes: 37 additions & 1 deletion server/src/providers/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface State {
backoffMs: number
lastJson: string | undefined
inFlight: boolean
/** Poll again as soon as the one in flight returns: it may have read a setting since changed. */
pollAgain: boolean
}

export class ProviderRegistry {
Expand All @@ -38,12 +40,17 @@ export class ProviderRegistry {
) {}

register(provider: Provider): void {
// A poll is the only way anything reaches a channel, so a provider without one publishes no
// address and could never take one back: the flag there is a mistake, not a no-op.
if (provider.publishesAccountEmail && !provider.poll) {
throw new Error(`provider ${provider.channel}: publishesAccountEmail needs a poll()`)
}
const previous = this.states.get(provider.channel)
// Read before the teardown, which zeroes it: the widgets watching this channel did not go
// away because the connection behind it was edited, so the replacement inherits them.
const subscribers = previous?.subscribers ?? 0
if (previous) this.teardown(previous, 'gone')
const state: State = { provider, subscribers, started: false, timer: null, backoffMs: 0, lastJson: undefined, inFlight: false }
const state: State = { provider, subscribers, started: false, timer: null, backoffMs: 0, lastJson: undefined, inFlight: false, pollAgain: false }
this.states.set(provider.channel, state)
if (state.subscribers > 0) this.activate(state)
}
Expand All @@ -58,6 +65,26 @@ export class ProviderRegistry {

channels(): string[] { return [...this.states.keys()] }

/**
* `privacy.showAccountEmail` changed: every provider that can publish the address answers again
* now, rather than at its next tick — five minutes for an account endpoint, during which an
* address the user has just hidden would stay on screen.
*
* The cached value goes first, watched or not, so the hub hands nothing stale to a widget that
* subscribes before the new answer arrives. A watched channel is then polled at once. A poll
* already in flight may have read the old setting, so its answer is thrown away when it returns
* — whether anyone is still watching or not — and the channel is polled again if someone is.
*/
reconsiderAccountEmail(): void {
for (const s of this.states.values()) {
if (!s.provider.publishesAccountEmail) continue
s.lastJson = undefined
this.forget(s.provider.channel)
if (s.inFlight) s.pollAgain = true
else if (s.subscribers > 0) this.schedule(s, 0)
}
}

has(channel: string): boolean { return this.states.has(channel) }

addSubscriber(channel: string): void {
Expand Down Expand Up @@ -162,6 +189,15 @@ export class ProviderRegistry {
}
// Checked again after the await, not only before it: this is where the replacement happens.
if (!this.isCurrent(s)) return
if (s.pollAgain) {
// Computed under a privacy setting the user has changed since: never published. Forgotten
// again in case the channel went idle meanwhile, so nothing is cached for the next widget.
s.pollAgain = false
s.lastJson = undefined
this.forget(s.provider.channel)
if (s.subscribers > 0) this.schedule(s, 0)
return
}
const json = JSON.stringify(data)
if (json !== s.lastJson) {
s.lastJson = json
Expand Down
7 changes: 7 additions & 0 deletions server/src/providers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ export interface Provider<T = unknown> {
/** Called when the last subscriber leaves, and when the provider is unregistered. */
stop?(): void
commands?: Record<string, (payload: unknown, ctx?: CommandContext) => Promise<unknown>>
/**
* Set by a provider whose snapshot can carry the account's e-mail address (see `privacy.ts`).
* Toggling `privacy.showAccountEmail` then polls it again at once, instead of leaving the old
* answer on screen until its next tick. Requires `poll`: the registry refuses the flag on a
* provider without one.
*/
publishesAccountEmail?: boolean
}
export type Publish = (channel: string, data: unknown) => void
49 changes: 49 additions & 0 deletions server/test/config-migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,55 @@ describe('privacy.claudeAccountUsage on an older config', () => {
})
})

describe('privacy.showAccountEmail on an older config', () => {
const page = (widgets: object[]) => ({ id: 'home', name: 'Accueil', widgets })
const widget = (widgetId: string) => ({ instanceId: 'a', widgetId, x: 0, y: 0, w: 8, h: 4 })

it('starts off for every config written before it existed', () => {
// Even next to the Claude opt-in being inferred on: reading the usage is not showing the e-mail.
const v3 = migrateConfig({ ...migrateConfig(v1), privacy: { claudeAccountUsage: true } })
// toMatchObject: other privacy keys arrive in other branches and must not break this.
expect(v3.privacy).toMatchObject({ claudeAccountUsage: true, showAccountEmail: false })
expect(migrateConfig({ version: 2, pages: [page([widget('claude-usage')])] }).privacy)
.toMatchObject({ claudeAccountUsage: true, showAccountEmail: false })
expect(migrateConfig(v1).privacy.showAccountEmail).toBe(false)
})

it('respects the field once the file carries it', () => {
const v3 = (showAccountEmail: boolean) => migrateConfig({
...migrateConfig(v1), privacy: { claudeAccountUsage: false, showAccountEmail },
}).privacy.showAccountEmail
expect(v3(true)).toBe(true)
expect(v3(false)).toBe(false)
})

it('leaves a v3 file without the field untouched on disk', async () => {
const dir = await mkdtemp(join(tmpdir(), 'fremkit-mig-'))
const file = join(dir, 'fremkit.json')
const { privacy: _privacy, ...rest } = migrateConfig(v1)
const before = JSON.stringify({ ...rest, privacy: { claudeAccountUsage: false } }, null, 2)
await writeFile(file, before)
const cfg = await new ConfigStore(file).load()
expect(cfg.privacy.showAccountEmail).toBe(false)
expect(await readFile(file, 'utf8')).toBe(before)
})

it('never rewrites a file whose value it cannot read', async () => {
const dir = await mkdtemp(join(tmpdir(), 'fremkit-mig-'))
const file = join(dir, 'fremkit.json')
const original = JSON.stringify({ ...migrateConfig(v1), privacy: { claudeAccountUsage: false, showAccountEmail: 'yes' } })
await writeFile(file, original)
const err = vi.spyOn(console, 'error').mockImplementation(() => {})
const store = new ConfigStore(file)
const cfg = await store.load()
err.mockRestore()
expect(store.degraded).toBe(true)
expect(cfg.privacy.showAccountEmail).toBe(false)
expect(await readFile(file, 'utf8')).toBe(original)
expect(await readdir(dir)).toEqual(['fremkit.json'])
})
})

describe('renamed stored values', () => {
const withModel = (model: string) => ({
version: 2,
Expand Down
Loading
Loading