-
Notifications
You must be signed in to change notification settings - Fork 786
fix(memos-local-plugin): prevent orphan episode scan from closing active sessions; add episode delete API #1546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
3bf3ead
328d1a5
27d64eb
f2571e7
68bfe16
bfee04d
23d0e89
dc985cf
948adff
e09f116
34bdb43
7e08cf7
981a1db
a641b1d
0fe7906
8abb30b
700f006
3fa7375
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,20 @@ export function registerSessionRoutes(routes: Routes, deps: ServerDeps): void { | |
| writeError(ctx, 400, "invalid_argument", "episodeId is required"); | ||
| return; | ||
| } | ||
| await deps.core.closeEpisode(id as EpisodeId); | ||
| return { ok: true }; | ||
| const result = await deps.core.deleteEpisode(id as EpisodeId); | ||
| return result; | ||
|
Starfie1d1272 marked this conversation as resolved.
Outdated
Starfie1d1272 marked this conversation as resolved.
Outdated
|
||
| }); | ||
|
|
||
| routes.set("POST /api/v1/episodes/delete", async (ctx) => { | ||
| const body = parseJson<{ ids?: unknown }>(ctx); | ||
| const ids = Array.isArray(body.ids) | ||
| ? body.ids.filter((v): v is string => typeof v === "string" && v.length > 0) | ||
| : []; | ||
| if (ids.length === 0) { | ||
| writeError(ctx, 400, "invalid_argument", "ids[] is required"); | ||
| return; | ||
| } | ||
| return await deps.core.deleteEpisodes(ids as EpisodeId[]); | ||
| }); | ||
|
Comment on lines
+48
to
69
|
||
|
|
||
| routes.set("GET /api/v1/episodes", async (ctx) => { | ||
|
|
@@ -61,10 +73,6 @@ export function registerSessionRoutes(routes: Routes, deps: ServerDeps): void { | |
| const rawOffset = numberOrUndefined(ctx.url.searchParams.get("offset")); | ||
| const limit = rawLimit && rawLimit > 0 ? rawLimit : 50; | ||
| const offset = rawOffset && rawOffset >= 0 ? rawOffset : 0; | ||
| // Return the rich row shape — the viewer's task list needs | ||
| // session id / status / turn count / preview. The old `ids`-only | ||
| // variant is still available under the `episode.list` JSON-RPC | ||
| // method and via `?shape=ids`. | ||
| if (ctx.url.searchParams.get("shape") === "ids") { | ||
| const episodeIds = await deps.core.listEpisodes({ sessionId, limit, offset }); | ||
| return { | ||
|
|
@@ -83,9 +91,6 @@ export function registerSessionRoutes(routes: Routes, deps: ServerDeps): void { | |
| }; | ||
| }); | ||
|
|
||
| // Backward-compat: legacy `/api/v1/episodes/timeline?episodeId=…` | ||
| // still works; the preferred path `/api/v1/episodes/:id/timeline` | ||
| // is registered in `trace.ts`. | ||
| routes.set("GET /api/v1/episodes/timeline", async (ctx) => { | ||
| const episodeId = ctx.url.searchParams.get("episodeId"); | ||
| if (!episodeId) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.