Skip to content

refactor(clipboard)!: actual clipboard - #381

Open
NSPC911 wants to merge 3 commits into
masterfrom
clipboard-changes
Open

NSPC911 wants to merge 3 commits into
masterfrom
clipboard-changes

Conversation

@NSPC911

@NSPC911 NSPC911 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

the premise of this refactor is to make the clipboard actually behave like a clipboard

previously i thought having the clipboard save items individually was a cool little feature, but the more i personally use it, i dont quite fw it

i've instead chosen to use a ListView to contain the copied items. A POC is available at https://github.com/NSPC911/textual-trials/blob/master/selecta.py, it is a fun little experiment.


by submitting this pull request, i agree that

  • i have run poe check to check for any style issues and fixed them
  • i have tested rovr (and also ran poe test if applicable) to make sure my changes do not break anything
  • cache, logs, dotfiles and/or others were not accidentally added to git's tracking history
  • my commits (or at least the pr title) follow the conventional commits format as much as possible
  • i did not use an AI (or LLM) in any way to write code.

Stack created with GitHub Stacks CLI • Give Feedback 💬

Summary by CodeRabbit

  • New Features

    • Clipboard items are grouped by copy or cut operation, with one active group available for pasting. You can select, clear, or remove clipboard entries.
    • Copy and cut commands can select newly added entries. Paste confirmations reflect the selected operation, and pasting requires a selected clipboard entry.
    • Custom preview commands support %clip to expand clipboard paths.
  • Documentation

    • Updated guidance for clipboard commands, responses, permissions, and preview expansions.

also renames %cut and %copy to %clip
@NSPC911
NSPC911 added this pull request to stack #383 November 17, 2026 11:54
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Automatic approval withheld

6 CodeRabbit review threads are still open and must be resolved first:

Resolve them on the pull request, or post @coderabbitai approve as a new top-level comment to resolve them and request approval.

Commit: 3f3e8583bdf3.

No actionable comments were generated in the recent review.

Walkthrough

The clipboard now stores deduplicated paths in copy or cut blocks and tracks one active block for paste operations. The IPC interface adds block removal, selection, and unselection, and changes copy and cut selection behavior to use --select. Clipboard command expansion now uses %clip instead of separate %copy and %cut placeholders. Configuration, schema and feature documentation, rendering, and tests are updated to reflect these changes.

Possibly related PRs

  • NSPC911/rovr#382: Builds on this clipboard change and removes ROVR’s copy-and-cut feature.
Merge Risk: Moderate · up to 3f3e8

The clipboard refactor still has open concerns. Concurrent clipboard operations, such as an IPC removal during an insert, could crash the app or activate the wrong block. The IPC test fixture may fail the test workflow. Cursor handling after removal, paging and focus is also inconsistent. These should be resolved before merge.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title "refactor(clipboard)!: actual clipboard" names the clipboard area, and the PR does rework the clipboard. However, "actual clipboard" is vague. It does not say what changed. The main change i… Rewrite the title to name the main change. For example: "refactor(clipboard)!: group clipboard entries into selectable blocks". Keep the conventional commit prefix.
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "refactor(clipboard)!: actual clipboard" names the clipboard area, and the PR does rework the clipboard. However, "actual clipboard" is vague. It does not say what changed. The main change is that the clipboard now stores blocks of paths in a ListView, with copy/cut selection on each block, instead of individual selection entries. The title does not convey that. The title is not unrelated, so it does not fail. It is too generic to tell a reader the primary change.

Resolution

Rewrite the title to name the main change. For example: "refactor(clipboard)!: group clipboard entries into selectable blocks". Keep the conventional commit prefix.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91bdd444-f470-4497-bb7a-8baaaa512163
Commits

Reviewing files that changed from the base of the PR and between d6b448c and 3f3e858.

Files selected for processing: 2

  • src/rovr/footer/clipboard_container.py
  • tests/test_action_buttons.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be5d2f41-6101-4da6-a295-c7b698f75a0d
Commits

Reviewing files that changed from the base of the PR and between 1e5492c and 70003e3.

Files selected for processing: 24

  • docs/scripts/screen_test.py
  • docs/src/content/docs/dev/features/context-menu.mdx
  • docs/src/content/docs/dev/features/ipc.mdx
  • docs/src/content/docs/dev/reference/schema.mdx
  • src/rovr/action_buttons/paste_button.py
  • src/rovr/assets/config.toml
  • src/rovr/assets/schema.json
  • src/rovr/classes/config.pyi
  • src/rovr/classes/textual_options.py
  • src/rovr/core/file_list_right_click_menu.py
  • src/rovr/core/preview_container.py
  • src/rovr/footer/__init__.py
  • src/rovr/footer/clipboard_container.py
  • src/rovr/functions/ipc_receiver.py
  • src/rovr/functions/ipc_sender.py
  • src/rovr/functions/utils.py
  • src/rovr/screens/paste_screen.py
  • src/rovr/style.tcss
  • tests/test_action_buttons.py
  • tests/test_clipboard.py
  • tests/test_filelist_component_classes.py
  • tests/test_functions.py
  • tests/test_ipc_receiver.py
  • tests/test_ipc_sender.py
Files with no reviewable changes: 1

  • docs/scripts/screen_test.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Comment thread src/rovr/footer/clipboard_container.py Outdated
action()

def action_cursor_page(self, pages: float) -> None:
(self.action_page_down if pages > 0 else self.action_page_up)()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Move the cursor when paging through blocks.

The inherited action_page_down and action_page_up only scroll the viewport. They do not change index. After Page Down, Enter therefore activates the original block, which can be outside the viewport. Calculate the destination block for the requested page movement and assign its index. This preserves the configured “Move down one page” behavior. (raw.githubusercontent.com)

Comment thread src/rovr/footer/clipboard_container.py Outdated
for option_id in option_ids:
self.safe_remove_option(option_id)
"""Remove paths from the clipboard that no longer exist."""
blocks = self.options

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Stability & Availability · Quick win

Take a real snapshot before checking paths.

options returns the live Textual children view; cast does not copy it. If a copy operation prepends block B while the worker checks block A, existing can omit B. The second traversal then raises KeyError for B. Textual workers exit the app on an unhandled error by default. Capture a tuple of blocks on the UI thread and use that snapshot for both traversals. (raw.githubusercontent.com)

Comment thread src/rovr/footer/clipboard_container.py Outdated
block = self.options[index]
if block is self._active:
self._set_active(None)
await block.remove()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Repair the cursor after removing a block.

With three blocks and index=2, deleting the last block leaves index=2. highlighted_child then returns None, so another Delete reports no selection although two blocks remain. Use ListView.pop or equivalent cursor repair. Apply the same correction to the removal at Line 242. Textual's pop handles index adjustment and highlight refresh. (raw.githubusercontent.com)

Comment thread src/rovr/functions/ipc_receiver.py Resolved
Comment thread tests/test_action_buttons.py Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5530e2e2-c824-4c80-8838-624e988c392a
Commits

Reviewing files that changed from the base of the PR and between 70003e3 and 0282768.

Files selected for processing: 2

  • src/rovr/footer/clipboard_container.py
  • src/rovr/functions/ipc_receiver.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Comment thread src/rovr/footer/clipboard_container.py Outdated
if self.children and (
self.highlighted_child is None or not self.highlighted_child.highlighted
):
self.set_index(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

Restore the cursor without activating a block.

After IPC unselect, both _active and index are None. When the clipboard next receives focus, this call activates block 0 and enables paste. Focus therefore reverses the explicit unselect operation.

Assign self.index directly here. Keep set_index for explicit selection operations.

self.Clipboard.set_index(index)
case "unselect":
if await checker():
if self.Clipboard._active is None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Quick win

Update the IPC test fixture for active-block selection.

The supplied pipeline failures show that test_conn_selects_and_unselects_clipboard_block uses a SimpleNamespace without _active. This access raises AttributeError and fails poe test across the supported platform matrix.

Update the fixture to provide _active and make its set_index stub update active-block state. Keep coverage where the cursor and active block differ. Do not replace this lookup with a cursor fallback; the real Clipboard initializes _active.

Tools

GitHub Actions: Testing / 11_Test on (windows-arm, Python 3.14).txt

[error] 209-209: Command 'uv run poe test -n 8' failed: clipboard unselect handling raised AttributeError because the Clipboard object had no '_active' attribute. The failure occurred in test_conn_selects_and_unselects_clipboard_block.

GitHub Actions: Testing / 12_Test on (windows-x64, Python 3.13).txt

[error] 209-209: Tests failed during uv run poe test -n 8 (pytest). The unselect handler accessed self.Clipboard._active, raising AttributeError because the test's SimpleNamespace clipboard has no _active attribute.

GitHub Actions: Testing / 4_Test on (linux-x64, Python 3.14).txt

[error] 209-209: Command 'uv run poe test -n 8' failed: the clipboard unselect action accesses self.Clipboard._active, which is missing on the test's SimpleNamespace, raising AttributeError. The failure occurs in test_conn_selects_and_unselects_clipboard_block.

GitHub Actions: Testing / 5_Test on (linux-arm64, Python 3.13).txt

[error] 209-209: Command uv run poe test -n 8 failed: handling the clipboard unselect action raised AttributeError because the test clipboard object has no _active attribute.

GitHub Actions: Testing / 8_Test on (linux-arm64, Python 3.14).txt

[error] 209-209: The uv run poe test -n 8 test step failed: handling the clipboard unselect action accesses self.Clipboard._active, which is absent on the test clipboard object, raising AttributeError. This failure recurred on all five test attempts.

GitHub Actions: Testing / 9_Test on (linux-x64, Python 3.13).txt

[error] 209-209: Command 'uv run poe test -n 8' failed: clipboard unselect handling raised AttributeError because the test clipboard object has no '_active' attribute. This also failed on all four attempts.

GitHub Actions: Testing / Test on (linux-arm64, Python 3.13)

[error] 209-209: Command uv run poe test -n 8 failed: test_conn_selects_and_unselects_clipboard_block raised AttributeError because self.Clipboard has no _active attribute while handling the unselect action.

GitHub Actions: Testing / Test on (linux-arm64, Python 3.14)

[error] 209-209: The uv run poe test -n 8 test command repeatedly failed: the clipboard unselect action raised AttributeError because self.Clipboard has no _active attribute. This caused test_conn_selects_and_unselects_clipboard_block to fail.

GitHub Actions: Testing / Test on (linux-x64, Python 3.13)

[error] 209-209: uv run poe test -n 8 failed: the clipboard unselect action raised AttributeError because self.Clipboard had no _active attribute. Reproduced across retries.

GitHub Actions: Testing / Test on (windows-arm, Python 3.13)

[error] 209-209: Test failure during uv run poe test -n 8: test_conn_selects_and_unselects_clipboard_block raised AttributeError because self.Clipboard (a SimpleNamespace in the test) has no _active attribute.

GitHub Actions: Testing / Test on (windows-arm, Python 3.14)

[error] 209-209: uv run poe test -n 8: pytest test_conn_selects_and_unselects_clipboard_block failed with AttributeError because the clipboard object has no '_active' attribute during the unselect action.

GitHub Actions: Testing / Test on (windows-x64, Python 3.13)

[error] 209-209: Test failed when running uv run poe test -n 8 (pytest): the unselect action accesses self.Clipboard._active, but the clipboard object has no _active attribute, raising AttributeError.

GitHub Actions: Testing / Test on (windows-x64, Python 3.14)

[error] 209-209: uv run poe test -n 8 (pytest -n 8) failed: the clipboard unselect action raised AttributeError because the test clipboard object has no _active attribute.

Source: Pipeline failures

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a64163f1-c0f4-4597-b125-f48efdf29334
Commits

Reviewing files that changed from the base of the PR and between 0282768 and d6b448c.

Files selected for processing: 3

  • src/rovr/footer/clipboard_container.py
  • tests/test_clipboard.py
  • tests/test_ipc_receiver.py

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Comment on lines +159 to +161
await self.insert(0, [block])
if activate:
self.set_index(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Stability & Availability · Quick win

Activate the inserted block by reference, and handle its removal during the mount await.

await self.insert(0, [block]) yields while the block mounts. Another task on the same event loop, such as an IPC remove 0, can run during that yield. If that removal leaves the clipboard empty before self.set_index(0) runs, set_index indexes an empty options sequence and raises IndexError. If another block has moved to index 0, the call activates that block instead of the new one.

Resolve the position of block after the await, and skip activation when the block is no longer in the clipboard. Do not assume index 0 identifies the inserted block.

@coderabbitai coderabbitai Bot mentioned this pull request Nov 18, 2026
5 tasks done

This branch has not been deployed

No deployments
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.

1 participant