Skip to content

feat(mobile): add glanceable agents snapshot contract - #5535

Open
iscekic wants to merge 7 commits into
mainfrom
audit-w8b-live-activities-3cf8
Open

feat(mobile): add glanceable agents snapshot contract#5535
iscekic wants to merge 7 commits into
mainfrom
audit-w8b-live-activities-3cf8

Conversation

@iscekic

@iscekic iscekic commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

No new behavior — no screen, widget, or notification shows anything different. This change only adds background plumbing that later levels render as an agents summary.


The GlanceableAgentsSnapshot contract is added: one versioned, privacy-minimal schema for every glanceable surface. It carries a status, three counts, safe timestamps, and an opaque scope key, and never titles, prompts, names, or raw ids. Producers may omit the optional account epoch until every producer sends it, then the option must be removed.

Files
  • packages/app-shared/src/glanceable-agents-snapshot.ts — adds the version-1 schema, session-count mapping, FNV-1a scope-key hashing, snapshot builder, and revision ordering.
  • packages/app-shared/package.json — exports the new ./glanceable-agents-snapshot subpath.

The GlanceablePublisher state machine derives a versioned snapshot from the active-sessions tray cache and emits it to every registered sink. It starts the activity on the first eligible emit, coalesces later happy updates, and schedules the 8-second terminal end when work empties. Expiry and strict revision ordering stop a stale producer from overwriting newer data.

Files
  • apps/mobile/src/lib/glanceable/publisher.ts — implements the state machine with session, fetch-start, and fetch-error handlers, coalesce and terminal timers, expiry, and the terminal-blank gate.
  • apps/mobile/src/lib/glanceable/sink-registry.ts — defines the GlanceableSink contract and registry, plus a pluggable delivery registrar that stays a no-op until later slices register tokens.
  • apps/mobile/src/lib/glanceable/mount.tsx — React glue that subscribes to the activeSessions.list tray cache and builds one publisher per signed-in context.
  • apps/mobile/src/app/(app)/_layout.tsx — mounts the publisher and the org fence in the app layout.

The persist sink mirrors the last snapshot and its scope key in SecureStore so a JS restart can fence the surface. A monotonic epoch guards the async restore, so a live write during the read is never clobbered by a stale record. Later levels read this stored snapshot for the iOS and Android widgets.

Files
  • apps/mobile/src/lib/glanceable/persist.ts — adds the SecureStore mirror, the epoch-guarded restore, the schema-validated parse, and the persistGlanceableSink.

Terminal blanking zeroes the surface on logout, direct account switch, org switch, and confirmed lost org. A monotonic terminal-blank epoch gates the publisher, so a cache success after a blank cannot republish or restart. Blanking runs before credentials persist, and a direct account switch also clears the query cache so a stale org list cannot drive a false blank.

Files
  • apps/mobile/src/lib/glanceable/cleanup.ts — terminal blanking, the terminal-blank epoch gate, the pure org-fence decision, and the stale republish path.
  • apps/mobile/src/lib/auth/auth-context.tsx — blanks synchronously at the start of sign-out and before account-switch credential persist; clears the query cache on switch.
  • apps/mobile/src/lib/organization-context.tsx — blanks before an org change and makes a same-value selection a no-op.

The org fence reacts to organizations.list: a selected org missing from a successful list blanks the surface as privacy, while a loading or errored list never blanks. An error republishes the last snapshot as stale, and a terminal snapshot keeps its signed-out or privacy status.

Files
  • apps/mobile/src/lib/glanceable/org-fence.ts — queries the org list and dispatches a privacy blank or a stale republish.

Presentation resolves a snapshot to locked copy keys with a ranked count order, and signed-out or org-invalid flags take precedence. Happy snapshots render counts only, and every other status maps to one locked copy key. The open action routes through the pending-deep-link gate instead of calling router.navigate.

Files
  • apps/mobile/src/lib/glanceable/presentation.ts — status resolution, count rank order, primary count, and spoken-label key assembly.
  • apps/mobile/src/lib/glanceable/open-agents.ts — stashes the Agents tab destination through the pending-deep-link gate.
  • apps/mobile/src/i18n/locales/en.json — adds the 13 locked English copy keys for the glanceable surface and a channel name.

The pure-logic vitest project includes the glanceable test directory.

Files
  • apps/mobile/vitest.pure.config.ts — adds src/lib/glanceable/**/*.test.ts to the include list.

Tests: 5 new suites cover the snapshot contract, publisher, persist, cleanup, and presentation.
Generated: none.


Verification

  • No manual test path. This level adds no native surface, so there is nothing to exercise manually, and no E2E report is attached.

Visual Changes

