Skip to content

Conversation

@viniciusventura29
Copy link
Contributor

@viniciusventura29 viniciusventura29 commented Jan 2, 2026

What is this contribution about?

Describe your changes and why they're needed.

Screenshots/Demonstration

https://www.loom.com/share/6f294db4798c4fd88b9cea23b380cd0e

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Add “Edit from here” branching in chat. Users can start a new thread from any user message and continue editing without changing the original conversation.

  • New Features

    • Branch from any user message via a branch button with tooltip and confirmation.
    • Create a new thread and copy prior messages (excluding system) before the selected message.
    • Pre-fill the input with the selected message text and show a preview banner with quick “go back” and cancel.
    • Chat.Input now supports controlled value and onValueChange; placeholder adapts when branching.
    • Added onBranchFromMessage to ChatMessages and MessageUser; integrated in ChatPanel and AssistantChatPanel.
  • Refactors

    • useMessageActions adds insertMany for batch inserts used in branching.
    • Centralized branching in usePersistedChat with branchFromMessage, branchContext, clearBranchContext, inputController, and onThreadChange.
    • Introduced ChatInputProvider, BranchPreview, and useInputValue to isolate input re-renders and manage branch context.

Written for commit f40eff2. Summary will update on new commits.

- Added editing capabilities to ChatMessages and MessageUser components, allowing users to edit their messages.
- Introduced new props for handling edit actions: onStartEdit, onCancelEdit, and onSubmitEdit.
- Updated ChatPanel and AssistantChatPanel to manage editing state and integrate message editing logic.
- Enhanced useMessageActions hook to support batch message deletion when editing.
- Improved user experience with appropriate UI changes during editing, including placeholders and button states.
- Replaced inline editing functionality with a new branching feature in ChatMessages and MessageUser components.
- Updated props to handle branching actions, allowing users to create new conversation threads from existing messages.
- Modified ChatPanel and AssistantChatPanel to manage branching state and integrate new branching logic.
- Enhanced user experience with UI updates for branching actions, including original message previews and input handling.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

🧪 Benchmark

Should we run the MCP Gateway benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Release Options

Should a new version be published when this PR is merged?

React with an emoji to vote on the release type:

Reaction Type Next Version
👍 Prerelease 1.0.16-alpha.1
🎉 Patch 1.0.16
❤️ Minor 1.1.0
🚀 Major 2.0.0

Current version: 1.0.15

Deployment

  • Deploy to production (triggers ArgoCD sync after Docker image is published)

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/mesh/src/web/hooks/use-chat-store.ts">

<violation number="1" location="apps/mesh/src/web/hooks/use-chat-store.ts:298">
P1: Query key mismatch: predicate checks for `&quot;threadMessages&quot;` but `KEYS.threadMessages` returns `&quot;thread-messages&quot;`. This will prevent thread message cache invalidation after bulk deletion.</violation>
</file>

<file name="apps/mesh/src/web/components/chat/side-panel-chat.tsx">

<violation number="1" location="apps/mesh/src/web/components/chat/side-panel-chat.tsx:432">
P2: This `&lt;span&gt;` with `onClick` is not keyboard accessible. Add `role=&quot;button&quot;`, `tabIndex={0}`, and an `onKeyDown` handler for Enter/Space keys to ensure keyboard users can dismiss the branch context.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

queryClient.invalidateQueries({
predicate: (query) =>
Array.isArray(query.queryKey) &&
query.queryKey[0] === "threadMessages" &&
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 2, 2026

Choose a reason for hiding this comment

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

P1: Query key mismatch: predicate checks for "threadMessages" but KEYS.threadMessages returns "thread-messages". This will prevent thread message cache invalidation after bulk deletion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/web/hooks/use-chat-store.ts, line 298:

<comment>Query key mismatch: predicate checks for `&quot;threadMessages&quot;` but `KEYS.threadMessages` returns `&quot;thread-messages&quot;`. This will prevent thread message cache invalidation after bulk deletion.</comment>

<file context>
@@ -278,10 +278,34 @@ export function useMessageActions() {
+      queryClient.invalidateQueries({
+        predicate: (query) =&gt;
+          Array.isArray(query.queryKey) &amp;&amp;
+          query.queryKey[0] === &quot;threadMessages&quot; &amp;&amp;
+          query.queryKey[1] === locator,
+      });
</file context>
Suggested change
query.queryKey[0] === "threadMessages" &&
query.queryKey[0] === "thread-messages" &&

✅ Addressed in 10a2fb1

{branchContext.originalMessageText}
</div>
</div>
<span
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 2, 2026

Choose a reason for hiding this comment

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

P2: This <span> with onClick is not keyboard accessible. Add role="button", tabIndex={0}, and an onKeyDown handler for Enter/Space keys to ensure keyboard users can dismiss the branch context.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mesh/src/web/components/chat/side-panel-chat.tsx, line 432:

<comment>This `&lt;span&gt;` with `onClick` is not keyboard accessible. Add `role=&quot;button&quot;`, `tabIndex={0}`, and an `onKeyDown` handler for Enter/Space keys to ensure keyboard users can dismiss the branch context.</comment>

<file context>
@@ -318,12 +402,46 @@ export function ChatPanel() {
+                  {branchContext.originalMessageText}
+                &lt;/div&gt;
+              &lt;/div&gt;
+              &lt;span
+                onClick={(e) =&gt; {
+                  e.stopPropagation();
</file context>

✅ Addressed in 22d5358

- Removed inline message editing and integrated branching logic directly into the usePersistedChat hook.
- Updated ChatPanel and AssistantChatPanel to utilize the new branchFromMessage method for creating threads from existing messages.
- Simplified state management for input values and branch context, enhancing clarity and maintainability.
- Improved user experience by ensuring consistent handling of branching actions across chat components.
…ching

- Introduced ChatInputContext to manage input state and branching context across chat components.
- Implemented BranchPreview and ChatInputField for better user experience during message editing.
- Updated ChatPanel and AssistantChatPanel to utilize the new context, enhancing input handling and state management.
- Streamlined input value management to prevent unnecessary re-renders, improving performance.
- Removed unnecessary branch context clearing in the chat input state management.
- Updated icon imports in the MessageUser component, replacing CornerUpLeft with ReverseLeft for better visual consistency.
- Enhanced button styling for improved user interaction feedback.
- Added keyboard accessibility to the BranchPreview component, allowing users to clear the branch context using the Enter and Space keys.
- Updated the query key format in the useMessageActions hook from "threadMessages" to "thread-messages" for consistency and clarity.
…e resetting input value, improving reliability of message submission.
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