Skip to content

feat(prompts): add create and rename flows for CLI and TUI#160

Merged
SaladDay merged 2 commits intoSaladDay:mainfrom
brushax:feat/prompt-rename
May 6, 2026
Merged

feat(prompts): add create and rename flows for CLI and TUI#160
SaladDay merged 2 commits intoSaladDay:mainfrom
brushax:feat/prompt-rename

Conversation

@brushax
Copy link
Copy Markdown
Contributor

@brushax brushax commented May 6, 2026

Summary

This PR completes prompt management as a first-class workflow instead of leaving it half in CLI and half missing in TUI.

It adds:

  • prompt rename for both CLI and TUI
  • prompt creation flow in TUI
  • explicit prompt naming on CLI create
  • prompt list refresh action in TUI for external changes

What changed

CLI

  • Added cc-switch prompts rename <id> [name]
  • rename falls back to an interactive single-line prompt when name is omitted
  • Extended cc-switch prompts create to cc-switch prompts create [name]
  • create now lets users set the prompt name up front instead of only generating a timestamp name

TUI

  • Added c on the Prompts page to create a prompt
  • Added n on the Prompts page to rename a prompt
  • Added r on the Prompts page to reload prompt data so prompts created outside the current TUI session become visible without restarting
  • Reused the existing single-line TextInput overlay for prompt naming and the existing multiline editor for prompt content

Shared backend

  • Added PromptService::create_prompt(...)
  • Added PromptService::rename_prompt(...)
  • Added shared prompt id generation so CLI and TUI create flows behave consistently

Why this design

The original prompt UX had three gaps:

  • TUI exposed prompt viewing/editing/activation but not creation
  • CLI-created prompts were easy to miss in TUI because there was no prompt-page refresh action
  • prompt names were effectively timestamp-generated on create, which made the workflow awkward if the user already knew the intended name

This change keeps the implementation aligned with existing repo patterns:

  • name entry uses the current single-line overlay
  • content editing uses the current editor
  • persistence goes through shared service methods instead of duplicating logic in CLI and TUI

Validation

Ran with cargo +stable in src-tauri/.

Passed:

  • cargo +stable fmt --all
  • cargo +stable test --test prompt_commands -- --nocapture
  • cargo +stable test prompts_ --lib -- --nocapture
  • cargo +stable test submit_prompt_create_persists_prompt_and_refreshes_selection --lib -- --nocapture

Notes

The local environment still has a flaky install path for the repo's pinned Rust 1.91.1 toolchain, so validation was run with cargo +stable.

Copilot AI review requested due to automatic review settings May 6, 2026 08:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes prompt management workflows across both the CLI and the TUI by adding create + rename flows, a TUI refresh action, and shared backend service methods so both frontends behave consistently.

Changes:

  • Added prompt creation (TUI overlay + editor submit) and prompt renaming (CLI + TUI) workflows.
  • Introduced shared backend helpers: PromptService::create_prompt, PromptService::rename_prompt, and shared prompt ID generation.
  • Updated TUI key hints/help text, CLI command surface (create [name], new rename <id> [name]), and added/extended tests.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src-tauri/tests/prompt_commands.rs Adds tests covering prompt create (explicit name) and rename behavior.
src-tauri/src/services/prompt.rs Adds shared prompt ID generation plus create_prompt/rename_prompt service methods.
src-tauri/src/cli/tui/ui/prompts.rs Updates Prompts page key legend to include create/refresh/rename.
src-tauri/src/cli/tui/runtime_actions/prompts.rs Adds runtime action handler for prompt rename.
src-tauri/src/cli/tui/runtime_actions/mod.rs Wires Action::PromptRename into the runtime action dispatcher.
src-tauri/src/cli/tui/runtime_actions/editor.rs Adds editor submit handling for prompt creation and a corresponding test.
src-tauri/src/cli/tui/app/types.rs Extends TextSubmit to support prompt create-name and rename flows.
src-tauri/src/cli/tui/app/tests.rs Adds TUI key/overlay/action unit tests for create/rename/refresh behavior.
src-tauri/src/cli/tui/app/overlay_handlers/dialogs.rs Handles prompt create-name and rename submits via the text input overlay.
src-tauri/src/cli/tui/app/editor_state.rs Adds EditorSubmit::PromptCreate.
src-tauri/src/cli/tui/app/content_entities.rs Adds prompts-page keybindings: c create, r reload, n rename.
src-tauri/src/cli/tui/app/content_config.rs Adds helper to open the create-name text input overlay with a default name.
src-tauri/src/cli/tui/app/app_state.rs Adds new Action::PromptRename { id, name }.
src-tauri/src/cli/mod.rs Updates CLI command description to include create/rename.
src-tauri/src/cli/i18n/texts/toasts.rs Adds new toasts for prompt created/renamed.
src-tauri/src/cli/i18n/texts/providers.rs Adds a TUI key label for “rename”.
src-tauri/src/cli/i18n/texts/core.rs Updates TUI help text to include new prompt keybindings.
src-tauri/src/cli/i18n/texts/config_actions.rs Adds prompt create/rename overlay titles/prompts and empty-name toast text.
src-tauri/src/cli/i18n.rs Mirrors i18n updates (help/footer/key labels/toasts/prompts) in the monolithic texts module.
src-tauri/src/cli/commands/prompts.rs Extends CLI prompts commands: create [name] and new rename <id> [name].
README.md Documents new/updated CLI prompt commands.
README_ZH.md Documents new/updated CLI prompt commands (Chinese).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src-tauri/src/services/prompt.rs
Comment thread src-tauri/src/cli/tui/runtime_actions/prompts.rs Outdated
Comment thread src-tauri/src/cli/tui/runtime_actions/editor.rs Outdated
@SaladDay
Copy link
Copy Markdown
Owner

SaladDay commented May 6, 2026

LGTM, THANKS!

@SaladDay SaladDay merged commit f2daf4e into SaladDay:main May 6, 2026
2 checks passed
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