Skip to content

Commit f0d81ba

Browse files
committed
fix(logs): address PR review comments on time filter
1 parent 3645d83 commit f0d81ba

4 files changed

Lines changed: 41 additions & 56 deletions

File tree

apps/sim/app/workspace/[workspaceId]/logs/components/logs-toolbar/logs-toolbar.tsx

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import { hasActiveFilters } from '@/lib/logs/filters'
2121
import { getTriggerOptions } from '@/lib/logs/get-trigger-options'
2222
import { captureEvent } from '@/lib/posthog/client'
2323
import { workflowBorderColor } from '@/lib/workspaces/colors'
24-
import { type LogStatus, STATUS_CONFIG } from '@/app/workspace/[workspaceId]/logs/utils'
24+
import {
25+
formatDateShort,
26+
type LogStatus,
27+
STATUS_CONFIG,
28+
} from '@/app/workspace/[workspaceId]/logs/utils'
2529
import { getBlock } from '@/blocks/registry'
2630
import { useFolderMap } from '@/hooks/queries/folders'
2731
import { useWorkflows } from '@/hooks/queries/workflows'
@@ -43,34 +47,6 @@ const TIME_RANGE_OPTIONS: ComboboxOption[] = [
4347
{ value: 'Custom range', label: 'Custom range' },
4448
] as const
4549

46-
/**
47-
* Formats a date string (YYYY-MM-DD or YYYY-MM-DDTHH:mm) for display.
48-
*/
49-
function formatDateShort(dateStr: string): string {
50-
const hasTime = dateStr.includes('T')
51-
const [datePart, timePart] = dateStr.split('T')
52-
const [year, month, day] = datePart.split('-').map(Number)
53-
const months = [
54-
'Jan',
55-
'Feb',
56-
'Mar',
57-
'Apr',
58-
'May',
59-
'Jun',
60-
'Jul',
61-
'Aug',
62-
'Sep',
63-
'Oct',
64-
'Nov',
65-
'Dec',
66-
]
67-
const dateLabel = `${months[month - 1]} ${day}`
68-
if (hasTime && timePart) {
69-
return `${dateLabel} ${timePart.slice(0, 5)}`
70-
}
71-
return dateLabel
72-
}
73-
7450
type ViewMode = 'logs' | 'dashboard'
7551

7652
interface LogsToolbarProps {

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import {
9191
DELETED_WORKFLOW_LABEL,
9292
extractRetryInput,
9393
formatDate,
94+
formatDateShort,
9495
getDisplayStatus,
9596
type LogStatus,
9697
parseDuration,
@@ -205,31 +206,6 @@ function SpinningRefreshCw(props: React.SVGProps<SVGSVGElement>) {
205206
return <RefreshCw {...props} animate />
206207
}
207208

208-
function formatDateShort(dateStr: string): string {
209-
const hasTime = dateStr.includes('T')
210-
const [datePart, timePart] = dateStr.split('T')
211-
const [year, month, day] = datePart.split('-').map(Number)
212-
const months = [
213-
'Jan',
214-
'Feb',
215-
'Mar',
216-
'Apr',
217-
'May',
218-
'Jun',
219-
'Jul',
220-
'Aug',
221-
'Sep',
222-
'Oct',
223-
'Nov',
224-
'Dec',
225-
]
226-
const dateLabel = `${months[month - 1]} ${day}`
227-
if (hasTime && timePart) {
228-
return `${dateLabel} ${timePart.slice(0, 5)}`
229-
}
230-
return dateLabel
231-
}
232-
233209
/**
234210
* Logs page component displaying workflow execution history.
235211
* Supports filtering, search, live updates, and detailed log inspection.

apps/sim/app/workspace/[workspaceId]/logs/utils.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,31 @@ export function formatLatency(ms: number): string {
179179
return formatDuration(ms, { precision: 2 }) ?? '—'
180180
}
181181

182+
export function formatDateShort(dateStr: string): string {
183+
const hasTime = dateStr.includes('T')
184+
const [datePart, timePart] = dateStr.split('T')
185+
const [, month, day] = datePart.split('-').map(Number)
186+
const months = [
187+
'Jan',
188+
'Feb',
189+
'Mar',
190+
'Apr',
191+
'May',
192+
'Jun',
193+
'Jul',
194+
'Aug',
195+
'Sep',
196+
'Oct',
197+
'Nov',
198+
'Dec',
199+
]
200+
const dateLabel = `${months[month - 1]} ${day}`
201+
if (hasTime && timePart) {
202+
return `${dateLabel} ${timePart.slice(0, 5)}`
203+
}
204+
return dateLabel
205+
}
206+
182207
export const formatDate = (dateString: string) => {
183208
const date = new Date(dateString)
184209
return {

apps/sim/components/emcn/components/date-picker/date-picker.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,17 @@ const DatePicker = React.forwardRef<HTMLDivElement, DatePickerProps>((props, ref
677677
const end = rangeEnd && rangeEnd < rangeStart ? rangeStart : rangeEnd || rangeStart
678678
const startStr = formatDateAsString(start.getFullYear(), start.getMonth(), start.getDate())
679679
const endStr = formatDateAsString(end.getFullYear(), end.getMonth(), end.getDate())
680+
681+
let effectiveStartTime = startTime
682+
let effectiveEndTime = endTime
683+
if (showTime && startStr === endStr && startTime > endTime) {
684+
effectiveStartTime = endTime
685+
effectiveEndTime = startTime
686+
}
687+
680688
props.onRangeChange(
681-
showTime ? `${startStr}T${startTime}` : startStr,
682-
showTime ? `${endStr}T${endTime}` : endStr
689+
showTime ? `${startStr}T${effectiveStartTime}` : startStr,
690+
showTime ? `${endStr}T${effectiveEndTime}:59` : endStr
683691
)
684692
setOpen(false)
685693
}

0 commit comments

Comments
 (0)