make some overall QoL improvements
CI / check (22) (push) Failing after 16m26s
CI / check (24) (push) Failing after 15m50s

This commit is contained in:
Frederik Spirgi
2026-10-08 11:02:32 +02:00
parent 0f58a996ec
commit 8666e09049
7 changed files with 271 additions and 50 deletions
+18
View File
@@ -228,6 +228,24 @@ export function createChatsRouter({repositories, chatService, modelService, conf
return res.json({message: "Chat deleted"});
});
router.get("/chats/:id/messages/search", (req, res) => {
const chatId = Number(req.params.id);
if (!repositories.getChat(chatId, req.session.user)) return res.status(404).json({error: "Chat not found"});
const query = String(req.query.q || "").trim().slice(0, 200).toLocaleLowerCase();
if (!query) return res.json({matches: []});
const matches = [];
for (const message of repositories.listActiveBranchMessages(chatId)) {
const content = String(message.content || "").toLocaleLowerCase();
let at = content.indexOf(query);
let occurrence = 0;
while (at >= 0) {
matches.push({messageId: message.id, occurrence: occurrence++});
at = content.indexOf(query, at + query.length);
}
}
return res.json({matches});
});
router.get("/chats/:id/messages", (req, res) => {
const chatId = Number(req.params.id);
const chat = repositories.getChat(chatId, req.session.user);