Skip to content

Migrate to monorepo - #215

Merged
Avni2000 merged 21 commits into
mainfrom
migrate-to-monorepo
Apr 3, 2026
Merged

Avni2000 merged 21 commits into
mainfrom
migrate-to-monorepo

Conversation

@Avni2000

@Avni2000 Avni2000 commented Apr 3, 2026 •

Copy link
Copy Markdown
Owner

Motivation

In order to create a git mergetool, AND have a codebase that follows DRY principles, creating a monorepo is somewhat necessary.

Solution

Refactor

  • Reorganized monorepo into modular packages: core (algorithms/utilities), web/client (UI), web/server (WebSocket). Migrated VS Code extension to apps/vscode-extension.
  • Updated import paths and test infrastructure across codebase to reflect new directory structure.
  • Adjusted test command entry points and configuration files for new layout.

Tests

  • move playwright and vscode tests to their respective (packages/web/tests and apps/vscode-extension/tests/) locations.

Docs

  • stub READMEs for each package/core,web-client,web-server and app.

Summary by CodeRabbit

Release Notes

  • Refactor

    • Reorganized monorepo structure: consolidated VSCode extension code into apps/vscode-extension/ and web components into packages/web/, with shared utilities in packages/core/.
    • Centralized type definitions and core algorithms into a shared package for consistency across environments.
    • Updated test infrastructure paths and commands for improved maintainability.
  • Documentation

    • Updated testing guides to reflect new repository layout and test runner locations.

Avni2000 added 16 commits April 2, 2026 17:29
- auto updates imports
- creates minimal package.json and tsconfig
- does not compile
- auto update imports
- creates minimal package.json and tsconfig
- does not compile
- auto updates imports
- creates minimal package.json and tsconfig
- does not compile
- for dependency injection (next commit) so that core doesn't depend on app
- Defines both interfaces in packages/core/src/types.ts and adds a barrel export in packages/core/src/index.ts
- settings.ts re-exports from core.
- conflictDetector now accepts a GitOperations param instead of importing gitIntegration directly;
- applyAutoResolutions requires settings explicitly;
- semanticResolution imports MergeNBSettings from core types.
- Root tsconfig uses moduleResolution bundler and covers apps/ + packages/
- each package tsconfig extends root
- package.json files add main/types fields.
- Corrects ../ depth in extension imports, fixes webServer/index.ts paths,
- updates esbuild.js entry points to apps/ and packages/ locations.
- test utils that are shared across vscode and web infra
- update tooling to point at new output paths
- move playwright and vscode tests to their respective (`packages/web/tests` and `apps/vscode-extension/tests/`) locations
@coderabbitai

coderabbitai Bot commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c4fd017d-2c9e-4be3-95e0-14df77f0e538

📥 Commits

Reviewing files that changed from the base of the PR and between 0517e53 and 99db73c.

📒 Files selected for processing (9)
  • .github/workflows/vscode-nbdime-guard.yml
  • apps/vscode-extension/resolver.ts
  • package.json
  • packages/core/src/semanticResolution.ts
  • packages/core/src/types.ts
  • packages/web/client/public/index.html
  • packages/web/client/src/types.ts
  • packages/web/server/src/webTypes.ts
  • tsconfig.json
✅ Files skipped from review due to trivial changes (4)
  • packages/core/src/semanticResolution.ts
  • packages/web/client/public/index.html
  • tsconfig.json
  • packages/core/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • package.json
  • apps/vscode-extension/resolver.ts
  • packages/web/server/src/webTypes.ts

📝 Walkthrough

Walkthrough

This PR reorganizes the repository into apps/packages/test-fixtures, extracts core/shared types/functions into packages/core, moves web client/server into packages/web/*, relocates the VSCode extension to apps/vscode-extension, and updates imports, test runner paths, and several function signatures (notably conflict detection to accept git operations).

Changes

Cohort / File(s) Summary
Monorepo layout & docs
AGENTS.md, README.md, src/tests/README.md
Updated documentation to reflect new test/layout paths and removed old src/tests README.
Root build & config
tsconfig.json, esbuild.js, playwright.config.ts, package.json
Adjusted TS config (ES2022, bundler, includes), updated esbuild entry points to apps//packages/, Playwright testDir/testMatch to packages/web/tests, and npm test scripts to new runner paths.
Core package & types
packages/core/package.json, packages/core/tsconfig.json, packages/core/README.md, packages/core/src/index.ts, packages/core/src/types.ts
New packages/core package with re-exports and new types: ResolvedRow, MergeNBSettings, GitOperations.
Conflict detection / core logic
packages/core/src/conflictDetector.ts, packages/core/src/semanticResolution.ts
detectSemanticConflicts now takes GitOperations; applyAutoResolutions requires settings; type imports updated to use core types.
VSCode extension core
apps/vscode-extension/extension.ts, apps/vscode-extension/package.json, apps/vscode-extension/tsconfig.json, apps/vscode-extension/settings.ts, apps/vscode-extension/resolver.ts, apps/vscode-extension/gitIntegration.ts, apps/vscode-extension/web/WebConflictPanel.ts
Moved/created extension package, redirected imports to packages/core/packages/web, re-exported MergeNBSettings from core, updated resolver to call detect with git ops options and updated related types.
VSCode extension tests & runner
apps/vscode-extension/tests/*.ts, apps/vscode-extension/tests/runIntegrationTest.ts, apps/vscode-extension/tests/runNbdimeGuardTest.ts, apps/vscode-extension/tests/testHarness.ts
Relocated tests and runners; updated many imports to packages/core, test-fixtures/shared, and packages/web/tests; updated fixture paths and runner behavior to new layout and git-ops wiring.
Web client package & assets
packages/web/client/package.json, packages/web/client/tsconfig.json, packages/web/client/public/index.html
New web-client package and public HTML entrypoint (loading UI, KaTeX/font preloads).
Web client code & types
packages/web/client/src/**/*, packages/web/client/src/types.ts, packages/web/client/src/components/*, packages/web/client/src/utils/*, packages/web/client/src/store/*, packages/web/client/src/hooks/*
Updated imports to consume shared core utilities/types; introduced client types.ts that re-exports core types and defines WSMessage, ResolutionMessage, MergeRow etc.
Web server package
packages/web/server/package.json, packages/web/server/tsconfig.json, packages/web/server/src/index.ts, packages/web/server/src/webServer.ts, packages/web/server/src/webTypes.ts
New web-server package; logger import redirected to core; removed WebConflictPanel re-export and moved web types to re-use core exports and conflictDetector types.
Web tests & fixtures
packages/web/tests/*, packages/web/tests/fixtures.ts, packages/web/tests/globalSetup.ts, packages/web/tests/globalTeardown.ts
Updated Playwright/global setup/teardown and many test imports to use test-fixtures/shared, packages/core, and apps/vscode-extension/tests for helpers and fixture resolution.
Test fixtures shared
test-fixtures/shared/repoSetup.ts, test-fixtures/shared/testHelpers.ts
Moved/shared test helpers updated to import core logger and adjusted fixture base paths to test-fixtures.
CI workflow change
.github/workflows/vscode-nbdime-guard.yml
CI runner path updated to the built extension tests under out/apps/vscode-extension/tests/....

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant VSCode as VSCode Extension
  participant Core as packages/core (conflictDetector)
  participant Git as Git (repo)
  participant WebSrv as Web Server
  participant Playwright as Playwright / Web Client Test

  VSCode->>Core: detectSemanticConflicts(filePath, { getThreeWayVersions, getCurrentBranch, getMergeBranch })
  Core->>Git: getThreeWayVersions(filePath)
  Git-->>Core: { base, current, incoming }
  Core->>Git: getCurrentBranch(filePath)
  Core-->>VSCode: NotebookSemanticConflict | null
  VSCode->>WebSrv: start/getWebServer()
  WebSrv-->>Playwright: serve conflict data (UnifiedConflictData)
  Playwright->>VSCode: send ResolutionMessage (resolvedRows)
  VSCode->>Core: applySemanticResolutionsFromRows(resolvedRows)
  Core-->>VSCode: AutoResolveResult / updated notebook
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

🐰 I hopped through folders, crate and nest,

core, apps, and tests all dressed their best.
Types moved home and runners found light—
imports aligned, the repo feels right.
A little rabbit cheers the new site!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Migrate to monorepo' accurately and concisely summarizes the primary change: a comprehensive reorganization of the repository structure into a modular monorepo layout with separate packages for core, web, and the VS Code extension.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate-to-monorepo

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/web/client/src/components/ConflictResolver.tsx (1)

722-724: ⚠️ Potential issue | 🟡 Minor

Orphaned JSDoc comment at end of file.

The file ends with a JSDoc block (/** Build merge rows from semantic conflict data. */) with no following function definition. This appears to be a leftover from removed or relocated code.

