mirror of
https://github.com/lmg-anon/mikupad.git
synced 2026-04-28 03:29:49 +00:00
Fix switchCompletion
This commit is contained in:
parent
2bf3b04873
commit
1157880919
1 changed files with 5 additions and 4 deletions
|
|
@ -4043,7 +4043,7 @@ export function App({ sessionStorage, templateStorage, useSessionState, useDBTem
|
|||
function undo() {
|
||||
if (!undoStack.current.length)
|
||||
return false;
|
||||
let currentUndo = undoStack.current.pop();
|
||||
const currentUndo = undoStack.current.pop();
|
||||
if (currentUndo.action === 'add') {
|
||||
setPromptChunks(p => [...p.slice(0, currentUndo.offset), ...p.slice(currentUndo.offset + currentUndo.chunks.length, p.length)]);
|
||||
} else if (currentUndo.action === 'remove') {
|
||||
|
|
@ -4058,7 +4058,7 @@ export function App({ sessionStorage, templateStorage, useSessionState, useDBTem
|
|||
function redo() {
|
||||
if (!redoStack.current.length)
|
||||
return false;
|
||||
let currentRedo = redoStack.current.pop();
|
||||
const currentRedo = redoStack.current.pop();
|
||||
if (currentRedo.action === 'add') {
|
||||
setPromptChunks(p => [...p.slice(0, currentRedo.offset), ...currentRedo.chunks, ...p.slice(currentRedo.offset, p.length)]);
|
||||
} else if (currentRedo.action === 'remove') {
|
||||
|
|
@ -4499,7 +4499,8 @@ export function App({ sessionStorage, templateStorage, useSessionState, useDBTem
|
|||
|
||||
async function switchCompletion(i, tok) {
|
||||
removePromptChunks(i, promptChunks.length);
|
||||
undoStack.current.push({ action: 'add', offset: i, chunks: [{ type: 'machine', content: tok }] });
|
||||
undoStack.current.push({ action: 'add', offset: i, chunks: [] });
|
||||
addPromptChunk({ ...promptChunks[i], content: tok });
|
||||
setTriggerPredict(true);
|
||||
setRestartedPredict(true);
|
||||
}
|
||||
|
|
@ -4891,7 +4892,7 @@ export function App({ sessionStorage, templateStorage, useSessionState, useDBTem
|
|||
<div className="shorts">
|
||||
<button
|
||||
title="Regenerate (Ctrl + R)"
|
||||
disabled=${!undoStack.current.length || undoStack.current.at(-1)?.action !== 'add'}
|
||||
disabled=${!undoStack.current.length || undoStack.current.at(-1)?.action !== 'add' || undoStack.current.at(-1)?.chunks.at(undoStack.current.at(-1)?.chunks.length > 1 ? -2 : -1)?.type === 'user'}
|
||||
onClick=${() => undoAndPredict()}
|
||||
onMouseEnter=${() => setUndoHovered(true)}
|
||||
onMouseLeave=${() => setUndoHovered(false)}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue