mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
sidebar
This commit is contained in:
parent
754c264ea1
commit
aeef21b2a8
1 changed files with 12 additions and 16 deletions
|
|
@ -9,20 +9,6 @@ export function Sidebar(props: { sessionID: string }) {
|
|||
const session = createMemo(() => sync.session.get(props.sessionID)!)
|
||||
const todo = createMemo(() => sync.data.todo[props.sessionID] ?? [])
|
||||
const messages = createMemo(() => sync.data.message[props.sessionID] ?? [])
|
||||
const files = createMemo(() => {
|
||||
const result = new Set<string>()
|
||||
for (const msg of messages()) {
|
||||
const parts = sync.data.part[msg.id] ?? []
|
||||
for (const part of parts) {
|
||||
if (part.type === "patch") {
|
||||
for (const file of part.files) {
|
||||
result.add(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...result.values()].sort((a, b) => a.length - b.length)
|
||||
})
|
||||
|
||||
const cost = createMemo(() => {
|
||||
const total = messages().reduce((sum, x) => sum + (x.role === "assistant" ? x.cost : 0), 0)
|
||||
|
|
@ -125,12 +111,22 @@ export function Sidebar(props: { sessionID: string }) {
|
|||
</For>
|
||||
</box>
|
||||
</Show>
|
||||
<Show when={files().length > 0}>
|
||||
<Show when={session().summary?.diffs}>
|
||||
<box>
|
||||
<text>
|
||||
<b>Modified Files</b>
|
||||
</text>
|
||||
<For each={files()}>{(file) => <text fg={Theme.textMuted}>{Locale.truncateMiddle(file, 40)}</text>}</For>
|
||||
<For each={session().summary?.diffs || []}>
|
||||
{(item) => (
|
||||
<box flexDirection="row" gap={1} justifyContent="space-between">
|
||||
<text fg={Theme.textMuted}>{Locale.truncateMiddle(item.file, 40)}</text>
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={Theme.diffAdded}>+{item.additions}</text>
|
||||
<text fg={Theme.diffRemoved}>-{item.deletions}</text>
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</Show>
|
||||
<Show when={todo().length > 0}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue