Archived
feat(sessions): add Reload action to refresh session from disk
Sessiond caches the in-memory SessionManager and never re-reads the session file. When the same session is also being edited by another process (e.g. the pi CLI), new entries on disk are invisible to the web UI \u2014 the tail of the conversation gets cut. Add a manual Reload action in the session three-dot menu: - Server: PiSessionService.reload(sessionId) closes the active session and re-opens it from disk, then publishes a fresh status. Exposed as POST /api/.../sessions/:sessionId/reload. - Client: api.reloadSession, SessionController.reloadSession which discards the cached transcript and re-runs selectSession so the history page is re-fetched. - ChatTranscriptStore gains discard(sessionId) and the history cache adapter gains optional remove(sessionId). - SessionList shows a Reload entry for non-archived, non-cached sessions; plumbed through AppNavigationPanel and PiWebApp. Note: pi-web-sessiond.service must be restarted manually after this change since the session daemon code path is affected.
This commit is contained in:
committed by
Federico Jaramillo Martinez
parent
ca30c970a7
commit
ea1ec1b595
@@ -560,6 +560,13 @@ export class PiSessionService {
|
||||
await this.archiveStore.deleteArchived(record.sessionId);
|
||||
}
|
||||
|
||||
async reload(ref: PiSessionLookup): Promise<void> {
|
||||
const active = await this.getActive(ref);
|
||||
await this.closeActive(active.runtime.session.sessionId);
|
||||
const reopened = await this.getActive(ref);
|
||||
this.publishStatus(reopened.runtime.session);
|
||||
}
|
||||
|
||||
async detachParent(ref: PiSessionLookup): Promise<void> {
|
||||
const session = await this.getOrOpen(ref);
|
||||
const sessionFile = session.sessionFile;
|
||||
|
||||
@@ -230,6 +230,15 @@ export function registerSessionRoutes(app: FastifyInstance, sessions: PiSessionS
|
||||
}
|
||||
});
|
||||
|
||||
app.post<{ Params: { sessionId: string }; Body: { cwd?: unknown } | undefined }>(`${prefix}/sessions/:sessionId/reload`, async (request, reply) => {
|
||||
try {
|
||||
await sessions.reload(sessionLookupFromBody(request.params.sessionId, optionalRecord(request.body)));
|
||||
return { reloaded: true };
|
||||
} catch (error) {
|
||||
return reply.code(mutationErrorStatus(error)).send({ error: errorMessage(error) });
|
||||
}
|
||||
});
|
||||
|
||||
app.post<{ Params: { sessionId: string }; Body: { cwd?: unknown } | undefined }>(`${prefix}/sessions/:sessionId/detach-parent`, async (request, reply) => {
|
||||
try {
|
||||
await sessions.detachParent(sessionLookupFromBody(request.params.sessionId, optionalRecord(request.body)));
|
||||
|
||||
Reference in New Issue
Block a user