Repository navigation
Conversation
…ge, so a restarted helper keeps them The Windows/Linux shell built the search helper's launch arguments once at setup and replayed them every time the helper started. A folder added during the session reaches a *running* helper through the live `folders` request, so it works — but when that helper exits by itself (idle) and the shell starts a new one from the saved arguments, the added folder is gone: the helper searches only the startup folders, so Settings rows stop showing `X of Y indexed` for it and its files drop out of search results (issue ARahim3#170, Windows 11, 0.7.0-beta.3; local folders added after startup show the same mechanism). The arguments are now a factory, `search_arguments()`, and the running set is saved in the `SearchService` (`launch: Mutex<Launch>`, `set_launch_args`). `apply_folders` — called on every folder change — and `turn_off_code` — which must not let a restarted helper reopen the code index the person just closed — both rebuild the saved list before sending the live request, so the next helper starts with exactly what Settings shows. A pre-push review folded in one detail: `start()` chained `launch.lock().unwrap().clone()` straight onto `.spawn()`, and a MutexGuard in a statement lives to the statement's end — the launch mutex stayed held across fork/exec (hundreds of ms under Windows AV scanning), stalling `set_launch_args` exactly while a helper is being born. The snapshot is a `let` now, and spawn runs without the lock; the swap stays atomic (a spawn sees all-old or all-new arguments, never a half-written list). Redundant clones in the unit tests went too. Known adjacent staleness, out of scope here: the saved launch env carries `DIGUP_MODELS` only, never `DIGUP_DEVICE` — `set_processor_only` relies on it for the index helper only, which rebuilds its env fresh; the search helper behaved identically before this change. Verified on this box: cargo test 15 green, including two new unit tests that check the rebuilt argument list carries the current folders, their exclusions, the code folders, and the index (and drops the index flag when there is none). End to end against the Swift helper: after `op:folders` grows 1 root to 3, a restart with startup args shows the reporter's symptom (summaries: root1 only), a restart with rebuilt args restores all three (root1:2, root2:1, root3:1 indexed). Swift suite 125 green (no Swift changes), shell JS tests 17 pass. GUI acceptance on Windows is the reporter/maintainer's call — this box runs only the shell's Rust unit tests, not the Tauri app.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shell: Rebuild Search Helper Launch Arguments When Folders Change (#199)
Closes #170.
Problem
The shell originally built the search helper's launch arguments once during setup and reused them every time the helper started.
When a folder was added during an active session, the running helper received the update through the live
foldersrequest, so searches worked as expected. However, if the helper exited automatically (for example, due to inactivity) and the shell restarted it, the original launch arguments were reused.This caused the newly added folder to disappear from the helper's configuration. As a result:
X of Y indexedcount no longer reflected the actual indexing state.Changes
This PR changes the search helper's launch arguments from a static list into a factory function,
search_arguments(), allowing them to be rebuilt using the current application state.The current launch configuration is now maintained by
SearchServicethrough:launch: Mutex<Launch>— protects the current launch configuration.set_launch_args— updates the saved launch arguments.Two operations now rebuild the saved arguments whenever the folder configuration changes:
apply_folders— updates the saved launch arguments whenever folders are added, removed, or modified, before sending the corresponding live request to the running helper.turn_off_code— updates the saved arguments when code indexing is disabled, ensuring that a subsequently restarted helper does not reopen the code index.This keeps the saved launch configuration synchronized with the current Settings state. Any subsequent helper restart now uses the latest folder configuration, including exclusions and code-index settings.
Concurrency and Process Startup
A related issue was identified during pre-push code review.
Previously,
start()chainedlaunch.lock().unwrap().clone()directly into.spawn(). Because aMutexGuardremains alive until the end of its statement, this meant the launch mutex was held throughout process creation.On Windows, antivirus scanning can make process creation take hundreds of milliseconds. Holding the mutex during this operation could therefore block
set_launch_args()while a new helper process was starting.The implementation now takes a snapshot of the launch configuration into a separate
letbinding before spawning the process.This provides two important guarantees:
fork/exec.Testing and Verification
Measured on the development machine:
Hardware and environment: Apple M1, 8 GB RAM, macOS 26.5.1.
Rust Tests
cargo test: 15 tests passed.End-to-End Verification
Tested against the Swift search helper.
The test started with one indexed root and then expanded the folder configuration to three roots through
op:folders.Two restart scenarios were compared:
root1was indexedThe rebuilt configuration successfully restored the expected indexing state:
root1:2, root2:1, root3:1This reproduces the original issue and verifies that rebuilding the launch arguments resolves it.
Additional Test Suites
node --test— 17 tests passed.Scope and Limitations
Windows GUI acceptance testing remains outstanding.
The development environment validates the shell's Rust unit tests but does not run the Tauri GUI application. Windows 11 GUI acceptance testing remains the responsibility of the reporter or maintainer.
Adjacent environment-variable behavior is unchanged and out of scope.
The saved launch environment currently carries
DIGUP_MODELSbut does not includeDIGUP_DEVICE.set_processor_onlyrelies on this behavior for the index helper, which rebuilds its environment independently. The search helper had the same behavior before this PR, and this change does not modify it.