Visual Changes: N/A

Reviewer Notes

No human steps are required for this change, before or after merge.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. audit-w8b-live-activities-3cf8feat(mobile): add glanceable agents snapshot contract #5535 ← this PR
  2. audit-w8b-live-activities-3cf8-s2feat(mobile): add iOS Live Activity and widgets #5553
  3. audit-w8b-live-activities-3cf8-s3feat(mobile): add Android agents widget and live update #5585
  4. audit-w8b-live-activities-3cf8-s4feat(mobile): deliver glanceable snapshot updates #5620 (tip)

@iscekic iscekic self-assigned this Aug 27, 2026
Comment thread apps/mobile/src/lib/glanceable/publisher.ts
Comment thread apps/mobile/src/lib/glanceable/publisher.ts
Comment thread apps/mobile/src/lib/glanceable/persist.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (87 files)
  • apps/mobile/src/i18n/locales/af.json
  • apps/mobile/src/i18n/locales/am.json
  • apps/mobile/src/i18n/locales/ar.json
  • apps/mobile/src/i18n/locales/az.json
  • apps/mobile/src/i18n/locales/be.json
  • apps/mobile/src/i18n/locales/bg.json
  • apps/mobile/src/i18n/locales/bn.json
  • apps/mobile/src/i18n/locales/bs.json
  • apps/mobile/src/i18n/locales/ca.json
  • apps/mobile/src/i18n/locales/ckb.json
  • apps/mobile/src/i18n/locales/cs.json
  • apps/mobile/src/i18n/locales/cy.json
  • apps/mobile/src/i18n/locales/da.json
  • apps/mobile/src/i18n/locales/de.json
  • apps/mobile/src/i18n/locales/el.json
  • apps/mobile/src/i18n/locales/en.json
  • apps/mobile/src/i18n/locales/es.json
  • apps/mobile/src/i18n/locales/et.json
  • apps/mobile/src/i18n/locales/eu.json
  • apps/mobile/src/i18n/locales/fa.json
  • apps/mobile/src/i18n/locales/fi.json
  • apps/mobile/src/i18n/locales/fil.json
  • apps/mobile/src/i18n/locales/fr.json
  • apps/mobile/src/i18n/locales/ga.json
  • apps/mobile/src/i18n/locales/gl.json
  • apps/mobile/src/i18n/locales/gu.json
  • apps/mobile/src/i18n/locales/ha.json
  • apps/mobile/src/i18n/locales/he.json
  • apps/mobile/src/i18n/locales/hi.json
  • apps/mobile/src/i18n/locales/hr.json
  • apps/mobile/src/i18n/locales/ht.json
  • apps/mobile/src/i18n/locales/hu.json
  • apps/mobile/src/i18n/locales/hy.json
  • apps/mobile/src/i18n/locales/id.json
  • apps/mobile/src/i18n/locales/ig.json
  • apps/mobile/src/i18n/locales/is.json
  • apps/mobile/src/i18n/locales/it.json
  • apps/mobile/src/i18n/locales/ja.json
  • apps/mobile/src/i18n/locales/ka.json
  • apps/mobile/src/i18n/locales/kk.json
  • apps/mobile/src/i18n/locales/km.json
  • apps/mobile/src/i18n/locales/kn.json
  • apps/mobile/src/i18n/locales/ko.json
  • apps/mobile/src/i18n/locales/lo.json
  • apps/mobile/src/i18n/locales/lt.json
  • apps/mobile/src/i18n/locales/lv.json
  • apps/mobile/src/i18n/locales/mg.json
  • apps/mobile/src/i18n/locales/mi.json
  • apps/mobile/src/i18n/locales/mk.json
  • apps/mobile/src/i18n/locales/ml.json
  • apps/mobile/src/i18n/locales/mn.json
  • apps/mobile/src/i18n/locales/mr.json
  • apps/mobile/src/i18n/locales/ms.json
  • apps/mobile/src/i18n/locales/mt.json
  • apps/mobile/src/i18n/locales/my.json
  • apps/mobile/src/i18n/locales/nb.json
  • apps/mobile/src/i18n/locales/ne.json
  • apps/mobile/src/i18n/locales/nl.json
  • apps/mobile/src/i18n/locales/om.json
  • apps/mobile/src/i18n/locales/or.json
  • apps/mobile/src/i18n/locales/pa.json
  • apps/mobile/src/i18n/locales/pl.json
  • apps/mobile/src/i18n/locales/ps.json
  • apps/mobile/src/i18n/locales/pt-BR.json
  • apps/mobile/src/i18n/locales/pt.json
  • apps/mobile/src/i18n/locales/ro.json
  • apps/mobile/src/i18n/locales/ru.json
  • apps/mobile/src/i18n/locales/si.json
  • apps/mobile/src/i18n/locales/sk.json
  • apps/mobile/src/i18n/locales/sl.json
  • apps/mobile/src/i18n/locales/so.json
  • apps/mobile/src/i18n/locales/sq.json
  • apps/mobile/src/i18n/locales/sr.json
  • apps/mobile/src/i18n/locales/sv.json
  • apps/mobile/src/i18n/locales/sw.json
  • apps/mobile/src/i18n/locales/ta.json
  • apps/mobile/src/i18n/locales/te.json
  • apps/mobile/src/i18n/locales/th.json
  • apps/mobile/src/i18n/locales/tr.json
  • apps/mobile/src/i18n/locales/uk.json
  • apps/mobile/src/i18n/locales/ur.json
  • apps/mobile/src/i18n/locales/uz.json
  • apps/mobile/src/i18n/locales/vi.json
  • apps/mobile/src/i18n/locales/yo.json
  • apps/mobile/src/i18n/locales/zh-Hans.json
  • apps/mobile/src/i18n/locales/zh-Hant.json
  • apps/mobile/src/i18n/locales/zu.json
