Skip to content

Improvement: Improve unsaved-changes handling when switching agent and automation settings tabs #2572

Closed

Description

@yannickmonney

Problem

Editing agent settings and then navigating to another tab triggers a Stay / Discard dialog that feels heavy-handed. Automation settings have the opposite gap — inline edits do not register with the global dirty blocker and tab switches are unguarded. Neither surface handles unsaved state in a cohesive way.

Current behaviour

Agent settings:

  • AgentNavigation registers global dirty state via useRegisterDirtySource(isDirty) (agent-navigation.tsx)
  • DirtyBlockerProvider blocks any route navigation when dirty, including switching between agent tabs (each tab is a separate route) (dirty-blocker-provider.tsx)
  • Dialog is two-button only (Stay / Discard) — no Save & Leave because onSaveAll is not passed to the provider on the dashboard shell (routes/dashboard/$id.tsx)
  • Save / Discard live in EditorActions in the tab nav header
  • Per-tab amber dots indicate which tabs have changes (tab-navigation.tsx, agent-navigation.tsx)

Automation settings:

  • Configuration tab is read-only; agent instructions/env edits happen in dialogs with local isDirty only (agent-instructions-dialog.tsx, agent-env-dialog.tsx)
  • Automation tabs use @tale/ui/tabs with URL ?tab= — client state, no navigation blocker (automation-page.tsx)
  • No unsaved-changes prompt when leaving automation pages or switching automation tabs

Proposed change

Design and implement a consistent unsaved-changes strategy for settings surfaces:

  1. Agent tabs: Switching between tabs on the same agent should not feel like leaving the page — consider scoping the blocker to cross-entity navigation (different agent, different section) while preserving edits per tab, or offer Save & Leave in the dialog via onSaveAll.
  2. Automation settings: Wire inline edits into the same dirty-source / blocker pattern where edits can be lost.
  3. Shared UX: Per-tab dirty indicators (Improvement: Add per-tab unsaved indicator to automation settings #2573) plus a dialog that offers a path to save when possible, not only Stay / Discard.

The exact approach should follow existing editor infrastructure (DirtyBlockerProvider, useRegisterDirtySource, changedKeys) rather than inventing a one-off per page.

Acceptance criteria

  • Switching agent settings tabs with unsaved edits on the current tab is handled predictably (no surprise data loss, no unnecessary friction).
  • Leaving an agent or automation settings context with unsaved edits shows a clear prompt with a save path when save is available.
  • Automation inline edits (instructions, environment, configuration changes) participate in the same dirty-state model.
  • Behaviour is consistent between agent settings and automation settings.
  • Existing Save / Discard header actions continue to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions