Skip to content

Conversation

@viniciusventura29
Copy link
Contributor

@viniciusventura29 viniciusventura29 commented Jan 5, 2026

  • Introduced ChatInputContext to manage input state and branching context for chat messages.
  • Added BranchPreview component to display original message when editing from a branch.
  • Enhanced MessageUser component with branching capabilities, allowing users to create new threads from existing messages.
  • Updated ChatPanel and AssistantChatPanel to utilize the new context and handle branching logic.
  • Refactored input handling in ChatInput to support controlled and uncontrolled states.

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

Adds chat branching (“Edit from here”) so users can fork a conversation from any message and edit the original text with a clear preview. Also introduces a lightweight input context and makes Chat.Input controllable without re-rendering the parent.

  • New Features

    • “Edit from here” in user messages (MessageUser) creates a new thread from the selected point with a confirm dialog.
    • BranchPreview banner shows the original message and lets users jump back to the source thread or cancel editing.
    • usePersistedChat adds branchFromMessage, BranchContext, clearBranchContext, setMessages, and onThreadChange to track and navigate branches.
    • ChatPanel and AssistantChatPanel use ChatInputProvider + BranchPreview; input placeholder switches to “Edit your message...” while editing.
  • Refactors

    • Chat.Input is now fully controlled via value and onValueChange.
    • Introduced an InputController (pub/sub) to manage input state efficiently and avoid parent re-renders.
    • UI tweaks: tooltip and icon for branching, compact expand/collapse for long messages.

Written for commit 73970d6. Summary will update on new commits.

- Introduced ChatInputContext to manage input state and branching context for chat messages.
- Added BranchPreview component to display original message when editing from a branch.
- Enhanced MessageUser component with branching capabilities, allowing users to create new threads from existing messages.
- Updated ChatPanel and AssistantChatPanel to utilize the new context and handle branching logic.
- Refactored input handling in ChatInput to support controlled and uncontrolled states.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 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 5, 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.18-alpha.1
🎉 Patch 1.0.18
❤️ Minor 1.1.0
🚀 Major 2.0.0

Current version: 1.0.17

Deployment

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

- Updated the useChatInputContext function to be non-exported, encapsulating its usage within the module for better context management.
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.

3 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/components/chat/side-panel-chat.tsx">

<violation number="1" location="apps/mesh/src/web/components/chat/side-panel-chat.tsx:218">
P2: Branch context is cleared before `sendMessage` completes, contradicting the comment &quot;Clear editing state after sending&quot;. If the message fails to send, the user loses their editing state. Move `clearBranchContext()` after the `await`.</violation>
</file>

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

<violation number="1" location="apps/mesh/src/web/components/chat/chat-input-context.tsx:124">
P2: Input is cleared before the async submission completes. If `onSubmit` fails, the user loses their typed message. Consider clearing the input only after successful submission, or restore it on error.</violation>
</file>

<file name="apps/mesh/src/web/components/details/assistant/index.tsx">

<violation number="1" location="apps/mesh/src/web/components/details/assistant/index.tsx:297">
P2: Branch context is cleared before `sendMessage` completes, contradicting the comment &quot;Clear editing state after sending&quot;. If the send fails, the user loses their editing context. Move `clearBranchContext()` after the await.</violation>
</file>

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

- Revised comment to clarify that the editing state is cleared after a successful message send in the AssistantChatPanel component.
- Revised comment to clarify that the editing state is cleared after a successful message send in the ChatPanel component.
onValueChange?: (value: string) => void;
}>) {
const [input, setInput] = useState("");
const [internalInput, setInternalInput] = useState("");
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- Removed internal state management for input, transitioning to a fully controlled component using the provided value and onValueChange props.
- Updated submission logic to directly utilize the controlled value, enhancing clarity and consistency in input handling.
- Eliminated the unused `useState` import from the Chat component, streamlining the code and improving clarity.
@viniciusventura29 viniciusventura29 merged commit 27b4444 into main Jan 5, 2026
5 checks passed
@viniciusventura29 viniciusventura29 deleted the feat/chat-edit-from-here branch January 5, 2026 16:32
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.

3 participants