Previous Review Summaries (5 snapshots, latest commit af85672)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit af85672)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/mobile/src/lib/glanceable/cleanup.test.ts
  • apps/mobile/src/lib/glanceable/cleanup.ts
  • apps/mobile/src/lib/glanceable/publisher.test.ts
  • apps/mobile/src/lib/glanceable/publisher.ts

Previous review (commit 404cdee)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (86 files)
  • apps/mobile/src/i18n/locales/af.json
  • apps/mobile/src/i18n/locales/am.json
  • apps/mobile/src/i18n/locales/ar.json
  • apps/mobile/src/i18n/locales/az.json
  • apps/mobile/src/i18n/locales/be.json
  • apps/mobile/src/i18n/locales/bg.json
  • apps/mobile/src/i18n/locales/bn.json
  • apps/mobile/src/i18n/locales/bs.json
  • apps/mobile/src/i18n/locales/ca.json
  • apps/mobile/src/i18n/locales/ckb.json
  • apps/mobile/src/i18n/locales/cs.json
  • apps/mobile/src/i18n/locales/cy.json
  • apps/mobile/src/i18n/locales/da.json
  • apps/mobile/src/i18n/locales/de.json
  • apps/mobile/src/i18n/locales/el.json
  • apps/mobile/src/i18n/locales/es.json
  • apps/mobile/src/i18n/locales/et.json
  • apps/mobile/src/i18n/locales/eu.json
  • apps/mobile/src/i18n/locales/fa.json
  • apps/mobile/src/i18n/locales/fi.json
  • apps/mobile/src/i18n/locales/fil.json
  • apps/mobile/src/i18n/locales/fr.json
  • apps/mobile/src/i18n/locales/ga.json
  • apps/mobile/src/i18n/locales/gl.json
  • apps/mobile/src/i18n/locales/gu.json
  • apps/mobile/src/i18n/locales/ha.json
  • apps/mobile/src/i18n/locales/he.json
  • apps/mobile/src/i18n/locales/hi.json
  • apps/mobile/src/i18n/locales/hr.json
  • apps/mobile/src/i18n/locales/ht.json
  • apps/mobile/src/i18n/locales/hu.json
  • apps/mobile/src/i18n/locales/hy.json
  • apps/mobile/src/i18n/locales/id.json
  • apps/mobile/src/i18n/locales/ig.json
  • apps/mobile/src/i18n/locales/is.json
  • apps/mobile/src/i18n/locales/it.json
  • apps/mobile/src/i18n/locales/ja.json
  • apps/mobile/src/i18n/locales/ka.json
  • apps/mobile/src/i18n/locales/kk.json
  • apps/mobile/src/i18n/locales/km.json
  • apps/mobile/src/i18n/locales/kn.json
  • apps/mobile/src/i18n/locales/ko.json
  • apps/mobile/src/i18n/locales/lo.json
  • apps/mobile/src/i18n/locales/lt.json
  • apps/mobile/src/i18n/locales/lv.json
  • apps/mobile/src/i18n/locales/mg.json
  • apps/mobile/src/i18n/locales/mi.json
  • apps/mobile/src/i18n/locales/mk.json
  • apps/mobile/src/i18n/locales/ml.json
  • apps/mobile/src/i18n/locales/mn.json
  • apps/mobile/src/i18n/locales/mr.json
  • apps/mobile/src/i18n/locales/ms.json
  • apps/mobile/src/i18n/locales/mt.json
  • apps/mobile/src/i18n/locales/my.json
  • apps/mobile/src/i18n/locales/nb.json
  • apps/mobile/src/i18n/locales/ne.json
  • apps/mobile/src/i18n/locales/nl.json
  • apps/mobile/src/i18n/locales/om.json
  • apps/mobile/src/i18n/locales/or.json
  • apps/mobile/src/i18n/locales/pa.json
  • apps/mobile/src/i18n/locales/pl.json
  • apps/mobile/src/i18n/locales/ps.json
  • apps/mobile/src/i18n/locales/pt-BR.json
  • apps/mobile/src/i18n/locales/pt.json
  • apps/mobile/src/i18n/locales/ro.json
  • apps/mobile/src/i18n/locales/ru.json
  • apps/mobile/src/i18n/locales/si.json
  • apps/mobile/src/i18n/locales/sk.json
  • apps/mobile/src/i18n/locales/sl.json
  • apps/mobile/src/i18n/locales/so.json
  • apps/mobile/src/i18n/locales/sq.json
  • apps/mobile/src/i18n/locales/sr.json
  • apps/mobile/src/i18n/locales/sv.json
  • apps/mobile/src/i18n/locales/sw.json
  • apps/mobile/src/i18n/locales/ta.json
  • apps/mobile/src/i18n/locales/te.json
  • apps/mobile/src/i18n/locales/th.json
  • apps/mobile/src/i18n/locales/tr.json
  • apps/mobile/src/i18n/locales/uk.json
  • apps/mobile/src/i18n/locales/ur.json
  • apps/mobile/src/i18n/locales/uz.json
  • apps/mobile/src/i18n/locales/vi.json
  • apps/mobile/src/i18n/locales/yo.json
  • apps/mobile/src/i18n/locales/zh-Hans.json
  • apps/mobile/src/i18n/locales/zh-Hant.json
  • apps/mobile/src/i18n/locales/zu.json

