Skip to content

fix: normalize paths in monaco model cleanup#27

Merged
jmaxdev merged 2 commits intoTrixtyAI:mainfrom
matiaspalmac:fix/editor-empty-content
Apr 19, 2026
Merged

fix: normalize paths in monaco model cleanup#27
jmaxdev merged 2 commits intoTrixtyAI:mainfrom
matiaspalmac:fix/editor-empty-content

Conversation

@matiaspalmac
Copy link
Copy Markdown
Contributor

Changes

The model cleanup effect in EditorArea.tsx was comparing f.path (Windows backslashes) against Monaco URIs (forward slashes, URL-encoded). None of the three comparisons in .some() ever matched on Windows, so every newly created model was immediately disposed — leaving the editor rendering against a disposed model (empty content).

  • Normalize both sides to forward slashes + lowercase before comparing. Uses Set lookup instead of the previous triple .some() fallback.
  • Use model.uri.scheme === "inmemory" (cleaner than startsWith("inmemory://")).
  • Drop currentFile from the effect deps — only openFiles matters for lifecycle.
  • Remove the unused openPaths variable and the console.log on each dispose.

Disposal still happens as originally intended — files that leave openFiles have their models freed. The behavior is now correct on Windows and unchanged on Linux/macOS (where normalization is a no-op on paths that are already forward-slashed).

Issues

Copilot AI review requested due to automatic review settings April 19, 2026 02:59
Copy link
Copy Markdown

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

Fixes incorrect Monaco model disposal on Windows by normalizing file paths before comparing open files to Monaco model URIs, preventing active models from being disposed and the editor from rendering blank.

Changes:

  • Normalize openFiles paths and Monaco model paths before comparison, using a Set for efficient membership checks.
  • Use model.uri.scheme === "inmemory" to skip internal Monaco models.
  • Reduce effect re-runs by removing currentFile from the cleanup effect dependency list and removing noisy disposal logging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/desktop/src/components/EditorArea.tsx Outdated
Comment thread apps/desktop/src/components/EditorArea.tsx Outdated
@jmaxdev jmaxdev self-requested a review April 19, 2026 03:02
@jmaxdev jmaxdev merged commit 967e965 into TrixtyAI:main Apr 19, 2026
4 checks passed
@matiaspalmac matiaspalmac deleted the fix/editor-empty-content branch April 19, 2026 04:05
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.

[Bug]: Editor shows empty content for opened files on Windows

3 participants