Skip to content

fix(sessions): auto-update other clients when a session is renamed#2798

Open
anuj7511 wants to merge 1 commit into
AgentWrapper:mainfrom
anuj7511:session-rename
Open

fix(sessions): auto-update other clients when a session is renamed#2798
anuj7511 wants to merge 1 commit into
AgentWrapper:mainfrom
anuj7511:session-rename

Conversation

@anuj7511

Copy link
Copy Markdown

Summary

Renaming a session did not emit a live update on the CDC/SSE event stream.
RenameSession updates only display_name (+ updated_at), but the
sessions_cdc_update trigger's WHEN guard did not include display_name,
so the update wrote no change_log row — and therefore no session_updated
event ever reached GET /api/v1/events.

Root cause

The trigger (introduced in 0001, later extended by 0017/0019) fires only
when one of the watched columns changes:

WHEN OLD.activity_state    <> NEW.activity_state
  OR OLD.is_terminated     <> NEW.is_terminated
  OR (OLD.first_signal_at IS NULL AND NEW.first_signal_at IS NOT NULL)
  OR OLD.preview_url       <> NEW.preview_url
  OR OLD.preview_revision  <> NEW.preview_revision

display_name is not in that list. Migrations 0017 and 0019 added the
preview_* columns to this same trigger for exactly this fan-out reason;
rename was left out.

Impact

The initiating desktop window happens to refetch on its own (the sidebar
invalidates its workspace query after a successful rename), which masks the
bug there. But any client relying on the CDC stream keeps showing the old
name until an unrelated event forces a refetch — e.g. a second desktop
window, the Connect Mobile client, or every connected client when the
rename comes from ao session rename (which does no client-side invalidation).

Fix

New migration 0024_session_rename_cdc.sql drops and recreates
sessions_cdc_update with OR OLD.display_name <> NEW.display_name added to
the guard and displayName added to the JSON payload (mirroring how
previewUrl/previewRevision are carried). display_name is NOT NULL, so a
plain <> comparison is complete. Per the repo's hard rule I added a new
migration rather than editing a merged one; the Down reverts to the 0019
trigger.

Reproduction

  1. Start the daemon and open an SSE reader against GET /api/v1/events
    (e.g. curl -N http://127.0.0.1:3001/api/v1/events).
  2. Rename a session via the sidebar or ao session rename <id> <name>.
  3. Before: no frame appears on the stream. After: a session_updated
    frame is delivered with the new displayName.

Add migration 0024 so a rename fires the sessions_cdc_update trigger.
@somewherelostt

Copy link
Copy Markdown
Collaborator

Thanks for contributing to Agent Orchestrator.

This PR is being picked up by the current external contributor on-call pair:

If someone is already working on this, please continue as usual.
The on-call pair is added for visibility, tracking, and support, not to take over the work.
If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @somewherelostt here.

For faster context or live questions, you can also join the AO Discord.

Join the session here:
https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

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.

3 participants