Previous review (commit 4083fdb)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (7 files)
  • apps/mobile/knip.json
  • apps/mobile/src/app/(app)/_layout.tsx
  • apps/mobile/src/i18n/locales/en.json
  • apps/mobile/src/lib/auth/auth-context.test.tsx
  • apps/mobile/src/lib/auth/auth-context.tsx
  • packages/app-shared/src/glanceable-agents-snapshot.test.ts
  • packages/app-shared/src/glanceable-agents-snapshot.ts

Previous review (commit 44f0caa)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • apps/mobile/knip.json
  • apps/mobile/src/lib/auth/auth-context.test.tsx
  • apps/mobile/src/lib/glanceable/persist.test.ts
  • apps/mobile/src/lib/glanceable/persist.ts
  • apps/mobile/src/lib/glanceable/publisher.test.ts
  • apps/mobile/src/lib/glanceable/publisher.ts

Previous review (commit e13a240)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
apps/mobile/src/lib/glanceable/publisher.ts 153 Fetch errors leave a coalesced happy emit pending
apps/mobile/src/lib/glanceable/publisher.ts 161 applySnapshot ignores the terminal-blank gate and leaves timers running
apps/mobile/src/lib/glanceable/persist.ts 90 Restore overwrites in-memory state after a prior persist
Files Reviewed (20 files)
  • apps/mobile/src/app/(app)/_layout.tsx
  • apps/mobile/src/i18n/locales/en.json
  • apps/mobile/src/lib/auth/auth-context.tsx
  • apps/mobile/src/lib/glanceable/cleanup.test.ts
  • apps/mobile/src/lib/glanceable/cleanup.ts
  • apps/mobile/src/lib/glanceable/mount.tsx
  • apps/mobile/src/lib/glanceable/open-agents.ts
  • apps/mobile/src/lib/glanceable/org-fence.ts
  • apps/mobile/src/lib/glanceable/persist.test.ts
  • apps/mobile/src/lib/glanceable/persist.ts - 1 issue
  • apps/mobile/src/lib/glanceable/presentation.test.ts
  • apps/mobile/src/lib/glanceable/presentation.ts
  • apps/mobile/src/lib/glanceable/publisher.test.ts
  • apps/mobile/src/lib/glanceable/publisher.ts - 2 issues
  • apps/mobile/src/lib/glanceable/sink-registry.ts
  • apps/mobile/src/lib/organization-context.tsx
  • apps/mobile/vitest.pure.config.ts
  • packages/app-shared/package.json
  • packages/app-shared/src/glanceable-agents-snapshot.test.ts
  • packages/app-shared/src/glanceable-agents-snapshot.ts

Reviewed by grok-4.6 · Input: 132.2K · Output: 7.5K · Cached: 271.2K

Review guidance: REVIEW.md from base branch main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant