feat(chat): structured context attachments with metadata round-trip
Every user-attached context item (diff/file/plan comments, terminal selections, browser annotations, PR comments and failed checks, linked issues/PRs, and new chat-quote comments from the selection menu) is now sent as its own synthetic text part carrying an openchamberContext metadata payload. The model-facing text keeps the previous wording; the timeline reads the metadata back and renders each item as a context card instead of raw prompt text. Legacy messages still render via the old text sniffing. The selection menu gains a Comment option with an inline multiline input, the quoted fragment stays highlighted while commenting, and on mobile the input overlays the composer pill by rendering inside the composer form. Add to chat is renamed Add to input; the menu is restyled and the mobile Copy tile removed. Terminal drafts move their terminal id out of the language field (persisted-draft migration v3), and the dead preview-console source is deleted.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { ContextPartMetadata } from '@/lib/messages/contextParts';
|
||||
import { createOpencodeClient, OpencodeClient } from "@opencode-ai/sdk/v2";
|
||||
import type { PermissionV2Request, PermissionV2Effect, PermissionV2Source } from "@opencode-ai/sdk/v2/client";
|
||||
import type { FilesAPI } from "../api/types";
|
||||
@@ -792,6 +793,7 @@ class OpencodeService {
|
||||
additionalParts?: Array<{
|
||||
text: string;
|
||||
synthetic?: boolean;
|
||||
metadata?: ContextPartMetadata;
|
||||
files?: Array<FileInputLite>;
|
||||
}>;
|
||||
messageId?: string;
|
||||
@@ -842,11 +844,10 @@ class OpencodeService {
|
||||
if (params.additionalParts && params.additionalParts.length > 0) {
|
||||
for (const additional of params.additionalParts) {
|
||||
if (additional.text && additional.text.trim()) {
|
||||
parts.push({
|
||||
type: 'text',
|
||||
text: additional.text,
|
||||
...(additional.synthetic ? { synthetic: true } : {}),
|
||||
});
|
||||
const additionalTextPart: TextPartInput = { type: 'text', text: additional.text };
|
||||
if (additional.synthetic) additionalTextPart.synthetic = true;
|
||||
if (additional.metadata) additionalTextPart.metadata = additional.metadata;
|
||||
parts.push(additionalTextPart);
|
||||
}
|
||||
if (additional.files && additional.files.length > 0) {
|
||||
for (const file of additional.files) {
|
||||
@@ -1193,7 +1194,7 @@ class OpencodeService {
|
||||
options?: {
|
||||
id?: string;
|
||||
save?: string[];
|
||||
metadata?: Record<string, unknown>;
|
||||
metadata?: ContextPartMetadata;
|
||||
source?: PermissionV2Source;
|
||||
agent?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user