From ddc4e893598b7aeb54d8476e97332ab97c02002f Mon Sep 17 00:00:00 2001 From: adamelmore <2363879+adamdottv@users.noreply.github.com> Date: Sun, 25 Jan 2026 06:20:44 -0600 Subject: [PATCH] fix(app): cleanup comment component usage --- packages/app/src/pages/session.tsx | 114 ++++-------------- packages/ui/src/components/line-comment.css | 61 ++++++++++ packages/ui/src/components/line-comment.tsx | 105 +++++++++++++++- packages/ui/src/components/session-review.css | 62 ---------- packages/ui/src/components/session-review.tsx | 94 +++------------ 5 files changed, 207 insertions(+), 229 deletions(-) diff --git a/packages/app/src/pages/session.tsx b/packages/app/src/pages/session.tsx index 38717317d..a14b6bcf6 100644 --- a/packages/app/src/pages/session.tsx +++ b/packages/app/src/pages/session.tsx @@ -15,7 +15,7 @@ import { DiffChanges } from "@opencode-ai/ui/diff-changes" import { ResizeHandle } from "@opencode-ai/ui/resize-handle" import { Tabs } from "@opencode-ai/ui/tabs" import { useCodeComponent } from "@opencode-ai/ui/context/code" -import { LineCommentAnchor } from "@opencode-ai/ui/line-comment" +import { LineComment as LineCommentView, LineCommentEditor } from "@opencode-ai/ui/line-comment" import { SessionTurn } from "@opencode-ai/ui/session-turn" import { createAutoScroll } from "@opencode-ai/ui/hooks" import { SessionReview } from "@opencode-ai/ui/session-review" @@ -1885,7 +1885,6 @@ export default function Page() { }) let wrap: HTMLDivElement | undefined - let textarea: HTMLTextAreaElement | undefined const fileComments = createMemo(() => { const p = path() @@ -1898,7 +1897,6 @@ export default function Page() { const [openedComment, setOpenedComment] = createSignal(null) const [commenting, setCommenting] = createSignal(null) const [draft, setDraft] = createSignal("") - const [draftError, setDraftError] = createSignal(false) const [positions, setPositions] = createSignal>({}) const [draftTop, setDraftTop] = createSignal(undefined) @@ -1986,7 +1984,6 @@ export default function Page() { const range = commenting() if (!range) return setDraft("") - requestAnimationFrame(() => textarea?.focus()) }) createEffect(() => { @@ -2047,7 +2044,7 @@ export default function Page() { /> {(comment) => ( - (current === comment.id ? null : comment.id)) file.setSelectedLines(p, comment.selection) }} - > -
-
- {comment.comment} -
-
- Comment on {commentLabel(comment.selection)} -
-
-
+ comment={comment.comment} + selection={commentLabel(comment.selection)} + /> )}
{(range) => ( - textarea?.focus()} + value={draft()} + selection={commentLabel(range())} + onInput={setDraft} + onCancel={() => setCommenting(null)} + onSubmit={(comment) => { + const p = path() + if (!p) return + addCommentToContext({ + file: p, + selection: range(), + comment, + origin: "file", + }) + setCommenting(null) + }} onPopoverFocusOut={(e) => { const target = e.relatedTarget as Node | null if (target && e.currentTarget.contains(target)) return @@ -2093,79 +2095,7 @@ export default function Page() { } }, 0) }} - > -
-