Repository navigation
Eliminate config sync $effect in textarea-controller (#695) - #699
Conversation
Replace config value with getter function to eliminate reactive sync effect.
The controller now reads config on-demand through a getter property instead
of storing a config value that needs effect-based synchronization.
Changes:
- Store `getConfig` getter instead of config value in constructor
- Add `private get config()` that reads from getter on-demand
- Remove `updateConfig()` method (no longer needed)
- Update factory to pass `getEditableConfig` directly as getter
- Update tests to use getter pattern `() => ({ allowMultiline: true })`
- Add new test verifying getter reads config changes reactively
This eliminates one of two $effect blocks. The content sync effect is
kept as it handles external changes (SSE updates, undo/redo).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
d471e71 to
14f0eb8
Compare
Code Review: Eliminate config sync $effect in textarea-controller (#695)Review TypeInitial Review Requirements ValidationIssue #695 Acceptance Criteria
Code Review FindingsArchitecture & DesignPositive Observations:
FindingsSuggested Improvements
Nitpicks
Test Coverage AnalysisThe test changes are appropriate and thorough:
Security ReviewNo security concerns. This is a pure refactoring of internal state management with no changes to:
SummaryThis is a clean, well-documented refactor that successfully:
The implementation follows the principle of reading state when needed rather than pushing state changes, which is more aligned with reactive programming patterns. RecommendationAPPROVE - The change is a net improvement to code health. It reduces effect complexity while maintaining functionality and improving documentation. Reviewed by: Principal Engineer AI Reviewer |
malibio
left a comment
There was a problem hiding this comment.
RECOMMENDATION: APPROVE - Clean refactor that eliminates config sync effect via getter pattern while preserving test isolation and maintaining excellent documentation.
Replace config value with getter function to eliminate reactive sync effect.
The controller now reads config on-demand through a getter property instead
of storing a config value that needs effect-based synchronization.
Changes:
- Store `getConfig` getter instead of config value in constructor
- Add `private get config()` that reads from getter on-demand
- Remove `updateConfig()` method (no longer needed)
- Update factory to pass `getEditableConfig` directly as getter
- Update tests to use getter pattern `() => ({ allowMultiline: true })`
- Add new test verifying getter reads config changes reactively
This eliminates one of two $effect blocks. The content sync effect is
kept as it handles external changes (SSE updates, undo/redo).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <[email protected]>
Replace config value with getter function to eliminate reactive sync effect.
The controller now reads config on-demand through a getter property instead
of storing a config value that needs effect-based synchronization.
Changes:
- Store `getConfig` getter instead of config value in constructor
- Add `private get config()` that reads from getter on-demand
- Remove `updateConfig()` method (no longer needed)
- Update factory to pass `getEditableConfig` directly as getter
- Update tests to use getter pattern `() => ({ allowMultiline: true })`
- Add new test verifying getter reads config changes reactively
This eliminates one of two $effect blocks. The content sync effect is
kept as it handles external changes (SSE updates, undo/redo).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <[email protected]>
Replace config value with getter function to eliminate reactive sync effect.
The controller now reads config on-demand through a getter property instead
of storing a config value that needs effect-based synchronization.
Changes:
- Store `getConfig` getter instead of config value in constructor
- Add `private get config()` that reads from getter on-demand
- Remove `updateConfig()` method (no longer needed)
- Update factory to pass `getEditableConfig` directly as getter
- Update tests to use getter pattern `() => ({ allowMultiline: true })`
- Add new test verifying getter reads config changes reactively
This eliminates one of two $effect blocks. The content sync effect is
kept as it handles external changes (SSE updates, undo/redo).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <[email protected]>
Summary
$effectby storing a config getter instead of a config valueprivate get config()property$effect- architecturally necessary for external updates (SSE, undo/redo)Changes
textarea-controller.svelte.ts:
getConfig: () => TextareaControllerConfiginstead ofconfig: TextareaControllerConfigprivate get config()getter that reads fromthis.getConfig()on-demandupdateConfig()method (no longer needed with getter pattern)getEditableConfigdirectly as gettertextarea-controller.test.ts:
() => ({ allowMultiline: true })Architecture Decision
After frontend-architect analysis, the content sync effect is kept because:
element.valuewrites in 7+ places)bind:valuewould conflict with cursor preservation logicThe content sync effect is the minimal coupling point between reactive (Svelte) and imperative (controller) systems.
Test plan
🤖 Generated with Claude Code