Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

Implements chatbot pattern from AI SDK to enable follow-up questions in the explain sidepanel. Users can now ask clarifying questions without restarting the explanation flow.

Changes

New chat wrapper (logic/explain/chat.ts)

  • useExplainChat composable maintains message history and supports multi-turn conversations
  • Converts internal Message[] to AI SDK's ModelMessage format for streaming
  • Preserves tool calling support (e.g., getPageContent)

Updated sidepanel UI (entrypoints/explain.sidepanel/Explain.vue)

  • Conversation view replaces single-response display
  • Follow-up input with textarea and send button
  • Keyboard shortcuts: Enter to send, Shift+Enter for newline
  • Save conversation feature includes full message history

Styling (Explain.scss)

  • Chat-specific styles for message containers and role labels
  • User messages: --color-surface-2, Assistant: --color-surface

Usage

import { useExplainChat } from "~/logic/explain";

const chat = useExplainChat({
  modelString: "openai:gpt-4",
  providers: llmProviders.value,
  onUpdate: (update) => {
    if (update.messages) messages.value = update.messages;
  },
});

// Initial question
await chat.sendMessage("Explain this code", tabId);

// Follow-up with context
await chat.sendMessage("Can you give an example?");

Type fixes

  • Fixed error handling in chat.ts and index.ts to properly type-cast unknown errors
  • Added type assertion for modelString in provider-registry.ts

Original useExplainAgent remains available for backward compatibility.

Original prompt

使用 https://ai-sdk.dev/docs/ai-sdk-ui/chatbot 进一步包装 useExplainAgent 以使得用户可以在 explain.sidepanel 中进一步追问

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 16, 2025 16:32
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance useExplainAgent for better user interaction Add multi-turn conversation support to explain sidepanel Nov 16, 2025
Copilot AI requested a review from xiaoland November 16, 2025 16:39
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.

2 participants