🔧 Suggested fix
-
-/**
- * Build merge rows from semantic conflict data.
- */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/client/src/components/ConflictResolver.tsx` around lines 722 -
724, Remove the orphaned JSDoc comment at the end of ConflictResolver.tsx (the
block that reads "Build merge rows from semantic conflict data.") or reattach it
to the actual implementation of the merge-row builder (e.g., the buildMergeRows
/ buildMergeRowsFromSemanticConflicts function) if that function exists
elsewhere; ensure the file no longer ends with a standalone JSDoc block so
comments correctly describe the associated function or are removed.
packages/web/tests/fixtures.ts (1)

160-166: ⚠️ Potential issue | 🟠 Major

Correct the extension URI path to reach the repository root.

path.resolve(__dirname, '../../..') from the compiled location out/packages/web/tests/ resolves to out/, not the repository root. The dist/web directory is built at the repository root (see esbuild.js line 52), so this path is incorrect.

Use '../../../..' (4 levels) instead, matching the pattern in apps/vscode-extension/tests/testHarness.ts:209. The same issue affects packages/web/tests/globalSetup.ts:20.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/tests/fixtures.ts` around lines 160 - 166, The extension URI
passed to server.setExtensionUri in getWebServer usage is resolving to the wrong
folder; change the path argument in the setExtensionUri call from
path.resolve(__dirname, '../../..') to path.resolve(__dirname, '../../../..') so
it points to the repository root (update the call in
packages/web/tests/fixtures.ts where server.setExtensionUri is invoked, and
apply the same fix to the analogous call in packages/web/tests/globalSetup.ts).
Ensure you only update the string path component to add one more "../" so
dist/web at repo root is targeted.
🧹 Nitpick comments (2)
packages/web/client/README.md (1)

1-1: Add trailing newline.

