diff --git a/plugins/_goal/AGENTS.md b/plugins/_goal/AGENTS.md index 758c32cea..36df52b22 100644 --- a/plugins/_goal/AGENTS.md +++ b/plugins/_goal/AGENTS.md @@ -27,6 +27,9 @@ - `/goal auto` fills the composer with a prompt asking the agent to create and manage its own goal instead of silently sending a message. - While a goal is active, response-tool calls are intermediate updates; only completing or blocking the goal restores normal loop termination. - Goal UI feedback uses toast notifications and inline controls, not modal dialogs. +- Goal state changes publish a context revision through the shared state-push + lifecycle; the WebUI refreshes on context or revision changes and never polls + the Goal API while idle. ## Work Guidance diff --git a/plugins/_goal/extensions/webui/apply_snapshot_before/refresh-goal.js b/plugins/_goal/extensions/webui/apply_snapshot_before/refresh-goal.js new file mode 100644 index 000000000..b937fb863 --- /dev/null +++ b/plugins/_goal/extensions/webui/apply_snapshot_before/refresh-goal.js @@ -0,0 +1,16 @@ +import { store as goalStore } from "/plugins/_goal/webui/goal-store.js"; + +let lastContextId = ""; +let lastRevision = null; + +export default async function refreshGoalOnRevision(ctx) { + const snapshot = ctx?.snapshot; + const contextId = String(snapshot?.context || ""); + const activeContext = (snapshot?.contexts || []).find(item => item?.id === contextId); + const revision = activeContext?._goal_revision ?? null; + + if (contextId === lastContextId && revision === lastRevision) return; + lastContextId = contextId; + lastRevision = revision; + await goalStore.refresh(true); +} diff --git a/plugins/_goal/extensions/webui/chat-input-progress-start/goal-strip.html b/plugins/_goal/extensions/webui/chat-input-progress-start/goal-strip.html index d75fd5583..adcb18c66 100644 --- a/plugins/_goal/extensions/webui/chat-input-progress-start/goal-strip.html +++ b/plugins/_goal/extensions/webui/chat-input-progress-start/goal-strip.html @@ -5,7 +5,6 @@