feat(desktop): refresh Agents tab live on inbound relay sync#1256
Open
wpfleger96 wants to merge 2 commits into
Open
feat(desktop): refresh Agents tab live on inbound relay sync#1256wpfleger96 wants to merge 2 commits into
wpfleger96 wants to merge 2 commits into
Conversation
Inbound persona/team/managed-agent relay events reconciled to disk but never signaled the UI, so a device only saw another device's edits after an app restart. The two inbound reconcile paths now emit a coarse `agents-data-changed` event after their disk write commits, and a new root-mounted listener invalidates the four agents query keys. The listener mounts identity-agnostic (it does not live inside the pubkey-keyed persona-sync hook, which would leak a listener per identity switch) and debounces with a trailing coalesce so a backfill burst of up to 500 events yields a single invalidate rather than leaning on React Query's implicit in-flight dedup. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
reconcile_inbound_persona_event drives the full inbound path (upsert + tombstone) and the agents-data-changed emit. Tests verify the record lands in list_personas, the deletion removes it, and the emit fires on both paths — covering the Phase 1 wiring that unit tests cannot reach. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inbound persona/team/managed-agent relay events are reconciled to disk on the receiving device, but nothing signaled the live UI — so another device's edit or deletion only appeared after an app restart. This wires the live refresh: the Agents tab now updates without a restart.
Changes
commands/personas.rs): both inbound reconcile paths —reconcile_inbound_persona_event(upserts, all three kinds) andreconcile_inbound_tombstone(deletions) — emit a coarseagents-data-changedTauri event after their disk write commits. These are the only inbound writers to the agents stores, so two emit sites cover the full inbound surface.useAgentsDataRefresh.ts, new): a root-mounted listener invalidates the four agents React Query keys (personasQueryKey,teamsQueryKey,managedAgentsQueryKey,relayAgentsQueryKey) on that event.Design notes
usePersonaSynchook. Folding it in would re-register the listener on every identity switch and leak one per switch; invalidation is global and has no reason to be pubkey-scoped.agents-data-changed; coalescing collapses the burst into a single invalidate rather than depending on React Query's implicit in-flight dedup and paying redundant disk-read IPC.This is part of the persona/team/agent relay-sync arc and is the user-visible follow-on to #939 (which landed the publish + inbound-reconcile-to-disk substrate). The live cross-device round-trip is exercised by an E2E test and manual two-device smoke in the next phase — this PR's unit/lib gates do not prove the render path on their own.