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
12 changes: 8 additions & 4 deletions src/app/api/worktrees/[id]/execution-logs/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ export async function GET(
}

// [S1-014] Exclude result column from list API for performance
// Return all execution logs with schedule name via LEFT JOIN
// (includes logs from renamed/disabled schedules)
const logs = db.prepare(`
SELECT id, schedule_id, worktree_id, message, exit_code, status, started_at, completed_at, created_at
FROM execution_logs
WHERE worktree_id = ?
ORDER BY created_at DESC
SELECT el.id, el.schedule_id, el.worktree_id, el.message, el.exit_code, el.status, el.started_at, el.completed_at, el.created_at,
se.name AS schedule_name
FROM execution_logs el
LEFT JOIN scheduled_executions se ON el.schedule_id = se.id
WHERE el.worktree_id = ?
ORDER BY el.created_at DESC
LIMIT 100
`).all(params.id);

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/worktrees/[id]/schedules/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function GET(
}

const schedules = db.prepare(
'SELECT * FROM scheduled_executions WHERE worktree_id = ? ORDER BY created_at DESC'
'SELECT * FROM scheduled_executions WHERE worktree_id = ? AND enabled = 1 ORDER BY created_at DESC'
).all(params.id);

return NextResponse.json({ schedules }, { status: 200 });
Expand Down
13 changes: 3 additions & 10 deletions src/components/worktree/ExecutionLogPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use client';

import React, { useState, useEffect, useCallback, useMemo, memo } from 'react';
import React, { useState, useEffect, useCallback, memo } from 'react';
import { useTranslations } from 'next-intl';

// ============================================================================
Expand All @@ -31,6 +31,7 @@ interface ExecutionLog {
started_at: number;
completed_at: number | null;
created_at: number;
schedule_name: string | null;
}

/** Execution log detail from the individual API (includes result) */
Expand Down Expand Up @@ -92,14 +93,6 @@ export const ExecutionLogPane = memo(function ExecutionLogPane({
const [expandedLogId, setExpandedLogId] = useState<string | null>(null);
const [logDetail, setLogDetail] = useState<ExecutionLogDetail | null>(null);

const scheduleNameMap = useMemo(() => {
const map = new Map<string, string>();
for (const s of schedules) {
map.set(s.id, s.name);
}
return map;
}, [schedules]);

const fetchData = useCallback(async () => {
setIsLoading(true);
setError(null);
Expand Down Expand Up @@ -229,7 +222,7 @@ export const ExecutionLogPane = memo(function ExecutionLogPane({
className="w-full text-left p-3 hover:bg-gray-50 transition-colors"
>
<div className="flex items-center justify-between">
<span className="text-sm truncate max-w-[60%]">{scheduleNameMap.get(log.schedule_id) || t('unknownSchedule')}</span>
<span className="text-sm truncate max-w-[60%]">{log.schedule_name || t('unknownSchedule')}</span>
<span className={`text-xs px-2 py-0.5 rounded ${getStatusColor(log.status)}`}>
{t(`status.${log.status}`)}
</span>
Expand Down