Skip to content

fix: Enable clipboard copy/paste in dashboard terminals#43

Merged
waleedkadous merged 4 commits into
mainfrom
builder/task-ynWc
Dec 6, 2025
Merged

fix: Enable clipboard copy/paste in dashboard terminals#43
waleedkadous merged 4 commits into
mainfrom
builder/task-ynWc

Conversation

@waleedkadous
Copy link
Copy Markdown
Contributor

Summary

Fixes GitHub issue #42: Cannot cut and paste from terminals.

Root cause: ttyd terminals embedded in iframes lacked clipboard permissions. The browser's Permissions Policy blocks clipboard access for cross-origin iframes by default.

Solution:

  • Added allow="clipboard-read; clipboard-write" to all iframe elements in the dashboard
  • Added rightClickSelectsWord=true ttyd option for better UX (standard macOS behavior)

Changes

  1. Dashboard templates (codev/templates/dashboard-split.html, codev-skeleton/templates/dashboard-split.html)

    • Added clipboard permissions to iframe elements
  2. ttyd configurations (start.ts, util.ts, dashboard-server.ts)

    • Added rightClickSelectsWord=true for better selection UX

How to test

  1. Start agent-farm: ./codev/bin/agent-farm start
  2. In the dashboard, try to:
    • Select text in the terminal and Cmd+C to copy
    • Cmd+V to paste into the terminal
    • Right-click on a word to select it
  3. Verify clipboard works in both architect terminal and shell tabs

Test plan

  • Unit tests pass (35/35)
  • Integration tests pass (existing failures unrelated to this change)
  • TypeScript compiles without errors
  • Manual testing in browser

Resolves: #42

Fixes GitHub issue #42.

Root cause: ttyd terminals embedded in iframes lacked clipboard permissions.

Changes:
1. Add allow="clipboard-read; clipboard-write" to all iframe elements in
   the dashboard templates to grant clipboard access via Permissions Policy
2. Add rightClickSelectsWord=true option to ttyd for better UX - this is
   standard behavior in macOS applications

Files changed:
- codev/templates/dashboard-split.html (iframe permissions)
- codev-skeleton/templates/dashboard-split.html (iframe permissions)
- agent-farm/src/commands/start.ts (ttyd option)
- agent-farm/src/commands/util.ts (ttyd option)
- agent-farm/src/servers/dashboard-server.ts (ttyd option)

Resolves: #42
@waleedkadous
Copy link
Copy Markdown
Contributor Author

3-Way Review Synthesis (Claude + Codex + Gemini)

Verdict: REQUEST_CHANGES (Minor)

The fix is well-reasoned and correctly identifies the root cause (Permissions Policy blocking clipboard in iframes). However, the implementation is incomplete:

Required Changes

1. Missing clipboard permissions in non-split dashboard
codev/templates/dashboard.html:91 and codev-skeleton/templates/dashboard.html:91 still render iframes without allow="clipboard-read; clipboard-write". Users of the non-split dashboard layout won't have clipboard access fixed.

2. Missing rightClickSelectsWord in spawn.ts
Three ttyd spawn locations are missing the new option:

  • agent-farm/src/commands/spawn.ts:250 (builder)
  • agent-farm/src/commands/spawn.ts:296 (shell)
  • agent-farm/src/commands/spawn.ts:610 (review/shell)

Only start.ts, util.ts, and dashboard-server.ts received the flag.

Recommended Tests

Add basic tests to prevent regression:

test('dashboard iframe includes clipboard permissions', () => {
  const html = fs.readFileSync('codev/templates/dashboard-split.html', 'utf8');
  expect(html).toMatch(/allow="clipboard-read; clipboard-write"/);
});

test('ttyd spawns with rightClickSelectsWord option', () => {
  // Verify args include '-t', 'rightClickSelectsWord=true'
});

What's Good

  • Correct root cause analysis (Permissions Policy)
  • Clean, focused changes
  • Good comments explaining purpose
  • Existing tests pass (35/35)

🤖 Synthesized from Claude Code, Codex, and Gemini reviews

- Add clipboard permissions to non-split dashboard.html (codev + skeleton)
- Add rightClickSelectsWord to spawn.ts builder/shell/worktree functions

Addresses review feedback on PR #43
@waleedkadous
Copy link
Copy Markdown
Contributor Author

✅ Review feedback addressed in f6f87c0:

  • Added clipboard permissions to non-split dashboard.html templates
  • Added rightClickSelectsWord to all spawn.ts ttyd launch points

Ready for re-review.

@waleedkadous
Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Fixed the two issues identified in the 3-way review:

1. Non-split dashboard.html templates ✅

Added allow="clipboard-read; clipboard-write" to all iframes in:

  • codev/templates/dashboard.html:91,122
  • codev-skeleton/templates/dashboard.html:91,122

2. Missing rightClickSelectsWord in spawn.ts ✅

Added -t rightClickSelectsWord=true to all three ttyd spawn locations:

  • agent-farm/src/commands/spawn.ts:254 (builder)
  • agent-farm/src/commands/spawn.ts:301 (shell)
  • agent-farm/src/commands/spawn.ts:616 (worktree)

Verification

  • ✅ TypeScript compiles without errors
  • ✅ All 35 unit tests pass

- Test that all dashboard HTML templates include clipboard permissions
- Test that all ttyd spawn locations include rightClickSelectsWord
- Prevents regression of issue #42 fix

9 new tests added, all passing (44 total)
@waleedkadous
Copy link
Copy Markdown
Contributor Author

Tests Added

Added agent-farm/src/__tests__/clipboard.test.ts with 9 regression tests:

Dashboard clipboard permissions (4 tests):

  • Tests all 4 dashboard HTML templates for allow="clipboard-read; clipboard-write" on iframes

ttyd rightClickSelectsWord (5 tests):

  • Tests start.ts, util.ts, spawn.ts, and dashboard-server.ts for rightClickSelectsWord option
  • Verifies all ttydArgs definitions in spawn.ts include the option

Results: All 44 tests pass (35 existing + 9 new)

waleedkadous added a commit that referenced this pull request Dec 5, 2025
- Add clipboard permissions to non-split dashboard.html (codev + skeleton)
- Add rightClickSelectsWord to spawn.ts builder/shell/worktree functions

Addresses review feedback on PR #43
@waleedkadous waleedkadous merged commit b33242a into main Dec 6, 2025
@waleedkadous waleedkadous deleted the builder/task-ynWc branch December 6, 2025 04:33
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.

Cannot cut and paste from terminals

1 participant