fix(app): disable unavailable file navigation (#37595)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
parent
3476e6baa5
commit
901c9e7329
@@ -165,15 +165,11 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const prev = () => {
|
const prev = () => {
|
||||||
const files = props.files
|
return props.files[fileIndex() - 1]
|
||||||
if (files.length === 0) return
|
|
||||||
return files[(fileIndex() - 1 + files.length) % files.length]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const next = () => {
|
const next = () => {
|
||||||
const files = props.files
|
return props.files[fileIndex() + 1]
|
||||||
if (files.length === 0) return
|
|
||||||
return files[(fileIndex() + 1) % files.length]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const canCycle = () => props.files.length > 0
|
const canCycle = () => props.files.length > 0
|
||||||
@@ -195,8 +191,10 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||||||
const target = event.target
|
const target = event.target
|
||||||
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select"))) return
|
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select"))) return
|
||||||
if (!props.hasDiffs || !canCycle()) return
|
if (!props.hasDiffs || !canCycle()) return
|
||||||
|
const file = event.key === "<" ? prev() : next()
|
||||||
|
if (!file) return
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
cycle(event.key === "<" ? prev() : next())
|
cycle(file)
|
||||||
})
|
})
|
||||||
|
|
||||||
const toolbarStart = () => (
|
const toolbarStart = () => (
|
||||||
@@ -217,6 +215,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<TooltipV2
|
<TooltipV2
|
||||||
openDelay={2000}
|
openDelay={2000}
|
||||||
|
inactive={!prev()}
|
||||||
value={
|
value={
|
||||||
<>
|
<>
|
||||||
{i18n.t("ui.sessionReviewV2.previousFile")}
|
{i18n.t("ui.sessionReviewV2.previousFile")}
|
||||||
@@ -229,13 +228,14 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="small"
|
size="small"
|
||||||
class="session-review-v2-file-nav-button"
|
class="session-review-v2-file-nav-button"
|
||||||
disabled={!canCycle()}
|
disabled={!prev()}
|
||||||
onClick={() => cycle(prev())}
|
onClick={() => cycle(prev())}
|
||||||
aria-label={i18n.t("ui.sessionReviewV2.previousFile")}
|
aria-label={i18n.t("ui.sessionReviewV2.previousFile")}
|
||||||
/>
|
/>
|
||||||
</TooltipV2>
|
</TooltipV2>
|
||||||
<TooltipV2
|
<TooltipV2
|
||||||
openDelay={2000}
|
openDelay={2000}
|
||||||
|
inactive={!next()}
|
||||||
value={
|
value={
|
||||||
<>
|
<>
|
||||||
{i18n.t("ui.sessionReviewV2.nextFile")}
|
{i18n.t("ui.sessionReviewV2.nextFile")}
|
||||||
@@ -248,7 +248,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="small"
|
size="small"
|
||||||
class="session-review-v2-file-nav-button"
|
class="session-review-v2-file-nav-button"
|
||||||
disabled={!canCycle()}
|
disabled={!next()}
|
||||||
onClick={() => cycle(next())}
|
onClick={() => cycle(next())}
|
||||||
aria-label={i18n.t("ui.sessionReviewV2.nextFile")}
|
aria-label={i18n.t("ui.sessionReviewV2.nextFile")}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user