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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"test:watch": "vitest",
"format": "prettier --write .",
"lint": "eslint --cache .",
"lint:fix": "eslint --cache --fix .",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "npm run typecheck:node && npm run typecheck:web",
Expand Down
31 changes: 21 additions & 10 deletions src/renderer/src/components/PrDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react'
import { useState, useEffect, useCallback } from 'react'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import type { PrDetail, PrCheckRun } from '../../../shared/types'
Expand Down Expand Up @@ -60,13 +60,10 @@ export default function PrDrawer({
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)

useEffect(() => {
let cancelled = false
// Reset handled via initial state; subsequent fetches reset in callbacks
const fetchPr = useCallback(() => {
window.konductorAPI
.getPrDetail(cwd, prNumber)
.then((d) => {
if (cancelled) return
if (d) {
setDetail(d)
setError(null)
Expand All @@ -75,16 +72,23 @@ export default function PrDrawer({
}
})
.catch(() => {
if (!cancelled) setError('Failed to load PR details')
setError('Failed to load PR details')
})
.finally(() => {
if (!cancelled) setLoading(false)
setLoading(false)
})
return () => {
cancelled = true
}
}, [cwd, prNumber])

useEffect(() => {
fetchPr()
}, [fetchPr])

const refresh = useCallback(() => {
setLoading(true)
setError(null)
fetchPr()
}, [fetchPr])

return (
<div className="h-full flex flex-col bg-surface-raised">
{/* Header */}
Expand All @@ -96,6 +100,13 @@ export default function PrDrawer({
{detail && <span className="text-xs text-gray-400 truncate">{detail.title}</span>}
</div>
<div className="flex items-center gap-1 shrink-0">
<button
onClick={refresh}
className="text-xs text-gray-500 hover:text-white px-1.5 py-0.5 transition-colors"
title="Refresh"
>
&#8635;
</button>
<button
onClick={() => onOpenExternal(detail?.url ?? '')}
className="text-xs text-gray-500 hover:text-white px-1.5 py-0.5 transition-colors"
Expand Down
Loading