Skip to content

fix: resolve onboarding welcome template empty content bug (BUG-ONBOARD-001)#140

Merged
ThisIs-Developer merged 1 commit into
mainfrom
fix-remediation-welcome-tabbar
May 31, 2026
Merged

fix: resolve onboarding welcome template empty content bug (BUG-ONBOARD-001)#140
ThisIs-Developer merged 1 commit into
mainfrom
fix-remediation-welcome-tabbar

Conversation

@ThisIs-Developer

Copy link
Copy Markdown
Owner

Overview

This PR resolves the critical onboarding bug BUG-ONBOARD-001, where first-time users see a blank editor and preview panel despite the "Welcome to Markdown" tab being successfully created.

Root Cause Analysis

  1. PWA Cache Mismatch (Stale-While-Revalidate): The PWA service worker caches index.html using a stale-while-revalidate strategy. If a user receives the cached version of index.html from a previous release (which defines the template as <template id="default-markdown">) but loads the new script.js (which expects <script type="text/markdown" id="default-markdown"> and accesses its textContent), the resulting retrieval evaluates to "" since a <template> tag's contents reside inside its .content document fragment.
  2. Brittle Fallback Check: Because the DOM element is found (non-null), the ternary operator selected the textContent branch. Evaluating "".trim() yielded an empty string "" and completely bypassed the hardcoded welcome markdown fallback.

Remediation Details

  • Resilient Template Extraction: Updated script.js to dynamically inspect the template element. It now safely extracts text content from both modern <script type="text/markdown"> and older cached <template> tags.
  • Robust Fallback: Switched the ternary assignment to a logical OR (||) condition. This guarantees that if retrieved text is empty or missing, the application automatically falls back to the hardcoded welcome markdown string rather than hydrating an empty editor.
  • Desktop Application Sync: Rebuilt the Neutralino desktop resources (node prepare.js) to sync the script.js changes to desktop-app/resources/js/script.js and update the offline-first resources/index.html.

Verification & Testing

  1. Hydration Verification:
    • Simulated standard <script> tag: PASS (retrieved full welcome markdown)
    • Simulated stale cached <template> tag: PASS (retrieved full welcome markdown)
    • Simulated null/missing element: PASS (fell back to hardcoded default)
    • Simulated empty element: PASS (fell back to hardcoded default)
  2. Web Regression Testing: Verified in Incognito mode and with cleared localStorage that the editor and preview hydrate perfectly. Existing saved tabs continue to load exactly as before.
  3. Desktop Regression Testing: Verified that fresh Neutralino client launches successfully hydrate the editor and preview.

Copilot AI review requested due to automatic review settings May 31, 2026 19:37
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-viwer Ready Ready Preview, Comment May 31, 2026 7:37pm

@ThisIs-Developer ThisIs-Developer merged commit 7a81d40 into main May 31, 2026
6 of 7 checks passed
@ThisIs-Developer ThisIs-Developer deleted the fix-remediation-welcome-tabbar branch May 31, 2026 19:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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