feat(file-preview): drag-range selection + right-click handoff to terminals & agent#17
Merged
Merged
Conversation
…er handling Refactored the Git graph implementation to replace the swim-lane layout with a native `git log --graph` representation. Updated the data structures to use `GitGraphEntry` for better clarity and streamlined the fetching of commit data. Improved gutter handling for better alignment and visual consistency in the sidebar. This change enhances the overall user experience by providing a more accurate representation of commit relationships.
Added support for previewing various file types including images, videos, Markdown, and Mermaid diagrams. Introduced a new `FilePreviewHeader` component to display file metadata such as name, path, size, and modification time. Enhanced the Markdown renderer to support inline Mermaid blocks and improved the overall user experience with loading states and error handling. Updated internationalization keys for new features across multiple languages.
… error handling and internationalization Completed the implementation of the file preview feature, supporting images, videos, Markdown, and Mermaid diagrams. Introduced a structured error handling system using `FilePreviewError` to provide user-friendly messages for various failure scenarios. Updated internationalization keys across multiple languages to reflect new error messages and improved user experience. Marked the file browser rich preview as active in the plans documentation.
…ers and documentation Expanded the file preview feature to support rich previews for images, videos, Markdown, and Mermaid diagrams. Introduced a new topbar displaying file metadata and improved error handling for unsupported file types. Updated documentation to include a dedicated section for file previews and added screenshots for better user guidance. Included internationalization updates for new keys across all supported languages.
…ew with line numbers and syntax highlighting Added a new `CodeView` component to the file preview feature, enabling a two-column layout for source code files with line numbers and syntax highlighting using highlight.js. This update allows users to select specific lines for reference, improving the usability of code previews. The implementation includes support for various programming languages and integrates with existing file preview functionalities. Updated styles and documentation to reflect these changes, along with new unit tests for the CodeView component.
…ght-click context menu Introduced drag-range selection in the `CodeView`, allowing users to select multiple lines by clicking and dragging. A new right-click context menu provides options to insert snippets into terminals, attach to agents, and copy content to the clipboard. This update improves usability by enabling quick access to actions based on selected code lines. Additionally, 22 new internationalization keys were added to support these features across 13 locales, along with corresponding updates to styles and documentation.
…and FileSnippet handoff Brings the developer architecture doc up to date with the new CodeView selection model (Option<(usize, usize)> + window-level mouseup), the code_context_menu module, build_file_snippet_block, render_file_snippet_envelope, list_terminal_targets_all_workspaces, the AgentContextItem.content field + FileSnippet kind, and the backend prompt-renderer section for inline file snippets. Co-authored-by: Cursor <cursoragent@cursor.com>
…ed performance Modified the terminal grid behavior to remain mounted throughout the workspace's lifecycle, only hidden when a different center tab is active. This change prevents the termination of running agents and maintains the integrity of the PTY registry, enhancing user experience by ensuring terminals remain accessible across tab switches.
…components Updated file preview components (CodeView, ImageView, MarkdownView, MermaidView, VideoView) to use `with_untracked` for workspace retrieval, ensuring that the file previews only refetch on explicit reload ticks. This change prevents unnecessary re-fetching and remounting during tab switches, enhancing performance and user experience across the file preview feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
CodeViewfile preview with drag-based line range selection and a right-click context menu that ships the highlighted snippet to any terminal in any workspace, attaches it to any workspace's BLXCode Agent context, or copies it to the clipboard. Cross-workspace handoffs prefix the snippet header with the source workspace label so the receiving agent can disambiguate.Highlights
code_view.rs:mousedown → mousemoveextendsselected: Option<(usize, usize)>; a window-levelmouseuplistener (installed once, cleaned up viaon_cleanup) ends drags even when the cursor leaves the gutter. Single-click toggle preserved..code-viewgotuser-select: none.file_preview/code_context_menu.rs) with four sections, all grouped per workspace:pty_write(base64).⟪ BLXCode attached context ⟫envelope.upsert_workspace_agent_contextwith newAgentContextKind::FileSnippetcarrying inlinecontent.navigator.clipboard.writeTextwith toast feedback.list_terminal_targets_all_workspacesenumerates every workspace's live terminals (shell workspaces filtered via existingis_shell_workspace), with the preview's own workspace pinned to the top and tagged with a localized current badge.build_file_snippet_blockinutil.rs(clamped + UTF-8 safe, 6 unit tests) andrender_file_snippet_envelopeinagent_context_handoff.rs(2 unit tests covering same-workspace and cross-workspace headers).AgentContextItemgained an optionalcontent: Option<String>field on bothsrc/agent_wire.rsandsrc-tauri/src/agent/protocol.rs; backendrender_context_promptpartitionsFileSnippetitems into a dedicated `Attached file snippets` prompt section;render_agent_context_blockmirrors this with an `## Attached file snippets` section.CodeViewMenu*,CodeViewToast*) with real translations in all 13 locales (en, de, fr, es, it, pt_br, pl, hu, ru, ja, ko, zh_cn, zh_tw) using `{workspace}`, `{terminal}`, `{slot}`, `{agent}`, `{error}` placeholders..code-context-menuthemed via existing tokens (sections, workspace groups, slot sublists, accent-pill badge, themed hover via--overlay-2).docs/user/file-preview.mdandCHANGELOG.mdupdated; plan tracked in.agents/plans/file-browser-rich-preview.md+.cursor/plans/code-preview-drag-select-handoff_f50216bd.plan.md.Test plan
build_file_snippet_block_*(single/range/cross-workspace/no-lang/UTF-8/clamping)render_file_snippet_envelope_*(in-workspace + cross-workspace source marker)file_snippet_*constructors + render sectionMade with Cursor