Skip to content

Audit and simplify header-node effects #629

Closed

Description

@malibio

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:

Acceptance Criteria

  • Each effect in header-node audited and categorized
  • Effects that should be $derived converted
  • 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:

  1. What triggers it? (what reactive dependencies)
  2. What does it do? (side effect vs computation)
  3. Is it truly a side effect or derived state?
  4. Could it be an event handler instead?

Header-Specific Concerns

Header level detection:

  • Should be $derived from content (parse # count)
  • No side effect needed

Content display (stripping # syntax):

  • Should be $derived from content
  • displayContent prop 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

Related Issues

Activity

  1. malibio commented on Nov 30, 2025

    @malibio
    CollaboratorAuthor

    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:

    • Line 57: headerLevel = $derived(parseHeaderLevel(internalContent)) - pure reactive computation
    • Line 63: headerMetadata = $derived({ headerLevel })
    • Line 66: wrapperClasses = $derived(...)
    • Line 69: displayContent = $derived(...)
    • Lines 98-109: handleContentChange event handler for newline stripping

    Comments document the refactoring:

    All acceptance criteria are met:

    • ✅ Each effect audited (all removed)
    • ✅ Effects converted to $derived
    • ✅ Side effects moved to event handlers
    • ✅ Net reduction: 6 → 0 effects (exceeds 'at least 2' requirement)
    • ✅ Tests pass

    Note: File header comments (lines 5, 12, 16) still mention $effect but this is outdated documentation. The actual code has no effects.

  2. malibio commented on Nov 30, 2025

    @malibio
    CollaboratorAuthor

    Closing as already complete - all 6 effects eliminated, converted to $derived and event handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions