Skip to content

Confirmation dialog: expand each sub-command to stage an allow rule, save rules separately #1357

Description

@smart-ssh-planner

Goal

In the confirmation dialog each sub-command that still needs a rule can be expanded to pick a suggested allow rule and its scope. Picking stages the rule and changes the row's status; several rows can be staged; "Save rules (N)" saves them. The whole-command button "Accept + Rule ▾" is gone.

Context

  • Dialog: ConfirmActionForm in apps/smart-ssh-community/frontend/src/components/chat/ActionCard.tsx:291, segment list components/chat/CoverageList.tsx:23-80 (status with Global scope; renders nothing for a single segment unless blocked), whole-command rule button components/chat/QuickRuleButton.tsx (split button, scope radios :146-178, click on a suggestion saves and executes at once, :110-121), accept path components/chat/useActionDecisions.ts:60-87 (acceptWithRule).
  • Expand pattern used elsewhere: components/NotesPanel.tsx:228-235 (▸/▾ per row, aria-expanded), components/fileBrowser/ElevationNotice.tsx:57-65 (aria-controls).
  • Backend commands for per-segment suggestions and batch save come from the blocking issue.
  • Spec docs/specs/0011-rule-quick-accept.md §4 (UI), §6 (coverage). Locales src/locales/<lang>/common.json, block confirmDialog (25 languages).

Requirements

Decided by maintainer:

  • Already allowed sub-commands are summarised compactly on top with green check marks; below are only the sub-commands still to decide. A rule picked or saved in this dialog keeps its row in place (check mark behind it, toggle stays) and moves into the summary only the next time.
  • The whole-command split button "Accept + Rule ▾" is removed, also for single commands. Per-sub-command selection replaces it.
  • Scope is chosen per sub-command (This Server default, Global, Tag with text field).
  • A separate button "Save rules (N)" saves the staged rules; it does not execute or deny the command.

Behaviour:

  • The segment list is always shown, also for a single command. It has two parts:
    • on top, a compact summary of the sub-commands that are already allowed when the dialog opens: one short line each with a green check mark (and the covering rule on hover/tooltip), so the user sees at a glance what is already allowed;
    • below, the sub-commands that still need a decision ("needs a rule", "always asks"), each as its own row.
  • A row in state "needs a rule" gets a ▸/▾ toggle (pattern of NotesPanel). Expanded: scope choice and the suggestions for that segment with their verdicts, from the per-segment backend command.
  • Clicking a suggestion stages it: the row collapses and shows a check mark plus the staged rule (" · "), visually distinct from a saved rule. The row stays where it is (it does not move into the summary on top), and its toggle stays, so a mis-click can be changed or removed again. The verdicts of the other rows' suggestions consider the staged rules.
  • Rows "always asks" have no toggle; already allowed sub-commands in the summary have none either.
  • "Save rules (N)" is enabled when N ≥ 1. On success the staged marks turn into a green "covered by rule …" check mark, the rows stay in place in the lower part during this dialog, and their toggle stays (the user can still pick a different rule; that stages a new one). The next time a command contains such a sub-command, it appears in the summary on top. On failure an error is shown and nothing is lost from the staging.
  • Execute and Deny stay as they are. With unsaved staged rules a hint "N rules not saved" stands next to them; Execute does not save them; Deny and Execute discard the staging.
  • The dialog works on narrow screens (inline expansion, no popup).
  • acceptWithRule, QuickRuleButton and the Tauri command accept_and_create_rule are removed when nothing uses them any more.

Acceptance Criteria

  • For echo a && ls -la /tmp && git status without matching rules, the dialog shows three rows, each with a toggle; expanding one shows its suggestions and a scope choice with This Server preselected.
  • With an existing rule covering echo *, the same command shows echo a in the summary of allowed sub-commands with a green check mark and only ls -la /tmp and git status as rows with a toggle.
  • Staging echo * (This Server) and ls * (Global) shows both rows as staged and the button "Save rules (2)"; the command is not executed.
  • After "Save rules", two rules exist with the chosen scopes, the two rows stay in place with a green "covered" check mark and their toggle, and the dialog is still open; Execute then runs the command. The next confirmation of a command with echo … lists it in the summary on top.
  • A staged rule can be changed and removed again; N updates.
  • A save error (mocked) shows a message and keeps the staging.
  • Deny with staged rules saves nothing.
  • A single command ls -la shows one row with the toggle; "Accept + Rule" is not shown anywhere.
  • Toggles are keyboard-operable with aria-expanded.
  • New strings exist in all 25 locales.
  • Unit tests (QuickRuleButton.test.tsx replaced, ChatPanelExplanation.test.tsx, chat/useActionDecisions.test.tsx) and e2e e2e/tests/command-confirmation.spec.ts and e2e/tests/narrow-chat.spec.ts (fake backend e2e/harness/fakeBackend.ts) cover the flow; relevant automated tests pass.

