feat(kol): return to source page after generation and poll while busy

- Add a ?source=workspace|templates query param when opening the
  generate page so the back button and the post-submit redirect return
  to the originating page; invalidate articles + workspace caches on
  success so the new article shows up immediately.
- Poll recent articles every 10s in WorkspaceView and TemplatesView
  while any article is in queued/pending/generating/running, and stop
  the timer once nothing is active.
- Mark the new article as generating inside the generation Submit
  transaction so the client sees the right status as soon as the task
  is queued.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 17:17:17 +08:00
parent fe4a4ffeaa
commit 6e77f72c53
5 changed files with 105 additions and 13 deletions
@@ -77,7 +77,11 @@ function handleGenerate(promptId: number) {
(sp) => sp.prompt_id === promptId && sp.package_id === packageId.value
);
if (subPrompt) {
void router.push({ name: "kol-generate", params: { subscriptionPromptId: String(subPrompt.id) } });
void router.push({
name: "kol-generate",
params: { subscriptionPromptId: String(subPrompt.id) },
query: { source: "templates" },
});
}
}