mirror of
https://github.com/aljazceru/claude-code-viewer.git
synced 2025-12-25 01:04:21 +01:00
fix: chore
This commit is contained in:
@@ -33,7 +33,7 @@ export class SessionMetaService extends Context.Tag("SessionMetaService")<
|
||||
this,
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const firstCommandCache =
|
||||
const firstUserMessageCache =
|
||||
yield* FileCacheStorage<ParsedUserMessage | null>();
|
||||
const sessionMetaCacheRef = yield* Ref.make(
|
||||
new Map<string, SessionMeta>(),
|
||||
@@ -44,7 +44,7 @@ export class SessionMetaService extends Context.Tag("SessionMetaService")<
|
||||
lines: string[],
|
||||
): Effect.Effect<ParsedUserMessage | null, Error> =>
|
||||
Effect.gen(function* () {
|
||||
const cached = yield* firstCommandCache.get(jsonlFilePath);
|
||||
const cached = yield* firstUserMessageCache.get(jsonlFilePath);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export class SessionMetaService extends Context.Tag("SessionMetaService")<
|
||||
}
|
||||
|
||||
if (firstUserMessage !== null) {
|
||||
yield* firstCommandCache.set(jsonlFilePath, firstUserMessage);
|
||||
yield* firstUserMessageCache.set(jsonlFilePath, firstUserMessage);
|
||||
}
|
||||
|
||||
return firstUserMessage;
|
||||
|
||||
@@ -28,13 +28,20 @@ const LayerImpl = Effect.gen(function* () {
|
||||
yield* fs.writeFileString(cacheFilePath, "[]");
|
||||
} else {
|
||||
const content = yield* fs.readFileString(cacheFilePath);
|
||||
const parsed = saveSchema.safeParse(JSON.parse(content));
|
||||
const parsed = (() => {
|
||||
try {
|
||||
return saveSchema.parse(JSON.parse(content));
|
||||
} catch (error) {
|
||||
console.error(`Cache file parse error: ${error}`);
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
|
||||
if (!parsed.success) {
|
||||
if (parsed === undefined || parsed.length === 0) {
|
||||
console.error(`Cache file removed: ${cacheFilePath}`);
|
||||
yield* fs.writeFileString(cacheFilePath, "[]");
|
||||
} else {
|
||||
parsed.data;
|
||||
return parsed.data;
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user