Skip to content

Conversation

@youngchingjui
Copy link
Owner

@youngchingjui youngchingjui commented Jan 1, 2026

Summary

  • Removed the rootDir option to simplify the configuration
  • Added path mappings for shared modules (@/shared/*shared/src/*) to enhance module resolution

Context

This change was extracted from a larger Neo4j feature PR to be tested separately, as it could have wide-ranging effects on the monorepo build process.

Test plan

  • Verify workflow-workers builds successfully with the new tsconfig
  • Ensure path mappings resolve correctly for shared modules
  • Check that existing tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Added a new import alias and marked the older alias as deprecated to simplify module resolution.
    • Updated import paths across the codebase to use the new alias.
    • Changed the runtime entrypoint used at startup to align container and local start behavior.
    • Adjusted environment loading to resolve from the process working directory.
  • Style

    • Converted a runtime import to a type-only import (no runtime impact).

✏️ Tip: You can customize this high-level summary in your review settings.

…dd path mappings\n\n- Removed the `rootDir` option to simplify the configuration.\n- Added path mappings for shared modules to enhance module resolution.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds new TypeScript path alias "@/shared/*" (and deprecates @shared/*), removes rootDir from a worker tsconfig, updates workflow-workers package/Docker entrypoint paths, and changes worker startup code to resolve root via process.cwd() and imports to the new alias.

Changes

Cohort / File(s) Summary
TypeScript configuration
tsconfig.json, shared/tsconfig.json, apps/workers/workflow-workers/tsconfig.json
Introduced "@/shared/*" path mapping (kept @shared/* with deprecation comment); removed rootDir from apps/workers/workflow-workers/tsconfig.json.
Runtime entrypoint
apps/workers/workflow-workers/package.json, apps/workers/workflow-workers/Dockerfile
Updated main and start to dist/apps/workers/workflow-workers/src/index.js; aligned Docker CMD/entrypoint to the same runtime path.
Worker initialization
apps/workers/workflow-workers/src/helper.ts
Changed worker root detection to use process.cwd() and adjusted imports to the new @/shared/* alias; added env-loading comment block.
Module imports / types
apps/workers/workflow-workers/src/index.ts, shared/src/adapters/ioredis/client.ts
Switched imports to use "@/shared/..." alias; changed RedisOptions import to a type-only import.

Possibly related PRs

Suggested labels

AI generated

✨ Finishing touches
  • 📝 Generate docstrings

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.

@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 09:23 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 09:23 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tsconfig.json (1)

24-25: Consider consolidating to a single alias.

Both @shared/* and @/shared/* map to the same location. Having two aliases for the same path adds maintenance overhead and can cause confusion about which alias to use in new code.

If this duplication is temporary for migration purposes, consider adding a comment to clarify the intent and timeline for removing the old alias.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f1a345 and 1012b00.

📒 Files selected for processing (3)
  • apps/workers/workflow-workers/tsconfig.json
  • lib/neo4j/index.ts
  • tsconfig.json
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,mts,mjs}

📄 CodeRabbit inference engine (.cursor/rules/code-structure.mdc)

Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Files:

  • lib/neo4j/index.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/convert.ts:69-74
Timestamp: 2025-09-22T09:34:43.580Z
Learning: The file lib/neo4j/convert.ts is being moved away from/deprecated, so fixes in this file may not be worth implementing since it will be replaced.
Learnt from: CR
Repo: youngchingjui/issue-to-pr PR: 0
File: .cursor/rules/code-structure.mdc:0-0
Timestamp: 2025-09-04T14:57:04.612Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mts,mjs} : Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/services/event.ts:365-370
Timestamp: 2025-09-22T09:33:51.194Z
Learning: The file lib/neo4j/services/event.ts is planned for migration/deprecation, so minor fixes may not be worth implementing since the file will be replaced.
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/adapters/PersistingEventBusAdapter.ts:55-58
Timestamp: 2025-09-22T09:28:41.886Z
Learning: The project is migrating away from neo4j/services/event adapters, so issues in files like lib/adapters/PersistingEventBusAdapter.ts that use these adapters may be temporary and lower priority.
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: shared/src/ports/events/publisher.ts:16-19
Timestamp: 2025-09-22T09:24:26.840Z
Learning: youngchingjui prefers to manage PR scope tightly and defer technical debt improvements to future PRs rather than expanding the current PR's scope, even for related consistency issues.
📚 Learning: 2025-09-04T14:57:04.612Z
Learnt from: CR
Repo: youngchingjui/issue-to-pr PR: 0
File: .cursor/rules/code-structure.mdc:0-0
Timestamp: 2025-09-04T14:57:04.612Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mts,mjs} : Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Applied to files:

  • tsconfig.json
  • apps/workers/workflow-workers/tsconfig.json
📚 Learning: 2025-09-22T09:34:43.580Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/convert.ts:69-74
Timestamp: 2025-09-22T09:34:43.580Z
Learning: The file lib/neo4j/convert.ts is being moved away from/deprecated, so fixes in this file may not be worth implementing since it will be replaced.

Applied to files:

  • lib/neo4j/index.ts
📚 Learning: 2025-09-22T09:33:51.194Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/services/event.ts:365-370
Timestamp: 2025-09-22T09:33:51.194Z
Learning: The file lib/neo4j/services/event.ts is planned for migration/deprecation, so minor fixes may not be worth implementing since the file will be replaced.

Applied to files:

  • lib/neo4j/index.ts
📚 Learning: 2025-09-22T09:28:41.886Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/adapters/PersistingEventBusAdapter.ts:55-58
Timestamp: 2025-09-22T09:28:41.886Z
Learning: The project is migrating away from neo4j/services/event adapters, so issues in files like lib/adapters/PersistingEventBusAdapter.ts that use these adapters may be temporary and lower priority.

Applied to files:

  • lib/neo4j/index.ts
🔇 Additional comments (3)
lib/neo4j/index.ts (1)

12-15: LGTM! Proper use of type imports.

The import statement correctly uses the type keyword for the type-only import, which helps TypeScript optimize compilation and enables better tree-shaking. The new path alias should resolve correctly with the updated tsconfig.

apps/workers/workflow-workers/tsconfig.json (2)

15-17: No @shared/* imports found in workflow-workers.

Verified that workflow-workers does not use the @shared/* alias. The root tsconfig.json includes both @shared/* and @/shared/* aliases, while workflow-workers tsconfig.json defines only @/shared/*. Since no code in workflow-workers uses @shared/*, there are no resolution failures. However, consider aligning the configuration by either adding @shared/* to workflow-workers tsconfig.json for consistency with the root configuration, or documenting why @/shared/* is the intended alias.


15-17: Path resolution is correctly configured through inherited baseUrl.

The nested tsconfig extends tsconfig.base.json, which explicitly sets baseUrl: "." at the monorepo root. Since the nested tsconfig does not override this value, it inherits the root-level baseUrl. Therefore, the relative path mapping "@/shared/*": ["shared/src/*"] resolves correctly to the monorepo root's shared/src/ directory regardless of the nested location. No changes needed.

@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 09:30 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 09:30 Inactive
…nt loading\n\n- Changed the main entry point in Dockerfile and package.json to the new path for consistency.\n- Updated the environment loading logic in helper.ts to use process.cwd() for better compatibility with nested directory structures.\n- Adjusted import paths in index.ts to align with the new module resolution strategy.
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 10:01 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 10:01 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/workers/workflow-workers/src/helper.ts (1)

16-18: Document the critical assumption about startup directory.

The change from fileURLToPath(import.meta.url) to process.cwd() makes env loading dependent on the process startup directory rather than the file location. This assumes the worker is always started from the repository root.

While this simplifies the logic and works with different dist structures, it's more fragile than the previous approach. If someone runs node dist/apps/workers/workflow-workers/src/index.js from a subdirectory, env files won't be found.

Consider adding a startup validation check that verifies expected files exist:

🔎 Proposed validation check
 function loadEnvFromWorkerRoot(): void {
   if (envLoaded) return
 
   // Use process.cwd() as the worker root, which is where the process is started from
   // This works correctly whether the dist structure is flat or nested
   const workerRoot = process.cwd()
+
+  // Validate we're starting from the expected directory
+  const packageJsonPath = path.join(workerRoot, 'package.json')
+  if (!fs.existsSync(packageJsonPath)) {
+    throw new Error(
+      `Worker must be started from repository root. Current directory: ${workerRoot}`
+    )
+  }
 
   const nodeEnv = process.env.NODE_ENV ?? "development"
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1012b00 and 4742ac4.

📒 Files selected for processing (4)
  • apps/workers/workflow-workers/Dockerfile
  • apps/workers/workflow-workers/package.json
  • apps/workers/workflow-workers/src/helper.ts
  • apps/workers/workflow-workers/src/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,mts,mjs}

📄 CodeRabbit inference engine (.cursor/rules/code-structure.mdc)

Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Files:

  • apps/workers/workflow-workers/src/index.ts
  • apps/workers/workflow-workers/src/helper.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: shared/src/ports/events/publisher.ts:16-19
Timestamp: 2025-09-22T09:24:26.840Z
Learning: youngchingjui prefers to manage PR scope tightly and defer technical debt improvements to future PRs rather than expanding the current PR's scope, even for related consistency issues.
📚 Learning: 2025-09-22T09:32:04.764Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/types/db/neo4j.ts:89-91
Timestamp: 2025-09-22T09:32:04.764Z
Learning: The new WorkflowStateEventSchema in shared/src/entities/events/WorkflowEvent.ts is built from BaseFields (id, timestamp) and does not contain a workflowId field, so DB-level schemas should not attempt to omit workflowId when using this schema.

Applied to files:

  • apps/workers/workflow-workers/src/index.ts
📚 Learning: 2025-09-22T09:32:04.764Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/types/db/neo4j.ts:89-91
Timestamp: 2025-09-22T09:32:04.764Z
Learning: The new WorkflowStateEventSchema in shared/src/entities/events/WorkflowEvent.ts does not contain a workflowId field, so DB-level schemas should not attempt to omit it when using this schema.

Applied to files:

  • apps/workers/workflow-workers/src/index.ts
📚 Learning: 2025-09-26T03:43:36.162Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1297
File: apps/workers/workflow-workers/src/orchestrators/simulateLongRunningWorkflow.ts:8-13
Timestamp: 2025-09-26T03:43:36.162Z
Learning: For workflow workers, Redis client connections should be established once at worker startup using a singleton pattern and shared across helper functions, rather than creating new connections for each function invocation to avoid connection leaks.

Applied to files:

  • apps/workers/workflow-workers/src/index.ts
🔇 Additional comments (1)
apps/workers/workflow-workers/Dockerfile (1)

57-57: LGTM! Entry point update aligns with package.json changes.

The CMD update correctly reflects the new nested dist structure. In the Docker context:

  • WORKDIR is /app (line 32), so process.cwd() returns /app
  • helper.ts will look for .env files at /app/.env*
  • Built artifacts are at /app/dist/apps/workers/workflow-workers/src/index.js

Note: .env files aren't explicitly copied in the Dockerfile, which is typical for production deployments that use environment variables. The dotenv.config() calls in helper.ts gracefully handle missing .env files.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
shared/tsconfig.json (1)

11-12: Clarify the migration path from @shared/* to @/shared/*.

The duplicate path aliases are an intentional migration pattern—__tests__/tsconfig.json already includes a deprecation comment directing to the new @/shared/* alias. Since @shared/* is still actively used throughout the codebase while @/shared/* is not yet adopted, consider adding similar deprecation comments to other tsconfig files (root, shared) to document the transition timeline and reduce confusion for contributors.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4742ac4 and 12281ec.

📒 Files selected for processing (1)
  • shared/tsconfig.json
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: shared/src/ports/events/publisher.ts:16-19
Timestamp: 2025-09-22T09:24:26.840Z
Learning: youngchingjui prefers to manage PR scope tightly and defer technical debt improvements to future PRs rather than expanding the current PR's scope, even for related consistency issues.
📚 Learning: 2025-09-04T14:57:04.612Z
Learnt from: CR
Repo: youngchingjui/issue-to-pr PR: 0
File: .cursor/rules/code-structure.mdc:0-0
Timestamp: 2025-09-04T14:57:04.612Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mts,mjs} : Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Applied to files:

  • shared/tsconfig.json

…e import paths\n\n- Added detailed comments explaining the environment loading strategy for different deployment scenarios.\n- Updated import paths to use aliasing for better module resolution consistency.
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 15:55 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 15:55 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 1, 2026 15:58 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 1, 2026 15:58 Inactive
@youngchingjui youngchingjui merged commit 94c02b0 into main Jan 1, 2026
4 of 5 checks passed
@youngchingjui youngchingjui deleted the chore/workflow-workers-tsconfig-path-mappings branch January 1, 2026 16:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12281ec and 76d142e.

📒 Files selected for processing (5)
  • apps/workers/workflow-workers/src/helper.ts
  • apps/workers/workflow-workers/src/index.ts
  • shared/src/adapters/ioredis/client.ts
  • shared/tsconfig.json
  • tsconfig.json
✅ Files skipped from review due to trivial changes (1)
  • shared/src/adapters/ioredis/client.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/workers/workflow-workers/src/index.ts
  • apps/workers/workflow-workers/src/helper.ts
  • shared/tsconfig.json
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: shared/src/ports/events/publisher.ts:16-19
Timestamp: 2025-09-22T09:24:26.840Z
Learning: youngchingjui prefers to manage PR scope tightly and defer technical debt improvements to future PRs rather than expanding the current PR's scope, even for related consistency issues.
📚 Learning: 2025-09-22T09:34:43.580Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/convert.ts:69-74
Timestamp: 2025-09-22T09:34:43.580Z
Learning: The file lib/neo4j/convert.ts is being moved away from/deprecated, so fixes in this file may not be worth implementing since it will be replaced.

Applied to files:

  • tsconfig.json
📚 Learning: 2025-09-04T14:57:04.612Z
Learnt from: CR
Repo: youngchingjui/issue-to-pr PR: 0
File: .cursor/rules/code-structure.mdc:0-0
Timestamp: 2025-09-04T14:57:04.612Z
Learning: Applies to **/*.{ts,tsx,js,jsx,mts,mjs} : Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Applied to files:

  • tsconfig.json

Comment on lines +24 to +25
"@shared/*": ["shared/src/*"], // @deprecated, migrate to using "@/shared/*" instead
"@/shared/*": ["shared/src/*"]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the tsconfig.json file to understand the context
cat -n tsconfig.json | head -30

Repository: youngchingjui/issue-to-pr

Length of output: 1096


🏁 Script executed:

# Search for any remaining usages of the deprecated "@shared/*" alias
rg -n '@shared/' --type=ts --type=js -g '!node_modules/**' -g '!**/dist/**' -g '!**/*.d.ts' 2>/dev/null | head -20

Repository: youngchingjui/issue-to-pr

Length of output: 2214


🏁 Script executed:

# Also check for dynamic imports with the deprecated alias
rg -n "import\(['\"]\@shared" --type=ts --type=js -g '!node_modules/**' -g '!**/dist/**' 2>/dev/null

Repository: youngchingjui/issue-to-pr

Length of output: 51


🏁 Script executed:

# Check if there are any other files that might reference this
rg -l '@shared/' --type=ts --type=js --type=json -g '!node_modules/**' -g '!**/dist/**' 2>/dev/null | head -20

Repository: youngchingjui/issue-to-pr

Length of output: 760


Migration from "@shared/" to "@/shared/" is incomplete and must be completed before this change can be merged.

The new "@/shared/" alias follows the consistent naming pattern with other path mappings. However, the codebase still contains numerous active imports using the deprecated "@shared/" alias that must be migrated:

  • shared/src/ui/button.tsx, shared/src/ui/alert.tsx
  • lib/workflows/createDependentPR.ts, lib/workflows/createDependentPR.formatMessage.ts
  • lib/agents/DependentPRAgent.ts
  • lib/github/auth.ts, lib/github/users.ts
  • shared/src/adapters/github/octokit/graphql/pullRequest.reader.ts, pullRequest.writer.ts
  • shared/src/lib/tools/UpdatePRTool.ts
  • __tests__/shared/usecases/generateBranchName.test.ts
  • And additional files

Update all imports to use "@/shared/" instead of "@shared/" before merging this change.

🤖 Prompt for AI Agents
In tsconfig.json around lines 24 to 25, the deprecated "@shared/*" path alias
remains and many files still import using it; update all imports to use the new
"@/shared/*" alias: search the codebase for occurrences of "@shared/" (including
the listed files: shared/src/ui/button.tsx, shared/src/ui/alert.tsx,
lib/workflows/createDependentPR.ts,
lib/workflows/createDependentPR.formatMessage.ts,
lib/agents/DependentPRAgent.ts, lib/github/auth.ts, lib/github/users.ts,
shared/src/adapters/github/octokit/pullRequest.reader.ts, pullRequest.writer.ts,
shared/src/lib/tools/UpdatePRTool.ts,
__tests__/shared/usecases/generateBranchName.test.ts, etc.) and replace them
with "@/shared/"; update any import typings or relative paths if necessary,
remove the deprecated comment in tsconfig or keep but mark migrated, run the
TypeScript build and tests to catch remaining references and fix any resulting
import path errors before merging.

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.

2 participants