On launch the app takes a little time and loads results for the last search term, if there was one.
I’d like this to be optional as I don’t rely on this feature, and I find the animations of new results popping up right as I open the app distracting. The animations, file processing, and facing my irrelevant past searches is something I’d like to avoid.
I’d like to see this feature also, since I will improve my start up time. Since I have a large vault, the ‘search on startup’ adds around 6 seconds to Obsidian’s startup time. (Which is of course nothing in the grand scheme, but still. )
Plugins load in a non-deterministic order, so you can’t stop loading searches that early, but early enough. More consistent solutions should override the saving the search part instead.
That said, I only found solutions in a plugin’s onload function. These might look a bit janky, but are barely noticable most of the time.
This one clicks the clear search button, then refocuses.
this.app.workspace.onLayoutReady(() => {
const focused = document.activeElement;
const clickEvent = new MouseEvent("click", {
view: window,
bubbles: true,
cancelable: false,
});
const bt = document.getElementsByClassName("search-input-clear-button")[0];
bt.dispatchEvent(clickEvent);
(focused as HTMLElement).focus();
});
This one loads a workspace using the core plugin, thus overriding your layout.
this.app.workspace.onLayoutReady(() => {
const workspaces = (this.app as any)?.internalPlugins?.plugins?.workspaces;
if (!workspaces) {
new Notice("Cannot find Workspaces plugin");
} else if (workspaces.enabled) {
workspaces.instance.loadWorkspace("your-workspace");
} else {
new Notice("Workspaces plugin is not enabled");
}
});
I have the same problem. For some reason, when starting Obsidian for the first time on a day and the last thing I did on the day before was a search (which happens frequently), then it takes particularly long for Obsidian to start up and become interactive. Maybe because it needs to reindex before running the search? Anyway, re-displaying the last search result is is usually not what I want and unnecessarily makes me wait before I can use Obsidian in the morning.
I wondered if using workspaces would be a solution? Because, as far as I see, the workspaces stores the state of the sidebars, which includes whether the search tab is active in the side bar or another tab. So if I could create and load a “default workspace” on startup which does not have the search tab active, this should solve the problem. However, I do not find a way to have Obsidian start with a default workspace.
Today I tried the homepage plugin and found that instead of a certain page itg can also load a certain workspace when Obsidian starts. Seems this exactly the solution to the problem I posted above. This really should become a core plugin I think!
The best solution I found is automatically clicking on the file explorer icon when the app loads. I added the code as a snippet using the User Plugins plugin.
plugin.app.workspace.onLayoutReady(() => {
const explorer = Array.from(document.getElementsByClassName('workspace-tab-header'))
.filter((x) => x.dataset['type'] == 'file-explorer')
.first();
explorer.click();
});
Still actual problem. Obsidian start last session’s search after start.
Thanks for the solution.