Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/app/src/context/comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ function createCommentSession(dir: string, id: string | undefined) {
setFocus((current) => (current?.id === id ? null : current))
}

const clear = () => {
batch(() => {
setStore("comments", {})
setFocus(null)
setActive(null)
})
}

const all = createMemo(() => {
const files = Object.keys(store.comments)
const items = files.flatMap((file) => store.comments[file] ?? [])
Expand All @@ -82,6 +90,7 @@ function createCommentSession(dir: string, id: string | undefined) {
all,
add,
remove,
clear,
focus: createMemo(() => state.focus),
setFocus,
clearFocus: () => setFocus(null),
Expand Down Expand Up @@ -144,6 +153,7 @@ export const { use: useComments, provider: CommentsProvider } = createSimpleCont
all: () => session().all(),
add: (input: Omit<LineComment, "id" | "time">) => session().add(input),
remove: (file: string, id: string) => session().remove(file, id),
clear: () => session().clear(),
focus: () => session().focus(),
setFocus: (focus: CommentFocus | null) => session().setFocus(focus),
clearFocus: () => session().clearFocus(),
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/pages/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,10 @@ export default function Page() {
}}
newSessionWorktree={newSessionWorktree()}
onNewSessionWorktreeReset={() => setStore("newSessionWorktree", "main")}
onSubmit={resumeScroll}
onSubmit={() => {
comments.clear()
resumeScroll()
}}
/>
</Show>
</div>
Expand Down
Loading