Completed in PR #6396: Steps 1–4 (WorkbookSessionContext, useSimpleWorkbookData decomposition, ColumnOperationsShared, orchestrator extraction).
Rename simple-workbook-table/ → workbook-table/ and reorganize hooks into subdirectories.
Why deferred: Touches 29+ files for mechanical import renaming. High conflict risk, no behavioral change. Best done during a quiet period with no other active workbook PRs.
If you do it:
- Rename directory:
features/simple-workbook-table/→features/workbook-table/ - Update all 29 import paths across the codebase
- Organize hooks into subdirectories:
hooks/ ├── data/ (use-simple-workbook-data, use-workbook-worker, use-data-store, use-cell-edit-batching, use-row-mutations, use-row-drag-preview, use-optimistic-column-data) ├── columns/ (use-column-actions-with-history, use-column-menu-actions, use-column-ordering, use-column-widths, use-pinned-columns, use-column-undo-redo) ├── orchestration/ (use-workbook-toolbar-effect, use-grid-selection-handler, use-cell-content-pipeline) └── (remaining) (use-formatting, use-search, use-selection, use-bulk-paste, etc.) - Move
workbook-renderer/use-column-operations.tsintoworkbook-table/hooks/columns/
Replace console.error / console.warn with toast.error for user-initiated operations that fail silently.
Files to audit:
hooks/use-column-menu-actions.ts—handleClearColumnActioncatches errors withalert()(should use toast), undo/redo callbacks useconsole.warnhooks/use-toolbar-actions.ts—clearSelectedColumncatches withalert()hooks/use-row-mutations.ts— row operations catch errors silentlyhooks/use-column-actions-with-history.ts— column operations catch errorshooks/use-simple-workbook-data.ts— cell edit failures, enrichment errorsworkbook-renderer/use-column-operations.ts— field save/add/delete/duplicate/clear errors
Pattern to follow:
// Before (silent)
catch (error) {
console.error('Failed to clear column:', error)
}
// After (user-visible)
catch (error) {
console.error('Failed to clear column:', error)
toast.error('Failed to clear column. Please try again.')
}Note: toast is already imported in simple-workbook-table.tsx via @/utils/toast. Add the import to each hook file as needed.
These hooks are >200 lines with no test coverage:
| Hook | Lines | Key behaviors to test |
|---|---|---|
use-column-actions-with-history.ts |
~500 | Column add/delete/duplicate/clear with undo/redo, selection tracking after operations |
use-column-menu-actions.ts |
~490 | Field save/add with state management, hide/format/sort/filter/pin column actions |
use-formatting.ts |
~420 | Bold/italic/underline toggle, text color, cell highlight, undo/redo, format persistence |
use-workbook-worker.ts |
~430 | Worker initialization, page fetching, data hydration, search field changes |
use-pinned-columns.ts |
~300 | Pin/unpin, persistence, optimistic updates, boundary crossing |
use-toolbar-actions.ts |
~260 | Column hide/duplicate/clear/delete, movement, sort, unhide |
Testing approach: Use renderHook from @testing-library/react with mock dependencies. Focus on:
- Happy path for each action
- Undo/redo round-trip correctness
- Edge cases (empty selection, last column, readonly mode)
| Metric | Before | After | Target |
|---|---|---|---|
| Orchestrator lines | 1,345 | 984 | ~500 |
| Largest hook lines | 1,217 | 796 | ~400 |
| Max hook params | 28 | 17 | ~10 |
| Callback data-lifting props | 3 | 0 | 0 ✓ |
| New focused hooks | 0 | 8 | — |