mirror of
https://github.com/aljazceru/claude-code-viewer.git
synced 2026-01-09 16:44:23 +01:00
feat: add error report message on invalid schema message
This commit is contained in:
@@ -119,7 +119,9 @@ export const routes = (app: HonoAppType) => {
|
||||
filteredSessions = Array.from(sessionMap.values());
|
||||
}
|
||||
|
||||
return { sessions: filteredSessions };
|
||||
return {
|
||||
sessions: filteredSessions,
|
||||
};
|
||||
}),
|
||||
] as const);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ConversationSchema } from "../../lib/conversation-schema";
|
||||
import type { ErrorJsonl } from "./types";
|
||||
|
||||
export const parseJsonl = (content: string) => {
|
||||
const lines = content
|
||||
@@ -6,11 +7,15 @@ export const parseJsonl = (content: string) => {
|
||||
.split("\n")
|
||||
.filter((line) => line.trim() !== "");
|
||||
|
||||
return lines.flatMap((line) => {
|
||||
return lines.map((line) => {
|
||||
const parsed = ConversationSchema.safeParse(JSON.parse(line));
|
||||
if (!parsed.success) {
|
||||
console.warn("Failed to parse jsonl, skipping", parsed.error);
|
||||
return [];
|
||||
const errorData: ErrorJsonl = {
|
||||
type: "x-error",
|
||||
line,
|
||||
};
|
||||
return errorData;
|
||||
}
|
||||
|
||||
return parsed.data;
|
||||
|
||||
@@ -21,7 +21,11 @@ const extractProjectPathFromJsonl = async (filePath: string) => {
|
||||
for (const line of lines) {
|
||||
const conversation = parseJsonl(line).at(0);
|
||||
|
||||
if (conversation === undefined || conversation.type === "summary") {
|
||||
if (
|
||||
conversation === undefined ||
|
||||
conversation.type === "summary" ||
|
||||
conversation.type === "x-error"
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,11 @@ export type SessionMeta = {
|
||||
lastModifiedAt: string | null;
|
||||
};
|
||||
|
||||
export type SessionDetail = Session & {
|
||||
conversations: Conversation[];
|
||||
export type ErrorJsonl = {
|
||||
type: "x-error";
|
||||
line: string;
|
||||
};
|
||||
|
||||
export type SessionDetail = Session & {
|
||||
conversations: (Conversation | ErrorJsonl)[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user