-
Notifications
You must be signed in to change notification settings - Fork 184
Add PR status overlay on git status icon #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8888542
Add PR status overlay to bottom-right of sidebar task icon
ctate 21d4d6c
Reduce cursor dot size in agent user interface
ctate 4a71317
Fix circle border to match task bg for active/inactive state
ctate f7f249f
Shrink status dot and hide on merged prs; show only for open prs
ctate 4bacaab
Prioritize failed over in progress in PRCheckStatus
ctate d41d467
Make the dot blue when the check is natural
ctate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| 'use client' | ||
|
|
||
| import { useEffect, useState } from 'react' | ||
| import { Check, Loader2, X } from 'lucide-react' | ||
|
|
||
| interface CheckRun { | ||
| id: number | ||
| name: string | ||
| status: string | ||
| conclusion: string | null | ||
| html_url: string | ||
| started_at: string | null | ||
| completed_at: string | null | ||
| } | ||
|
|
||
| interface PRCheckStatusProps { | ||
| taskId: string | ||
| prStatus: 'open' | 'closed' | 'merged' | ||
| isActive?: boolean | ||
| className?: string | ||
| } | ||
|
|
||
| export function PRCheckStatus({ taskId, prStatus, isActive = false, className = '' }: PRCheckStatusProps) { | ||
| const [checkRuns, setCheckRuns] = useState<CheckRun[]>([]) | ||
| const [isLoading, setIsLoading] = useState(true) | ||
|
|
||
| useEffect(() => { | ||
| const fetchCheckRuns = async () => { | ||
| try { | ||
| const response = await fetch(`/api/tasks/${taskId}/check-runs`) | ||
| if (response.ok) { | ||
| const data = await response.json() | ||
| if (data.success && data.checkRuns) { | ||
| setCheckRuns(data.checkRuns) | ||
| } | ||
| } | ||
| } catch (error) { | ||
| console.error('Error fetching check runs:', error) | ||
| } finally { | ||
| setIsLoading(false) | ||
| } | ||
| } | ||
|
|
||
| fetchCheckRuns() | ||
| // Refresh every 30 seconds for in-progress checks | ||
| const interval = setInterval(fetchCheckRuns, 30000) | ||
| return () => clearInterval(interval) | ||
| }, [taskId]) | ||
|
|
||
| // Only show indicator for open PRs | ||
| if (prStatus !== 'open') { | ||
| return null | ||
| } | ||
|
|
||
| // Don't render anything if loading or no check runs | ||
| if (isLoading || checkRuns.length === 0) { | ||
| return null | ||
| } | ||
|
|
||
| // Determine overall status | ||
| const hasInProgress = checkRuns.some((run) => run.status === 'in_progress' || run.status === 'queued') | ||
| const hasFailed = checkRuns.some((run) => run.conclusion === 'failure' || run.conclusion === 'cancelled') | ||
| const allPassed = checkRuns.every((run) => run.status === 'completed' && run.conclusion === 'success') | ||
|
|
||
| // Determine background color based on active state | ||
| const bgColor = isActive ? 'bg-accent' : 'bg-card' | ||
|
|
||
| // Render the appropriate indicator | ||
| if (hasInProgress) { | ||
| return ( | ||
| <div className={`absolute -bottom-0.5 -right-0.5 ${bgColor} rounded-full p-0.5 ${className}`}> | ||
| <div className="w-1 h-1 rounded-full bg-yellow-500 animate-pulse" /> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| if (hasFailed) { | ||
| return ( | ||
| <div className={`absolute -bottom-0.5 -right-0.5 ${bgColor} rounded-full p-0.5 ${className}`}> | ||
| <div className="w-1 h-1 rounded-full bg-red-500" /> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| if (allPassed) { | ||
| return ( | ||
| <div className={`absolute -bottom-0.5 -right-0.5 ${bgColor} rounded-full p-0.5 ${className}`}> | ||
| <Check className="w-1.5 h-1.5 text-green-500" strokeWidth={3} /> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| return null | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.