Skip to content

Action card: show chained commands one per line with a formatted/original toggle #1663

Backlog

Description

@smart-ssh-planner

Goal

In the chat action card, a command that chains several independent commands is shown one command per line, with a toggle back to the original single line, so the user can review AI-proposed commands (from the chat and from MCP clients) at a glance.

Context

  • apps/smart-ssh-community/frontend/src/components/chat/ActionCard.tsx renders the command as one <code> block ($ prefix, whitespace-pre-wrap, strike-through when rejected/expired/blocked), from describeAction (components/chat/chatItem.ts).
  • The blocking issue adds the IPC command command_display_layout(command) → null or lines { text, operator } (see the epic's shared decisions).
  • ActionCard also hosts the command editor for "edit then approve" (initialCommand), which keeps the raw text.
  • No spec describes the action card's command block yet (related: 0026/0029 risk badges, 0027 cancel, 0028 MCP).

Requirements

  • For every action card with a shell command (pending, auto-executed, executed, rejected, expired, blocked; chat and MCP sessions), call command_display_layout once per command (cache by command text) and, when it returns lines, render them one per line: each line its text followed by its operator (;, &&, ||, &) at the end; the $ prompt only before the first line; long lines still wrap.
  • Toggle (decided by maintainer) next to the command, icon button with an accessible name ("Show original" / "Show formatted") and aria-pressed; default: formatted. The choice is global and remembered across cards and app restarts (frontend preference, same mechanism as other remembered UI choices). The toggle is shown only when the layout has more than one line.
  • Pipes are never broken (comes from the core layout).
  • When the layout is null or the IPC call fails, the card shows the original single line exactly as today, without a toggle.
  • Strike-through and colour states apply to all lines.
  • Selecting and copying the command text yields the original command (e.g. a copy handler or a hidden original), never the reformatted text.
  • The "edit then approve" editor keeps the original raw text.
  • Labels in all app locales.

Acceptance Criteria

  • echo a; echo b && rm -f x shows three lines with ; and && at the line ends; cat f | grep x; ls shows two lines with the pipeline intact.
  • The toggle switches to the original single line and back; the choice persists for other cards and after reload.
  • No toggle for a single command or for a command the layout returns null for (e.g. a here-doc); such commands render exactly as before.
  • Copying from a formatted card puts the original command on the clipboard.
  • Rejected/expired cards show the strike-through on every line.
  • Works for MCP-originated action cards as well as chat ones.
  • Unit tests in a new test file for the command block component; a Playwright e2e test for the formatted view and the toggle; axe checks pass.
  • New spec describing the command display in the action card.
  • Relevant automated tests pass.

Technical Notes

  • Put the rendering in its own component (e.g. components/chat/CommandBlock.tsx + CommandBlock.test.tsx) and use it from ActionCard.tsx.
  • Display-only: what is confirmed and executed is unchanged; the IPC result is never sent back to the backend.

Files: apps/smart-ssh-community/frontend/src/components/chat/ (new CommandBlock component and test, ActionCard.tsx), apps/smart-ssh-community/frontend/src/api/api.ts, apps/smart-ssh-community/frontend/src/locales/, apps/smart-ssh-community/frontend/e2e/tests/, docs/specs/ (new spec)

Spec impact: new

Open questions

  • None.

Related Work

  • Part of the epic (linked as parent); blocked by the core display-layout issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrontend

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions