fix(chat): improve history + polish SwiftUI panel

This commit is contained in:
Peter Steinberger
2025-12-14 04:18:21 +00:00
parent 01341d983c
commit e0545e2f94
5 changed files with 61 additions and 44 deletions

View File

@@ -458,6 +458,7 @@ export const CronRunLogEntrySchema = Type.Object(
export const ChatHistoryParamsSchema = Type.Object(
{
sessionKey: NonEmptyString,
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 500 })),
},
{ additionalProperties: false },
);

View File

@@ -793,13 +793,19 @@ export async function startGatewayServer(
},
};
}
const { sessionKey } = params as { sessionKey: string };
const { sessionKey, limit } = params as {
sessionKey: string;
limit?: number;
};
const { storePath, entry } = loadSessionEntry(sessionKey);
const sessionId = entry?.sessionId;
const messages =
const rawMessages =
sessionId && storePath
? readSessionMessages(sessionId, storePath)
: [];
const max = typeof limit === "number" ? limit : 200;
const messages =
rawMessages.length > max ? rawMessages.slice(-max) : rawMessages;
const thinkingLevel =
entry?.thinkingLevel ??
loadConfig().inbound?.reply?.thinkingDefault ??