Skip to content

Add clipboard image paste support#3

Merged
InbarR merged 1 commit into
InbarR:mainfrom
m-tantan:feat/clipboard-image-paste
Mar 7, 2026
Merged

Add clipboard image paste support#3
InbarR merged 1 commit into
InbarR:mainfrom
m-tantan:feat/clipboard-image-paste

Conversation

@m-tantan
Copy link
Copy Markdown
Contributor

@m-tantan m-tantan commented Mar 5, 2026

Summary

  • Detect images on the clipboard when pasting (Ctrl+V / Cmd+V or right-click), save as PNG to a temp directory (os.tmpdir()/tmax-clipboard/), and insert the file path into the terminal
  • Enables sharing screenshots directly with AI tools like Claude Code and Copilot
  • Fixes paste shortcut on macOS by checking both ctrlKey and metaKey in all paste handlers (main window, detached window, and right-click)

Changed files

File Change
src/shared/ipc-channels.ts New CLIPBOARD_SAVE_IMAGE IPC channel
src/main/main.ts IPC handler to save PNG buffer to temp dir
src/preload/preload.ts clipboardHasImage() (sync) and clipboardSaveImage() (async) APIs
src/renderer/components/TerminalPanel.tsx Image-first paste for Ctrl+V/Cmd+V and right-click
src/renderer/DetachedApp.tsx Image-first paste for detached windows
CHANGELOG.md New changelog file with v1.3.4 entry

Test plan

  • npm start → screenshot to clipboard → Ctrl+V → temp file path appears in terminal
  • Verify the file at that path is a valid PNG
  • Copy plain text → Ctrl+V → text pastes normally (no regression)
  • Right-click paste with image clipboard → file path pasted
  • Right-click paste with text clipboard → text pasted
  • Test in a detached terminal window
  • Verify on macOS with Cmd+V (if available)

🤖 Generated with Claude Code

Detect images on the clipboard when pasting (Ctrl+V / Cmd+V or right-click),
save as PNG to a temp directory, and insert the file path into the terminal.
This enables sharing screenshots with AI tools like Claude Code directly.

Also fixes paste shortcut on macOS by checking both ctrlKey and metaKey.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@InbarR InbarR merged commit f146d7c into InbarR:main Mar 7, 2026
InbarR pushed a commit that referenced this pull request Apr 28, 2026
Two independent bugs in this area combined to produce the user-visible
"sidebar highlights the wrong session" report. Both are fixed and
covered by Playwright regressions in tests/e2e/session-sidebar-highlight.

1. Sticky auto-link binding (terminal-store.ts:2380)

   updateTerminalTitleFromSession refused to bind any terminal whose
   aiSessionId was already set ("if (t.aiSessionId) continue;"). Once a
   pane was linked, that link was permanent - even when the user closed
   the original AI process and started a fresh one in the same pane.
   The auto-highlight then faithfully showed the now-superseded session.

   Fix: allow the focused pane to rebind when it already has a (now
   stale) link and the new session's cwd matches. Non-focused panes with
   an existing link remain off-limits so a background pane never
   silently has its session moved.

2. Auto-highlight target hidden by group collapse (CopilotPanel.tsx:336)

   When groupByRepo is on (default) and #69's auto-collapse fires on
   initial mount, every group is collapsed. setSelectedIndex picks the
   right idx in displayList, but the matching .ai-session-item is gated
   behind {!isCollapsed && ...} and never renders - so the .selected
   class lands on no DOM node, and whichever row was selected before
   (commonly the pinned tmax session at idx 0) appears to stay
   highlighted.

   Fix: when the auto-highlight effect resolves the focused pane's
   session, also remove that session's group key from collapsedGroups
   so its row actually renders. Doesn't affect any other groups.

Tests (tests/e2e/session-sidebar-highlight.spec.ts):
- auto-link rebinds focused pane on supersession (AC #3)
- auto-link safety net: non-focused pane keeps its binding
- visual highlight follows focus when groupByRepo is off (AC #2)
- visual highlight expands the focused session's group when collapsed
  (the user's actual symptom)

Verified 7 adjacent AI-session tests still green
(issue-69-group-by-repo, pin-sessions-persist, jump-to-prompt x4,
pane-menu-show-prompts).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
InbarR pushed a commit that referenced this pull request May 24, 2026
When the Copilot CLI changes directory internally (via cwd command),
the diff panel failed with 'No git repository found from: C:\Users'
because terminal.cwd (shell CWD) stays stale — the CLI doesn't emit
OSC sequences.

Instead of overwriting terminal.cwd (which causes ping-pong, WSL path
corruption, and session restore poisoning), the diff panel's CWD
selector now checks the linked AI session's CWD first, falling back
to shell CWD when no session is linked.

Closes #3

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
InbarR pushed a commit that referenced this pull request May 24, 2026
Follow-up to #3 (diff panel CWD resolution).

Two improvements based on adversarial review feedback:

1. Stale session guard: getEffectiveCwd() only prefers AI session CWD
   when the session is active (status !== 'idle'). After CLI exit, the
   session goes idle and the helper falls back to shell CWD — preventing
   the diff panel from showing the wrong repo.

2. Centralized helper: findSessionById() and getEffectiveCwd() are
   exported from terminal-store.ts. This eliminates the hardcoded
   copilotSessions.find() ?? claudeCodeSessions.find() pattern and
   makes adding a third provider a single-point change.

DiffReview.tsx now uses getEffectiveCwd() instead of inline logic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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