Skip to content

Commit d864adf

Browse files
committed
fix(ui): coerce TaskRelation.toId to string at Epic-id boundaries
TaskRelation.toId is now correctly typed as number, but the Epic selection state and link/unlink helpers still use string ids. Convert at the call sites in TaskForm and the task detail page so the build passes.
1 parent f9d0880 commit d864adf

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

ui/src/features/task-crud/TaskForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export function TaskForm({ task, defaults, onSubmit, onCancel, submitLabel = 'Sa
8080
useEffect(() => {
8181
if (!projectId || !task) return;
8282
listTaskRelations(projectId, task.id).then(rels => {
83-
const epicId = rels.find(r => r.kind === 'belongs_to')?.toId ?? '';
83+
const epicLink = rels.find(r => r.kind === 'belongs_to');
84+
const epicId = epicLink ? String(epicLink.toId) : '';
8485
setSelectedEpicId(epicId);
8586
setInitialEpicId(epicId);
8687
}).catch(e => console.error('Failed to load task relations', e));

ui/src/pages/tasks/[taskId].tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ export default function TaskDetailPage() {
283283
<FieldRow label="Epic">
284284
{(() => {
285285
const epicLink = relations.find(r => r.kind === 'belongs_to');
286-
const currentEpicId = epicLink?.toId ?? '';
286+
const currentEpicId = epicLink ? String(epicLink.toId) : '';
287287
const selectableEpics = epics.filter(e => e.status === 'open' || e.status === 'in_progress' || e.id === currentEpicId);
288288
if (!canWrite) {
289289
if (!epicLink) return <Typography variant="body2" color="text.secondary"></Typography>;
290290
return (
291-
<Link component="button" variant="body2" onClick={() => navigate(`/${projectId}/tasks/epics/${epicLink.toId}`)}>
291+
<Link component="button" variant="body2" onClick={() => navigate(`/${projectId}/tasks/epics/${currentEpicId}`)}>
292292
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
293293
<FlagIcon sx={{ fontSize: 14, color: '#1976d2' }} />
294-
{epicLink.title || epicLink.toId}
294+
{epicLink.title || currentEpicId}
295295
</Box>
296296
</Link>
297297
);
@@ -303,7 +303,7 @@ export default function TaskDetailPage() {
303303
displayEmpty
304304
onChange={async (e) => {
305305
const newEpicId = e.target.value as string;
306-
if (epicLink) await unlinkTaskFromEpic(projectId!, epicLink.toId, taskId!);
306+
if (epicLink) await unlinkTaskFromEpic(projectId!, currentEpicId, taskId!);
307307
if (newEpicId) await linkTaskToEpic(projectId!, newEpicId, taskId!);
308308
load();
309309
}}

0 commit comments

Comments
 (0)