show last ran time stamp

This commit is contained in:
Arjun 2026-03-19 01:14:14 +05:30
parent e561616c75
commit 73c281aa33
2 changed files with 20 additions and 0 deletions

View file

@ -3,22 +3,37 @@ import { ReactNodeViewRenderer, NodeViewWrapper } from '@tiptap/react'
import { CalendarClock, Loader2, X } from 'lucide-react'
import { inlineTask } from '@x/shared'
function formatDateTime(iso: string): string {
const d = new Date(iso)
return d.toLocaleString('en-US', {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
hour12: true,
})
}
function TaskBlockView({ node, deleteNode }: { node: { attrs: Record<string, unknown> }; deleteNode: () => void }) {
const raw = node.attrs.data as string
let instruction = ''
let scheduleLabel = ''
let processing = false
let lastRunAt = ''
try {
const parsed = inlineTask.InlineTaskBlockSchema.parse(JSON.parse(raw))
instruction = parsed.instruction
scheduleLabel = parsed['schedule-label'] ?? ''
processing = parsed.processing ?? false
lastRunAt = parsed.lastRunAt ?? ''
} catch {
// Fallback: show raw data
instruction = raw
}
const lastRunLabel = lastRunAt ? formatDateTime(lastRunAt) : ''
return (
<NodeViewWrapper className="task-block-wrapper" data-type="task-block">
<div className="task-block-card">
@ -41,6 +56,7 @@ function TaskBlockView({ node, deleteNode }: { node: { attrs: Record<string, unk
<span className="task-block-schedule">
<CalendarClock size={12} />
{scheduleLabel}
{lastRunLabel && <span className="task-block-last-run"> · last ran {lastRunLabel}</span>}
</span>
)}
</div>

View file

@ -608,6 +608,10 @@
color: color-mix(in srgb, var(--foreground) 55%, transparent);
}
.tiptap-editor .ProseMirror .task-block-last-run {
color: color-mix(in srgb, var(--foreground) 38%, transparent);
}
/* Shared block styles (image, embed, chart, table) */
.tiptap-editor .ProseMirror .image-block-wrapper,
.tiptap-editor .ProseMirror .embed-block-wrapper,