Volver a Documentación
Execution

Copy Buttons

Template-driven handoff from implementation plans to PTY terminals and external tools.

10 min de lectura

Copy buttons resolve template placeholders against the active plan and then send the result to the clipboard (plan views) or the PTY (terminal modal). They are a lightweight way to hand plan context to agent CLIs or terminals without extra steps.

Template resolution flow

Templates resolve {{IMPLEMENTATION_PLAN}}, {{TASK_DESCRIPTION}}, and {{STEP_CONTENT}} before copying or sending to the terminal.

Flow showing copy button template resolution
Click to expand
Placeholder for a template resolution flow diagram.

Template Configuration Sources

Copy button templates follow a layered configuration model. Server defaults provide baseline templates, and project-level overrides customize the implementation_plan task for a given repo.

Server Defaults

Shared templates from /api/config/desktop-runtime-config. Includes button labels and template strings.

Project Overrides

Templates stored in SQLite key_value_store under project_task_settings. Merged at runtime with server defaults to customize team standards.

Task-Specific

Copy buttons are configured per task type (implementation_plan) and stored per project. There is no per-job override in the current release.

Placeholder Resolution

Templates use double-brace placeholders that are resolved against the active plan and session context at click time. Supported placeholders include the full plan, the current task description, and the selected step content.

// Example template with placeholders
You are an AI coding assistant. Execute the following plan:

{{IMPLEMENTATION_PLAN}}

Task: {{TASK_DESCRIPTION}}

Available Placeholders

{{IMPLEMENTATION_PLAN}}Full plan content as shown in the viewer
{{STEP_CONTENT}}Content of the selected plan step (when a step is selected)
{{TASK_DESCRIPTION}}Current task description from the session

Resolution: Missing placeholders are replaced with empty strings. Step content is only available when a plan step is selected.

Template Processing Pipeline

When a button is clicked, the template processor executes a multi-step pipeline: placeholder extraction, context lookup, value substitution, and delivery to clipboard or terminal.

1

Extract Placeholders

Regex scan for {{...}} patterns in the template string

2

Lookup Context

Query job metadata, plan content, and session state for values

3

Substitute Values

Replace placeholders with resolved values, preserving formatting

4

Send Output

Copy to clipboard (plan views) or write to the PTY input buffer (terminal modal)

Large Plan Chunking

Terminal handoff splits large content into 4KB segments and appends a carriage return after sending. Clipboard copy is a single write.

PTY Terminal Handoff

In the plan terminal modal, copy buttons write the resolved template to the PTY input buffer. Large content is chunked and a carriage return is appended after sending.

// Terminal handoff (PlanTerminalModal)
const textToSend = replacePlaceholders(button.content, {
  IMPLEMENTATION_PLAN: planContent,
  TASK_DESCRIPTION: taskDescription ?? ''
});
await sendInChunks(sessionId, textToSend);

Handoff Details

  • • Content sent via write_terminal_input_command
  • • Chunked into 4KB segments for large plans
  • • Appends a carriage return after sending

Clipboard Handoff

In plan cards and plan modals, buttons copy the resolved template to the system clipboard using the browser clipboard API. This enables handoff to external tools like IDE terminals or web-based agents.

Cross-Platform API

Uses navigator.clipboard.writeText() inside the Tauri webview for clipboard access.

User Feedback

Toast notification confirms the copy action.

Default Copy Buttons

PlanToCode ships with several default copy buttons that cover common workflows. These can be customized or extended through project settings.

Parallel Claude Coding Agentsparallel-agents

Template that instructs Claude Code to launch parallel agents using the plan.

Investigate Resultsinvestigate-results

Template that asks the agent to review changes without launching new agents.

Tasktask-only

Copies only the task description.

Task + Plantask-and-plan

Combines task description and plan for full context.

Planplan-only

Copies only the plan content.

Customizing Copy Buttons

Copy buttons can be customized at two levels: global defaults and project-level overrides for the implementation_plan task type.

Global Defaults

Server-side configuration in /api/config/desktop-runtime-config defines the base set of copy buttons. These are loaded when the desktop app starts and cached for offline use.

Project-Level Customization

Each project can override the default buttons through the Settings panel. Project-specific buttons are stored in key_value_store and merged with server defaults at runtime.

Task-Level Configuration

Copy buttons are configured per task type (implementation_plan) and stored per project. There are no per-job overrides.

The copy button editor in Settings allows drag-and-drop reordering, inline label editing, and template content modification. Changes are debounced and persisted automatically.

UI Integration and Safety

Copy buttons appear in plan viewers and terminal headers. Clicking a button sends output immediately; there is no preview step by default.

Token Counts

Plan cards display total token counts for the plan job. Copy buttons do not compute per-template token estimates.

Preview

There is no preview popover or modal in the current release. Open the plan content to inspect what will be copied.

Disabled State

Buttons are disabled when required context is missing (e.g., no active plan, missing session). Tooltips explain what context is needed to enable the button.

Mobile Integration

Copy buttons work across desktop and mobile clients with consistent behavior. The iOS client uses the same placeholder resolution logic and can send content to linked terminals.

Device Link Support

When a mobile device is linked to a desktop session, copy buttons can target the desktop terminal directly. The resolved content is sent through the device link WebSocket connection.

Mobile-Specific Buttons

Mobile clients support the same button customization as desktop. Button configurations sync through the server to maintain consistency across devices.

Trace handoff to execution

Terminal sessions show where copy button output lands and keep the session output log.