Skip to content

fix(desktop): surface relay profile-sync failure on agent rename - #2302

Closed
Bartok9 wants to merge 1 commit into
block:mainfrom
Bartok9:bartok9/rename-profile-sync-feedback
Closed

fix(desktop): surface relay profile-sync failure on agent rename#2302
Bartok9 wants to merge 1 commit into
block:mainfrom
Bartok9:bartok9/rename-profile-sync-feedback

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Refs #1822

When agent rename local-save succeeds but relay kind:0 profile sync fails, surface a warning toast (same pattern as create/persona) instead of only console.warn and a quiet close.

@Bartok9
Bartok9 requested a review from a team as a code owner July 21, 2026 22:09
@Bartok9
Bartok9 force-pushed the bartok9/rename-profile-sync-feedback branch 2 times, most recently from dd70b9a to 00664ac Compare July 22, 2026 14:33
When renaming an agent, the local save (disk + AGENTS.md) always succeeds,
but the async relay kind:0 profile republish can fail (network blip, auth
expiry, relay unreachable). The edit dialog only `console.warn`-ed that error
and closed as if the rename fully succeeded, so the user never learned the
relay still had the old name/@mention handle (block#1822).

Surface it with a warning toast — matching the create and persona flows,
which already toast `profileSyncError`. Local-save behavior is unchanged.

Refs block#1822

Signed-off-by: Bartok9 <danielrpike9@gmail.com>
@Bartok9
Bartok9 force-pushed the bartok9/rename-profile-sync-feedback branch from 00664ac to 561dcf0 Compare July 24, 2026 16:42
@Bartok9

Bartok9 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by merged #2279 (fix(desktop): surface agent rename relay profile sync failure as a warning toast), which landed the same seam on main via showAgentProfileSyncWarning / agentProfileSyncWarning.ts.

Our open tip conflicted on AgentInstanceEditDialog.tsx against that merge and no longer has independent value. Glad the warning toast shipped.

Credit/thanks to the #2279 authors — happy to help on follow-ups if anything residual remains.

@Bartok9 Bartok9 closed this Jul 25, 2026
wpfleger96 added a commit that referenced this pull request Jul 27, 2026
…propagates (#2607)

## Problem

Part of #2423 (renaming personal agents desynchronises identity).

Renaming an agent definition (persona) propagates the new display name
to its
linked agent instances (`propagate_persona_name_rename` in
`desktop/src-tauri/src/commands/personas/mod.rs`) and saves
`managed-agents.json` — but, unlike the instance-rename path
(`update_managed_agent`), it never re-retains the renamed instances'
kind:30177
managed-agent identity records. `record.name` is part of the published
identity
projection (`agent_event_content`), so after a persona rename:

- `managed-agents.json` says the NEW name,
- the retained kind:30177 row (retention.db → relay flush loop) still
carries
  the OLD name, with the OLD `created_at`.

The stale identity record stays live on the relay until the next app
launch,
when the boot-time reconcile (`reconcile_agents_in_dir`) finally notices
the
content diff and republishes. Until that restart, any surface that
resolves
agents from kind:30177 records (second desktop of the same owner, CLI,
other
NIP-AP clients) sees the OLD name bound to the agent pubkey while the
kind:0
profile already shows the NEW one — the name→identity binding desync
described
in #2423, and consistent with the report's observation that repairing
state
required "a separate restart".

## Fix

- Extract the per-record retain body of the boot reconcile into
`managed_agents::reconcile::retain_agent_record(conn, keys, record) ->
Result<bool, String>`
— one shared content-diff + monotonic-`created_at`-bump engine (returns
whether a row was rewritten). `reconcile_agents_in_dir` now calls it per
  record (behavior unchanged; existing reconcile tests still pass).
- `commands::agents::retain_managed_agent_pending` delegates to the
shared
  engine instead of carrying a duplicate implementation (same semantics:
  projection-equality no-op guard, monotonic bump, `pending_sync = 1`).
- `update_persona` (Phase 1, still under the store lock, after
`save_managed_agents`): call `retain_managed_agent_pending` for every
record
the rename propagated to — mirroring `update_managed_agent`. Avatar-only
edits are deliberately excluded (the avatar is not part of the
kind:30177
  projection; retaining would be a guaranteed no-op).

No new events, kinds, or APIs — this uses the existing signed-event
retention
and flush pipeline, per CONTRIBUTING's guidance to prefer a signed Nostr
event
and the existing ingest path over endpoint-specific JSON APIs.

## Out of scope (deliberately)

- Rename → runtime restart is #1823, fixed by open PR #2507
(spawn_hash).
- Surfacing kind:0 relay profile-sync failures on rename is PR
#2302/#2279
  territory (and largely superseded by the merged rollback in #2258).
- Mention-picker UX (owner/status disambiguation) and channel-membership
repair for stale identities: TS-side, noted in #2423, not touched here.

## Test evidence

Two new unit tests in
`desktop/src-tauri/src/managed_agents/reconcile/tests.rs`
(same harness as the existing reconcile tests — tempdir + retention.db +
fresh
keys, no AppHandle):

- `rename_re_retains_identity_record_with_new_name` — retain "Fizz",
confirm
  flush, rename to "Spark", re-retain: row keeps the pubkey coordinate,
  carries the new name only, is `pending_sync`, and its `created_at` is
  strictly past the retained head (replaceable-event acceptance).
- `retain_agent_record_is_noop_when_unchanged` — an unchanged projection
does
  not rewrite the row and produces zero `pending_sync` churn.

Ran scoped per CONTRIBUTING build discipline (from `desktop/src-tauri`):

```
cargo fmt -p buzz-desktop                                  # applied, clean
cargo clippy -p buzz-desktop --lib --tests -- -D warnings  # exit 0, no warnings
cargo test -p buzz-desktop --lib                           # full lib suite
```

Full `buzz-desktop` lib suite: **1562 passed, 0 failed, 13 ignored** —
including all 12 `managed_agents::reconcile` tests (10 pre-existing, all
unmodified in behavior, plus the 2 new regression tests above).

## Links

- Issue: #2423
- Adjacent (no overlap): PR #2507 (rename-restart, #1823), PRs
#2302/#2279
(kind:0 sync-failure surfacing), merged #2258 (instance-rename
rollback).

---------

Signed-off-by: Sean Gearin <sgearin@gmail.com>
Co-authored-by: Sean Gearin <sgearin@gmail.com>
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
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