mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
sync
This commit is contained in:
parent
c61cc1b635
commit
13dedb8027
2 changed files with 60 additions and 38 deletions
|
|
@ -110,47 +110,12 @@ export function Autocomplete(props: {
|
|||
{
|
||||
display: "/undo",
|
||||
description: "undo the last message",
|
||||
onSelect: () => {
|
||||
const revert = s.revert?.messageID
|
||||
const message = (sync.data.message[s.id] ?? []).findLast(
|
||||
(x) => (!revert || x.id < revert) && x.role === "user",
|
||||
)
|
||||
if (!message) return
|
||||
sdk.session.revert({
|
||||
path: {
|
||||
id: s.id,
|
||||
},
|
||||
body: {
|
||||
messageID: message.id,
|
||||
},
|
||||
})
|
||||
},
|
||||
onSelect: () => command.trigger("session.undo"),
|
||||
},
|
||||
{
|
||||
display: "/redo",
|
||||
description: "redo the last message",
|
||||
onSelect: () => {
|
||||
const messageID = s.revert?.messageID
|
||||
if (!messageID) return
|
||||
const messages = sync.data.message[s.id] ?? []
|
||||
const message = messages.find((x) => x.role === "user" && x.id > messageID)
|
||||
if (!message) {
|
||||
sdk.session.unrevert({
|
||||
path: {
|
||||
id: s.id,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
sdk.session.revert({
|
||||
path: {
|
||||
id: s.id,
|
||||
},
|
||||
body: {
|
||||
messageID: message.id,
|
||||
},
|
||||
})
|
||||
},
|
||||
onSelect: () => command.trigger("session.redo"),
|
||||
},
|
||||
{
|
||||
display: "/compact",
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ export function Session() {
|
|||
if (keybind.match("messages_page_down", evt)) scroll.scrollBy(scroll.height / 2)
|
||||
})
|
||||
|
||||
function toBottom() {
|
||||
scroll.scrollTo(scroll.scrollHeight)
|
||||
}
|
||||
|
||||
const local = useLocal()
|
||||
|
||||
const command = useCommandDialog()
|
||||
|
|
@ -100,6 +104,59 @@ export function Session() {
|
|||
dialog.clear()
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Undo",
|
||||
value: "session.undo",
|
||||
keybind: "messages_undo",
|
||||
category: "Session",
|
||||
onSelect: (dialog) => {
|
||||
const revert = session().revert?.messageID
|
||||
const message = messages().findLast((x) => (!revert || x.id < revert) && x.role === "user")
|
||||
if (!message) return
|
||||
sdk.session
|
||||
.revert({
|
||||
path: {
|
||||
id: route.sessionID,
|
||||
},
|
||||
body: {
|
||||
messageID: message.id,
|
||||
},
|
||||
})
|
||||
.then(() => setTimeout(() => toBottom(), 100))
|
||||
dialog.clear()
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "Redo",
|
||||
value: "session.redo",
|
||||
keybind: "messages_redo",
|
||||
category: "Session",
|
||||
onSelect: () => {
|
||||
const messageID = session().revert?.messageID
|
||||
if (!messageID) return
|
||||
const message = messages().find((x) => x.role === "user" && x.id > messageID)
|
||||
if (!message) {
|
||||
sdk.session
|
||||
.unrevert({
|
||||
path: {
|
||||
id: route.sessionID,
|
||||
},
|
||||
})
|
||||
.then(() => setTimeout(() => toBottom(), 100))
|
||||
return
|
||||
}
|
||||
sdk.session
|
||||
.revert({
|
||||
path: {
|
||||
id: route.sessionID,
|
||||
},
|
||||
body: {
|
||||
messageID: message.id,
|
||||
},
|
||||
})
|
||||
.then(() => setTimeout(() => toBottom(), 100))
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
const revert = createMemo(() => {
|
||||
|
|
@ -178,7 +235,7 @@ export function Session() {
|
|||
<box flexShrink={0}>
|
||||
<Prompt
|
||||
onSubmit={() => {
|
||||
scroll.scrollTo(scroll.scrollHeight)
|
||||
toBottom()
|
||||
}}
|
||||
sessionID={route.sessionID}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue