MCPcopy Index your code
hub / github.com/anomalyco/opencode / openComment

Function openComment

packages/app/src/components/prompt-input.tsx:281–319  ·  view source on GitHub ↗
(item: { path: string; commentID?: string; commentOrigin?: "review" | "file" })

Source from the content-addressed store, hash-verified

279 }
280
281 const openComment = (item: { path: string; commentID?: string; commentOrigin?: "review" | "file" }) => {
282 if (!item.commentID) return
283
284 const focus = { file: item.path, id: item.commentID }
285 comments.setActive(focus)
286
287 const queueCommentFocus = (attempts = 6) => {
288 const schedule = (left: number) => {
289 requestAnimationFrame(() => {
290 comments.setFocus({ ...focus })
291 if (left <= 0) return
292 requestAnimationFrame(() => {
293 const current = comments.focus()
294 if (!current) return
295 if (current.file !== focus.file || current.id !== focus.id) return
296 schedule(left - 1)
297 })
298 })
299 }
300
301 schedule(attempts)
302 }
303
304 const wantsReview = item.commentOrigin === "review" || (item.commentOrigin !== "file" && commentInReview(item.path))
305 if (wantsReview) {
306 if (!props.controls.session.reviewPanel.opened()) props.controls.session.reviewPanel.open()
307 layout.fileTree.setTab("changes")
308 tabs().setActive("review")
309 queueCommentFocus()
310 return
311 }
312
313 if (!props.controls.session.reviewPanel.opened()) props.controls.session.reviewPanel.open()
314 layout.fileTree.setTab("all")
315 const tab = files.tab(item.path)
316 void tabs().open(tab)
317 tabs().setActive(tab)
318 void Promise.resolve(files.load(item.path)).finally(() => queueCommentFocus())
319 }
320
321 const recent = createMemo(() => {
322 const all = tabs().all()

Callers

nothing calls this directly

Calls 4

commentInReviewFunction · 0.85
queueCommentFocusFunction · 0.85
openMethod · 0.80
tabsFunction · 0.70

Tested by

no test coverage detected