Skip to content

Commit 4ccc61f

Browse files
authored
Merge pull request Stack-Cairn#146 from Stack-Cairn/feat/editor-insert-code-mention
Composer mention-chip overhaul: insert code references, CSS-based chip spacing, caret navigation fixes
2 parents 8f7cb5d + 5ee3d11 commit 4ccc61f

19 files changed

Lines changed: 1186 additions & 94 deletions

File tree

crates/agent-gateway/web/src/app/GatewayApp.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { LocaleContext, t as translate } from "@/i18n";
2727
import type { ChatHistorySummary } from "@/lib/chat/chatHistory";
2828
import { buildModelOptions } from "@/lib/chat/chatPageHelpers";
2929
import type { HistoryMessageRef } from "@/lib/chat/conversationState";
30+
import type { CodeMentionReference } from "@/lib/chat/mentionReferences";
3031
import { createActivityStore } from "@/lib/chat/stream/activityStore";
3132
import {
3233
type ChatCommandOutcome,
@@ -3697,6 +3698,10 @@ export default function GatewayApp() {
36973698
composerRef.current?.insertGitFileMention(file);
36983699
composerRef.current?.focus();
36993700
}, []);
3701+
const handleInsertCodeMention = useCallback((reference: CodeMentionReference) => {
3702+
composerRef.current?.insertCodeMention(reference);
3703+
composerRef.current?.focus();
3704+
}, []);
37003705
// Guards re-entry while a suggestion is still typing in: the cards stay
37013706
// disabled and further clicks are ignored until the composer settles.
37023707
const [isSuggestionTyping, setIsSuggestionTyping] = useState(false);
@@ -4369,6 +4374,7 @@ export default function GatewayApp() {
43694374
workspaceEditorOpen={workspaceEditorOpen}
43704375
workspaceEditorCleanupPending={workspaceEditorCleanupPending}
43714376
onWorkspaceEditorPreviewFile={openWorkspaceFilePreview}
4377+
onWorkspaceEditorInsertCodeMention={handleInsertCodeMention}
43724378
onWorkspaceEditorHide={handleWorkspaceEditorHide}
43734379
onWorkspaceEditorClose={handleWorkspaceEditorClosed}
43744380
workspaceFilePreviewMounted={workspaceFilePreviewMounted}

crates/agent-gateway/web/src/app/WorkspaceOverlayHost.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { WorkspaceCodeEditorOpenRequest } from "@/components/workspace-edit
44
import type { WorkspaceFilePreviewOpenRequest } from "@/components/workspace-editor/WorkspaceFilePreviewOverlay";
55
import type { WorkspaceSshTerminalOpenRequest } from "@/components/workspace-editor/WorkspaceSshTerminalOverlay";
66
import { t as translate } from "@/i18n";
7+
import type { CodeMentionReference } from "@/lib/chat/mentionReferences";
78
import { lockMonacoNlsLocale, preparePreferredMonacoNlsLocale } from "@/lib/monacoNls";
89
import type { AppSettings, EffectiveTheme } from "@/lib/settings";
910
import type { SftpClient } from "@/lib/sftp/types";
@@ -41,6 +42,7 @@ type WorkspaceOverlayHostProps = {
4142
workspaceEditorOpen: boolean;
4243
workspaceEditorCleanupPending: boolean;
4344
onWorkspaceEditorPreviewFile: (request: WorkspaceCodeEditorOpenRequest) => void;
45+
onWorkspaceEditorInsertCodeMention?: (reference: CodeMentionReference) => void;
4446
onWorkspaceEditorHide: () => void;
4547
onWorkspaceEditorClose: () => void;
4648
workspaceFilePreviewMounted: boolean;
@@ -69,6 +71,7 @@ export function WorkspaceOverlayHost(props: WorkspaceOverlayHostProps) {
6971
workspaceEditorOpen,
7072
workspaceEditorCleanupPending,
7173
onWorkspaceEditorPreviewFile,
74+
onWorkspaceEditorInsertCodeMention,
7275
onWorkspaceEditorHide,
7376
onWorkspaceEditorClose,
7477
workspaceFilePreviewMounted,
@@ -104,6 +107,7 @@ export function WorkspaceOverlayHost(props: WorkspaceOverlayHostProps) {
104107
finalCloseRequested={workspaceEditorCleanupPending}
105108
theme={theme}
106109
onPreviewFile={onWorkspaceEditorPreviewFile}
110+
onInsertCodeMention={onWorkspaceEditorInsertCodeMention}
107111
onHide={onWorkspaceEditorHide}
108112
onClose={onWorkspaceEditorClose}
109113
/>

crates/agent-gateway/web/src/app/chatDraft.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
MentionComposerGitFileMention,
55
MentionComposerLargePaste,
66
} from "@/components/chat/MentionComposer";
7-
import { formatFileMentionToken } from "@/lib/chat/mentionReferences";
7+
import { formatCodeMentionToken, formatFileMentionToken } from "@/lib/chat/mentionReferences";
88
import type { PendingUploadedFile } from "@/lib/chat/uploadedFiles";
99
import { withPastedTextDisplayMetadata } from "@/lib/chat/uploadedFiles";
1010
import { importReadableFiles } from "@/lib/uploadReadableFiles";
@@ -70,6 +70,9 @@ export function buildTextFromComposerDraft(
7070
if (segment.type === "gitFileMention") {
7171
return formatComposerGitFileMention(segment.file);
7272
}
73+
if (segment.type === "codeMention") {
74+
return formatCodeMentionToken(segment.reference);
75+
}
7376
const file = pastedFileById?.get(segment.paste.id);
7477
return file ? `[${segment.paste.label}: ${file.relativePath}]` : segment.paste.text;
7578
})

0 commit comments

Comments
 (0)