Skip to content

Commit c3cad16

Browse files
committed
fix: ui stopped showing source code in Code block details
Signed-off-by: Nick Mitchell <[email protected]>
1 parent ff54158 commit c3cad16

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

pdl-live-react/src/helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,15 @@ export function extractStructuredModelResponse({
305305
export function isArgs(block: ArgsBlock | CodeBlock): block is ArgsBlock {
306306
return Array.isArray((block as ArgsBlock).args)
307307
}
308+
309+
export function extractCode({ code }: CodeBlock): string {
310+
if (
311+
isNonScalarPdlBlock(code) &&
312+
hasResult(code) &&
313+
typeof code.pdl__result !== "object"
314+
) {
315+
return String(code.pdl__result)
316+
}
317+
318+
return String(code)
319+
}

pdl-live-react/src/view/detail/DrawerContentBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default function DrawerContentBody({
5353

5454
default: {
5555
// some blocks have nothing interesting to show other than their result
56-
const hasSummary = !(block.kind === "data" || block.kind === "code")
56+
const hasSummary = !(block.kind === "data")
5757

5858
return [
5959
...(!hasSummary
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Group from "../Group"
22

33
import Code from "../../code/Code"
4-
import Result from "../../Result"
5-
import { isArgs } from "../../../helpers"
4+
import { isArgs, extractCode } from "../../../helpers"
65

76
export default function CodeItems({
87
block,
@@ -11,27 +10,25 @@ export default function CodeItems({
1110
| import("../../../pdl_ast").ArgsBlock
1211
| import("../../../pdl_ast").CodeBlock
1312
}) {
14-
const { lang, pdl__result } = block
15-
const code = isArgs(block) ? block.args.join(" ") : block.code
13+
const { lang } = block
14+
const code = isArgs(block) ? block.args.join(" ") : extractCode(block)
15+
1616
return (
1717
<>
18-
{typeof code === "string" && (
19-
<Group
20-
term="Code"
21-
description={
22-
<Code
23-
block={code.trim()}
24-
showLineNumbers
25-
language={
26-
lang === "pdl" || lang === "jinja" || lang === "command"
27-
? "plaintext"
28-
: lang || "yaml"
29-
}
30-
/>
31-
}
32-
/>
33-
)}
34-
<Result result={pdl__result} term="Execution Output" />
18+
<Group
19+
term="Code"
20+
description={
21+
<Code
22+
block={code.trim()}
23+
showLineNumbers
24+
language={
25+
lang === "pdl" || lang === "jinja" || lang === "command"
26+
? "plaintext"
27+
: lang || "yaml"
28+
}
29+
/>
30+
}
31+
/>
3532
</>
3633
)
3734
}

0 commit comments

Comments
 (0)