Skip to content

Allow a snippet as host Pre/Post command (keep inline support); fix docs mismatch #63

Description

@kipavy

Summary

Allow a saved snippet to be used as a host Pre-command (and Post-command), in addition to the current inline command string. The docs already describe this as if it exists, but the implementation only supports a literal inline command — so this is both a feature request and a docs/product mismatch to close.

Current behavior

The host Pre/Post command fields are plain single-line text inputs whose raw string is written verbatim to the shell. There is no snippet integration anywhere in the path:

  • UIConnectionForm.tsx:567-583: plain <input> fields (placeholders "Pre Command" / "Post Command"). No snippet picker / reference.
  • Passthroughconnection.pre_commandsessionStore.ts:131ssh.ts:52, untouched.
  • Backend — typed straight into the shell:
    • client.rs:892writer.write_all(format!("{}\n", cmd)) on connect
    • session.rs:242/256 — same for post_command on disconnect

No snippet_id resolution, no steps expansion, no snippet lookup. Multi-step snippets — snippet-call and transfer steps (SnippetStep, types/index.ts:234) — cannot run here at all. A one-line snippet only "works" if you manually paste its command text (i.e. it's inline, not a snippet).

Docs mismatch

https://docs.voltius.app/terminal/snippets currently claims:

"Set a snippet as the Pre-command on a host (connection form → Advanced) to run it every time you connect."

That capability does not exist today. Either the docs should be corrected or the feature built — this issue proposes building it.

Proposed behavior

  • Let the Pre-command and Post-command fields accept either an inline command string (current behavior — must keep working) or a reference to a saved snippet.
  • Add a snippet picker affordance next to each field (e.g. a small "insert snippet" button) that stores a snippet reference.
  • On connect (pre) / disconnect (post), resolve the snippet and run its full step sequence — including multi-step, snippet-call, and transfer steps — reusing the existing snippet-run engine rather than just writing a raw line.
  • Post-command clarification: it currently runs on disconnect, not connect; the docs only mention pre-command. Decide whether snippet-as-post-command is in scope and document accordingly.

Requirements / constraints

  • Inline commands must remain fully supported. The field is a superset, not a replacement.
  • Reuse the existing snippet execution path so behavior matches running the snippet manually.
  • Storage: a connection needs to persist whether pre/post is an inline string or a snippet reference (pre_command is currently Option<String>).

Acceptance

  • Inline pre/post commands still work exactly as today.
  • A saved snippet can be assigned as a host pre-command and runs its full step sequence on connect.
  • Docs at /terminal/snippets match the shipped behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions