Skip to content

Fix desktop clipboard and scroll edge cases - #38109

Closed
LiWithDream wants to merge 1 commit into
NousResearch:mainfrom
LiWithDream:fix/desktop-clipboard-scroll
Closed

Fix desktop clipboard and scroll edge cases#38109
LiWithDream wants to merge 1 commit into
NousResearch:mainfrom
LiWithDream:fix/desktop-clipboard-scroll

Conversation

@LiWithDream

@LiWithDream LiWithDream commented Jun 3, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes two desktop chat edge cases observed on Windows/Electron:

  • Pasting a screenshot can attach it twice because the same image may be exposed through both DataTransfer.items and DataTransfer.files as different File objects.
  • The thread viewport can lose sticky-bottom behavior when a programmatic scroll/virtualizer measurement moves scrollTop upward without an actual user scroll gesture.

The clipboard fix dedupes images by stable metadata and only falls back to clipboard.files when clipboard.items did not provide image blobs. The scroll fix only treats upward scroll movement as user intent when it follows recent wheel/touch input.

Related Issue

N/A - no linked issue.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Security fix
  • Documentation update
  • Tests (adding or improving test coverage)
  • Refactor (no behavior change)
  • New skill (bundled or hub)

Changes Made

  • apps/desktop/src/app/chat/composer/text-utils.ts: dedupe pasted image blobs by type:size and avoid double-reading clipboard.files when clipboard.items already yielded images.
  • apps/desktop/src/app/chat/composer/text-utils.test.ts: add regression coverage for duplicate screenshot paste paths.
  • apps/desktop/src/components/assistant-ui/thread-virtualizer.tsx: require recent wheel/touch intent before disarming sticky-bottom due to upward scrollTop movement.
  • apps/desktop/src/components/assistant-ui/streaming.test.tsx: add regression coverage for programmatic upward scroll movement while sticky-bottom remains armed.

How to Test

  1. Run npm run test:ui -- src/app/chat/composer/text-utils.test.ts src/components/assistant-ui/streaming.test.tsx.
  2. Run npm run type-check.
  3. On Windows desktop, copy a screenshot to the clipboard and paste it into the composer; it should attach once.
  4. During streaming, allow the thread to stay at bottom while content grows; virtualizer/programmatic scroll movement should not leave the viewport detached from the bottom unless the user scrolls up.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows 11

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) - N/A
  • I've updated cli-config.yaml.example if I added/changed config keys - N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows - N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  • I've updated tool descriptions/schemas if I changed tool behavior - N/A

Screenshots / Logs

Targeted test output:

Test Files  2 passed (2)
Tests       16 passed (16)

Also verified npm run type-check passes.

@LiWithDream
LiWithDream force-pushed the fix/desktop-clipboard-scroll branch from b6544a1 to 40865f7 Compare June 3, 2026 10:10
@LiWithDream
LiWithDream force-pushed the fix/desktop-clipboard-scroll branch from 40865f7 to 8f8d53a Compare June 3, 2026 10:15
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have labels Jun 3, 2026

Copy link
Copy Markdown
Author

This PR is ready for review. Since it comes from a fork, the required GitHub Actions workflows are awaiting maintainer approval before they can report statuses.

I ran the targeted desktop checks locally on Windows 11:

npm run test:ui -- src/app/chat/composer/text-utils.test.ts src/components/assistant-ui/streaming.test.tsx
npm run type-check

Both passed locally.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused desktop regression coverage. This automated hermes-sweeper review found both changes superseded on current main.

  • Clipboard deduplication was merged in fix(desktop): dedupe clipboard image paste #38306 as c711146ad4cd23b3137bf8a262be2e3f3c4a2162: apps/desktop/src/app/chat/composer/text-utils.ts:21-66 now uses stable metadata keys and only falls back to clipboard.files when clipboard.items did not yield an image. Regression coverage is present at apps/desktop/src/app/chat/composer/text-utils.test.ts:62-103.
  • The virtualizer path this PR updates no longer exists. 76b93869d8edddab860e225b11ef9e04df33ba63 replaced it with the single-owner useStickToBottom implementation; current apps/desktop/src/components/assistant-ui/thread/list.tsx:36-42 explicitly removes virtualizer scroll competition, and :109-117 delegates follow/escape/re-lock behavior to that owner.
  • The cross-referenced Desktop app: pasted screenshots attach duplicate copies #38435 also records fix(desktop): dedupe clipboard image paste #38306 as the merged duplicate-paste fix.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants