@prevalentware/opencode-goal-plugin 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tui.tsx +9 -3
package/package.json
CHANGED
package/src/tui.tsx
CHANGED
|
@@ -37,6 +37,8 @@ type GoalSessionState = {
|
|
|
37
37
|
messageIndex: number
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
const goalCache = new Map<string, GoalSnapshot>()
|
|
41
|
+
|
|
40
42
|
function currentSessionID(api: TuiPluginApi) {
|
|
41
43
|
const route = api.route.current
|
|
42
44
|
if (route.name !== "session") return undefined
|
|
@@ -175,7 +177,7 @@ function parseGoalToolOutput(part: GoalToolPart): GoalSnapshot | null | undefine
|
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
function goalStateFromSession(api: TuiPluginApi, sessionID: string): GoalSessionState {
|
|
180
|
+
export function goalStateFromSession(api: TuiPluginApi, sessionID: string): GoalSessionState {
|
|
179
181
|
const messages = [...api.state.session.messages(sessionID)] as SessionMessage[]
|
|
180
182
|
for (let messageIndex = messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
|
|
181
183
|
const message = messages[messageIndex]
|
|
@@ -183,10 +185,14 @@ function goalStateFromSession(api: TuiPluginApi, sessionID: string): GoalSession
|
|
|
183
185
|
const parts = [...api.state.part(message.id)].reverse() as GoalToolPart[]
|
|
184
186
|
for (const part of parts) {
|
|
185
187
|
const goal = parseGoalToolOutput(part)
|
|
186
|
-
if (goal !== undefined)
|
|
188
|
+
if (goal !== undefined) {
|
|
189
|
+
if (goal) goalCache.set(sessionID, goal)
|
|
190
|
+
else goalCache.delete(sessionID)
|
|
191
|
+
return { goal, messageIndex }
|
|
192
|
+
}
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
|
-
return { goal: null, messageIndex: -1 }
|
|
195
|
+
return { goal: goalCache.get(sessionID) ?? null, messageIndex: -1 }
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
function goalFromSession(api: TuiPluginApi, sessionID: string) {
|