Repository navigation
Closed
Description
Overview
Audit the 6 $effect blocks in header-node.svelte and refactor or eliminate those that don't represent true side effects.
Problem Statement
header-node.svelte has 6 $effect blocks. Given that it's a relatively focused component (header rendering with level detection), this seems excessive and suggests some effects may be better expressed as derived state or event handlers.
Proposed Solution
Audit each effect and apply the appropriate pattern:
- True side effect → Keep as
$effect - Derived state → Convert to
$derived - Event response → Move to event handler
- Prop sync → May be addressed by Refactor TextareaController to reactive .svelte.ts module #624 (TextareaController refactor)
Acceptance Criteria
- Each effect in header-node audited and categorized
- Effects that should be
$derivedconverted - Effects that should be event handlers moved
- Net reduction of at least 2 effects
- Header level detection works correctly
- Header rendering displays correctly (H1-H6 styles)
- Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
File to Modify
- header-node.svelte:
packages/desktop-app/src/lib/design/components/header-node.svelte
Audit Framework
For each effect:
- What triggers it? (what reactive dependencies)
- What does it do? (side effect vs computation)
- Is it truly a side effect or derived state?
- Could it be an event handler instead?
Header-Specific Concerns
Header level detection:
- Should be
$derivedfrom content (parse#count) - No side effect needed
Content display (stripping # syntax):
- Should be
$derivedfrom content displayContentprop pattern
Metadata updates:
- May be event-driven when content changes
Testing Requirements
- Create headers with
/h1,/h2, etc. - Verify correct styling for each level
- Type
#characters and verify level changes - Edit header content and verify it persists
- Blur and verify syntax stripped in view mode
Dependencies
- May benefit from completing Refactor TextareaController to reactive .svelte.ts module #624 first (TextareaController refactor)
Related Issues
- Epic: Eliminate $effect Anti-patterns - Embrace Svelte 5 Reactivity #623 (parent epic)
- Refactor TextareaController to reactive .svelte.ts module #624 (may address some effects via controller refactor)
Activity
malibio commentedon Nov 30, 2025
This issue is already complete in the current codebase. Analysis:
Current state: ZERO $effect blocks in header-node.svelte
The component now uses only $derived and event handlers:
headerLevel = $derived(parseHeaderLevel(internalContent))- pure reactive computationheaderMetadata = $derived({ headerLevel })wrapperClasses = $derived(...)displayContent = $derived(...)handleContentChangeevent handler for newline strippingComments document the refactoring:
All acceptance criteria are met:
Note: File header comments (lines 5, 12, 16) still mention $effect but this is outdated documentation. The actual code has no effects.
malibio commentedon Nov 30, 2025
Closing as already complete - all 6 effects eliminated, converted to $derived and event handlers.