Skip to content

Preserve explicit TreeFocus overrides across Obsidian reloads#7

Merged
iOSonntag merged 2 commits into
masterfrom
copilot/fix-folder-focus-disappearing
May 27, 2026
Merged

Preserve explicit TreeFocus overrides across Obsidian reloads#7
iOSonntag merged 2 commits into
masterfrom
copilot/fix-folder-focus-disappearing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

Explicit folder/file focus overrides could be dropped on reload because startup cleanup treated non-rendered File Explorer items as orphaned. This led to intermittent loss of saved focused views despite paths still existing in the vault.

  • Problem

    • Startup cleanup derived validity from current File Explorer render state, which is transient/incomplete during reload.
    • Valid persisted overrides were removed when their nodes were not yet present in the explorer tree.
  • Change

    • Reworked orphan detection in performPluginCleanupTask() to validate persisted override paths against vault existence, not UI visibility.
    • Cleanup now removes only entries whose paths are truly absent from the vault.
  • Behavioral impact

    • Persisted fileOverwrites survive reloads unless the underlying file/folder was actually deleted.
    • Eliminates random reset behavior while keeping orphan cleanup semantics intact.
const availableExplicitPaths = [...PluginSettings.getExplicitModePaths()];
const orphanedExplicitPaths = availableExplicitPaths.filter(
  (path) => this.app.vault.getAbstractFileByPath(path) === null
);

Copilot AI changed the title [WIP] Fix folder focus disappearing on reload Preserve explicit TreeFocus overrides across Obsidian reloads May 27, 2026
Copilot AI requested a review from iOSonntag May 27, 2026 04:07
@iOSonntag iOSonntag marked this pull request as ready for review May 27, 2026 04:09
@iOSonntag iOSonntag requested a review from Copilot May 27, 2026 04:09
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

This PR fixes intermittent loss of persisted explicit TreeFocus overrides across Obsidian reloads by changing startup cleanup to validate overrides against vault existence rather than transient File Explorer render state.

Changes:

  • Reworked performPluginCleanupTask() orphan detection to use app.vault.getAbstractFileByPath(path) === null.
  • Removed File Explorer traversal during cleanup so explicit overrides aren’t dropped just because nodes aren’t rendered yet.

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

@iOSonntag iOSonntag merged commit ce0a281 into master May 27, 2026
1 check passed
@iOSonntag iOSonntag deleted the copilot/fix-folder-focus-disappearing branch May 27, 2026 04:12
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.

Folder Focus Disappearing on Reload - Help with Saving Configuration

3 participants