Skip to content

fix(ui): 🐛 fix double-paste and related UI issues#185

Open
HayWolf wants to merge 3 commits into
masterfrom
fix/composer-double-paste
Open

fix(ui): 🐛 fix double-paste and related UI issues#185
HayWolf wants to merge 3 commits into
masterfrom
fix/composer-double-paste

Conversation

@HayWolf
Copy link
Copy Markdown
Contributor

@HayWolf HayWolf commented May 16, 2026

Summary

  • Fix pasted image duplication on macOS in prompt input by deduplicating by MIME type
  • Hide BranchSelector when git repository or CLI is unavailable
  • Refactor command creation to separate field updates from backend commit

Test Plan

  • Verify pasting a single image no longer duplicates on macOS
  • Verify BranchSelector is hidden in non-git workspaces
  • Verify new command creation works correctly with explicit save/commit

🤖 Generated with TiyCode

@github-actions
Copy link
Copy Markdown

AI Code Review Summary

PR: #185 (fix(ui): 🐛 fix double-paste and related UI issues)
Preferred language: English

Overall Assessment

Detected 5 actionable findings, prioritize CRITICAL/HIGH before merge.

Major Findings by Severity

  • HIGH (2)
    • src/modules/settings-center/model/settings-ipc-actions.ts:1128 - Missing tests for commitNewCommand error handling and inflight cleanup
    • src/modules/settings-center/ui/settings-center-overlay.tsx:1620 - Missing tests for pendingCreate command edit and cancel interactions
  • MEDIUM (3)
    • src/modules/settings-center/model/settings-ipc-actions.ts:1093 - Missing boundary tests for commitNewCommand empty name guard
    • src/modules/settings-center/model/settings-ipc-actions.ts:1095 - Missing tests for commitNewCommand non-Tauri fallback
    • src/modules/settings-center/ui/settings-center-overlay.tsx:1713 - Missing tests for command remove button source gate

Actionable Suggestions

  • Scope clipboard deduplication in prompt-input.tsx to avoid dropping distinct files of the same MIME type, or verify multi-file paste is unsupported.
  • Make commitNewCommand awaitable (return Promise) so settings-center-overlay.tsx can exit edit mode only after successful commit and surface errors to the user.
  • Add explicit user-facing validation or a pending/loading indicator in the command row while commitNewCommand is inflight.
  • Add comprehensive Vitest tests for commitNewCommand in settings-ipc-actions.ts: non-existent ID, non-pending entry, empty/whitespace name, non-Tauri store update, Tauri success, Tauri error with inflight cleanup, and concurrent invocation deduplication.
  • Expose or isolate inflightCreateIds module state so tests can reset it between runs and avoid flakiness.
  • Add tests for prompt-input.tsx paste handler: duplicate MIME types, empty type strings, and multiple files.
  • Add React Testing Library tests for CommandItem in settings-center-overlay.tsx: pendingCreate edit commits, pendingCreate cancel removes, and remove button visibility per source.
  • Add component tests for BranchSelector conditional rendering in dashboard-workbench.tsx when git capabilities are false or undefined.

Potential Risks

  • Users may lose pasted file attachments when multiple files share the same MIME type.
  • Users may leave pending commands in an unpersisted state due to silent backend failures or empty-name validation.
  • Silent failures in commitNewCommand error path due to untested console.warn handling.
  • Test flakiness from module-level inflightCreateIds leaking across test cases.
  • Clipboard paste deduplication may drop distinct files with identical MIME types without regression detection.
  • Unverified pendingCreate UX flows may allow users to enter inconsistent edit states.

Test Suggestions

  • Add frontend tests for commitNewCommand covering empty name guard, non-Tauri fallback, and inflight duplicate suppression.
  • Add tests for prompt-input paste handling that verify multiple distinct same-type files are all retained.
  • Add UI tests for CommandsSection confirming that pending commands are removed on cancel and committed on save.
  • Unit tests for commitNewCommand async flows (src/modules/settings-center/model/settings-ipc-actions.ts).
  • Boundary tests for clipboard paste deduplication (src/components/ai-elements/prompt-input.tsx).
  • Component tests for settings command CRUD interactions (src/modules/settings-center/ui/settings-center-overlay.tsx).

