Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Sep 9, 2025

Summary

Fixes the context mentions menu appearing behind other elements when editing messages by keeping the text area in its fixed position at the bottom instead of creating inline text areas.

Problem

Previously, when editing a message, a new text area would appear at the message's location in the chat. This caused the context mentions menu (triggered by typing @) to appear behind other chat elements due to stacking context issues.

Solution

Keep the text area always in its normal position at the bottom. When editing a message, show an "Editing message" indicator above the text area while the actual editing happens in the fixed text area. This ensures the context mentions menu stays in the proper stacking context.

Changes

  • ✅ Text area now stays in fixed position when editing messages
  • ✅ Added "Editing message" card above text area to show which message is being edited
  • ✅ Added Escape key to exit edit mode
  • ✅ Added click-outside functionality (click blurred background to exit)

Related Issues

Testing

  1. Edit a message and type @ to trigger context mentions
  2. Verify the context menu appears above all other elements
  3. Press Escape or click the blurred area to exit edit mode

Important

Fixes context menu z-index issue by keeping text area fixed and adds draft persistence for message editing.

  • Behavior:
    • Keeps text area fixed at the bottom in ChatView.tsx to resolve context menu z-index issue.
    • Adds "Editing message" indicator above text area during message editing.
    • Allows exiting edit mode with Escape key or clicking outside.
  • Draft Persistence:
    • Introduces useDraftPersistence in useDraftPersistence.tsx to save, restore, and clear drafts.
    • Wraps ChatView with DraftPersistenceProvider.
  • Testing:
    • Adds DraftPersistence.spec.tsx to test draft save, restore, and clear functionalities.
  • Misc:

This description was created by Ellipsis for c1332c5. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working UI/UX UI/UX related or focused labels Sep 9, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've reviewed the changes and the solution to keep the text area in a fixed position is creative and effectively solves the z-index issue.

Suggestions for Improvement

Accessibility Concerns

  • The blur effect (blur-[1px] opacity-70) on line 1923 of ChatView.tsx might make it difficult for users with visual impairments to see the context. Consider using a more subtle visual indicator or making this configurable.
  • The editing overlay (line 1947) should have proper ARIA attributes for screen readers (e.g., role="status" and aria-live="polite").

Code Quality

  • Potential memory leak: In ChatRow.tsx (line 132), the message event listener for image selection during edit mode should be cleaned up when isEditing changes to false, not just on component unmount.
  • UX improvement: When clicking outside to cancel edit mode, users might accidentally click on interactive elements. Consider adding a semi-transparent overlay behind the editing indicator.
  • Code consistency: The blur value blur-[1px] appears in multiple places. Consider extracting it to a constant for maintainability.

Testing

The new editing overlay functionality would benefit from unit tests to ensure the escape key handling and click-outside behavior work correctly.

Overall, this is a good solution to the z-index problem. The above suggestions would help improve accessibility, prevent potential issues, and make the code more maintainable.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 9, 2025
@mrubens
Copy link
Collaborator

mrubens commented Sep 10, 2025

Hmm, did you look at all into what it would take to get the right z-index for the context menu with the inline editing? Aside from the bug I think the inline editing is more expected behavior.

@daniel-lxs
Copy link
Member Author

@mrubens Yeah, I did set the z-index all the way up but that didn't seem to do the trick, however I can try again since that's a simple change.

I will report back.

@daniel-lxs daniel-lxs moved this from Triage to PR [Changes Requested] in Roo Code Roadmap Sep 10, 2025
@hannesrudolph hannesrudolph added PR - Changes Requested and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 10, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap Sep 10, 2025
@daniel-lxs
Copy link
Member Author

I dug into the z-index problem and it turns out it’s not really a z-index bug. Each ChatRow creates its own stacking context, so the context menu gets trapped inside and ends up behind later rows. That’s why just bumping z-index didn’t help, and why portals or dynamic z-indexes run into issues with Virtuoso.

The approach in this PR makes sense: instead of fighting stacking contexts, we move editing to the main input at the bottom, like WhatsApp and similar apps do. That avoids the whole z-index mess, keeps the UX consistent, and lets us reuse all the features of the main textarea. It’s also a lot simpler to maintain.

Much cleaner than trying to get inline editing to play nicely with CSS.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Sep 10, 2025
- Move editing message card to same stacking context as text area
- Add Escape key to exit edit mode
- Add click-outside functionality to exit edit mode
- Ensure edit overlay appears above action buttons and auto-approve checks
- Created DraftPersistenceProvider context to manage draft state
- Integrated draft saving when starting message edit
- Integrated draft restoration when canceling or saving edit
- Added automatic cleanup after restoration to prevent memory leaks
- Added comprehensive test coverage
@daniel-lxs daniel-lxs force-pushed the feature/edit-message-overlay branch from 9a1a344 to 36a46de Compare September 10, 2025 22:10
@NaccOll
Copy link
Contributor

NaccOll commented Sep 11, 2025

I'm sorry I only saw this question now. I usually use drag and drop to add files to the context, but I didn't test it thoroughly enough.

If the team still wants to inline edit, you can try the following changes:

image

webview-ui\src\components\chat\ChatTextArea.tsx:906-912

					"flex flex-col gap-1 bg-editor-background outline-none border border-none box-border",
					isEditMode ? "p-2 w-full" : "relative px-1.5 pb-1 w-[calc(100%-16px)] ml-auto mr-auto",
				)}>
				<div className={cn(!isEditMode && "relative")}>
					<div
						className={cn("chat-text-area", "flex", "flex-col", "outline-none", !isEditMode && "relative")}

By adjusting the position, the ContextMenu can be displayed in the outer container. Of course, the bottom left spacing of the ContextMenu needs to be optimized.

@daniel-lxs
Copy link
Member Author

Thanks @NaccOll I tried to come up with something like this but couldn't, I told the rest of the team to evaluate this option as well, I'll let you know what we decide.

@NaccOll
Copy link
Contributor

NaccOll commented Sep 12, 2025

@daniel-lxs Okay. Actually, for bugs like this that are related to me, you can just assign the issue directly to me. I'll fix them. That's my fault.

@daniel-lxs
Copy link
Member Author

@NaccOll I think you can create a PR with your fix, it's probably the solution that the team prefers

@NaccOll
Copy link
Contributor

NaccOll commented Sep 12, 2025

@NaccOll I think you can create a PR with your fix, it's probably the solution that the team prefers

Okay, right away

#7951

@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Oct 20, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

The editing information element is obscured (isEditMode = true)

5 participants