mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-24 17:35:19 +08:00
fix(bots): restore sessions across processor types
This commit is contained in:
@@ -227,11 +227,13 @@ export default function BotDetailContent({ id }: { id: string }) {
|
||||
</div>
|
||||
{canManage && (
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<AdapterEventDebugDialog
|
||||
key={id}
|
||||
botId={id}
|
||||
adapterLabel={adapterLabel}
|
||||
/>
|
||||
{activeTab === 'config' && (
|
||||
<AdapterEventDebugDialog
|
||||
key={id}
|
||||
botId={id}
|
||||
adapterLabel={adapterLabel}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
form="bot-form"
|
||||
|
||||
@@ -410,6 +410,25 @@ const BotSessionMonitor = forwardRef<
|
||||
if (Array.isArray(parsed)) {
|
||||
return parsed as MessageChainComponent[];
|
||||
}
|
||||
if (parsed && typeof parsed === 'object') {
|
||||
const chain = parsed.message_chain ?? parsed.event?.message_chain;
|
||||
if (Array.isArray(chain)) return chain as MessageChainComponent[];
|
||||
if (Array.isArray(chain?.root)) return chain.root as MessageChainComponent[];
|
||||
if (Array.isArray(parsed.contents)) {
|
||||
const components: MessageChainComponent[] = [];
|
||||
for (const part of parsed.contents) {
|
||||
if (part.type === 'text' && typeof part.text === 'string') {
|
||||
components.push({ type: 'Plain', text: part.text } as Plain);
|
||||
} else if (part.type === 'image' && part.image_url) {
|
||||
components.push({ type: 'Image', url: part.image_url } as MessageChainComponent);
|
||||
}
|
||||
}
|
||||
if (components.length) return components;
|
||||
}
|
||||
if (typeof parsed.text === 'string') {
|
||||
return [{ type: 'Plain', text: parsed.text } as Plain];
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Not JSON, return as plain text
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user