|
@@ -102,6 +102,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
imageAttachments: ImageAttachmentPart[]
|
|
imageAttachments: ImageAttachmentPart[]
|
|
|
mode: "normal" | "shell"
|
|
mode: "normal" | "shell"
|
|
|
applyingHistory: boolean
|
|
applyingHistory: boolean
|
|
|
|
|
+ userHasEdited: boolean
|
|
|
}>({
|
|
}>({
|
|
|
popover: null,
|
|
popover: null,
|
|
|
historyIndex: -1,
|
|
historyIndex: -1,
|
|
@@ -111,6 +112,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
imageAttachments: [],
|
|
imageAttachments: [],
|
|
|
mode: "normal",
|
|
mode: "normal",
|
|
|
applyingHistory: false,
|
|
applyingHistory: false,
|
|
|
|
|
+ userHasEdited: false,
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const MAX_HISTORY = 100
|
|
const MAX_HISTORY = 100
|
|
@@ -139,6 +141,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
const applyHistoryPrompt = (p: Prompt, position: "start" | "end") => {
|
|
const applyHistoryPrompt = (p: Prompt, position: "start" | "end") => {
|
|
|
const length = position === "start" ? 0 : promptLength(p)
|
|
const length = position === "start" ? 0 : promptLength(p)
|
|
|
setStore("applyingHistory", true)
|
|
setStore("applyingHistory", true)
|
|
|
|
|
+ setStore("userHasEdited", false)
|
|
|
prompt.set(p, length)
|
|
prompt.set(p, length)
|
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
|
editorRef.focus()
|
|
editorRef.focus()
|
|
@@ -440,6 +443,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
|
|
|
|
|
if (shouldReset) {
|
|
if (shouldReset) {
|
|
|
setStore("popover", null)
|
|
setStore("popover", null)
|
|
|
|
|
+ setStore("userHasEdited", false)
|
|
|
if (store.historyIndex >= 0 && !store.applyingHistory) {
|
|
if (store.historyIndex >= 0 && !store.applyingHistory) {
|
|
|
setStore("historyIndex", -1)
|
|
setStore("historyIndex", -1)
|
|
|
setStore("savedPrompt", null)
|
|
setStore("savedPrompt", null)
|
|
@@ -474,6 +478,10 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
setStore("savedPrompt", null)
|
|
setStore("savedPrompt", null)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (!store.applyingHistory) {
|
|
|
|
|
+ setStore("userHasEdited", true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
prompt.set(rawParts, cursorPosition)
|
|
prompt.set(rawParts, cursorPosition)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -565,6 +573,8 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const navigateHistory = (direction: "up" | "down") => {
|
|
const navigateHistory = (direction: "up" | "down") => {
|
|
|
|
|
+ if (store.userHasEdited) return false
|
|
|
|
|
+
|
|
|
const entries = history.entries
|
|
const entries = history.entries
|
|
|
const current = store.historyIndex
|
|
const current = store.historyIndex
|
|
|
|
|
|
|
@@ -696,6 +706,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|
|
addToHistory(currentPrompt)
|
|
addToHistory(currentPrompt)
|
|
|
setStore("historyIndex", -1)
|
|
setStore("historyIndex", -1)
|
|
|
setStore("savedPrompt", null)
|
|
setStore("savedPrompt", null)
|
|
|
|
|
+ setStore("userHasEdited", false)
|
|
|
|
|
|
|
|
let existing = info()
|
|
let existing = info()
|
|
|
if (!existing) {
|
|
if (!existing) {
|