fix(app): clear comments on prompt submission (#12148)
This commit is contained in:
@@ -70,6 +70,14 @@ function createCommentSession(dir: string, id: string | undefined) {
|
|||||||
setFocus((current) => (current?.id === id ? null : current))
|
setFocus((current) => (current?.id === id ? null : current))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clear = () => {
|
||||||
|
batch(() => {
|
||||||
|
setStore("comments", {})
|
||||||
|
setFocus(null)
|
||||||
|
setActive(null)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const all = createMemo(() => {
|
const all = createMemo(() => {
|
||||||
const files = Object.keys(store.comments)
|
const files = Object.keys(store.comments)
|
||||||
const items = files.flatMap((file) => store.comments[file] ?? [])
|
const items = files.flatMap((file) => store.comments[file] ?? [])
|
||||||
@@ -82,6 +90,7 @@ function createCommentSession(dir: string, id: string | undefined) {
|
|||||||
all,
|
all,
|
||||||
add,
|
add,
|
||||||
remove,
|
remove,
|
||||||
|
clear,
|
||||||
focus: createMemo(() => state.focus),
|
focus: createMemo(() => state.focus),
|
||||||
setFocus,
|
setFocus,
|
||||||
clearFocus: () => setFocus(null),
|
clearFocus: () => setFocus(null),
|
||||||
@@ -144,6 +153,7 @@ export const { use: useComments, provider: CommentsProvider } = createSimpleCont
|
|||||||
all: () => session().all(),
|
all: () => session().all(),
|
||||||
add: (input: Omit<LineComment, "id" | "time">) => session().add(input),
|
add: (input: Omit<LineComment, "id" | "time">) => session().add(input),
|
||||||
remove: (file: string, id: string) => session().remove(file, id),
|
remove: (file: string, id: string) => session().remove(file, id),
|
||||||
|
clear: () => session().clear(),
|
||||||
focus: () => session().focus(),
|
focus: () => session().focus(),
|
||||||
setFocus: (focus: CommentFocus | null) => session().setFocus(focus),
|
setFocus: (focus: CommentFocus | null) => session().setFocus(focus),
|
||||||
clearFocus: () => session().clearFocus(),
|
clearFocus: () => session().clearFocus(),
|
||||||
|
|||||||
@@ -2603,7 +2603,10 @@ export default function Page() {
|
|||||||
}}
|
}}
|
||||||
newSessionWorktree={newSessionWorktree()}
|
newSessionWorktree={newSessionWorktree()}
|
||||||
onNewSessionWorktreeReset={() => setStore("newSessionWorktree", "main")}
|
onNewSessionWorktreeReset={() => setStore("newSessionWorktree", "main")}
|
||||||
onSubmit={resumeScroll}
|
onSubmit={() => {
|
||||||
|
comments.clear()
|
||||||
|
resumeScroll()
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user