Skip to content

fix(module-context): restore path-based initial context resolution - #5288

Merged
Noggling merged 2 commits into
mainfrom
fix/revert-context-initial-path-resolution
Aug 13, 2026
Merged

fix(module-context): restore path-based initial context resolution#5288
Noggling merged 2 commits into
mainfrom
fix/revert-context-initial-path-resolution

Conversation

@Noggling

Copy link
Copy Markdown
Collaborator

Why is this change needed?
The context-navigation plugin (#4751) simplified resolveInitialContext in @equinor/fusion-framework-module-context to only resolve from the parent context, moving URL-based resolution into the plugin. Consumers that haven't adopted the plugin yet lost the ability to resolve their initial context from the URL path.

What is the current behavior?
resolveInitialContext() only resolves the initial context from the parent context module; it no longer looks at the URL path at all.

What is the new behavior?
resolveInitialContext(options) first attempts to resolve the context from the URL path (via resolveContextFromPath, using the configurator's extractContextIdFromPath), and falls back to the parent context if that yields nothing — restoring the pre-plugin behavior. ContextModuleConfigurator.createConfig now passes path.extract/path.validate derived from extractContextIdFromPath.

Also included: a fix in @equinor/fusion-framework-plugin-context-navigation's createPathAdaptercanHandle now rejects URLs that don't parse as a valid app route (e.g. portal chrome), so the path adapter doesn't incorrectly claim ownership of non-app URLs.

What is the intended behavior or invariant?
resolveInitialContext must try path-based resolution first, then parent-context resolution, emitting only the first non-empty result (first() over the concatenated observables). The path adapter must only claim URLs that parse as valid app routes.

Does this PR introduce a breaking change?
No.

Impact assessment:

  • Breaking changes: No
  • Version bump: Patch for both @equinor/fusion-framework-module-context and @equinor/fusion-framework-plugin-context-navigation (changesets included)
  • Consumer impact: Consumers relying on the module's own URL-based initial context resolution (without the context-navigation plugin) regain that behavior.
  • Downstream impact: None expected; the context-navigation plugin's own routing is unaffected.

Review guidance:
Focus on the concat(...).pipe(first()) composition in resolve-initial-context.ts and the app-route guard added to create-path-adapter.ts's canHandle.

Related issues
N/A

Checklist

  • Confirm completion of the self-review checklist
  • Confirm TSDoc captures intent for functions, hooks, components, classes, and named arrow functions
  • Confirm iterator blocks, decision gates, RxJS chains, and complex decisions explain why they exist
  • Confirm React logic and derived values are resolved before markup when applicable (n/a, no React code)
  • Confirm README/docs are updated for user-facing changes (n/a, no public docs reference this internal fallback)
  • Confirm changes to target branch validation
    • Included files validated (build + lint pass)
    • No new linting warnings
    • Not a duplicate PR
  • Confirm adherence to code of conduct

…text

The context-navigation plugin (#4751) removed URL-based resolution from
resolveInitialContext in favor of the plugin. Consumers not yet on the
plugin lost the ability to resolve initial context from the path, so
restore it as a deprecated fallback composed with parent-context
resolution.
@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b570fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@equinor/fusion-framework-module-context Patch
@equinor/fusion-framework-plugin-context-navigation Patch
@equinor/fusion-framework-dev-portal Patch
@equinor/fusion-framework Patch
@equinor/fusion-framework-module-analytics Patch
portal-analytics Patch
@equinor/fusion-framework-cli Patch
@equinor/fusion-framework-app Patch
poc-portal Patch
@equinor/fusion-framework-react-app Patch
portal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added 🐞 bug Something isn't working 🧬 Modules labels Aug 13, 2026
@Noggling
Noggling marked this pull request as ready for review August 13, 2026 11:22
@Noggling
Noggling requested a review from a team as a code owner August 13, 2026 11:22
@Noggling
Noggling requested a balanced review from Copilot August 13, 2026 11:23

Copilot AI 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.

Pull request overview

Restores URL path-based initial context resolution while preventing the path adapter from handling non-app routes.

Changes:

  • Resolves context from URL path before parent context.
  • Passes configured path extraction behavior to the resolver.
  • Guards path-adapter selection using app-route parsing.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/modules/context/src/utils/resolve-initial-context.ts Composes path and parent resolution.
packages/modules/context/src/configurator.ts Configures path extraction and validation.
packages/plugins/context-navigation/src/adapters/create-path-adapter.ts Rejects non-app routes.
.changeset/module-context_restore-path-based-initial-context.md Adds module-context patch release note.
.changeset/plugin-context-navigation_path-adapter-app-route-guard.md Adds plugin patch release note.
Suppressed comments (2)

packages/modules/context/src/utils/resolve-initial-context.ts:47

  • ref is optional, so when the local navigation module is absent this dereferences undefined before the optional chain reaches navigation. That makes top-level initialization fail instead of falling back to an empty path/parent context; optional-chain ref itself.
      (ref as Partial<ModulesInstance<[NavigationModule]>>).navigation?.path.pathname;

packages/modules/context/src/utils/resolve-initial-context.ts:52

  • first() throws EmptyError when neither the URL nor the parent provides a context, which is a normal initialization state; postInitialize then logs this as a failed resolution. Use take(1) (and update the import) so the concatenated stream completes quietly when empty while still accepting only its first emission.
    ).pipe(first());

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/modules/context/src/utils/resolve-initial-context.ts Outdated
@Noggling
Noggling force-pushed the fix/revert-context-initial-path-resolution branch from e1c9083 to 3b570fa Compare August 13, 2026 11:30
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 67.16% 4027 / 5996
🔵 Statements 66.88% 4794 / 7167
🔵 Functions 53.58% 1381 / 2577
🔵 Branches 55.55% 2110 / 3798
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/modules/context/src/configurator.ts 0% 0% 0% 0% 194-296
packages/modules/context/src/utils/resolve-initial-context.ts 18.18% 0% 0% 18.18% 15-22, 40-52
packages/plugins/context-navigation/src/adapters/create-path-adapter.ts 17.39% 11.11% 50% 18.18% 46-89, 101
Generated in workflow #15311 for commit 3b570fa by the Vitest Coverage Report Action

@Noggling
Noggling merged commit 73bfe52 into main Aug 13, 2026
10 checks passed
@Noggling
Noggling deleted the fix/revert-context-initial-path-resolution branch August 13, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working 🧬 Modules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants