Skip to content

fix(relations): remove the correct reverse relation - #10266

Open
JunaidAhamed-7777 wants to merge 1 commit into
makeplane:previewfrom
JunaidAhamed-7777:fix/reverse-relation-removal
Open

JunaidAhamed-7777 wants to merge 1 commit into
makeplane:previewfrom
JunaidAhamed-7777:fix/reverse-relation-removal

Conversation

@JunaidAhamed-7777

@JunaidAhamed-7777 JunaidAhamed-7777 commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

Remove the correct reverse relation from the client cache when deleting a work-item relation.

For A blocking B, with B blocked by both A and C, the reverse lookup searched for B instead of A. It usually returned -1, so the subsequent splice removed C while leaving A visible. The reverse update also incorrectly depended on the forward list's index.

Look up the original issue ID and check the reverse index independently. This handles partially loaded caches and local-only removal without changing API requests or error recovery.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots and Media (if applicable)

No layout changes.

Test Scenarios

Validated on preview 0b9ca512c8a841bcbe9be62e22146daa74d71edb, using Node 24.22.1, pnpm 11.25.0 (repository declares 11.10.0), and Vitest 4.1.12.

  • Fifteen native store tests pass with real MobX/lodash and mocked relation-service/root-store boundaries. Cases cover directional and symmetric relations, first/middle/last positions, sparse caches, unrelated relations, local-only removal and API rejection.
  • With current-preview production store bytes and the same regression harness, ten tests fail and five pass. Restoring the fix returns all fifteen to passing.
  • All 45 format/lint/typecheck tasks and 11 prerequisite builds in the repository's turbo run check --dry=json graph passed using installed native tools, preserving every executable task and dependency order. This includes all four app typechecks; full web lint reports 431 warnings and zero errors.
  • The standard i18n generator's tsx CLI requires an IPC socket unavailable in this environment. The same generator ran using node --import tsx scripts/generate-types.ts; manifests were not changed. This is equivalent task coverage, not a claim that the unmodified pnpm check wrapper itself ran.
  • Full-workspace frozen-lockfile installation, supply-chain policy verification, and git diff --check pass.

The web test setup matches the setup in #10265, which covers a separate comment-draft bug. It uses dependencies already pinned in the workspace catalog; reconcile the shared setup if that PR lands first.

For a fresh checkout, use pnpm turbo run test --filter=web, whose existing task graph builds workspace prerequisites. Direct pnpm --filter web test assumes those artifacts are already built.

Full application production builds, backend/database integration, live-browser workflows and hosted CI were not run.

References

The relation-row removal, relation selector and local related-item-deletion paths call this store method. No issue is claimed closed.

Summary by CodeRabbit

  • Bug Fixes
    • Removing an issue relation now also clears the matching reverse relation from the related issue’s cached list, including when the current issue is not first in that entry.
    • Reverse relations are cleaned up even when the forward relation is absent, while unrelated entries are preserved.
    • If the removal request fails, the reverse cache remains unchanged and the forward relations are refreshed.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The reverse-relation lookup now matches the current issue ID. The pull request adds tests for relation removal and configures Vitest with its test dependencies.

Changes: Issue relation removal

Layer / File(s) Summary
Reverse-relation removal and regression coverage
apps/web/store/issue/issue-details/relation.store.ts, apps/web/store/issue/issue-details/relation.store.test.ts, apps/web/vitest.config.ts, apps/web/package.json
The reverse-list lookup now matches issueId. Tests cover relation types, reverse-list positions, missing forward relations, local removal, and API failure. The web app adds Vitest configuration, a test script, and test dependencies.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: prateekshourya29

Merge Risk: Minimal · up to b59d4

Removing a work-item relation now removes the matching reverse entry instead of a different one. The added test tooling affects development only, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(relations): remove the correct reverse relation" matches the main change. The diff changes removeRelation in relation.store.ts so it looks up the original issue ID in the related issu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description clearly states the problem, the fix, and the test scenarios, and it selects the Bug fix type. It covers the required sections of the template except Screenshots, which the author addre…
Full details: Title check

Explanation

The title "fix(relations): remove the correct reverse relation" matches the main change. The diff changes removeRelation in relation.store.ts so it looks up the original issue ID in the related issue's reverse list instead of searching for related_issue. Tests for this path were added in relation.store.test.ts. The title is specific and conveys the primary bug fix. It uses a conventional commit prefix, which is consistent with repository practice.

Full details: Description check

Explanation

The description clearly states the problem, the fix, and the test scenarios, and it selects the Bug fix type. It covers the required sections of the template except Screenshots, which the author addressed with 'No layout changes.' The References section names the affected paths but does not link an issue. The description is detailed and technically specific, so it is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 053c13ba-e999-456d-b1e7-084c2e4126f8
Commits

Reviewing files that changed from the base of the PR and between 0b9ca51 and b59d46d.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 4

  • apps/web/package.json
  • apps/web/store/issue/issue-details/relation.store.test.ts
  • apps/web/store/issue/issue-details/relation.store.ts
  • apps/web/vitest.config.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant