diff --git a/src/client/TextEditor.tsx b/src/client/TextEditor.tsx index 95e7240d..8aeed642 100644 --- a/src/client/TextEditor.tsx +++ b/src/client/TextEditor.tsx @@ -38,7 +38,7 @@ import { cmSurfaceTheme, CmThemeCompartment } from './cm-themes.ts' import { cmSearchExtensions, CmSearchPhrases } from './cm-search.ts' import { isDarkScheme, subscribeColorScheme } from './theme.ts' import { SandboxStatusBar } from './SandboxStatusBar.tsx' -import { insertReferenceOrText, type DraftReference } from './conversation-draft.ts' +import { insertReferenceOrText, type PendingReference } from './conversation-draft.ts' import { useSelectionPopup } from './selection-popup.ts' import { buildSelectionInsert, linesOfSelection } from './selection-payload.ts' import { analyzeMarkdownHtml } from './markdown-html.ts' @@ -220,7 +220,7 @@ export function TextEditor(props: FileViewerProps) { * listeners (outside mousedown, Escape, hidden tab/window, surface * leaving the viewport) — see selection-popup.ts. */ - const selectionPopup = useSelectionPopup({ + const selectionPopup = useSelectionPopup({ onCommit: (insert) => { insertReferenceOrText(ctx, scope.sessionId, insert) }, diff --git a/src/client/conversation-draft.ts b/src/client/conversation-draft.ts index 3c01a2f9..0bfd50d2 100644 --- a/src/client/conversation-draft.ts +++ b/src/client/conversation-draft.ts @@ -33,8 +33,12 @@ import { baseName, workspaceRelativePath } from './paths.ts' * composer shows, and the `text` the model receives on send. The two are * deliberately different — a selection reads as `docs/a.md:12-15` on screen * while the model still gets the whole fenced block. + * + * Named `Pending*` to keep clear of the host's own `DraftReference`, which is + * the opposite thing: a chip ALREADY in the draft, carrying its offset and + * length. */ -export interface DraftReference { +export interface PendingReference { label: string text: string /** @@ -146,7 +150,7 @@ function appendOffset(snapshot: ReturnType SELECTION_LIMIT) return { label: header, text: header } return { label: header, text: `\`\`\`${header}\n${selected}\n\`\`\`` } diff --git a/src/client/selection-popup.ts b/src/client/selection-popup.ts index f573886c..18f9a97b 100644 --- a/src/client/selection-popup.ts +++ b/src/client/selection-popup.ts @@ -33,13 +33,13 @@ import { useEffect, useRef, useState, type RefObject } from 'react' * The floating "add to conversation" action: payload + viewport anchor. * The payload type belongs to the caller; the hook only carries it through. */ -export interface SelectionPopup { +export interface SelectionPopup { insert: T left: number top: number } -export interface SelectionPopupOptions { +export interface SelectionPopupOptions { /** Commit the payload into the composer draft (button click). */ onCommit(insert: T): void /** @@ -50,7 +50,7 @@ export interface SelectionPopupOptions { getSurface(): HTMLElement | null } -export interface SelectionPopupControls { +export interface SelectionPopupControls { /** The current popup (null = hidden). */ popup: SelectionPopup | null /** Attach to the portaled button element. */ @@ -63,7 +63,7 @@ export interface SelectionPopupControls { commit(): void } -export function useSelectionPopup(options: SelectionPopupOptions): SelectionPopupControls { +export function useSelectionPopup(options: SelectionPopupOptions): SelectionPopupControls { // Latest-callback refs: the dismissal listeners live for the mount's // lifetime, so they must not capture stale closures across renders. const onCommitRef = useRef(options.onCommit)