Add session list refresh with server cache bypass
useSession now exposes a refreshSessions() callback that fetches /api/sessions?refresh=1. The sessions route checks for the refresh query parameter and resets the cache timestamp to zero, forcing a fresh scan of ~/.claude/projects/ on the next request. This enables users to pick up new sessions without restarting the server or waiting for the 30-second cache to expire. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,11 @@ async function getCachedSessions(): Promise<SessionEntry[]> {
|
||||
return cachedSessions;
|
||||
}
|
||||
|
||||
sessionsRouter.get("/", async (_req, res) => {
|
||||
sessionsRouter.get("/", async (req, res) => {
|
||||
try {
|
||||
if (req.query.refresh === "1") {
|
||||
cacheTimestamp = 0;
|
||||
}
|
||||
const sessions = await getCachedSessions();
|
||||
res.json({ sessions });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user