Same as the server README—add a newline at end of file for POSIX compliance.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/client/README.md` at line 1, Add a single trailing newline
character at the end of the packages/web/client README.md so the file ends with
a newline for POSIX compliance; open README.md and ensure the last line
"Frontend for all conflict resolution across apps" is followed by a newline
character (save the file so the newline is present).
packages/web/server/README.md (1)

1-1: Add trailing newline.

POSIX convention expects files to end with a newline character to avoid issues with certain tools.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/server/README.md` at line 1, The README entry "WebSocket server
for browser-app communication." is missing a trailing newline; open the file and
ensure the final line ends with a single newline character (append '\n' at EOF)
so the file conforms to POSIX convention and avoids tooling issues, then
save/commit the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/src/semanticResolution.ts`:
- Around line 6-7: The ResolvedRow type is imported from the web/server module,
creating an unwanted web dependency; extract the ResolvedRow interface into the
core public types module (the core types file) and update imports so
semanticResolution.ts (and any web client/server copies) import ResolvedRow from
core instead; ensure functions that use it — BuildResolvedNotebookOptions,
getCellForSide, isConsistentTakeAllSelection, inferPreferredSide — keep their
signatures and are updated to reference the new core types export.

In `@packages/web/client/public/index.html`:
- Line 7: The preload link currently uses rel="preload" as="style" which will
fetch but not apply the font stylesheet; change the markup that creates the
preload link (the <link rel="preload" as="style" ...> element) to either add an
onload handler that sets its rel to "stylesheet" after loading (e.g.,
onload="this.rel='stylesheet'") or keep the preload and add a separate <link
rel="stylesheet" href="..."> for the same href so the stylesheet is actually
applied; update the same link element referenced in index.html accordingly.

In `@tsconfig.json`:
- Around line 16-22: The tsconfig.json "include" array is missing the
apps/**/*.tsx glob so .tsx files under apps/ won't be type-checked; update the
"include" entry for "apps" (the include array in tsconfig.json) to add
"apps/**/*.tsx" alongside "apps/**/*.ts" so both .ts and .tsx files in the apps
folder are included by the TypeScript compiler.

---

Outside diff comments:
In `@packages/web/client/src/components/ConflictResolver.tsx`:
- Around line 722-724: Remove the orphaned JSDoc comment at the end of
ConflictResolver.tsx (the block that reads "Build merge rows from semantic
conflict data.") or reattach it to the actual implementation of the merge-row
builder (e.g., the buildMergeRows / buildMergeRowsFromSemanticConflicts
function) if that function exists elsewhere; ensure the file no longer ends with
a standalone JSDoc block so comments correctly describe the associated function
or are removed.

In `@packages/web/tests/fixtures.ts`:
- Around line 160-166: The extension URI passed to server.setExtensionUri in
getWebServer usage is resolving to the wrong folder; change the path argument in
the setExtensionUri call from path.resolve(__dirname, '../../..') to
path.resolve(__dirname, '../../../..') so it points to the repository root
(update the call in packages/web/tests/fixtures.ts where server.setExtensionUri
is invoked, and apply the same fix to the analogous call in
packages/web/tests/globalSetup.ts). Ensure you only update the string path
component to add one more "../" so dist/web at repo root is targeted.

---

Nitpick comments:
In `@packages/web/client/README.md`:
- Line 1: Add a single trailing newline character at the end of the
packages/web/client README.md so the file ends with a newline for POSIX
compliance; open README.md and ensure the last line "Frontend for all conflict
resolution across apps" is followed by a newline character (save the file so the
newline is present).

In `@packages/web/server/README.md`:
- Line 1: The README entry "WebSocket server for browser-app communication." is
missing a trailing newline; open the file and ensure the final line ends with a
single newline character (append '\n' at EOF) so the file conforms to POSIX
convention and avoids tooling issues, then save/commit the change.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61354b9f-27a1-458f-a11f-1bbfa9425f57

📥 Commits

Reviewing files that changed from the base of the PR and between 4075912 and 0517e53.

⛔ Files ignored due to path filters (1)
  • test-fixtures/logo.svg is excluded by !**/*.svg
📒 Files selected for processing (108)
  • AGENTS.md
  • README.md
  • apps/vscode-extension/extension.ts
  • apps/vscode-extension/gitIntegration.ts
  • apps/vscode-extension/package.json
  • apps/vscode-extension/resolver.ts
  • apps/vscode-extension/settings.ts
  • apps/vscode-extension/tests/auUaPickOneRegression.test.ts
  • apps/vscode-extension/tests/duUdPickOneRegression.test.ts
  • apps/vscode-extension/tests/e2eResolution.test.ts
  • apps/vscode-extension/tests/gitTestUtils.ts
  • apps/vscode-extension/tests/logicRegression.test.ts
  • apps/vscode-extension/tests/nbdimeGuard.test.ts
  • apps/vscode-extension/tests/runIntegrationTest.ts
  • apps/vscode-extension/tests/runNbdimeGuardTest.ts
  • apps/vscode-extension/tests/settingsFile.ts
  • apps/vscode-extension/tests/statusIndicatorsRegression.test.ts
  • apps/vscode-extension/tests/testHarness.ts
  • apps/vscode-extension/tests/unmergedStatusMatrix.test.ts
  • apps/vscode-extension/tests/vscodeRegression.test.ts
  • apps/vscode-extension/tsconfig.json
  • apps/vscode-extension/typings/git.d.ts
  • apps/vscode-extension/web/WebConflictPanel.ts
  • esbuild.js
  • package.json
  • packages/core/README.md
  • packages/core/package.json
  • packages/core/src/cellMatcher.ts
  • packages/core/src/conflictDetector.ts
  • packages/core/src/index.ts
  • packages/core/src/logger.ts
  • packages/core/src/notebookParser.ts
  • packages/core/src/notebookUtils.ts
  • packages/core/src/positionUtils.ts
  • packages/core/src/semanticResolution.ts
  • packages/core/src/types.ts
  • packages/core/src/types/katexAutoRender.d.ts
  • packages/core/tsconfig.json
  • packages/web/client/README.md
  • packages/web/client/package.json
  • packages/web/client/public/index.html
  • packages/web/client/src/components/App.tsx
  • packages/web/client/src/components/CellContent.tsx
  • packages/web/client/src/components/ConflictResolver.tsx
  • packages/web/client/src/components/MergeRow.tsx
  • packages/web/client/src/hooks/useWebSocket.ts
  • packages/web/client/src/index.tsx
  • packages/web/client/src/store/resolverStore.ts
  • packages/web/client/src/styles.ts
  • packages/web/client/src/types.ts
  • packages/web/client/src/utils/markdown.ts
  • packages/web/client/src/utils/mergeRowBuilder.ts
  • packages/web/client/src/utils/reorderUtils.ts
  • packages/web/client/tsconfig.json
  • packages/web/server/README.md
  • packages/web/server/package.json
  • packages/web/server/src/index.ts
  • packages/web/server/src/webServer.ts
  • packages/web/server/src/webTypes.ts
  • packages/web/server/tsconfig.json
  • packages/web/tests/fixtures.ts
  • packages/web/tests/globalSetup.ts
  • packages/web/tests/globalTeardown.ts
  • packages/web/tests/incomingNonConflictRegression.spec.ts
  • packages/web/tests/perCellResolution.spec.ts
  • packages/web/tests/rendermimeOutputs.spec.ts
  • packages/web/tests/reorderUnmatch.spec.ts
  • packages/web/tests/reorderUnmatchApplyDisk.spec.ts
  • packages/web/tests/settingsMatrix.spec.ts
  • packages/web/tests/syntaxHighlighting.spec.ts
  • packages/web/tests/takeAllButtons.spec.ts
  • packages/web/tests/undoRedoActions.spec.ts
  • packages/web/tests/unmatchGuardNoReorder.spec.ts
  • playwright.config.ts
  • src/tests/README.md
  • test-fixtures/02_Spectral_Hashing_and_OMS.ipynb
  • test-fixtures/02_base.ipynb
  • test-fixtures/02_current.ipynb
  • test-fixtures/02_incoming.ipynb
  • test-fixtures/03_base.ipynb
  • test-fixtures/03_current.ipynb
  • test-fixtures/03_incoming.ipynb
  • test-fixtures/04_base.ipynb
  • test-fixtures/04_current.ipynb
  • test-fixtures/04_incoming.ipynb
  • test-fixtures/05_mime_base.ipynb
  • test-fixtures/05_mime_current.ipynb
  • test-fixtures/05_mime_incoming.ipynb
  • test-fixtures/06_base.ipynb
  • test-fixtures/06_current.ipynb
  • test-fixtures/06_incoming.ipynb
  • test-fixtures/07_syntax_base.ipynb
  • test-fixtures/07_syntax_current.ipynb
  • test-fixtures/07_syntax_incoming.ipynb
  • test-fixtures/08_settings_base.ipynb
  • test-fixtures/08_settings_current.ipynb
  • test-fixtures/08_settings_incoming.ipynb
  • test-fixtures/09_reorder_base.ipynb
  • test-fixtures/09_reorder_current.ipynb
  • test-fixtures/09_reorder_incoming.ipynb
  • test-fixtures/demo_base.ipynb
  • test-fixtures/demo_current.ipynb
  • test-fixtures/demo_incoming.ipynb
  • test-fixtures/shared/integrationUtils.ts
  • test-fixtures/shared/repoSetup.ts
  • test-fixtures/shared/testHelpers.ts
  • test-fixtures/shared/testRunnerShared.ts
  • tsconfig.json
💤 Files with no reviewable changes (2)
  • packages/web/server/src/index.ts
  • src/tests/README.md

Comment thread packages/core/src/semanticResolution.ts Resolved
Comment thread packages/web/client/public/index.html Resolved
Comment thread tsconfig.json Resolved
- VSCode tests need this

Let's compare the two build systems.
old: "module": "commonjs" + "moduleResolution": "node" + "esModuleInterop": true
new: "module": "ES2022" + "moduleResolution": "bundler"

benefit: more accurate type checking, and how esbuild would actually resolve modules
 - including `exports` field in package.json
drawback: tsconfig no longer doubles as a compile config for directly run node files.
@Avni2000
Avni2000 force-pushed the migrate-to-monorepo branch from 94921d1 to 6886958 Compare April 3, 2026 03:29
Avni2000 and others added 4 commits April 2, 2026 22:35
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- as opposed to simply fetching the resource

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Avni2000

Avni2000 commented Apr 3, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Avni2000
Avni2000 merged commit 39fb836 into main Apr 3, 2026
5 checks passed
@Avni2000
Avni2000 deleted the migrate-to-monorepo branch April 3, 2026 04:34
@coderabbitai coderabbitai Bot mentioned this pull request Apr 3, 2026
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