mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
fix(schedules): use real row buttons and correct run timestamps
- replace row-level keyboard handlers with buttons and aria-labels - keep the active run resolvable when filtered out of the list - show run startedAt consistently and ignore the unread shortcut with modifiers
This commit is contained in:
1 parent
4cf69e9023
commit
f695c142f1
6 files changed
+41
-41
No files matched your search
@@ -145,20 +145,22 @@ export function PromptsTab({ promptDialog, templateId, onNew, onEdit, onDelete,
|
||||
{visibleTemplates.map((template) => (
|
||||
<tr
|
||||
key={template.id}
|
||||
tabIndex={0}
|
||||
onClick={() => onEdit(template.id)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.target !== event.currentTarget) return
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault()
|
||||
onEdit(template.id)
|
||||
}
|
||||
}}
|
||||
className="cursor-pointer transition-colors hover:bg-accent/40"
|
||||
>
|
||||
<td className="px-3 py-2.5">
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="max-w-[32rem] truncate font-medium">{template.title}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
onEdit(template.id)
|
||||
}}
|
||||
aria-label={`Edit ${template.title}`}
|
||||
className="max-w-[32rem] truncate font-medium rounded-sm text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
|
||||
>
|
||||
{template.title}
|
||||
</button>
|
||||
{template.description && (
|
||||
<span className="max-w-[32rem] truncate text-xs text-muted-foreground">{template.description}</span>
|
||||
)}
|
||||
|
||||
@@ -57,7 +57,7 @@ export function RunHistoryTab({
|
||||
formatRunBranch(run),
|
||||
run.errorText,
|
||||
].some((field) => field?.toLowerCase().includes(searchTerm)))
|
||||
const activeRun = runId !== null ? runList.find((run) => run.id === runId) ?? null : null
|
||||
const activeRun = runId !== null ? runs?.find((run) => run.id === runId) ?? null : null
|
||||
const activeIndex = activeRun ? runList.findIndex((run) => run.id === activeRun.id) : -1
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { KeyboardEvent, MouseEvent } from 'react'
|
||||
import type { MouseEvent } from 'react'
|
||||
import { formatDistanceToNow } from 'date-fns'
|
||||
import { Loader2, MoreHorizontal } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -97,14 +97,6 @@ export function ScheduleJobsTable({
|
||||
action?.(job)
|
||||
}
|
||||
|
||||
const handleKeyDown = (job: ScheduleJobWithRepo) => (event: KeyboardEvent<HTMLTableRowElement>) => {
|
||||
if (event.target !== event.currentTarget) return
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault()
|
||||
onOpen(job)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 z-10 whitespace-nowrap bg-background text-xs uppercase text-muted-foreground">
|
||||
@@ -162,9 +154,7 @@ export function ScheduleJobsTable({
|
||||
return (
|
||||
<tr
|
||||
key={job.id}
|
||||
tabIndex={0}
|
||||
onClick={() => onOpen(job)}
|
||||
onKeyDown={handleKeyDown(job)}
|
||||
className={cn(
|
||||
'cursor-pointer transition-colors hover:bg-accent/40',
|
||||
isPaused && 'opacity-60',
|
||||
@@ -179,7 +169,17 @@ export function ScheduleJobsTable({
|
||||
</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="max-w-[11rem] truncate font-medium sm:max-w-[20rem]">{job.name}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
onOpen(job)
|
||||
}}
|
||||
aria-label={`Open ${job.name}`}
|
||||
className="max-w-[11rem] truncate font-medium sm:max-w-[20rem] rounded-sm text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50"
|
||||
>
|
||||
{job.name}
|
||||
</button>
|
||||
{job.description && <span className="max-w-[11rem] truncate text-xs text-muted-foreground sm:max-w-[20rem]">{job.description}</span>}
|
||||
<span className="max-w-[11rem] truncate text-xs text-muted-foreground sm:hidden" title={scheduleTitle}>{mobileDetail}</span>
|
||||
<span className="mt-0.5 text-xs sm:hidden">
|
||||
|
||||
@@ -42,7 +42,6 @@ export function ScheduleRunDrawer({
|
||||
const title = run ? getRunTitle(run) : 'Run'
|
||||
const repoName = run ? getRunRepoName(run) : null
|
||||
const branch = activeRun ? formatRunBranch(activeRun) : null
|
||||
const startedAt = activeRun ? activeRun.finishedAt ?? activeRun.startedAt : null
|
||||
|
||||
const meta = activeRun ? (
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
|
||||
@@ -51,11 +50,9 @@ export function ScheduleRunDrawer({
|
||||
<span>{getRunStatusLabel(activeRun.status)}</span>
|
||||
</span>
|
||||
{repoName && <span className="truncate">{repoName}</span>}
|
||||
{startedAt !== null && (
|
||||
<span title={new Date(startedAt).toLocaleString()}>
|
||||
{activeRun.status === 'running' ? 'Running' : formatDistanceToNow(startedAt, { addSuffix: true })}
|
||||
</span>
|
||||
)}
|
||||
<span title={new Date(activeRun.startedAt).toLocaleString()}>
|
||||
{activeRun.status === 'running' ? 'Running' : formatDistanceToNow(activeRun.startedAt, { addSuffix: true })}
|
||||
</span>
|
||||
<span className="tabular-nums">{formatRunDuration(activeRun)}</span>
|
||||
{branch && <span className="truncate font-mono">{branch}</span>}
|
||||
</div>
|
||||
|
||||
@@ -65,21 +65,12 @@ export function ScheduleRunsTable({
|
||||
{runs.map((run) => {
|
||||
const isUnread = run.viewedAt === null && (run.status === 'completed' || run.status === 'failed')
|
||||
const isSelected = selectedRunId === run.id
|
||||
const startedAt = run.finishedAt ?? run.startedAt
|
||||
const repoName = getRunRepoName(run)
|
||||
|
||||
return (
|
||||
<tr
|
||||
key={run.id}
|
||||
tabIndex={0}
|
||||
onClick={() => onSelectRun(run.id)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.target !== event.currentTarget) return
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault()
|
||||
onSelectRun(run.id)
|
||||
}
|
||||
}}
|
||||
className={cn('cursor-pointer transition-colors hover:bg-accent/40', isSelected && 'bg-accent/30')}
|
||||
>
|
||||
<td className="px-3 py-2.5">
|
||||
@@ -91,7 +82,17 @@ export function ScheduleRunsTable({
|
||||
<td className="px-3 py-2.5">
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<span className={cn('truncate', isUnread ? 'font-semibold' : 'font-medium')}>{getRunTitle(run)}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
onSelectRun(run.id)
|
||||
}}
|
||||
aria-label={`Open run ${getRunTitle(run)}`}
|
||||
className={cn('truncate rounded-sm text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50', isUnread ? 'font-semibold' : 'font-medium')}
|
||||
>
|
||||
{getRunTitle(run)}
|
||||
</button>
|
||||
{isUnread && (
|
||||
<span className="shrink-0 rounded-full bg-primary/15 px-1.5 py-0.5 text-[10px] font-medium text-primary">NEW</span>
|
||||
)}
|
||||
@@ -110,8 +111,8 @@ export function ScheduleRunsTable({
|
||||
)}
|
||||
<td className="hidden px-3 py-2.5 capitalize text-muted-foreground sm:table-cell">{run.triggerSource}</td>
|
||||
<td className="px-3 py-2.5">
|
||||
<span className="text-muted-foreground" title={new Date(startedAt).toLocaleString()}>
|
||||
{run.status === 'running' ? 'Running' : formatDistanceToNow(startedAt, { addSuffix: true })}
|
||||
<span className="text-muted-foreground" title={new Date(run.startedAt).toLocaleString()}>
|
||||
{run.status === 'running' ? 'Running' : formatDistanceToNow(run.startedAt, { addSuffix: true })}
|
||||
</span>
|
||||
</td>
|
||||
<td className="hidden px-3 py-2.5 tabular-nums text-muted-foreground sm:table-cell">{formatRunDuration(run)}</td>
|
||||
|
||||
@@ -102,7 +102,7 @@ export function GlobalSchedules() {
|
||||
useEffect(() => {
|
||||
if (scheduleTab !== 'runs' && runId === null) return
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key !== 'u') return
|
||||
if (event.key !== 'u' || event.metaKey || event.ctrlKey || event.altKey) return
|
||||
const target = event.target as HTMLElement | null
|
||||
if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)) return
|
||||
event.preventDefault()
|
||||
|
||||
Reference in new issue
Block a user