Skip to content

🐛 Fix stale chunk errors after deploy + AI Missions navbar button#4336

Merged
clubanderson merged 1 commit intomainfrom
fix/chunks-and-a11y
Apr 2, 2026
Merged

🐛 Fix stale chunk errors after deploy + AI Missions navbar button#4336
clubanderson merged 1 commit intomainfrom
fix/chunks-and-a11y

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

Summary

  • 🐛 Stale chunk errors after deploy: AlertRules, EventSummary, WarningEvents #4313 — Stale chunk errors: Reduced auto-reload cooldown from 30s to 5s, expanded error pattern matching to cover Failed to fetch, Firefox NetworkError, and Unexpected token '<' (HTML returned for missing chunks). Added proactive stale-HTML detection via app-build-id meta tag + visibility/interval checks that auto-reload when the server has a newer build.
  • Better accessibility for AI missions side panel #4287 — AI Missions accessibility: Added a prominent "AI Missions" button with Sparkles icon to the navbar (visible at lg+ breakpoints) that opens the missions sidebar. Includes attention badge for missions needing input. Also added to the overflow menu for narrower viewports. Button auto-hides when sidebar is already open.

Fixes #4313, Fixes #4287

Changes

File What changed
web/index.html Added <meta name="app-build-id"> tag for stale-HTML detection
web/vite.config.ts Added inject-build-id plugin to replace placeholder with commit hash at build time
web/src/main.tsx Reduced cooldown to 5s, added proactive stale-HTML detection (visibility change + 2min interval)
web/src/lib/chunkErrors.ts Added 3 new error patterns: Failed to fetch, NetworkError, Unexpected token '<'
web/src/lib/analytics.ts Reduced GLOBAL_RELOAD_THROTTLE_MS from 30s to 5s
web/src/components/ChunkErrorBoundary.tsx Reduced RELOAD_THROTTLE_MS from 30s to 5s
web/src/components/layout/navbar/Navbar.tsx Added AI Missions button (desktop + overflow menu)
web/src/lib/__tests__/chunkErrors.test.ts Added tests for new error patterns
web/src/lib/__tests__/analytics.test.ts Updated throttle values in tests to match 5s

Test plan

  • Build passes (npm run build)
  • Chunk error tests pass (vitest run chunkErrors.test.ts)
  • AI Missions button visible in navbar at lg+ breakpoints
  • Clicking button opens missions sidebar
  • Button disappears when sidebar is open, reappears when closed
  • Attention badge shows count when missions need input
  • Button appears in overflow menu on narrow viewports
  • Stale-HTML detection reloads when tab is re-focused after a deploy

Chunk error fixes (#4313):
- Reduce auto-reload cooldown from 30s to 5s across all handlers
- Expand error pattern matching to cover Failed to fetch, NetworkError,
  and Unexpected token '<' (HTML returned for missing chunks)
- Add app-build-id meta tag injected at build time with commit hash
- Add proactive stale-HTML detection that checks on tab visibility
  change and every 2 minutes, reloading if server has a newer build
- Update chunk error tests for new patterns and throttle values

AI Missions navbar button (#4287):
- Add Sparkles-icon "AI Missions" button to navbar (lg+ breakpoint)
- Button opens the missions sidebar and shows attention badge count
- Also add button to overflow menu for narrower viewports
- Button auto-hides when sidebar is already open

Fixes #4313, Fixes #4287

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 2, 2026 21:30
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 2, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 67f48e6
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69cedfe589ebe00008d3b893
😎 Deploy Preview https://deploy-preview-4336.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses two console UX/reliability issues: improving recovery from stale Vite chunk references after deploys (#4313) and making the AI Missions sidebar easier to access via the navbar (#4287).

Changes:

  • Added build-stamp metadata + proactive stale-HTML detection that reloads when the server build is newer.
  • Expanded chunk-load error pattern detection and reduced auto-reload throttles from 30s to 5s.
  • Added an “AI Missions” navbar button (desktop + overflow) with an attention badge for missions needing input.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/index.html Adds app-build-id meta tag placeholder used to detect stale HTML after deploys.
web/vite.config.ts Adds inject-build-id plugin to stamp the HTML meta tag with the current commit hash.
web/src/main.tsx Reduces vite:preloadError cooldown and adds proactive stale-HTML polling/visibility checks.
web/src/lib/chunkErrors.ts Adds additional message patterns for chunk-load detection.
web/src/lib/analytics.ts Lowers global chunk reload throttle to 5s to match boundary behavior.
web/src/components/ChunkErrorBoundary.tsx Lowers reload throttle to 5s.
web/src/components/layout/navbar/Navbar.tsx Adds AI Missions button (desktop + overflow) and attention count badge.
web/src/lib/tests/chunkErrors.test.ts Adds tests for new chunk error patterns.
web/src/lib/tests/analytics.test.ts Updates throttle-related test values to match the new 5s throttle.

Comment on lines 15 to 27
// Lazy-load SearchDropdown — it imports useSearchIndex which pulls in 5 MCP
// modules (~135 KB). The search bar appears after the chunk loads (near-instant).
const SearchDropdown = lazy(() =>
import('./SearchDropdown').then(m => ({ default: m.SearchDropdown }))
)

// Lazy-load AgentSelector — agent UI components (~41 KB) are only needed
// when a local kc-agent is available (never on console.kubestellar.io).
const AgentSelector = lazy(() =>
import('../../agent/AgentSelector').then(m => ({ default: m.AgentSelector }))
)
import { useMissions } from '../../../hooks/useMissions'
import { TokenUsageWidget } from './TokenUsageWidget'
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

import { useMissions } ... is placed after executable statements (const SearchDropdown / const AgentSelector). ES modules require all import declarations to appear before other statements, so this will fail to parse/compile. Move the useMissions import up with the other imports at the top of the file (before the lazy-loaded const declarations).

Copilot uses AI. Check for mistakes.
Comment on lines 34 to +42
msg.includes('Importing a module script failed') ||
// safeLazy() throws this when a named export is missing from a stale chunk
msg.includes('chunk may be stale')
msg.includes('chunk may be stale') ||
// Generic fetch failure — often occurs when a chunk 404s on the CDN
msg.includes('Failed to fetch') ||
// Network error variant seen in Firefox for missing chunks
msg.includes('NetworkError when attempting to fetch resource') ||
// Chrome: TypeError when dynamic import() receives a non-JS response (e.g. 404 HTML)
msg.includes("Unexpected token '<'")
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

isChunkLoadMessage is used by the global unhandledrejection/error handlers to decide whether to auto-reload (see tryChunkReloadRecovery). Matching the plain substring "Failed to fetch" is very broad and can also occur for ordinary API/network failures (offline, CORS, backend down), which could trigger disruptive auto-reloads unrelated to stale chunks. Consider narrowing this pattern (e.g., require dynamic-import specific context like dynamically imported module or a chunk path) so non-chunk fetch errors don’t cause reloads.

Copilot uses AI. Check for mistakes.
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🔄 Auto-Applying Copilot Code Review

Copilot code review found 0 code suggestion(s) and 2 general comment(s).

Also address these general comments:

  • web/src/components/layout/navbar/Navbar.tsx (line 27): import { useMissions } ... is placed after executable statements (const SearchDropdown / const AgentSelector). ES
  • web/src/lib/chunkErrors.ts (line 42): isChunkLoadMessage is used by the global unhandledrejection/error handlers to decide whether to auto-reload (see `

Push all fixes in a single commit. Run cd web && npm run build && npm run lint before committing.


Auto-generated by copilot-review-apply workflow.

@clubanderson
Copy link
Copy Markdown
Collaborator Author

/lgtm
/approve

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@clubanderson: you cannot LGTM your own PR.

Details

In response to this:

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
@clubanderson clubanderson merged commit 1876fe4 into main Apr 2, 2026
15 of 16 checks passed
@kubestellar-prow kubestellar-prow bot deleted the fix/chunks-and-a11y branch April 2, 2026 21:47
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Stale chunk errors after deploy: AlertRules, EventSummary, WarningEvents Better accessibility for AI missions side panel

3 participants