File-Level Coverage Notes

  • src/modules/settings-center/model/settings-ipc-actions.ts: Major async refactor with no visible tests; missing coverage for success, error, boundary, and non-Tauri paths. Module-level state introduces flakiness risk.
  • src/components/ai-elements/prompt-input.tsx: Small deduplication change with untested boundary cases.
  • src/modules/workbench-shell/ui/dashboard-workbench.tsx: Trivial conditional render change; low risk with existing manual verification likely sufficient.
  • src/modules/settings-center/ui/settings-center-overlay.tsx: New interaction patterns (commit on edit, remove on cancel, source-gated delete) need component tests.
  • src/modules/workbench-shell/ui/dashboard-overlays.tsx: Pure prop plumbing with no new logic; minimal testing concern.

Inline Downgraded Items (processed but not inline)

  • None

Coverage Status

  • Target files: 5
  • Covered files: 5
  • Uncovered files: 0
  • No-patch/binary covered as file-level: 0
  • Findings with unknown confidence (N/A): 0

Uncovered list:

  • None

No-patch covered list:

  • None

Runtime/Budget

  • Rounds used: 1/4
  • Planned batches: 1
  • Executed batches: 1
  • Sub-agent runs: 2
  • Planner calls: 1
  • Reviewer calls: 3
  • Model calls: 4/64
  • Structured-output summary-only degradation: NO

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated PR review completed.

  • Findings kept: 5
  • Findings with unknown confidence: 0
  • Inline comments attempted: 5
  • Target files: 5
  • Covered files: 5
  • Uncovered files: 0
    See the summary comment for detailed analysis and coverage details.

),
}));
})
.catch((error) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[HIGH] Missing tests for commitNewCommand error handling and inflight cleanup

No tests verify that commitNewCommand removes the inflight ID on rejection or that the error path behaves correctly.

Suggestion: Add unit tests mocking promptCommandCreate rejection to assert inflightCreateIds is cleared and console.warn is called.

Risk: Memory leak in tests due to unresolved Set entries; production UX may fail silently without coverage.

Confidence: 0.90

[From SubAgent: testing]

isEditing={editingId === command.id}
onEdit={() => setEditingId(editingId === command.id ? null : command.id)}
onCancelEdit={() => setEditingId(null)}
onEdit={() => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[HIGH] Missing tests for pendingCreate command edit and cancel interactions

New UX flow where editing a pending command commits it and canceling removes it is not covered by tests.

Suggestion: Add React Testing Library tests rendering CommandItem with pendingCreate=true to verify onCommitNewCommand is called on edit and onRemoveCommand on cancel.

Risk: Users may lose unsaved pending commands or enter broken edit states due to unverified interaction logic.

Confidence: 0.90

[From SubAgent: testing]

const current = settingsStore.getState();
const cmd = current.commands.find((c) => c.id === id);
if (!cmd || !cmd.pendingCreate) return;
if (!cmd.name.trim()) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Missing boundary tests for commitNewCommand empty name guard

Whitespace-only names are rejected early but this guard has no regression tests.

Suggestion: Add tests for empty string, whitespace-only, and valid name inputs to ensure the boundary is respected.

Risk: Accidental backend calls with invalid names if the trim check is removed or altered.

Confidence: 0.85

[From SubAgent: testing]

if (!cmd || !cmd.pendingCreate) return;
if (!cmd.name.trim()) return;

if (!isTauri()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Missing tests for commitNewCommand non-Tauri fallback

The non-Tauri branch strips pendingCreate locally but lacks test coverage.

Suggestion: Add a test that mocks isTauri() returning false and asserts the store update strips pendingCreate without calling the backend.

Risk: Regression in web-only mode where pending commands may never become persisted or may trigger unintended IPC calls.

Confidence: 0.85

[From SubAgent: testing]

>
<Trash2 className="size-3.5" />
</button>
{command.source === "user" ? (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM] Missing tests for command remove button source gate

The conditional rendering of the remove button based on command.source is untested.

Suggestion: Add component tests asserting the remove button is present for user-sourced commands and absent for built-in/system sources.

Risk: Built-in commands could be accidentally exposed to deletion if the gate logic regresses.

Confidence: 0.85

[From SubAgent: testing]

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