Skip to content

✨ keep non-overlapping edits when a flaw save is stale - #893

Open
C-Valen wants to merge 1 commit into
mainfrom
feature/OSIDB-5790-collision-conflict-controller
Open

C-Valen wants to merge 1 commit into
mainfrom
feature/OSIDB-5790-collision-conflict-controller

Conversation

@C-Valen

@C-Valen C-Valen commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

OSIDB-5790 keep non-overlapping edits when a flaw save is stale

Checklist:

  • Commits consolidated
  • Changelog updated
  • Test cases added/updated
  • Integration tests updated

Summary:

Adds a collision check on flaw saves. After a 409, the current flaw is fetched and compared with the page-load copy and the unsaved user edits.

  • If no field was changed on both sides, the save is retried. User edits are kept and server-only changes are taken. A toast names those server fields.
  • If the same field was changed on both sides to different values, the existing mid-air warning is shown and the form is left unchanged. Follow up tickets will replace that warning with a dialog to choose which value to keep.

Changes:

  • Compare the writable flaw fields after a stale flaw save.
  • Retry the save when the edits do not overlap, integrating the server version (auto rebase).
  • Keep the existing mid-air warning when the same field was changed on both sides.
  • Add unit tests for the comparison and the flaw save adjustments.

Considerations:

Affects, labels, CVSS, references, acknowledgments, and SRP are copied through and not compared. Their collision handling comes in follow-up PRs.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1812660f-ebe7-4aca-9e1c-89c6221e1844
Commits

Reviewing files that changed from the base of the PR and between 09a19c0 and 9c34053.

Files selected for processing: 8
  • CHANGELOG.md
  • src/composables/__tests__/useCollisionConflict.spec.ts
  • src/composables/__tests__/useFlawModel.spec.ts
  • src/composables/useCollisionConflict.ts
  • src/composables/useFlawModel.ts
  • src/services/FlawService.ts
  • src/utils/__tests__/flawRebase.spec.ts
  • src/utils/flawRebase.ts

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

📝 Summary

Summary by CodeRabbit

  • New Features
    • Saving flaw edits now preserves non-overlapping changes made on the server. When both sides change the same field differently, the save is not retried; server changes that are adopted are shown in an informational notice.

Flaw updates now handle HTTP 409 conflicts by reloading the server version, rebasing disjoint edits, and retrying when no fields conflict. The update flow reports adopted server fields and keeps overlapping edits unresolved.

Changes: Flaw conflict resolution

Layer / File(s) Summary
Define and test flaw rebasing
src/utils/flawRebase.ts, src/utils/__tests__/flawRebase.spec.ts
The rebase utility compares configured fields, adopts server-only edits, and reports conflicting edits. It builds a merged flaw when possible and preserves the form’s child collections. Tests cover disjoint changes, overlapping changes, identical edits, nullish values, and 409 detection.
Handle 409 saves and retries
src/composables/useCollisionConflict.ts, src/services/FlawService.ts, src/composables/__tests__/useCollisionConflict.spec.ts
The conflict handler reloads after a 409 and retries with a merged flaw when there are no conflicting fields. putFlaw can suppress the initial 409 toast. Tests cover accepted saves, retries, overlap, and reload failure.
Integrate conflict resolution into flaw updates
src/composables/useFlawModel.ts, src/composables/__tests__/useFlawModel.spec.ts, CHANGELOG.md
Flaw updates use the conflict handler, refetch the flaw, and show an informational toast for adopted fields. Tests cover disjoint and overlapping edits. The changelog records the change.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant FlawForm
  participant useFlawModel
  participant useCollisionConflict
  participant OSIDB
  FlawForm->>useFlawModel: Submit flaw update
  useFlawModel->>useCollisionConflict: Resolve save
  useCollisionConflict->>OSIDB: Save flaw
  OSIDB-->>useCollisionConflict: Return 409 conflict
  useCollisionConflict->>useFlawModel: Request latest flaw
  useFlawModel->>OSIDB: Fetch latest flaw
  OSIDB-->>useFlawModel: Return latest flaw
  useFlawModel-->>useCollisionConflict: Provide latest flaw
  useCollisionConflict->>useCollisionConflict: Rebase form edits
  useCollisionConflict->>OSIDB: Retry if fields do not conflict
Loading

Suggested reviewers: superbuggy

Merge Risk: Minimal · up to 9c340

The stale-save retry preserves disjoint edits, and no merge-blocking issue remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "✨ keep non-overlapping edits when a flaw save is stale" matches the main change: after a 409, the save is retried when user and server edits do not overlap, and same-field conflicts keep th…
Description check Passed The description follows the repository template. It has the OSIDB-ID and title heading (OSIDB-5790), the checklist, Summary, Changes, and Considerations sections. The Summary explains the 409 comparis…
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.
Full details: Title check

Explanation

The title "✨ keep non-overlapping edits when a flaw save is stale" matches the main change: after a 409, the save is retried when user and server edits do not overlap, and same-field conflicts keep the existing warning. It is short, specific, and states the primary behavior. The emoji is a minor style choice and does not affect clarity.

Full details: Description check

Explanation

The description follows the repository template. It has the OSIDB-ID and title heading (OSIDB-5790), the checklist, Summary, Changes, and Considerations sections. The Summary explains the 409 comparison, the retry path, the same-field warning path, and the follow-up work. The Changes section lists the modified behavior and tests. The Considerations section names the fields that are copied through without comparison and states that their handling comes in follow-up PRs. The unchecked integration tests item is consistent with the stated scope. The description does not state why the Integration tests item is unchecked, and it is the only gap.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@C-Valen
C-Valen force-pushed the feature/OSIDB-5790-collision-conflict-controller branch from bb3830f to 4b7b317 Compare October 27, 2026 13:57
@C-Valen C-Valen self-assigned this Oct 27, 2026
@C-Valen C-Valen added the enhancement New feature or request label Oct 27, 2026
@C-Valen
C-Valen force-pushed the feature/OSIDB-5790-collision-conflict-controller branch from 4b7b317 to 88331d9 Compare October 27, 2026 14:45
Co-authored-by: Cursor <cursoragent@cursor.com>
@C-Valen
C-Valen force-pushed the feature/OSIDB-5790-collision-conflict-controller branch from 88331d9 to 9c34053 Compare October 27, 2026 15:00
@C-Valen
C-Valen marked this pull request as ready for review October 27, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant