@prevalentware/opencode-goal-plugin 0.1.8 → 0.1.9
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 +6 -25
package/package.json
CHANGED
package/src/tui.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui"
|
|
3
|
-
import { createMemo,
|
|
3
|
+
import { createMemo, Show } from "solid-js"
|
|
4
4
|
|
|
5
5
|
type GoalSnapshot = {
|
|
6
6
|
sessionID: string
|
|
@@ -116,22 +116,13 @@ function formatDuration(seconds: number) {
|
|
|
116
116
|
const hours = Math.floor(total / 3600)
|
|
117
117
|
const minutes = Math.floor((total % 3600) / 60)
|
|
118
118
|
const secs = total % 60
|
|
119
|
-
|
|
120
|
-
if (
|
|
121
|
-
return `${
|
|
119
|
+
const paddedSecs = String(secs).padStart(2, "0")
|
|
120
|
+
if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${paddedSecs}`
|
|
121
|
+
return `${minutes}:${paddedSecs}`
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function formatDurationBadge(seconds: number) {
|
|
125
|
-
|
|
126
|
-
const hours = Math.floor(total / 3600)
|
|
127
|
-
const minutes = Math.floor((total % 3600) / 60)
|
|
128
|
-
if (hours > 0) return `${hours}h${minutes > 0 ? ` ${minutes}m` : ""}`
|
|
129
|
-
if (minutes > 0) return `${minutes}m`
|
|
130
|
-
return `${total}s`
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function nowSeconds() {
|
|
134
|
-
return Math.floor(Date.now() / 1000)
|
|
125
|
+
return formatDuration(seconds)
|
|
135
126
|
}
|
|
136
127
|
|
|
137
128
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
@@ -191,11 +182,6 @@ function goalFromSession(api: TuiPluginApi, sessionID: string) {
|
|
|
191
182
|
return goalStateFromSession(api, sessionID).goal
|
|
192
183
|
}
|
|
193
184
|
|
|
194
|
-
function liveTimeUsed(goal: GoalSnapshot, currentSeconds: number) {
|
|
195
|
-
if (visibleStatus(goal.status) !== "active" || goal.sampledAt == null) return goal.timeUsedSeconds
|
|
196
|
-
return goal.timeUsedSeconds + Math.max(0, currentSeconds - goal.sampledAt)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
185
|
function visibleStatus(status: GoalSnapshot["status"]) {
|
|
200
186
|
return status === "budgetLimited" ? "active" : status
|
|
201
187
|
}
|
|
@@ -214,11 +200,6 @@ function formatGoal(goal: GoalSnapshot | null) {
|
|
|
214
200
|
|
|
215
201
|
function GoalSidebar(props: { api: TuiPluginApi; sessionID: string }) {
|
|
216
202
|
const theme = () => props.api.theme.current
|
|
217
|
-
const [currentSeconds, setCurrentSeconds] = createSignal(nowSeconds())
|
|
218
|
-
onMount(() => {
|
|
219
|
-
const interval = setInterval(() => setCurrentSeconds(nowSeconds()), 1000)
|
|
220
|
-
onCleanup(() => clearInterval(interval))
|
|
221
|
-
})
|
|
222
203
|
const state = createMemo(() => {
|
|
223
204
|
props.api.state.session.messages(props.sessionID)
|
|
224
205
|
return goalStateFromSession(props.api, props.sessionID)
|
|
@@ -226,7 +207,7 @@ function GoalSidebar(props: { api: TuiPluginApi; sessionID: string }) {
|
|
|
226
207
|
const goal = createMemo(() => state().goal)
|
|
227
208
|
const elapsed = createMemo(() => {
|
|
228
209
|
const value = goal()
|
|
229
|
-
return value
|
|
210
|
+
return value?.timeUsedSeconds ?? 0
|
|
230
211
|
})
|
|
231
212
|
const objective = createMemo(() => {
|
|
232
213
|
const value = goal()?.objective ?? ""
|