mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 03:56:55 +03:00
fix(tui): pass markdown renderer into /btw answer dialog (#49804)
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
810e79a6d4
commit
cab11795e5
@@ -43,6 +43,8 @@ export default Plugin.define({
|
||||
append: "app",
|
||||
render() {
|
||||
const toast = useToast()
|
||||
// Dialogs render beside PluginProvider, so Answer cannot call usePlugin().
|
||||
const plugins = usePlugin()
|
||||
context.keymap.layer(() => ({
|
||||
mode: "global",
|
||||
commands: [
|
||||
@@ -66,7 +68,9 @@ export default Plugin.define({
|
||||
await context.client.session
|
||||
.generate({ sessionID: route.sessionID, prompt: [instructions, question].join("\n\n") })
|
||||
.then((result) => {
|
||||
context.ui.dialog.show(() => <Answer question={question} answer={result.text.trim()} />)
|
||||
context.ui.dialog.show(() => (
|
||||
<Answer question={question} answer={result.text.trim()} markdown={plugins.markdown} />
|
||||
))
|
||||
context.ui.dialog.set({ size: "large", centered: true })
|
||||
})
|
||||
.catch((cause: unknown) => toast.error(cause))
|
||||
@@ -81,11 +85,14 @@ export default Plugin.define({
|
||||
},
|
||||
})
|
||||
|
||||
function Answer(props: { question: string; answer: string }) {
|
||||
export function Answer(props: {
|
||||
question: string
|
||||
answer: string
|
||||
markdown: ReturnType<typeof usePlugin>["markdown"]
|
||||
}) {
|
||||
const dialog = useDialog()
|
||||
const toast = useToast()
|
||||
const clipboard = useClipboard()
|
||||
const plugins = usePlugin()
|
||||
const theme = useTheme().surface("dialog")
|
||||
const overlay = useTheme()
|
||||
const syntax = useThemes().currentSyntax
|
||||
@@ -142,7 +149,7 @@ function Answer(props: { question: string; answer: string }) {
|
||||
<box paddingLeft={2} paddingRight={2} paddingTop={1} paddingBottom={1}>
|
||||
<markdown
|
||||
syntaxStyle={syntax()}
|
||||
renderNode={plugins.markdown()}
|
||||
renderNode={props.markdown()}
|
||||
content={props.answer}
|
||||
conceal
|
||||
internalBlockMode="top-level"
|
||||
|
||||
Reference in New Issue
Block a user