diff --git a/src/page/workspace/workplan/chat-conversation.tsx b/src/page/workspace/workplan/chat-conversation.tsx index d7917b2..b70dc68 100644 --- a/src/page/workspace/workplan/chat-conversation.tsx +++ b/src/page/workspace/workplan/chat-conversation.tsx @@ -22,11 +22,15 @@ import type { } from "./chat/types"; import { EMPTY_STREAM } from "./chat/types"; import { ModelSelectorPopover } from "./chat/model-selector-popover"; +import { RepoMentionPopover } from "./chat/repo-mention-popover"; import { MessageBubble } from "./chat/message-bubble"; import { StreamingView } from "./chat/streaming-view"; import { CodePreviewProvider } from "./chat/code-preview-context"; import { CodePreviewPanel } from "./chat/code-preview-panel"; import { MessageNavDots } from "./chat/message-nav-dots"; +import { mentionAtCursor } from "@/components/ai-elements/mention-textarea-overlay"; +import { extractMentions } from "@/lib/ir/parser"; +import { MentionChip } from "@/lib/ir/mention-chip"; // ---- Helpers ---- @@ -514,6 +518,28 @@ function ChatInner({ const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { + // ---- Mention-aware backspace ---- + if (e.key === "Backspace") { + const ta = e.currentTarget; + const { selectionStart, selectionEnd } = ta; + if (selectionStart === selectionEnd && selectionStart > 0) { + const hit = mentionAtCursor(textInput.value, selectionStart); + if (hit) { + e.preventDefault(); + const newText = + textInput.value.slice(0, hit.start) + + textInput.value.slice(hit.end); + textInput.setInput(newText); + // Restore cursor to the position where the mention was. + requestAnimationFrame(() => { + ta.selectionStart = ta.selectionEnd = hit.start; + }); + return; + } + } + } + + // ---- Enter to submit ---- if (e.key === "Enter" && !e.shiftKey && !sending) { e.preventDefault(); const text = textInput.value; @@ -546,7 +572,7 @@ function ChatInner({

- {conversation?.title ?? "Loading..."} + {conversation?.title && conversation.title.trim().length > 2 ? conversation.title : "New conversation"}

@@ -626,6 +652,35 @@ function ChatInner({ {/* Composer */}