res-sheets Phase 4g: array/spill (deferred design) #7

Open
opened 2026-07-19 02:30:54 +00:00 by agent · 0 comments
Member

Plan: res-sheets Phase 4g — Array/Spill Functions (design-only)

Goal

Design how UNIQUE, SORT, FILTER, SEQUENCE, and TRANSPOSE can return 2D result blocks that spill into neighboring cells. Implementation is deferred until after Phases 4a–4f are complete.

Why this is a separate epic

The current Value type is a scalar (Number, Text, Bool, Error, Empty). Array functions produce rectangular results. Supporting them requires either:

  1. A new ValueKind for arrays plus spill logic in recalc.go and the TUI renderer, or
  2. A separate "spill result" concept attached to a cell that the renderer expands into adjacent empty cells.

Either path touches the storage model, dependency graph, and UI rendering.

Affected areas (to be designed)

  • extra/lib/sheets/formula_value.go — array Value representation.
  • extra/lib/sheets/recalc.go — how a spilled cell writes into neighbors.
  • extra/lib/sheets/tui/view.go — rendering spilled values without overwriting real cell content.
  • extra/lib/sheets/cell.go — possibly a Spill field on Cell.

Candidate functions

  • UNIQUE(range) — remove duplicate rows.
  • SORT(range, [sort_index], [sort_order]) — sort by column.
  • FILTER(range, include_range, [if_empty]) — include rows where condition is true.
  • SEQUENCE(rows, [columns], [start], [step]) — generate numeric grid.
  • TRANSPOSE(range) — swap rows/columns.

Open design questions

  • Should spilled values be stored in neighbor cells, or rendered virtually?
  • How do we detect a blocked spill (neighbor cell is non-empty)?
  • How do deleted/changed source cells clear the spill?
  • How do UNIQUE/SORT compare mixed text/number values?

Next step

Do not implement. Revisit after Phases 4a–4f and Phase 5 are complete.

# Plan: res-sheets Phase 4g — Array/Spill Functions (design-only) ## Goal Design how `UNIQUE`, `SORT`, `FILTER`, `SEQUENCE`, and `TRANSPOSE` can return 2D result blocks that spill into neighboring cells. Implementation is deferred until after Phases 4a–4f are complete. ## Why this is a separate epic The current `Value` type is a scalar (`Number`, `Text`, `Bool`, `Error`, `Empty`). Array functions produce rectangular results. Supporting them requires either: 1. A new `ValueKind` for arrays plus spill logic in `recalc.go` and the TUI renderer, or 2. A separate "spill result" concept attached to a cell that the renderer expands into adjacent empty cells. Either path touches the storage model, dependency graph, and UI rendering. ## Affected areas (to be designed) - `extra/lib/sheets/formula_value.go` — array Value representation. - `extra/lib/sheets/recalc.go` — how a spilled cell writes into neighbors. - `extra/lib/sheets/tui/view.go` — rendering spilled values without overwriting real cell content. - `extra/lib/sheets/cell.go` — possibly a `Spill` field on `Cell`. ## Candidate functions - `UNIQUE(range)` — remove duplicate rows. - `SORT(range, [sort_index], [sort_order])` — sort by column. - `FILTER(range, include_range, [if_empty])` — include rows where condition is true. - `SEQUENCE(rows, [columns], [start], [step])` — generate numeric grid. - `TRANSPOSE(range)` — swap rows/columns. ## Open design questions - Should spilled values be stored in neighbor cells, or rendered virtually? - How do we detect a blocked spill (neighbor cell is non-empty)? - How do deleted/changed source cells clear the spill? - How do `UNIQUE`/`SORT` compare mixed text/number values? ## Next step Do not implement. Revisit after Phases 4a–4f and Phase 5 are complete.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
residual/.agent#7
No description provided.