Skip to content

Commit b21837d

Browse files
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6wtellaho
andcommitted
docs(desktop): document pre-identity observer mount; normalize owner value
Two review follow-ups on owner-global observer ingestion: - Document (AppShell + hook jsdoc) that useAgentObserverIngestion intentionally mounts before identity resolves: managed agents are ingested immediately, relay-owned agents join once currentPubkey arrives. Guards against a future identity/startup gate that would drop managed-agent coverage during startup. - Store ownerByPubkey values normalized (was: normalized key, raw value, normalize-at-compare) so lookups and ownership comparisons never depend on relay casing. Behavior unchanged; removes the asymmetry footgun. Addresses review feedback on #1493. Co-authored-by: Taylor Ho <[email protected]> Signed-off-by: Taylor Ho <[email protected]>
1 parent ec29b2e commit b21837d

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎desktop/src/app/AppShell.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export function AppShell() {
151151
// Owner-global observer ingestion: receives + decrypts agent observer
152152
// frames and keeps derived active-turn liveness in sync app-wide, so no
153153
// individual screen/panel has to mount its own bridge for ingestion.
154+
// Intentionally mounted without a `startupReady`/identity guard: before
155+
// `currentPubkey` resolves the hook ingests managed agents only, and
156+
// relay-owned agents join automatically once identity arrives. Adding a
157+
// guard here would drop managed-agent coverage during startup.
154158
useAgentObserverIngestion();
155159
const profileQuery = useProfileQuery();
156160
const deferredPubkey = startupReady ? identityQuery.data?.pubkey : undefined;

‎desktop/src/features/agents/useAgentObserverIngestion.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ export function combineObserverIngestionAgents(
6666
* This is the product invariant: if the current identity owns an agent (local
6767
* managed agent or declared-owned relay agent), its turn activity is ingested
6868
* app-wide — not only while a panel that happens to mount a bridge is open.
69+
*
70+
* Mounts before identity resolves by design: while `currentPubkey` is still
71+
* `undefined`, `combineObserverIngestionAgents` returns managed agents only,
72+
* and relay-owned agents are folded in on the render after identity arrives.
73+
* Do not gate this hook on identity/startup readiness — that would drop
74+
* managed-agent observer coverage during startup.
6975
*/
7076
export function useAgentObserverIngestion() {
7177
const identityQuery = useIdentityQuery();
@@ -89,7 +95,12 @@ export function useAgentObserverIngestion() {
8995
const ownerByPubkey = new Map<string, string>();
9096
for (const [pubkey, summary] of Object.entries(profiles ?? {})) {
9197
if (summary.ownerPubkey) {
92-
ownerByPubkey.set(normalizePubkey(pubkey), summary.ownerPubkey);
98+
// Store both key and value normalized so lookups and ownership
99+
// comparisons never depend on the casing the relay happened to send.
100+
ownerByPubkey.set(
101+
normalizePubkey(pubkey),
102+
normalizePubkey(summary.ownerPubkey),
103+
);
93104
}
94105
}
95106
return combineObserverIngestionAgents(

0 commit comments

Comments
 (0)