Repository navigation
Closed
Description
Overview
Replace $effect blocks that watch state to update autocomplete/slash command results with direct function calls from the event handlers that change that state.
Problem Statement
Current implementation uses effects to react to state changes:
// Lines 267-277: Effect watches showAutocomplete and currentQuery
$effect(() => {
if (showAutocomplete && nodeReferenceService) {
if (services?.nodeManager) {
performRealSearch(currentQuery);
} else {
autocompleteResults = generateMockResultsForTests(currentQuery);
}
}
});
// Lines 360-364: Effect watches showSlashCommands and currentSlashQuery
$effect(() => {
if (showSlashCommands) {
slashCommands = slashCommandService.filterCommands(currentSlashQuery);
}
});This is the "effect as event handler" anti-pattern. When the user types, we should call the search function directly - not set state and watch for it to change.
Proposed Solution
Move the search/filter logic to the event handlers that trigger the state changes:
// In triggerDetected handler (or wherever currentQuery is set)
function handleTriggerDetected(data) {
currentQuery = data.triggerContext.query;
autocompletePosition = data.cursorPosition;
showAutocomplete = true;
// Direct call instead of effect
updateAutocompleteResults(currentQuery);
}
function updateAutocompleteResults(query: string) {
if (services?.nodeManager) {
performRealSearch(query);
} else {
autocompleteResults = generateMockResultsForTests(query);
}
}Acceptance Criteria
- Autocomplete search triggered directly from event handlers
- Slash command filtering triggered directly from event handlers
- Two
$effectblocks eliminated from base-node.svelte - Autocomplete works identically (results appear, update on typing)
- Slash commands work identically
- Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
Files to Modify
- base-node.svelte:
packages/desktop-app/src/lib/design/components/base-node.svelte- Lines 267-277, 360-364
Events That Trigger State Changes
triggerDetected- SetscurrentQuery,showAutocomplete- Keyboard input while autocomplete open - Updates
currentQuery slashCommandDetected- SetscurrentSlashQuery,showSlashCommands- Keyboard input while slash commands open - Updates
currentSlashQuery
Migration Steps
- Identify all places where
currentQueryis set - Add direct
updateAutocompleteResults()call after each - Identify all places where
currentSlashQueryis set - Add direct
filterSlashCommands()call after each - Remove the two
$effectblocks
Testing Requirements
- Type
@and verify autocomplete appears with results - Continue typing and verify results filter
- Type
/and verify slash commands appear - Continue typing and verify commands filter
- Select items and verify they work
Activity
malibio commentedon Nov 30, 2025
Test baseline: Frontend 1469 passed (74 files), Rust 531 passed (16 ignored)
malibio commentedon Nov 30, 2025
This issue is already complete in the current codebase. Analysis:
All acceptance criteria are met:
malibio commentedon Nov 30, 2025
Closing as already complete - all acceptance criteria met in current codebase.