mirror of
https://github.com/stablyai/orca.git
synced 2026-09-26 08:02:38 +00:00
Derive GitHub reviewer picker active index during render (#3114)
This commit is contained in:
@@ -393,7 +393,7 @@ function PRReviewersPanel({
|
||||
const [reviewerInput, setReviewerInput] = useState('')
|
||||
const [reviewerPickerSide, setReviewerPickerSide] = useState<'top' | 'bottom'>('bottom')
|
||||
const [reviewerPickerMaxHeight, setReviewerPickerMaxHeight] = useState<number | null>(null)
|
||||
const [activeReviewerIndex, setActiveReviewerIndex] = useState(0)
|
||||
const [activeReviewerCursor, setActiveReviewerCursor] = useState({ resetKey: '', index: 0 })
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [localReviewRequests, setLocalReviewRequests] = useState<GitHubAssignableUser[]>(
|
||||
() => item.reviewRequests ?? []
|
||||
@@ -558,9 +558,24 @@ function PRReviewersPanel({
|
||||
[everyoneElseReviewerRows, suggestedReviewerRows]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveReviewerIndex(0)
|
||||
}, [reviewerQuery, actionableReviewerRows.length])
|
||||
const reviewerCursorResetKey = `${reviewerQuery}\u0000${actionableReviewerRows.length}`
|
||||
if (activeReviewerCursor.resetKey !== reviewerCursorResetKey) {
|
||||
setActiveReviewerCursor({ resetKey: reviewerCursorResetKey, index: 0 })
|
||||
}
|
||||
const activeReviewerIndex =
|
||||
activeReviewerCursor.resetKey === reviewerCursorResetKey ? activeReviewerCursor.index : 0
|
||||
const setActiveReviewerIndex = useCallback(
|
||||
(nextIndex: number | ((current: number) => number)): void => {
|
||||
setActiveReviewerCursor((current) => {
|
||||
const currentIndex = current.resetKey === reviewerCursorResetKey ? current.index : 0
|
||||
return {
|
||||
resetKey: reviewerCursorResetKey,
|
||||
index: typeof nextIndex === 'function' ? nextIndex(currentIndex) : nextIndex
|
||||
}
|
||||
})
|
||||
},
|
||||
[reviewerCursorResetKey]
|
||||
)
|
||||
|
||||
const hasReviewerMetadata =
|
||||
item.reviewDecision !== undefined ||
|
||||
|
||||
@@ -472,7 +472,7 @@ function PRReviewersPanel({
|
||||
const [reviewerInput, setReviewerInput] = useState('')
|
||||
const [reviewerPickerSide, setReviewerPickerSide] = useState<'top' | 'bottom'>('bottom')
|
||||
const [reviewerPickerMaxHeight, setReviewerPickerMaxHeight] = useState<number | null>(null)
|
||||
const [activeReviewerIndex, setActiveReviewerIndex] = useState(0)
|
||||
const [activeReviewerCursor, setActiveReviewerCursor] = useState({ resetKey: '', index: 0 })
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [localReviewRequests, setLocalReviewRequests] = useState<GitHubAssignableUser[]>(
|
||||
() => item.reviewRequests ?? []
|
||||
@@ -637,9 +637,24 @@ function PRReviewersPanel({
|
||||
[everyoneElseReviewerRows, suggestedReviewerRows]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveReviewerIndex(0)
|
||||
}, [reviewerQuery, actionableReviewerRows.length])
|
||||
const reviewerCursorResetKey = `${reviewerQuery}\u0000${actionableReviewerRows.length}`
|
||||
if (activeReviewerCursor.resetKey !== reviewerCursorResetKey) {
|
||||
setActiveReviewerCursor({ resetKey: reviewerCursorResetKey, index: 0 })
|
||||
}
|
||||
const activeReviewerIndex =
|
||||
activeReviewerCursor.resetKey === reviewerCursorResetKey ? activeReviewerCursor.index : 0
|
||||
const setActiveReviewerIndex = useCallback(
|
||||
(nextIndex: number | ((current: number) => number)): void => {
|
||||
setActiveReviewerCursor((current) => {
|
||||
const currentIndex = current.resetKey === reviewerCursorResetKey ? current.index : 0
|
||||
return {
|
||||
resetKey: reviewerCursorResetKey,
|
||||
index: typeof nextIndex === 'function' ? nextIndex(currentIndex) : nextIndex
|
||||
}
|
||||
})
|
||||
},
|
||||
[reviewerCursorResetKey]
|
||||
)
|
||||
|
||||
const hasReviewerMetadata =
|
||||
item.reviewDecision !== undefined ||
|
||||
|
||||
@@ -1434,7 +1434,7 @@ function PRReviewCell({
|
||||
reviewRequests: item.reviewRequests
|
||||
}))
|
||||
const patchWorkItem = useAppStore((s) => s.patchWorkItem)
|
||||
const [activeReviewerIndex, setActiveReviewerIndex] = useState(0)
|
||||
const [activeReviewerCursor, setActiveReviewerCursor] = useState({ resetKey: '', index: 0 })
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const settings = useAppStore((s) => s.settings)
|
||||
const reviewerInputRef = useRef<HTMLInputElement | null>(null)
|
||||
@@ -1576,9 +1576,24 @@ function PRReviewCell({
|
||||
[everyoneElseReviewerRows, suggestedReviewerRows]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
setActiveReviewerIndex(0)
|
||||
}, [reviewerQuery, actionableReviewerRows.length])
|
||||
const reviewerCursorResetKey = `${reviewerQuery}\u0000${actionableReviewerRows.length}`
|
||||
if (activeReviewerCursor.resetKey !== reviewerCursorResetKey) {
|
||||
setActiveReviewerCursor({ resetKey: reviewerCursorResetKey, index: 0 })
|
||||
}
|
||||
const activeReviewerIndex =
|
||||
activeReviewerCursor.resetKey === reviewerCursorResetKey ? activeReviewerCursor.index : 0
|
||||
const setActiveReviewerIndex = useCallback(
|
||||
(nextIndex: number | ((current: number) => number)): void => {
|
||||
setActiveReviewerCursor((current) => {
|
||||
const currentIndex = current.resetKey === reviewerCursorResetKey ? current.index : 0
|
||||
return {
|
||||
resetKey: reviewerCursorResetKey,
|
||||
index: typeof nextIndex === 'function' ? nextIndex(currentIndex) : nextIndex
|
||||
}
|
||||
})
|
||||
},
|
||||
[reviewerCursorResetKey]
|
||||
)
|
||||
|
||||
if (item.type !== 'pr') {
|
||||
return <span className="text-[11px] text-muted-foreground">Issue</span>
|
||||
|
||||
Reference in New Issue
Block a user