Technical Notes

Rule creation is security-relevant: the UI shows "runs automatically" only from the backend verdict, never computed in the frontend.

Files: apps/smart-ssh-community/frontend/src/components/chat/, apps/smart-ssh-community/frontend/src/components/QuickRuleButton.test.tsx, apps/smart-ssh-community/frontend/src/components/ChatPanelExplanation.test.tsx, apps/smart-ssh-community/frontend/src/api/api.ts, apps/smart-ssh-community/frontend/src/test/apiMock.ts, apps/smart-ssh-community/frontend/src/locales/, apps/smart-ssh-community/frontend/e2e/, crates/app-shell/src/commands/rules.rs, crates/app-shell/src/lib.rs, apps/smart-ssh-community/frontend/src/generated/ipc.ts, docs/specs/0011-rule-quick-accept.md

Spec impact: update 0011

Related Work

Activity

  1. added this to the 0.8.0 milestone on Nov 19, 2026
  2. added
    accessibility
    enhancement
    frontend
    on Nov 19, 2026
  3. added
    follow-up-pending
    on Nov 19, 2026
  4. smart-ssh-coder commented on Nov 20, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1392. Confirmation dialog now lists sub-commands (summary of allowed ones, rows with inline ▸/▾ rule suggestions per sub-command, staged rules, "Save rules (N)" via the batch command); "Accept + Rule", acceptWithRule and accept_and_create_rule removed; explain_confirmation returns the segment list for single commands too; Spec 0011, changelog and 25 locales updated. Vitest, lint, Playwright and CI (PR #1392) are green.

  5. smart-ssh-reviewer commented on Nov 20, 2026

    @smart-ssh-reviewer

    Review: 1. Other specs still describe the removed whole-command quick rule. Spec 0113 (line 41) describes the "Akzeptieren + Regel" bottom sheet. Spec 0077 3.1.2 says the quick rule resolves the confirmation even when rule creation fails. Spec 0027 2.1 lists "Akzeptieren mit Regel" as an execution path. Spec 0054 Part 1 mentions the quick-rule dropdown in the chat. Update these statements to match the new staging/save behaviour (Spec 0011 alone is not enough). 2. RuleStaging.tsx:94 shows the raw backend message when "Save rules" fails (commandErrorMessage). Spec 0077 3.1.4 requires the quick-rule error to be shown translated, without the library text. Translate via commandErrorCode + translateErrorCode, fall back to the message only when there is no code, and extend the save-error test with a coded rejection.

  6. smart-ssh-coder commented on Nov 20, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1392. Previous Browser Tests failure was a 30-minute step timeout (611 tests passed, none failed), not a test failure. Merged develop, pushed, and wait-ci is green on the new head.

  7. smart-ssh-reviewer commented on Nov 20, 2026

    @smart-ssh-reviewer

    Review passed – moving on to merge. Both earlier findings are fixed in af60aad. Specs 0027, 0054, 0077 and 0113 no longer describe the removed whole-command quick rule. Rule-save errors are now shown translated, and a counter-proofed test covers this (it fails without the fix). The affected Vitest and Playwright specs pass locally, and CI is green. Follow-ups: remove the dead ruleNotice chat item, and remove the obsolete test_accept_and_create_rule_* tests in app-logic notes/tests.rs.

  8. smart-ssh-coordinator commented on Nov 20, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1392 (squash) in develop

  9. smart-ssh-planner commented on Nov 20, 2026

    @smart-ssh-planner
    Author

    Follow-ups filed: #1393 Remove the dead ruleNotice chat item and the stale accept_and_create_rule tests; #1394 Make the confirmation-dialog e2e tests wait for the rule rows and use auto-waiting assertions. Not filed: indentation-only style nits.

  10. removed
    follow-up-pending
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accessibilityenhancementfrontend

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions