Repository navigation
Make due dates, sub issues, relations and comment files writable - #150
Conversation
assertParentAllowed only checked the workspace, so a member could hang an issue under a parent in a team they cannot see. listRelations and the new listRelatedIssues now load the issue through the same visibility check every other read uses, and a related issue outside the caller teams is dropped from the result.
…rents included The presign and complete routes carried the business rules: which scope an upload publishes on, what a comment attachment belongs to, and who may finish an upload. That now lives in registerUpload, finishUpload and attachFile, so the web app and MCP take the same path. A comment upload publishes on the issue of that comment rather than on the uploader, and only the person who registered an upload can finish it.
Adds GET, POST and DELETE on /api/issues/[id]/relations, each a thin handler over setRelation, removeRelation and listRelatedIssues. The issue detail payload now carries the parent the server resolved, so the client never has to turn a parent id into an identifier itself.
update_issue takes a parent so an agent can build a sub issue tree, remove_relation undoes what set_relation wrote, and attach_file uploads bytes against an issue, comment, doc or project through the same registerUpload path the web app uses. get_issue now lists relations through listRelatedIssues, which hides an issue in a team the caller cannot see.
… files The properties panel gains a due date and a parent, the detail page gains a sub issue list that can create or adopt a child, and a links section that adds and removes every relation type. Comment composers now take files: a new comment holds them behind a local placeholder and uploads them against the comment once the server has one, an edit uploads straight away. Every value goes to the server as it stands, and the relation deltas invalidate the links the reader is looking at.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds issue parent and relation workflows, calendar-date validation, centralized attachment upload services, comment attachment uploads, and MCP tools. It also adds web UI components, query integration, realtime invalidation, authorization checks, and tests. ChangesIssue and attachment workflows
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
removeRelation loaded only the issue in the path, so a member of one team could delete a relation whose far end sits in a team they cannot see, even though listRelatedIssues already refuses to show them that link. The new DELETE route made it reachable over HTTP, and the MCP tool was stricter than the route because it resolved both issues itself. Load both ends in the service, the way setRelation does, so every caller gets the same gate.
z.coerce.date() took anything Date can swallow. true became 1970-01-01, and a year outside four digits survived the parse and then lost its tail to toISOString().slice(0, 10), so PATCH /api/issues/[id] handed postgres '+275760-09' and answered 500 instead of 422. A string the ISO parser rejects also fell through to the host timezone, so '10000-01-01' landed on a different day depending on where the server ran. calendarDateSchema takes YYYY-MM-DD, reads it as that day in UTC, and refuses anything a date column cannot hold. Project and milestone dates go through the same helper for the same reason.
…rded attachFile put the bytes and then wrote the row. A failed insert left an object nothing in the database points at. Take it back out. The comment lookup behind a scope now names the workspace, and attach_file declares the same size bound the service enforces, so an agent sees the limit in the tool schema rather than in a rejection.
One usePendingCommentFiles served the thread composer and every reply composer, so the first submit drained the queue for all of them: one comment took another one's files and the other kept revoked blob urls. Each composer now owns its own queue. The body that creates the comment no longer carries blob urls either. It goes out with the placeholders reduced to file names, and the upload rewrites it afterwards, so a rewrite that never lands leaves a readable comment instead of links only the author's browser could ever resolve.
The new button hand rolled transition-colors, which skips the easing and the prefers-reduced-motion opt out every other hover in the app carries.
A filtered list can be parent sensitive through the relation filter, and the detail carries both the parent and the sub issues. Mount an observer on each and prove the update refetches them, so the next change to settleFilteredLists or to the detail invalidation cannot go quiet.
Second adversarial pass, with
|
Three renderHook roots racing against a 1s waitFor was tight enough to time out on a loaded runner. One hook mounts the filtered list, the detail and the mutation together, the mutate goes through act, and the waits carry a deadline that fits a slow machine. Both mutations that matter still turn it red.
Six web test files call mock.module on @/lib/query/use-issues.ts and none put it back, so by the time this file runs useUpdateIssue is a stub with no isSuccess and no request behind mutate. The test passed alone and was inert in the suite, which is worse than not having it. The claim it was answering is argued on the thread from issue-search.ts and settleFilteredLists instead, and the module mock leak is worth its own change rather than a workaround here.
Correction on the reparent cache testI added a test in 8f73aad asserting that a reparent refetches the filtered list and the detail. CI failed on it, and the reason is worth reporting rather than burying. Six web test files call So the test passed when I ran the file alone and was inert in the suite. That is exactly the failure mode worth avoiding, so I removed it in c7ced7d rather than pad its timeouts into passing. The Greptile finding it was answering is argued on the thread from The leak itself is a real and pre-existing trap, and it is not confined to this module: the PR description already documents the same shape for Nothing about the shipped behaviour changed with that removal. The five defects this pass found are still fixed and still covered:
|
|
@coderabbitai review |
|
CI is red on
|
draft() drains the queue at submit, so a create that fails left the blob urls alive for the page's lifetime. The mutation now releases them on error. It already toasts, and the composer clearing its box before the server answers is how every comment has always behaved, so that part is not this change to make.
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (4)
apps/web/src/features/issues/issue-relations.tsx (1)
18-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the shared hover helper for the unlink control.
Replace the raw
hover:bg-surface-2 hover:text-textutilities withsurfaceHover. This keeps the control consistent with the shared interaction policy.Proposed change
-import { revealOnHover, rowHover } from '`@/lib/interaction.ts`'; +import { revealOnHover, rowHover, surfaceHover } from '`@/lib/interaction.ts`'; @@ - 'mr-1.5 flex size-6 shrink-0 items-center justify-center rounded-md text-faint hover:bg-surface-2 hover:text-text', + 'mr-1.5 flex size-6 shrink-0 items-center justify-center rounded-md text-faint', + surfaceHover, revealOnHover,As per coding guidelines: "Use shared interaction tokens for color transitions." Based on learnings: use
rowHover,cardHover, orsurfaceHoverinstead of raw hover color classes.Also applies to: 135-138
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/features/issues/issue-relations.tsx` at line 18, Replace the raw hover color utilities on the unlink control with the shared surfaceHover helper, using the existing interaction import in issue-relations.tsx. Update the corresponding unlink-control usage near the additional referenced lines while preserving its other classes and behavior.Sources: Coding guidelines, Learnings
packages/core/tests/content/attachment-service.test.ts (1)
42-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the double assertion on the fake storage driver.
as unknown as StorageDriverdisables structural checking of the fake. IfStorageDriverchanges, this fake keeps compiling and the tests silently exercise a stale contract. Annotate the constant instead.Promise.reject(...)returnsPromise<never>, which is assignable toPromise<string>, and a callback that declares fewer parameters is assignable, so the direct annotation should compile.♻️ Proposed typing change
- const driver = { - name: 's3', + const driver: StorageDriver = { + name: 's3', createUploadTarget: (key: string, contentType: string, contentLength: number) => Promise.resolve({ key, url: `https://storage.test/${key}`, - method: 'PUT', + method: 'PUT' as const, headers: { 'content-type': contentType }, maxBytes: contentLength, expiresAt: new Date(Date.now() + 60_000).toISOString(), }), @@ stat: (key: string) => Promise.resolve(objects.get(key) ?? null), - } as unknown as StorageDriver; + };As per coding guidelines: "Maintain strict types: do not use
anyor non-null assertions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/content/attachment-service.test.ts` around lines 42 - 65, Replace the `as unknown as StorageDriver` assertion on the `driver` fake with a direct `StorageDriver` type annotation, preserving the existing methods and behavior while enabling structural contract checking.Source: Coding guidelines
packages/core/tests/work/issue-service.test.ts (1)
859-867: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the error type for non-calendar due dates.
This test uses
rejects.toThrow(), while the neighbouring boundary test usesrejects.toBeInstanceOf(ZodError). A baretoThrow()also passes if the value reaches the database and Postgres raises an error. That would hide a regression back to coercion. AssertZodErrorhere as well so the test fails when schema validation stops rejecting these values.♻️ Proposed test change
for (const nonsense of [true, false, 0, 1_700_000_000_000, 'banana', {}, []]) { - await expect(updateIssue(workspace.admin, issue.id, { dueDate: nonsense })).rejects.toThrow(); + await expect( + updateIssue(workspace.admin, issue.id, { dueDate: nonsense }), + ).rejects.toBeInstanceOf(ZodError); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/tests/work/issue-service.test.ts` around lines 859 - 867, Update the non-calendar due-date assertions in the “refuses a due date that is not a calendar day” test to require each updateIssue rejection to be an instance of ZodError, matching the neighboring boundary test; keep the existing invalid-value coverage and final null dueDate assertion.packages/core/src/content/attachment-service.ts (1)
106-114: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winType
parentTypewith the shared attachment parent union.
AttachmentDraft.parentTypeisstring.resolveAttachmentScopesandattachmentScopesbranch on the literals'doc','issue','project', and'comment'. A widenedstringremoves the compile-time guarantee that only those values reach the draft, and it also weakens the type passed toassertUploadParent, which expectsAttachmentParentType. Use the union type instead.♻️ Proposed typing change
interface AttachmentDraft { - readonly parentType: string; + readonly parentType: AttachmentParentType; readonly parentId: string;Import the type from the storage package:
import { assertUploadParent, + type AttachmentParentType, fileUrlFor,Verify the exported name before applying:
#!/bin/bash rg -nP 'AttachmentParentType' --type=ts -C2As per coding guidelines: "Use strict types: do not use
anyor non-null assertions".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/content/attachment-service.ts` around lines 106 - 114, Update AttachmentDraft.parentType to use the shared AttachmentParentType union imported from the storage package, rather than string. Verify and reuse the existing exported type so resolveAttachmentScopes, attachmentScopes, and assertUploadParent retain literal-type safety without introducing any or non-null assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/features/comments/comment-thread.tsx`:
- Around line 86-93: Update the comment creation/edit flow around the create
mutation’s onSuccess callback and draft.settle so subsequent edit submissions
cannot run until attachment settlement completes; serialize or gate edits
against the pending settlement, preserving the settled body as the authoritative
result, and add a regression test covering create, settlement, and a later user
edit.
In `@apps/web/src/features/comments/comment-uploads.ts`:
- Around line 41-95: Add a discard operation alongside hold, upload, and draft
that releases all entries in held.current and clears the collection; invoke it
when comment edit/reply drafts are canceled, removed, or the owning component
unmounts. Update draft to discard stale pending placeholders before
attachPending uploads, while preserving normal settlement behavior, and add
coverage for canceled edits and removals.
In `@apps/web/src/features/issues/issue-properties.tsx`:
- Around line 34-35: Update the rowClassName constant to remove its custom hover
and transition utility classes and compose the base layout classes with the
shared rowHover helper. Preserve the existing spacing, typography, and layout
classes while ensuring property buttons use rowHover for interaction behavior.
In `@apps/web/tests/app/api/issues/writable-fields.test.ts`:
- Around line 1-2: Split the suites in writable-fields.test.ts by endpoint and
move them into test files mirroring each source route: issues/[id]/route.ts,
issues/[id]/relations/route.ts, and attachments/presign/route.ts. Preserve each
suite’s behavior and imports, and extract shared fixture setup into a nearby
test helper only if it is reused across the new files.
In `@apps/web/tests/features/comments/comment-uploads.test.tsx`:
- Around line 75-77: Update the test setup around the existing fetch
preservation to also save the original globalThis.XMLHttpRequest, then restore
it in afterEach(). Ensure tests that replace XMLHttpRequest with FakeUpload do
not leak that mock into subsequent tests.
In `@apps/web/tests/features/issues/writable-fields.test.tsx`:
- Around line 206-245: The IssueProperties tests only cover existing parent
display and detachment, not picker selection mutations. Add interaction tests
for both the parent picker and sub-issue picker that select an issue through
each picker’s UI and assert patched contains { parentId: selected.id }, so
removing either onPick callback causes failure.
In `@packages/mcp-server/tests/tools.test.ts`:
- Around line 25-35: Move the issue-tool test coverage from
packages/mcp-server/tests/tools.test.ts lines 25-35 into
packages/mcp-server/tests/tools/issues.test.ts, including relation, parent,
due-date, and authorization cases. Move the attachment-tool cases from
packages/mcp-server/tests/tools/attachments.test.ts lines 1-193 into
packages/mcp-server/tests/tools/issues.test.ts, or into a focused helper
imported by that mirrored test file; preserve coverage while making the tests
mirror src/tools/issues.ts.
- Around line 291-308: Add coverage in the “unlinks two issues from either end”
test by creating a fresh blocks relation after the inverse-removal assertion,
then call remove_relation with first.identifier, second.identifier, and type
'blocks'. Assert the relation is removed so the direct deletion branch is
exercised independently of the inverse blocked_by path.
In `@packages/mcp-server/tests/tools/attachments.test.ts`:
- Around line 56-81: Update the attachment test setup around beforeAll and the
individual test cases to execute each case, including its required workspace,
members, issue, comment, and attachment fixtures, inside a real Postgres
transaction that is rolled back afterward. Remove reliance on shared persisted
fixtures from beforeAll while preserving the existing admin and guest behavior,
and ensure cleanup in afterAll remains safe for connections created per test.
In `@packages/shared/tests/validators/validators.test.ts`:
- Around line 113-116: Update the extreme-year cases in the dayOf validation
test to also assert that safeParse(...).success is false for each unsupported
date, while retaining the existing dayOf null assertion. Use the validator
symbol already exercised by this test so the test fails when invalid years are
coerced into a null date.
---
Nitpick comments:
In `@apps/web/src/features/issues/issue-relations.tsx`:
- Line 18: Replace the raw hover color utilities on the unlink control with the
shared surfaceHover helper, using the existing interaction import in
issue-relations.tsx. Update the corresponding unlink-control usage near the
additional referenced lines while preserving its other classes and behavior.
In `@packages/core/src/content/attachment-service.ts`:
- Around line 106-114: Update AttachmentDraft.parentType to use the shared
AttachmentParentType union imported from the storage package, rather than
string. Verify and reuse the existing exported type so resolveAttachmentScopes,
attachmentScopes, and assertUploadParent retain literal-type safety without
introducing any or non-null assertions.
In `@packages/core/tests/content/attachment-service.test.ts`:
- Around line 42-65: Replace the `as unknown as StorageDriver` assertion on the
`driver` fake with a direct `StorageDriver` type annotation, preserving the
existing methods and behavior while enabling structural contract checking.
In `@packages/core/tests/work/issue-service.test.ts`:
- Around line 859-867: Update the non-calendar due-date assertions in the
“refuses a due date that is not a calendar day” test to require each updateIssue
rejection to be an instance of ZodError, matching the neighboring boundary test;
keep the existing invalid-value coverage and final null dueDate assertion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: dd13f3cc-e752-4d57-88a6-f2edee4f2fe8
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (42)
apps/web/src/app/api/attachments/[id]/complete/route.tsapps/web/src/app/api/attachments/presign/route.tsapps/web/src/app/api/issues/[id]/relations/route.tsapps/web/src/app/api/issues/[id]/route.tsapps/web/src/features/comments/comment-composer.tsxapps/web/src/features/comments/comment-thread.tsxapps/web/src/features/comments/comment-uploads.tsapps/web/src/features/issues/due-date-field.tsxapps/web/src/features/issues/issue-detail.tsxapps/web/src/features/issues/issue-picker.tsxapps/web/src/features/issues/issue-properties.tsxapps/web/src/features/issues/issue-relations.tsxapps/web/src/features/issues/pending-attachments.tsapps/web/src/features/issues/sub-issues.tsxapps/web/src/lib/query/keys.tsapps/web/src/lib/query/schemas.tsapps/web/src/lib/query/use-issues.tsapps/web/src/lib/query/use-relations.tsapps/web/src/lib/realtime/delta-bridge.tsxapps/web/tests/app/api/issues/writable-fields.test.tsapps/web/tests/features/comments/comment-composer.test.tsxapps/web/tests/features/comments/comment-uploads.test.tsxapps/web/tests/features/issues/issue-detail-delete.test.tsxapps/web/tests/features/issues/issue-relations.test.tsxapps/web/tests/features/issues/writable-fields.test.tsxpackages/core/src/content/attachment-service.tspackages/core/src/work/issue-service.tspackages/core/tests/content/attachment-service.test.tspackages/core/tests/work/issue-service.test.tspackages/mcp-server/package.jsonpackages/mcp-server/src/tools/issues.tspackages/mcp-server/tests/tools.test.tspackages/mcp-server/tests/tools/attachments.test.tspackages/services/src/storage/index.tspackages/services/src/storage/key.tspackages/shared/src/constants/upload.tspackages/shared/src/validators/common.tspackages/shared/src/validators/issue.tspackages/shared/src/validators/milestone.tspackages/shared/src/validators/project.tspackages/shared/src/validators/upload.tspackages/shared/tests/validators/validators.test.ts
# Conflicts: # packages/core/src/work/issue-service.ts
hold() kept every attached file in a ref and only draft() ever cleared it, so attaching files to a new comment and then navigating away or cancelling left the object URLs alive for the life of the page. The hook now exposes discard(), and the composer calls it on unmount. Also restores XMLHttpRequest between tests, which afterEach left replaced, so a fake upload leaked into every test that ran after it. Property rows compose the shared rowHover token instead of hand rolling transition-colors and a hover colour, which had lost motion-reduce:transition-none along the way.
…inned remove_relation deletes through an OR of two shapes, the relation as it was written and its mirror. Only the mirror end was exercised, so the direct branch could be deleted without a test noticing. Removing it now fails two tests rather than none. The calendar year test read a rejected parse and a parse that yielded no date as the same thing, because its helper returns null for both. A schema that accepted year 10000 and stored nothing would have passed. It now asserts safeParse fails.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/features/comments/comment-thread.tsx (1)
90-96: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winDo not silently discard settlement failures.
When
draft.settle()rejects, Line 96 hides the error. Report the failure to the user and release any remaining pending resources.As per coding guidelines, "Throw typed domain errors from
@orbit/shared/errors, map them to responses in route handlers, and never silently swallow errors."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/features/comments/comment-thread.tsx` around lines 90 - 96, Update the draft.settle chain in the comment creation flow so rejection is not swallowed by catch(() => undefined). Surface the settlement failure to the user and release any remaining pending resources, using the existing typed domain-error and error-reporting conventions rather than silently ignoring the error.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/tests/features/comments/comment-uploads.test.tsx`:
- Around line 229-242: Update the test around usePendingCommentFiles to exercise
the real settlement flow: configure the upload mock for success, call await
draft.settle(commentId) instead of draft.release(), then call discard(). Keep
the existing revoked URL assertion so the test fails if settlement no longer
releases the held URL.
---
Outside diff comments:
In `@apps/web/src/features/comments/comment-thread.tsx`:
- Around line 90-96: Update the draft.settle chain in the comment creation flow
so rejection is not swallowed by catch(() => undefined). Surface the settlement
failure to the user and release any remaining pending resources, using the
existing typed domain-error and error-reporting conventions rather than silently
ignoring the error.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e9f02bee-99dd-4e61-8cdf-5824016641e8
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (11)
apps/web/src/features/comments/comment-thread.tsxapps/web/src/features/comments/comment-uploads.tsapps/web/src/features/issues/issue-properties.tsxapps/web/src/lib/query/keys.tsapps/web/src/lib/query/schemas.tsapps/web/src/lib/realtime/delta-bridge.tsxapps/web/tests/app/api/issues/writable-fields.test.tsapps/web/tests/features/comments/comment-uploads.test.tsxpackages/core/src/work/issue-service.tspackages/mcp-server/tests/tools.test.tspackages/shared/tests/validators/validators.test.ts
💤 Files with no reviewable changes (2)
- apps/web/src/lib/query/keys.ts
- apps/web/src/lib/realtime/delta-bridge.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
- apps/web/src/lib/query/schemas.ts
- apps/web/src/features/issues/issue-properties.tsx
- packages/mcp-server/tests/tools.test.ts
- packages/core/src/work/issue-service.ts
- packages/shared/tests/validators/validators.test.ts
- apps/web/src/features/comments/comment-uploads.ts
Settlement rewrites the body it created, so anything typed between the create and the upload finishing was overwritten. Apply the rewritten body only when the cached comment still reads exactly as it was created.
writable-fields.test.ts covered three routes at a path that mirrored none of them. Split it per route and move the shared world, mocks and fixtures into a package root support module, which the auth mock isolation guard now reads too.
Four issue fields were readable and filterable but had no write path anywhere in the product: due dates, sub issues, issue relations, and attachments on a comment. This closes all four, in the service layer first, then the route, then the UI, and adds the MCP tools so an agent reaches the same behaviour through the same functions.
No migration is needed. There is no schema change:
due_date,parent_id,issue_relationandattachment.parent_typeall already exist in production.What was missing, and where
issueUpdateSchemaPATCH /api/issues/[id]IssuePatchcould not even carry itupdate_issuecreate_issue, absent fromupdate_issuesetRelation,removeRelation,listRelationsexistedset_relationonlyassertUploadParentalready allowed a comment parentonUploadServer
packages/core/src/work/issue-service.tsassertParentAllowednow loads the parent through the same visibility check every other read uses. Before this, a member could set an issue in a team they cannot see as the parent of their own issue, which both leaks that the issue exists and drags it into a tree they can read.listRelationsnow refuses an issue the caller cannot see. It was reachable for any issue id in the workspace.listRelatedIssuesreturns the link plus the related issue row, and drops a related issue in a team the caller is not in. Used by both the route and the MCPget_issue, so the two cannot drift.getParentIssuereturns the parent the caller may actually see, or null. The issue detail payload carries it so the client never has to turn an id into an identifier.packages/core/src/content/attachment-service.tsregisterUpload,finishUploadandattachFilenow hold what the presign and complete routes used to: the scope an upload publishes on, the comment to issue lookup, the size check, and who may finish an upload. Only the person who registered an upload can complete it; before, any member of the workspace could.issue:<id>, not on the uploader, so the people watching the issue see it.apps/web/src/app/api/issues/[id]/relations/route.tsis new:GET,POST,DELETE, each parsing withissueRelationSchemaand calling a service.UI
shift+d) and Parent, next to the seven that were already there.blocks,blocked by,relates to,duplicate ofandduplicated by.MCP
update_issuetakesparent(nullable, so an agent can detach).remove_relationis new.attach_fileis new: base64 bytes against an issue, comment, doc or project, returning a url and ready-made markdown. It callsattachFile, which callsassertUploadParent, the same gate the web presign route goes through.get_issuelists relations throughlistRelatedIssues, so it no longer names an issue in a team the caller cannot see.Tests, and the mutation that makes each one bite
Every test below was watched failing first, then the production code was deliberately broken and confirmed RED, then restored.
assertParentAllowedreverts to the workspace-only lookup → resolves instead of 404loadIssuefromlistRelations→ resolves instead of 404isInTeamfilter inlistRelatedIssues→ the hidden issue comes backtrack('dueDate', ...)→ stays nullresolveAttachmentScopesalways returnsattachmentScopes→user:instead ofissue:assertUploadParent→ resolves and writes byteslistRelatedIssues→ 200parentfrombuildIssuePatch→ parentId stays nullregisterRemoveRelation→ tool not foundonChangebecomes a no-op → nothing is patchedparentIdfrom the create input → missingtypefrom the query string → server would delete the wrong linkonUploadfrom the thread composer → no file inputparentType: 'issue'→ wrong parentAuthorization is proved against the route, not the component: a guest is refused 403 on
POSTandDELETErelations and on presign, and a member outside the team is refused 404 on the same routes and on setting a hidden parent. The same four refusals are proved over MCP.bun run verifyexits 0: 2675 tests across every package.Test isolation
apps/web/tests/app/api/docs/home.test.tsmocks@/lib/auth/principal.tsat module scope and never restores it. Bun evaluates every test file before running any of them, so that mock wins for the whole run. The new route test therefore installs its own session and membership mocks inbeforeEach, and builds the membership from a principalresolvePrincipalreally resolved out of the database, so the service still decides every authorization question. Nothing existing was changed to make this work.Greptile Summary
The PR adds write paths for issue due dates, hierarchy, relations, and comment attachments across the service, HTTP, UI, and MCP layers.
Confidence Score: 4/5
The PR is not yet safe to merge because a failed comment rewrite still leaves successfully uploaded attachments stored and registered without links from the comment.
Comment attachment uploads complete before the comment-body patch, but failure of that patch has no rollback or cleanup path, leaving attachment records and stored objects unreferenced.
Files Needing Attention: apps/web/src/features/comments/comment-thread.tsx
Important Files Changed
Sequence Diagram
Reviews (11): Last reviewed commit: "test(issues): mirror the route tree in t..." | Re-trigger Greptile
Context used: