fix(tui): make undo inclusive of last user message and simplify revert banner
This commit is contained in:
parent
f4720be08e
commit
49e7dc191f
2 changed files with 42 additions and 5 deletions
|
|
@ -878,7 +878,8 @@ export function Session() {
|
||||||
</For>
|
</For>
|
||||||
<Show when={session()?.revert?.messageID}>
|
<Show when={session()?.revert?.messageID}>
|
||||||
<RevertMessage
|
<RevertMessage
|
||||||
count={messages().filter((message) => message.id > session()!.revert!.messageID).length}
|
count={messages().filter((message) => message.id >= session()!.revert!.messageID && message.type === "user").length}
|
||||||
|
files={session()!.revert!.files ?? []}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
</scrollbox>
|
</scrollbox>
|
||||||
|
|
@ -1167,7 +1168,21 @@ function CompactionMessage() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function RevertMessage(props: { count: number }) {
|
function statusLabel(status: "added" | "modified" | "deleted") {
|
||||||
|
if (status === "added") return "A"
|
||||||
|
if (status === "deleted") return "D"
|
||||||
|
return "M"
|
||||||
|
}
|
||||||
|
|
||||||
|
function RevertMessage(props: {
|
||||||
|
count: number
|
||||||
|
files: ReadonlyArray<{
|
||||||
|
readonly path: string
|
||||||
|
readonly status: "added" | "modified" | "deleted"
|
||||||
|
readonly additions: number
|
||||||
|
readonly deletions: number
|
||||||
|
}>
|
||||||
|
}) {
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
const route = useRouteData("session")
|
const route = useRouteData("session")
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
|
|
@ -1186,13 +1201,35 @@ function RevertMessage(props: { count: number }) {
|
||||||
})()
|
})()
|
||||||
}}
|
}}
|
||||||
flexShrink={0}
|
flexShrink={0}
|
||||||
|
marginTop={1}
|
||||||
border={["left"]}
|
border={["left"]}
|
||||||
customBorderChars={SplitBorder.customBorderChars}
|
customBorderChars={SplitBorder.customBorderChars}
|
||||||
borderColor={theme.backgroundPanel}
|
borderColor={theme.backgroundPanel}
|
||||||
>
|
>
|
||||||
<box paddingTop={1} paddingBottom={1} paddingLeft={2} backgroundColor={hover() ? theme.backgroundElement : theme.backgroundPanel}>
|
<box paddingTop={1} paddingBottom={1} paddingLeft={2} backgroundColor={hover() ? theme.backgroundElement : theme.backgroundPanel}>
|
||||||
<text fg={theme.textMuted}>{props.count} message{props.count === 1 ? "" : "s"} reverted</text>
|
<text fg={theme.textMuted}>
|
||||||
<text fg={theme.textMuted}>Click to redo</text>
|
{props.count} message{props.count === 1 ? "" : "s"} reverted
|
||||||
|
</text>
|
||||||
|
<Show when={props.files.length > 0}>
|
||||||
|
<box marginTop={1} flexDirection="column">
|
||||||
|
<For each={props.files}>
|
||||||
|
{(file) => (
|
||||||
|
<box flexDirection="row" gap={1} flexShrink={0}>
|
||||||
|
<text fg={theme.textMuted}>{statusLabel(file.status)}</text>
|
||||||
|
<text fg={theme.text} wrapMode="none">
|
||||||
|
{Locale.truncateLeft(file.path, 60)}
|
||||||
|
</text>
|
||||||
|
<Show when={file.additions > 0}>
|
||||||
|
<text fg={theme.diffAdded}>+{file.additions}</text>
|
||||||
|
</Show>
|
||||||
|
<Show when={file.deletions > 0}>
|
||||||
|
<text fg={theme.diffRemoved}>-{file.deletions}</text>
|
||||||
|
</Show>
|
||||||
|
</box>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</box>
|
||||||
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export function createSessionRows(sessionID: Accessor<string>) {
|
||||||
function reduce() {
|
function reduce() {
|
||||||
const messages = data.session.message.list(sessionID())
|
const messages = data.session.message.list(sessionID())
|
||||||
const boundary = revertBoundary()
|
const boundary = revertBoundary()
|
||||||
return reduceSessionRows(boundary ? messages.filter((message) => message.id <= boundary) : messages)
|
return reduceSessionRows(boundary ? messages.filter((message) => message.id < boundary) : messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue