Skip to content

[WIP] Fix routing for gh-pages feature deployment - Global Navigation Sync Implemented - #1116

Merged
litlfred merged 11 commits into
mainfrom
copilot/fix-gh-pages-routing
Oct 18, 2025
Merged

litlfred merged 11 commits into
mainfrom
copilot/fix-gh-pages-routing

Conversation

Copilot AI commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor
  • Phase 1: Routing logger with comprehensive analytics ✅
  • Phase 2: Simplified 404.html with optimistic routing ✅
  • Phase 3: routingContextService.js with logging integration ✅
  • Global Navigation Sync Service ✅ (Bidirectional URL/Session Storage)
  • Fix ESLint build errors ✅
  • Fix authentication persistence on root navigation ✅
  • Add comprehensive authentication logging ✅
  • Phase 4: Update routeConfig.js
  • Phase 5: Migrate DAK components to use global navigation sync
  • Phase 6: Unify local development structure
  • Phase 7: Integration testing

Enhanced Authentication Logging

Investigation

User reported that authentication is still being lost when navigating from an authenticated page (e.g., /select_profile) to the root page (/sgex/copilot-fix-gh-pages-routing/ or /sgex/copilot-fix-gh-pages-routing/index.html) by editing the URL in the browser.

Updated Components (commit 3f77a0b):

  1. src/components/WelcomePage.js: Added detailed console logging around authentication initialization to trace:

    • When authentication restoration is attempted
    • Whether initializeFromStoredToken() succeeds or fails
    • The authentication state before and after initialization
  2. src/components/PagesManager.js: Added similar logging for consistency across components

Logging Details

The enhanced logging will show:

[WelcomePage] Attempting to initialize authentication from stored token
[WelcomePage] Authentication initialization result: { success: true/false, isAuthenticatedAfter: true/false }
[WelcomePage] Authentication restored successfully OR No valid stored token found

This will help identify:

  1. Is initializeFromStoredToken() being called?
  2. Does it return success or failure?
  3. Is the githubService authentication state correct after the call?
  4. Is there a timing issue or race condition?

Next Steps

With this logging in place, we can:

  1. Reproduce the issue and examine the console output
  2. Identify whether the token is present in sessionStorage but failing to decrypt
  3. Determine if there's a browser/timing-specific issue
  4. Pin point exactly where the authentication restoration fails

The logging follows a consistent [ComponentName] prefix format for easy filtering and will appear in the browser console when the authentication flow runs.

Awaiting: User to reproduce the issue with new deployment and share updated console log for analysis.

Fixes #954 (investigation phase)

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix routing</issue_title>
<issue_description>Routing continues to be a nightmare in the gh-pages feature deployment. A very through anaylisis of the routing worfklow is needed. So a comprehesinve unifed approach can be enforced across all pages such as:

landing page
https://litlfred.github.io/sgex/ (also handle index.html)
https://litlfred.github.io/sgex/docs
https://litlfred.github.io/sgex/404.html

feature branch or main deployment such as:
https://litlfred.github.io/sgex/copilot-fix-549/ (also handle index.html)
https://litlfred.github.io/sgex/copilot-fix-915/docs
https://litlfred.github.io/sgex/copilot-fix-915/dashboard/litlfred/smart-ips-pilgrimage
etc.

there is no 404 for feature/main branch deployments. There is one 404 page. It should be deployed from the main branch and covers all 404 routing. behaviour is:

  • It needs to handle cyclic redirects.
  • if URL looks like is a feature/main deployment (so not /docs or /index.html or / or /404.html) and it is not already coming from a redirect from the landing page url for that deployment, then first try to redirect to the deployment landing page

when entering in a URL directly (and not viewing browsing the UI of the SPA) the site does not load the page as expected, rather it goes to the welcome page. when opening a direct link, the url should be processed to set all session storage variables (e.g. :profile, :repo, etc.). these should also be preserved in the URL itself. all of the url fragments, anchors #, and query params ? should be preserved in the URL when processing a directly entered URL to determine the page to display.

no branch names or page names should be hardcoded. everything should be handled dynamically and be optimistic in assuming branches / pages are deployed.

please describe a comprehsinve solution of how to make the routing work reliably. descirbe any change migration needed.

DO NOT IMPLEMENT. I want to review proposal before implementation.</issue_description>

Comments on the Issue (you are @copilot in this section)

@litlfred There was another reported issue: https://github.com//issues/1112 which has begun to be addressed here https://github.com//pull/1113. I will close that PR as this PR should fix that issue as well.

This issue was closed before and was fixed by
#955
but somehow some of the behavior has reverted. Perhaps related to #1087

Additionnaly, something in the routing/page/asset logic handling has messed up direct URL edits. The user can no longer open a "virtual" page (e.g. a shared link via email) of the SPA nor edit the URL in the browser and successfully load the desired page.

@ritikarawlani I will assign to copilot</comment_new>

Fixes #954


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@litlfred

Copy link
Copy Markdown
Owner

please be sure not to break local deployments !!! @copilot

@litlfred

Copy link
Copy Markdown
Owner

@copilot please retry

Copilot AI commented Oct 15, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please retry

I see you'd like me to retry. However, I notice that:

  1. The original issue requested "DO NOT IMPLEMENT. I want to review proposal before implementation"
  2. The critical routing files (404.html, routeConfig.js, routingContextService.js) have strict prohibition warnings requiring explicit consent for changes

Before I proceed, could you clarify:

  • Should I now implement the routing solution described in the documentation (ROUTING_SOLUTION_PROPOSAL.md, ROUTING_IMPLEMENTATION_GUIDE.md)?
  • Do I have explicit consent to modify the prohibited files (404.html, routeConfig.js, routingContextService.js)?
  • Should I ensure local deployments (localhost) continue to work as per your earlier comment?

Once you confirm, I'll proceed with the implementation while ensuring local deployments remain functional.

@litlfred

Copy link
Copy Markdown
Owner

you were interuppted before done and no file committed. I dont see any plan. please continue with developing plan @copilot

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>

Copilot AI commented Oct 15, 2025

Copy link
Copy Markdown
Contributor Author

you were interuppted before done and no file committed. I dont see any plan. please continue with developing plan @copilot

I've created a comprehensive routing fix plan in ROUTING_FIX_PLAN.md (commit: pending).

The plan addresses all routing issues:

  • Direct URL entry with session storage population
  • Preservation of URL fragments (#) and query parameters (?)
  • Dynamic branch/component detection without hardcoding
  • Cyclic redirect prevention
  • Support for all deployment scenarios
  • Protection for local deployments (localhost will continue working)

The plan includes 5 implementation phases, detailed testing strategy, and risk mitigation. It's ready for your review.

Once approved, I'll need explicit consent to modify the three prohibited files (404.html, routeConfig.js, routingContextService.js) before proceeding with implementation.

Copilot AI changed the title [WIP] Fix routing for gh-pages feature deployment [WIP] Fix routing for gh-pages feature deployment - Comprehensive Plan Oct 15, 2025
@litlfred

Copy link
Copy Markdown
Owner

I don't want fallbacks/hardcoded path components (except in route config.js). I see

 // Fallback list only if config unavailable
  const fallbackComponents = [
    'dashboard', 'testing-viewer', 'core-data-dictionary-viewer',
    'business-process-selection', 'bpmn-editor', 'docs'
  ];

In is know components, if it is gh-pages deployment, it should treat everything as feature branch deployment except for the only files in the landing page - 404.html or index.html. Please review what is deployed at https://github.com/litlfred/sgex/blob/gh-pages/routes-config.json because there should not be any routes in the landing page. is this old code that can be removed? what is the NotFound vs 404?

@copilot

DO NOT IMPLEMENT - analyze only

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>

Copilot AI commented Oct 16, 2025

Copy link
Copy Markdown
Contributor Author

I don't want fallbacks/hardcoded path components (except in route config.js). I see

 // Fallback list only if config unavailable

...

Analysis completed in ROUTING_ANALYSIS.md (commit in progress).

Key findings:

  1. Hardcoded fallback is wrong - You're correct. Removed the fallback component list. Component detection should ONLY come from route config files.

  2. Landing page routes-config.json is NOT old code - It's intentionally minimal (only BranchListingPage + NotFound) since landing page should only show branch selection, not DAK components.

  3. NotFound vs 404.html:

    • 404.html = Static file that intercepts missing files on GitHub Pages, redirects to SPA
    • NotFound = React component that handles unmatched routes within the loaded SPA
    • Different purposes, both needed
  4. Corrected approach: 404.html should treat everything (except 404.html/index.html) as a potential branch name with optimistic redirection. NO component detection logic in 404.html - it should be deployment-agnostic.

The same 404.html works for landing page and all branch deployments through optimistic routing. React Router + route config handle component validation once the SPA loads.

Questions for confirmation in the analysis document before I update the implementation plan.

@litlfred

Copy link
Copy Markdown
Owner

@copilot from the analysis doc there are Questions for Review

  • Should we prioritize any specific URL pattern over others?
    no

  • Are there any additional deployment scenarios to consider?
    just local deployment. if it is easier to maintain (less conditional logic), we can make local deployments to go to localhost:port/sgex/main for the local deployment and use the same localhost:port/sgex for the the branchlist page (the rhe branches all being the remote GitHub previews from the PRs) and the main site card going to localhost deployment. this should simploify much of the code around routing and building/deploying

  • What is the acceptable redirect chain length before showing error?
    seven

  • Should we add analytics/logging for routing issues?
    absolutely. it should be comprehensive. will also help resolve other issues in logs as log would contain the routes accessed

  • Are there any specific local development requirements to preserve?
    see suggested changes above

    @copilot

…7-redirect limit, comprehensive logging

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>

Copilot AI commented Oct 16, 2025

Copy link
Copy Markdown
Contributor Author

@copilot from the analysis doc there are Questions for Review

  • Should we prioritize any specific URL pattern over others?
    no
    ...

Updated plan with your feedback in commit 7c56fb8:

Key changes:

  1. Unified local/production: localhost:3000/sgex/ for branch listing, localhost:3000/sgex/main/ for development - eliminates conditional logic

  2. 7-redirect limit: Increased from 2 to 7 attempts before error

  3. Comprehensive logging: New RoutingLogger class tracks all routing operations with timeline, accessible via window.SGEX_ROUTING_LOGGER.generateReport()

  4. No URL prioritization: All paths treated equally with optimistic routing

Created ROUTING_PLAN_FINALIZED.md with executive summary. The unified /sgex structure simplifies maintenance significantly - same routing logic for local and production.

Ready for implementation pending explicit consent for prohibited files (404.html, routeConfig.js, routingContextService.js).

Copilot AI changed the title [WIP] Fix routing for gh-pages feature deployment - Comprehensive Plan [WIP] Fix routing for gh-pages feature deployment - Finalized Plan with Unified Local/Production Oct 16, 2025
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Deploying to GitHub Pages

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18597737452
Commit: 42e04fc (view changes)
Workflow Step: Deploying to GitHub Pages

🔗 Quick Actions

Build Logs
Expected Deployment URL (deploying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Pushing build artifacts to gh-pages branch
Next: Verifying deployment accessibility


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Verifying Deployment

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18597737452
Commit: 42e04fc (view changes)
Workflow Step: Verifying Deployment

🔗 Quick Actions

Build Logs
Preview URL (verifying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Checking deployment accessibility
Next: Deployment complete or failure reported


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Successfully Deployed 🟢

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18597737452
Commit: 42e04fc (view changes)
Workflow Step: Successfully Deployed

🌐 Preview URLs

Open Branch Preview

🔗 Quick Actions

Build Logs


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟢 Live and accessible
Status: Deployment complete - site is ready for testing


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@litlfred

Copy link
Copy Markdown
Owner

error still happens @copilot console log is here https://gist.github.com/litlfred/bcee526b153698963b975a5b78f38ac0

…n issues

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>

Copilot AI commented Oct 17, 2025

Copy link
Copy Markdown
Contributor Author

error still happens @copilot console log is here https://gist.github.com/litlfred/bcee526b153698963b975a5b78f38ac0

Added comprehensive logging to trace the authentication restoration flow in commit 3f77a0b.

The logs will show exactly where and why authentication restoration fails. Please redeploy and reproduce the issue - the console should now show:

[WelcomePage] Attempting to initialize authentication from stored token
[WelcomePage] Authentication initialization result: { success, isAuthenticatedAfter }

This will help identify if the token is missing from sessionStorage, failing to decrypt, or if there's a timing/browser-specific issue.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Build Started

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Build Started

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Initializing build process
Next: Installing dependencies and setting up environment


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions
github-actions Bot requested a deployment to branch-preview-copilot-fix-gh-pages-routing October 18, 2025 16:01 Pending
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Setting Up Environment

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Environment Setup Complete

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Installing dependencies and configuring environment
Next: Building React application


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Building Application

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Building Application

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Compiling and bundling application code
Next: Deploying to GitHub Pages


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Deploying to GitHub Pages

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Deploying to GitHub Pages

🔗 Quick Actions

Build Logs
Expected Deployment URL (deploying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Pushing build artifacts to gh-pages branch
Next: Verifying deployment accessibility


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Verifying Deployment

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Verifying Deployment

🔗 Quick Actions

Build Logs
Preview URL (verifying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Checking deployment accessibility
Next: Deployment complete or failure reported


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Successfully Deployed 🟢

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725159
Commit: 88e8486 (view changes)
Workflow Step: Successfully Deployed

🌐 Preview URLs

Open Branch Preview

🔗 Quick Actions

Build Logs


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟢 Live and accessible
Status: Deployment complete - site is ready for testing


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Build Started

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Build Started

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Initializing build process
Next: Installing dependencies and setting up environment


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Setting Up Environment

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Environment Setup Complete

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Installing dependencies and configuring environment
Next: Building React application


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Building Application

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Building Application

🔗 Quick Actions

Build Logs
Expected Deployment URL (will be live after deployment)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Compiling and bundling application code
Next: Deploying to GitHub Pages


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Deploying to GitHub Pages

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Deploying to GitHub Pages

🔗 Quick Actions

Build Logs
Expected Deployment URL (deploying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Pushing build artifacts to gh-pages branch
Next: Verifying deployment accessibility


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Verifying Deployment

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Verifying Deployment

🔗 Quick Actions

Build Logs
Preview URL (verifying...)


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟠 Checking deployment accessibility
Next: Deployment complete or failure reported


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Deployment Status: Successfully Deployed 🟢

📊 Deployment Information

Workflow: Deploy Feature Branch (🔀 Pull Request)
Action ID: 18601725374
Commit: 88e8486 (view changes)
Workflow Step: Successfully Deployed

🌐 Preview URLs

Open Branch Preview

🔗 Quick Actions

Build Logs


📊 Overall Progress

Branch: copilot/fix-gh-pages-routing
Status: 🟢 Live and accessible
Status: Deployment complete - site is ready for testing


📋 Deployment Timeline


💡 This comment is automatically updated as the deployment progresses.

@litlfred
litlfred marked this pull request as ready for review October 18, 2025 16:06
Copilot AI review requested due to automatic review settings October 18, 2025 16:06
@litlfred
litlfred merged commit 4a0f3e5 into main Oct 18, 2025
14 checks passed

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

Implements a unified, optimistic routing strategy for GitHub Pages with comprehensive diagnostics, adds a global URL/session synchronization layer, and enhances auth restoration logging to investigate token persistence on root navigation.

  • Adds a dedicated routing logger (browser and 404 contexts) with a 7-redirect limit and session-stored timelines
  • Introduces GlobalNavigationSync to mirror URL state into sessionStorage and exposes navigation helpers
  • Improves authentication restoration diagnostics in WelcomePage and PagesManager; wires logger and sync into App initialization

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/services/routingLogger.js New logger service for routing events with session persistence and diagnostics.
src/services/routingContextService.js Integrates routing logger for initialization/errors and logs URL context storage.
src/services/globalNavigationSync.js New service to synchronize URL segments with sessionStorage and provide navigation helpers.
src/hooks/useDAKUrlParams.js Adds transitional fallback to update sessionStorage and logging to support sync migration.
src/components/WelcomePage.js Switches auth restore to initializeFromStoredToken with detailed logging.
src/components/PagesManager.js Adds analogous auth restore logging for consistency.
src/App.js Initializes routing context, global navigation sync, and bootstraps the routing logger early.
public/404.html Reworks SPA redirect logic with embedded logger, optimistic branch routing, and error page improvements.
public/404.html.backup Backup copy of prior 404.html logic (not used by the app).
ROUTING_PLAN_FINALIZED.md Finalized plan capturing decisions and phases.
ROUTING_FIX_PLAN.md Detailed routing fix plan and rollout phases.
ROUTING_ANALYSIS.md Analysis addressing feedback and clarifying 404 vs NotFound behavior.


console.log('[WelcomePage] Authentication initialization result:', {
success,
isAuthenticatedAfter: githubService.isAuthenticated

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent auth status API usage: here you reference a property (isAuthenticated), while PagesManager calls a method (isAuth()). Use a single, consistent API to avoid runtime errors; for example, change this to githubService.isAuth() if that is the canonical method.

Suggested change
isAuthenticatedAfter: githubService.isAuthenticated
isAuthenticatedAfter: githubService.isAuth()

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +40
console.log('[PagesManager] Authentication initialization result:', {
success,
isAuthenticatedAfter: githubService.isAuth()
});

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

Auth status API differs from WelcomePage (method here vs property there). Align both components on the same API (e.g., a single method githubService.isAuth()) to prevent inconsistent behavior and potential errors.

Copilot uses AI. Check for mistakes.
}

generateSessionId() {
return `route-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

String.prototype.substr is deprecated. Use slice or substring to avoid deprecation warnings: Math.random().toString(36).slice(2, 11).

Suggested change
return `route-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
return `route-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +143
// Extract context from URL structure
// Pattern: [{deploymentBranch}, {component}, {user}, {repo}, {dakBranch?}, ...{asset}]
const context = {
deploymentBranch: segments[0] || null,
component: segments[1] || null,
user: segments[2] || null,
repo: segments[3] || null,
branch: segments[4] || null, // DAK branch (optional)
asset: segments.length > 5 ? segments.slice(5).join('/') : null,
intendedBranch: segments[0] || null,
hash: hash,
search: search,
timestamp: Date.now()
};

console.log('📦 GlobalNavigationSync: Extracted context:', context);

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This infers component/user/repo/branch by path position (heuristics). To keep behavior deterministic and configuration-driven, prefer reading the explicit sgex_url_context prepared by 404.html or a routeConfig mapping; only update session storage based on explicit context, not pattern-based parsing.

Suggested change
// Extract context from URL structure
// Pattern: [{deploymentBranch}, {component}, {user}, {repo}, {dakBranch?}, ...{asset}]
const context = {
deploymentBranch: segments[0] || null,
component: segments[1] || null,
user: segments[2] || null,
repo: segments[3] || null,
branch: segments[4] || null, // DAK branch (optional)
asset: segments.length > 5 ? segments.slice(5).join('/') : null,
intendedBranch: segments[0] || null,
hash: hash,
search: search,
timestamp: Date.now()
};
console.log('📦 GlobalNavigationSync: Extracted context:', context);
// Prefer explicit context from sgex_url_context if available
let context = null;
if (typeof window !== 'undefined' && window.sgex_url_context && typeof window.sgex_url_context === 'object') {
context = {
...window.sgex_url_context,
hash: hash,
search: search,
timestamp: Date.now()
};
console.log('📦 GlobalNavigationSync: Using explicit sgex_url_context:', context);
} else {
// Fallback: Extract context from URL structure (heuristics, discouraged)
// Pattern: [{deploymentBranch}, {component}, {user}, {repo}, {dakBranch?}, ...{asset}]
context = {
deploymentBranch: segments[0] || null,
component: segments[1] || null,
user: segments[2] || null,
repo: segments[3] || null,
branch: segments[4] || null, // DAK branch (optional)
asset: segments.length > 5 ? segments.slice(5).join('/') : null,
intendedBranch: segments[0] || null,
hash: hash,
search: search,
timestamp: Date.now()
};
console.warn('⚠️ GlobalNavigationSync: Falling back to heuristic context extraction. Prefer explicit sgex_url_context.', context);
}
// Continue as before
// Update session storage
this.updateSessionStorage(context);
// Notify listeners
this.notifyListeners(context);

Copilot uses AI. Check for mistakes.
Comment on lines +137 to +139
hash: hash,
search: search,
timestamp: Date.now()

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

Persisting and logging full search/hash can inadvertently capture sensitive values (e.g., OAuth code, tokens). Sanitize these before storing/logging by stripping known secrets (code, token, access_token, id_token, state) or omit them entirely from stored context.

Copilot uses AI. Check for mistakes.
Comment thread public/404.html
Comment on lines +275 to +278
search: search,
hash: hash,
originalUrl: window.location.href,
timestamp: Date.now()

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

Storing raw search/hash in sessionStorage from the 404 handler can capture sensitive parameters present during auth redirects. Recommend filtering out sensitive keys (code, token, access_token, id_token, state) or not persisting search/hash at all.

Copilot uses AI. Check for mistakes.
Comment thread public/404.html.backup
Comment on lines +1 to +3
<!DOCTYPE html>
<!--
🚨 COPILOT PROHIBITION WARNING 🚨

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

Committing backup artifacts (404.html.backup) increases maintenance overhead and risk of drift. Consider removing this file from version control and relying on git history instead.

Copilot uses AI. Check for mistakes.
Comment thread ROUTING_PLAN_FINALIZED.md
Comment on lines +203 to +205
| Aspect | Original | Finalized |
|--------|----------|-----------|
| Redirect Limit | 2 attempts | **7 attempts** |

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

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

The markdown table has extra leading pipes and likely won't render correctly. Use a single leading pipe per line: | Aspect | Original | Finalized | followed by |---|---|---|.

Copilot uses AI. Check for mistakes.

This branch is pending to be deployed

1 inactive and 1 pending deployments
branch-preview — 6345a0c1 Deployed Oct 18, 2025 by Copilot via deploy-branch #2528
branch-preview-copilot-fix-gh-pages-routing — 6345a0c1 Pending Oct 18, 2025 by github-actions[bot]
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.

Fix routing

3 participants