Repository navigation
Closed
Description
Context
Repository to-dos can already be turned into work in two ways:
- Plan first — the to-dos are linked to a planner draft (
repo_todos.linked_draft_idvialinkTodosToDraft), and when that plan reaches themergedstatuscheckAndUpdateDraftStatuscallscompleteTodosForDraft, which flipsis_completedfor every linked to-do. The UI then shows a "Linked to plan" chip on the to-do. - Run task — the to-do panel's Run task action (and the New Task launcher it opens) sends
todoIdstoPOST /api/task-submissions. The server stores them in the submission payload (SubmissionPayload.todoIds) and… nothing else happens. The to-do stays open forever, with no record of the issue it produced. The docs even state this explicitly: "Select a to-do and choose Run task to prefill its text; launching does not mark the to-do complete."
That asymmetry is the bug being reported: a to-do that has been turned into a running task is still presented as outstanding work, and there is no way back from the to-do to the issue that was opened for it.
Requirements
- When a task submission successfully creates its GitHub issue, every to-do named by that submission's
todoIdsmust be marked completed. - Each of those to-dos must record which issue it produced, so the UI can link back to it — mirroring how a plan-linked to-do records
linked_draft_id. - The behaviour must be idempotent.
POST /api/task-submissionsis retried (sameIdempotency-Key),POST /api/task-submissions/:key/retryresumes a stopped submission, and MCPcreate_taskgoes through the same route. Repeating any of those must not produce a different outcome or an error. - Completing a to-do must never fail an otherwise accepted submission. The issue already exists on GitHub and the run is queued; a failed to-do write is a bookkeeping problem, not a reason to report failure to the caller.
- Every surface that reads to-dos must carry the new link: the REST API (including demo mode), the MCP
list_todos/get_todotools, the CLI client types and the Web UI. - The Web UI must show the link on both active and completed to-dos as a chip that opens the GitHub issue.
- The plan path must keep working exactly as before.
linked_draft_id,linkTodosToDraft,completeTodosForDraftandgetTodosForDraftmust be untouched. - The documentation sentence that promises the old behaviour must be corrected.
Implementation Specification
Where the completion happens
Server-side, in packages/api/routes/taskSubmissionRoutes.ts, immediately after resumeTaskSubmission returns a row that has an issue_number. Both the submit and retry handlers call it. See the implementation section for why this location was chosen over the browser.
Files to change
| File | Change |
|---|---|
packages/core/src/db/migrations/20261013000000_add_todo_issue_link.js |
New. Adds linked_issue_repository, linked_issue_number, linked_task_id to repo_todos, plus an index. |
packages/core/src/services/repoTodosTypes.ts |
Record and domain types gain the three fields; new CompleteTodosForIssueParams. |
packages/core/src/services/repoTodosService.ts |
toTodoDomain maps the new fields; new completeTodosForIssue. |
packages/core/src/index.ts |
Export completeTodosForIssue and CompleteTodosForIssueParams. |
packages/api/routes/repoTodoRoutes.ts |
The demo-mode toTodoDomain mapper gains the new fields. |
packages/api/routes/taskSubmissionRoutes.ts |
New linkSubmissionTodos helper, injectable through services, called from submit and retry. |
packages/api/mcp/toolsManagement.ts |
list_todos selects the new columns. |
packages/cli/src/api/todos.ts |
RepoTodo interface gains the new fields. |
propr-ui/src/api/repoTodosApi.ts |
RepoTodo interface gains the new fields. |
propr-ui/src/components/Repositories/RepoTodos/TodoIssueLink.tsx |
New. The shared chip. |
propr-ui/src/components/Repositories/RepoTodos/index.ts |
Export the chip. |
propr-ui/src/components/Repositories/RepoTodos/SortableTodoItem.tsx |
Render the chip. |
propr-ui/src/components/Repositories/RepoTodos/CompletedItemsAccordion.tsx |
Render the chip. |
docs/docs/features/launching-work.md |
Correct the "launching does not mark the to-do complete" sentence. |
CHANGELOG.md |
Unreleased → Changed entry. |
packages/core/test/repoTodosIssueLink.test.ts |
New. Service-level tests. |
packages/api/test/taskSubmissionRoutes.test.ts |
New case: submission completes and links its to-dos; failures are swallowed. |
propr-ui/src/components/Repositories/RepoTodos/TodoIssueLink.test.tsx |
New. Chip rendering tests. |
Behavioural detail
completeTodosForIssuescopes itsUPDATEbyuser_idandrepositoryas well astodo_id, so a submission can only ever complete to-dos that belong to the submitting user in the repository the issue was opened in. A forged or staletodoIdsentry simply matches no row.- The update always writes the issue of the submission being resumed. Resuming the same submission always supplies the same issue number, which is what makes it idempotent; a deliberate relaunch of a reopened to-do intentionally retargets it at the issue that is now running.
linked_task_idis written when the submission already knows its task id and is otherwise leftnull; it is a convenience for later navigation, not a key anything depends on.
Acceptance Criteria
npm run migrateapplies the new migration on an existing SQLite database, and rolling it back removes the three columns and the index.- Launching a task from the repository To-Dos panel (select a to-do → Run task → Run task in the launcher) marks that to-do completed. Reopening the repository workspace shows it under Completed Items with a chip reading
#<issue number>that opens the GitHub issue in a new tab. - The same launch performed through MCP
create_taskwithtodoIds, and through a retry of a submission whose dispatch failed, produces exactly the same single completion — no duplicate work, no error. - A to-do belonging to another user, or named with a repository that does not match the submission, is left untouched.
- With the to-do table made unwritable (simulate by making
completeTodosForIssuethrow),POST /api/task-submissionsstill returns its normal200/202body and the run is still queued; a warning is logged. - Plan-created to-dos still show "Linked to plan" and are still completed when the plan merges;
completeTodosForDraftbehaviour is unchanged. npm run typecheck,npm run lintand the touched test suites pass with no new warnings.docs/docs/features/launching-work.mdno longer claims that launching leaves the to-do open.
Created by ProPR AI Planner
Activity
propr-dev commentedon Oct 8, 2026
Suggested Implementation:
Implementation Approach
Why complete the to-do on the server, in the task-submission route, rather than in the browser.
The submission row is the one durable, idempotent record of "a task was initiated from these to-dos": it already stores
todoIdsin its payload, it already knows the authenticateduser_idand therepository, andresumeTaskSubmissionalready guarantees exactly one GitHub issue per submission key. Hooking the completion there means every caller gets it for free — the Web UI launcher, MCPcreate_task, the retry endpoint and any future CLI path — and it cannot be lost because the browser navigated to/tasks/:idthe moment the submission resolved. A browser-sidePUT /api/repos/todos/:idaftersubmitTaskresolves was considered and rejected: it would silently leave the to-do open whenever that second request failed or the tab was closed, and it would not cover MCP or CLI submissions at all.Why new columns instead of reusing
linked_draft_id.linked_draft_idis read bycompleteTodosForDraftandgetTodosForDraftand is a foreign-key-ish reference totask_drafts.draft_id. A GitHub issue number is a different kind of object in a different namespace. Storing one in the other field would makecompleteTodosForDraftmatch rows it has no business matching and would make the "Linked to plan" chip lie. Three nullable columns (linked_issue_repository,linked_issue_number,linked_task_id) keep the two lifecycles independent; the repository is stored alongside the number because an issue number alone is meaningless.Why completion happens at launch rather than on merge.
Plans complete their to-dos when the plan reaches
merged, because a plan has a lifecycle to hang that on. A one-off task does not, and the request is explicit: the to-do should be completed once the task has been initiated. The recorded issue link is what makes that safe — if the run turns out badly, the user can follow the chip to the issue and reopen the to-do with the existing incomplete toggle.Trade-off accepted. Because the update always writes the issue of the submission being resumed, a very late retry of an old submission for a to-do that has since been relaunched would retarget the chip backwards. This is rare, visible and trivially recoverable, and the alternative (
coalesce, keeping the first link forever) makes a deliberate relaunch point at a stale issue, which is worse.File:
packages/core/src/db/migrations/20261013000000_add_todo_issue_link.js(new file)Why this file: The link has to survive restarts and be queryable, so it belongs in the schema next to
linked_draft_idrather than in a cache. A dated migration file is how every other schema change in this repository is delivered, and the timestamp is chosen to sort after the newest existing migration (20260928000000).File:
packages/core/src/services/repoTodosTypes.tsWhy this file: It is the single source of truth for the database row shape and the domain object every consumer (API, MCP, CLI, UI) is typed against. The new columns have to appear here first, or
toTodoDomaincannot be made to carry them and TypeScript will reject every downstream change.Note that
UpdateTodoParamsis intentionally not extended. The link is written only by the submission path; letting an ordinaryPUT /api/repos/todos/:todoIdset it would let a client claim any issue number.File:
packages/core/src/services/repoTodosService.tsWhy this file: This is the only module that talks to the
repo_todostable, so both the read mapping and the new write belong here. Putting the write besidecompleteTodosForDraftkeeps the two "a to-do is finished" paths next to each other and visibly parallel.Then add the new writer next to
completeTodosForDraft, so the two completion paths read as siblings:File:
packages/core/src/index.tsWhy this file:
@propr/coreis the only entry point the API package imports from, so the new function and type are unreachable until they are re-exported from this barrel.File:
packages/api/routes/taskSubmissionRoutes.tsWhy this file: This is the route that owns task submissions, and
resumeTaskSubmissionreturning a row with anissue_numberis the exact moment the issue is known to exist. Both thesubmitandretryhandlers funnel through it, so one helper covers the first attempt, an idempotent repeat, a recovery retry and MCPcreate_task(which callsroutes.submit).Add the helper next to the other submission helpers (above
createTaskSubmissionRoutes):Make it injectable so tests can observe and fail it, then call it from both handlers:
File:
packages/api/routes/repoTodoRoutes.tsWhy this file: Demo mode reads
repo_todosrows directly through this module's owntoTodoDomaincopy instead of going through the core service, so without this change a demo instance would silently drop the new fields and the UI chip would never appear there.File:
packages/api/mcp/toolsManagement.tsWhy this file:
list_todoshand-picks its columns, so MCP clients would otherwise see a to-do as completed with no explanation of why. Adding the columns makes the MCP view agree with the Web UI.Open
packages/api/mcp/listSummaries.tsand checksummarizeTodo. If it copies fields explicitly rather than spreading the row, addlinkedIssueRepository,linkedIssueNumberandlinkedTaskIdto it from the selected columns; if it spreads, no change is needed.File:
packages/cli/src/api/todos.tsWhy this file: The CLI declares its own
RepoTodointerface against the same endpoint. Leaving it behind would makepropr's typed client disagree with the API it calls.File:
propr-ui/src/api/repoTodosApi.tsWhy this file: The UI type drives the components. Without it, the chip's
todo.linkedIssueNumberread is a TypeScript error.File:
propr-ui/src/components/Repositories/RepoTodos/TodoIssueLink.tsx(new file)Why this file: The same chip is needed on active to-dos (
SortableTodoItem) and completed ones (CompletedItemsAccordion). One shared component keeps the two in step and keeps the link-building logic in a single place.File:
propr-ui/src/components/Repositories/RepoTodos/index.tsWhy this file: It is the single entry point for the to-dos feature, so the chip must be re-exported for the panel and the tests to import it the same way as its siblings.
Match whatever export style the file already uses; the summary describes it as re-exporting the components and their prop types.
File:
propr-ui/src/components/Repositories/RepoTodos/SortableTodoItem.tsxWhy this file: An active to-do can carry the link too — the user may have reopened it after the task finished — so the row has to be able to show where it came from.
File:
propr-ui/src/components/Repositories/RepoTodos/CompletedItemsAccordion.tsxWhy this file: This is where a to-do completed by a launch now lands, so it is the most important place for the chip: without it the user sees a to-do that completed itself with no explanation.
File:
docs/docs/features/launching-work.mdWhy this file: It currently documents the old behaviour as a guarantee. Leaving it would make the shipped feature look like a bug.
File:
CHANGELOG.mdWhy this file: Every user-visible behaviour change in this repository is recorded under
Unreleased.Place the entry in the existing
Unreleased→Changedsection; create that heading ifUnreleaseddoes not have one yet.File:
packages/core/test/repoTodosIssueLink.test.ts(new file)Why this file: The scoping rules (
user_idandrepository) and the idempotency are the parts most likely to be broken by a later refactor, and they are cheap to pin down against an in-memory SQLite database the way the other core service tests do.If
packages/core/testsuites are listed individually in the rootpackage.jsonscripts rather than globbed, add this file to the script that runs the otherpackages/core/test/*.test.tssuites.File:
packages/api/test/taskSubmissionRoutes.test.tsWhy this file: It already owns the submission route's contract, including its idempotency and failure handling, so the "a launch finishes its to-dos" and "a to-do failure never fails the submission" guarantees belong beside those cases.
The suite's existing
fixture()builds thetask_submissionstable from its migrations;completeTodosis stubbed, so norepo_todostable is needed here.File:
propr-ui/src/components/Repositories/RepoTodos/TodoIssueLink.test.tsx(new file)Why this file: The chip's URL and its "only when the link is whole" rule are easy to get wrong and are what the user actually clicks.
Verification
npm run migrate # applies 20261013000000_add_todo_issue_link npm run typecheck npm run lint node --test packages/core/test/repoTodosIssueLink.test.ts node --test packages/api/test/taskSubmissionRoutes.test.ts npx vitest run propr-ui/src/components/Repositories/RepoTodosThen exercise it by hand: open a repository workspace, add a to-do, select it, choose Run task, submit, and confirm the to-do moves to Completed Items with a
#<number>chip that opens the new GitHub issue.propr-dev commentedon Oct 8, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-52886/claude-opus-5-5-complete-and-link-reposit-20261008-1428-1rymainissue-2886-20261008-1428-claude-opus-5-5-1ry🔍 Track Task Execution