Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions plugin/dashboard/app/sessions/[sessionId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ export default function InteractionDetailPage({
<div className="flex items-center gap-1 flex-wrap">
{turn.tools_used.map((t, ti) => {
const input = t.tool_data?.input;
const output = t.tool_data?.output;
const hasInput =
input && Object.keys(input).length > 0;
if (!hasInput) {
const hasOutput =
typeof output === "string" && output.length > 0;
if (!hasInput && !hasOutput) {
return (
<span key={ti}>
<Badge
Expand All @@ -171,9 +174,28 @@ export default function InteractionDetailPage({
<ChevronRight className="h-3 w-3 transition-transform group-open:rotate-90" />
</Badge>
</summary>
<pre className="mt-1 whitespace-pre-wrap break-words rounded-md border border-border bg-muted/40 px-2 py-1 text-[10px] font-mono text-muted-foreground">
{JSON.stringify(input, null, 2)}
</pre>
<div className="mt-1 space-y-1.5">
{hasInput && (
<div>
<div className="text-[10px] font-mono uppercase tracking-wide text-muted-foreground/70 mb-0.5">
input
</div>
<pre className="whitespace-pre-wrap break-words rounded-md border border-border bg-muted/40 px-2 py-1 text-[10px] font-mono text-muted-foreground">
{JSON.stringify(input, null, 2)}
</pre>
</div>
)}
{hasOutput && (
<div>
<div className="text-[10px] font-mono uppercase tracking-wide text-muted-foreground/70 mb-0.5">
output
</div>
<pre className="whitespace-pre-wrap break-words rounded-md border border-border bg-muted/40 px-2 py-1 text-[10px] font-mono text-muted-foreground">
{output}
</pre>
</div>
)}
</div>
</details>
);
})}
Expand Down
26 changes: 25 additions & 1 deletion plugin/dashboard/lib/session-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ import type {
UserActionType,
} from "./types";

// Mirrors _TOOL_DATA_FIELD_MAX_LEN in plugin/src/claude_smart/state.py — we
// truncate to the same length the publisher ships to reflexio so the
// dashboard renders the exact bytes the extractor sees.
const TOOL_DATA_FIELD_MAX_LEN = 256;

function truncateToolField<T>(value: T): T {
if (typeof value === "string" && value.length > TOOL_DATA_FIELD_MAX_LEN) {
return value.slice(0, TOOL_DATA_FIELD_MAX_LEN) as T;
}
return value;
}

export function stateDir(): string {
const override = process.env.CLAUDE_SMART_STATE_DIR;
if (override) return override;
Expand All @@ -30,6 +42,7 @@ type RawRecord = {
user_id?: string;
tool_name?: string;
tool_input?: Record<string, unknown>;
tool_output?: string;
status?: string;
user_action?: UserActionType;
user_action_description?: string;
Expand Down Expand Up @@ -81,8 +94,19 @@ function foldTurns(records: RawRecord[]): {
tool_name: rec.tool_name ?? "",
status: rec.status ?? "success",
};
const toolData: { input?: Record<string, unknown>; output?: string } = {};
if (rec.tool_input && Object.keys(rec.tool_input).length > 0) {
entry.tool_data = { input: rec.tool_input };
const input: Record<string, unknown> = {};
for (const [k, v] of Object.entries(rec.tool_input)) {
input[k] = truncateToolField(v);
}
toolData.input = input;
}
if (typeof rec.tool_output === "string" && rec.tool_output.length > 0) {
toolData.output = truncateToolField(rec.tool_output);
}
if (toolData.input || toolData.output) {
entry.tool_data = toolData;
}
pendingTools.push(entry);
continue;
Expand Down
2 changes: 1 addition & 1 deletion plugin/dashboard/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ProfileStatus = "CURRENT" | "ARCHIVED" | "PENDING";
export interface ToolUsed {
tool_name: string;
status: string;
tool_data?: { input?: Record<string, unknown> };
tool_data?: { input?: Record<string, unknown>; output?: string };
}

export interface CitedItem {
Expand Down
Loading