Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

After the SSH runtime commit (#178, commit 5f200a6), there was significant duplication in test infrastructure and repeated copy-to-clipboard patterns across components.

Test Infrastructure Consolidation

Consolidated 3 overlapping test helper modules and inline duplicates into tests/ipcMain/helpers.ts:

  • Added extractTextFromEvents(), sendMessageAndWait(), createWorkspaceWithInit()
  • Centralized test constants (INIT_HOOK_WAIT_MS, SSH_INIT_WAIT_MS, HAIKU_MODEL, timeouts)
  • Updated 4 test files to use consolidated helpers
  • Deleted tests/ipcMain/test-helpers/runtimeTestHelpers.ts (149 lines)

Result: -240 lines, single source of truth for ipcMain integration test utilities.

Copy-to-Clipboard Deduplication

The copy feedback pattern (copied state + 2000ms timeout) was duplicated across 4 components with identical implementations.

  • Created src/hooks/useCopyToClipboard.ts for reusable copy functionality
  • Added COPY_FEEDBACK_DURATION_MS constant to src/constants/ui.ts
  • Updated AssistantMessage, UserMessage, ProposePlanToolCall, FileEditToolCall

Result: 54 lines of duplicated code replaced with single 33-line hook.

Generated with cmux

After the SSH runtime commit (#178), testing infrastructure had significant
duplication across helper modules and inline functions.

Changes:
- Consolidated shared utilities into tests/ipcMain/helpers.ts
  - Added extractTextFromEvents(), sendMessageAndWait(), createWorkspaceWithInit()
  - Centralized test constants (INIT_HOOK_WAIT_MS, SSH_INIT_WAIT_MS, HAIKU_MODEL, etc.)
- Deleted tests/ipcMain/test-helpers/runtimeTestHelpers.ts (149 lines)
- Removed inline helper duplicates from test files
  - runtimeFileEditing.test.ts: -120 lines
  - removeWorkspace.test.ts: -39 lines
  - renameWorkspace.test.ts: -45 lines
  - runtimeExecuteBash.test.ts: simplified imports

Result: 240 net lines removed, improved consistency across integration tests.

All tests use consistent patterns from single source of truth.
The copy feedback pattern (copied state + 2000ms timeout) was duplicated across
4 components with identical implementations.

Changes:
- Created src/hooks/useCopyToClipboard.ts hook for reusable copy functionality
- Added COPY_FEEDBACK_DURATION_MS constant to src/constants/ui.ts (2000ms)
- Updated components to use the hook:
  - AssistantMessage: -11 lines
  - UserMessage: -18 lines (also removed useState import)
  - ProposePlanToolCall: -12 lines
  - FileEditToolCall: -13 lines

Result: 54 lines of duplicated code replaced with single 33-line hook.
Single source of truth for copy feedback duration and implementation.
@ammario ammario enabled auto-merge October 27, 2025 03:07
@ammario ammario added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit 9db5f11 Oct 27, 2025
13 checks passed
@ammario ammario deleted the rt-test-dedup branch October 27, 2025 03:22
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.

2 participants