Skip to content

fix: fill the pane with the last column and auto-fit worker-backed column widths#5

Merged
sciro24 merged 1 commit into
sciro24:mainfrom
singularitti:fix/grid-fill-and-autofit-columns
Jul 4, 2026
Merged

fix: fill the pane with the last column and auto-fit worker-backed column widths#5
sciro24 merged 1 commit into
sciro24:mainfrom
singularitti:fix/grid-fill-and-autofit-columns

Conversation

@singularitti

Copy link
Copy Markdown
Contributor

Why this change is needed

Opening a file whose columns don't fill the editor width shows a blank, headerless "phantom column" after the last real column. The easiest repro is a 3-column JSONL — e.g. a Codex rollout log with timestamp / type / payload — viewed on a normal-width editor.

This looks like a parsing bug or a malformed file, but it is neither. The grid parses exactly the right columns (verified: every line of the sample file is valid NDJSON with the same three keys). The blank region is simply unused horizontal space:

  • .grid-header and .grid-row are full-width flex containers (.grid-sizer is min-width: 100%).
  • Cells are flex-shrink: 0 with fixed pixel widths and pack to the left.
  • When the columns are narrower than the pane, the leftover width still carries the header's background and each row's bottom border — so it reads as an empty, unlabeled column.

It is most visible for worker-backed formats (JSON/Parquet/Arrow/Excel): these never received the auto-width pass that CSV gets, so their columns fell back to narrow type-default widths and rarely filled the pane. A wide field like payload was crammed into 160px while a large gap sat to its right.

before                                            after
┌──┬───────────┬────────┬─────────┬───────────┐   ┌──┬───────────┬────────┬──────────────────────────┐
│# │ timestamp │ type   │ payload │           │   │# │ timestamp │ type   │ payload                  │
├──┼───────────┼────────┼─────────┤  ← empty, ├   ├──┼───────────┼────────┼──────────────────────────┤
│1 │ 2026-03…  │ sessi… │ {"id":… │  no header│   │1 │ 2026-03…  │ sessi… │ {"id":"019cc4cd-ae7e-7e… │
└──┴───────────┴────────┴─────────┴───────────┘   └──┴───────────┴────────┴──────────────────────────┘

How it was implemented

1. Stretch the last column to fill the panewebview-ui/src/components/DataGrid.svelte

The last visible (non-frozen) column now flex-grows to absorb the leftover width, so the grid always spans the pane with no phantom column. Because cells keep flex-shrink: 0 and their pixel width acts as the flex-basis, the column only ever grows past its natural width — when columns overflow the pane there is nothing to absorb and horizontal scrolling behaves exactly as before. It is pure CSS, so it re-fits on window/pane resize for free and the header and body stay aligned automatically. A frozen last column is skipped because position: sticky and flex-grow don't combine cleanly.

2. Auto-fit widths for worker-backed formatswebview-ui/src/stores/grid.svelte.ts

JSON/Parquet/Arrow/Excel never populate _csvAllRows, so the CSV/raw-rows auto-width pass never ran for them. Column widths are now fitted once from the first chunk on worker READY, so columns size to their content like CSV already does. A flag (reset on each READY) guards the pass so filtering or sorting — which re-requests chunk 0 — doesn't re-fit.

What it fixes

  • No more blank "phantom column" after the last column for narrow datasets (JSONL, CSV, Parquet, Arrow, Excel, …).
  • Columns fill the editor width; any spare space goes to the last column.
  • JSON/Parquet/Arrow/Excel columns now auto-fit their content instead of falling back to fixed type-default widths.

The fill behavior applies to every file type, so narrow CSVs that previously showed the same trailing gap now fill the pane as well.

Behavior notes

  • Since the last column always fills available width, dragging its resize handle narrower won't visibly shrink it while there's leftover space (it refills); dragging wider works and triggers horizontal scroll.
  • The overflow case (more/wider columns than the pane) is unchanged — natural widths plus horizontal scroll.

Testing

  • npm run build (extension + webview) passes; no new warnings.
  • Packaged a .vsix and confirmed both changes are in the shipped bundle (.col-fill { flex-grow: 1 } in main.css; the auto-width path in main.js).
  • Confirmed the sample JSONL parses to exactly three columns, so the data was never the problem.

🤖 Generated with Claude Code

Opening a file whose columns don't fill the editor width — e.g. a 3-column
JSONL such as a Codex rollout log (timestamp/type/payload) — showed a blank,
headerless "phantom column" after the last real column. This was not a
parsing bug and the file was not malformed: the grid parses exactly the right
columns. The blank area is unused horizontal space. `.grid-header` and
`.grid-row` are full-width flex containers (`.grid-sizer` is `min-width:100%`),
so when the fixed-width cells don't fill the row the leftover width still
carries the header background and each row's bottom border, which reads as an
empty column.

Two changes:

- DataGrid.svelte: the last visible (non-frozen) column now `flex-grow`s to
  absorb the leftover width, so the grid always spans the pane with no phantom
  column. Cells keep `flex-shrink:0` and their px width acts as the flex-basis,
  so the column only ever grows past its natural width — when columns overflow
  the pane there is nothing to absorb and horizontal scroll behaves exactly as
  before. It is pure CSS, so it re-fits on window/pane resize for free and the
  header and body stay aligned. A frozen last column is skipped because sticky
  positioning and flex-grow don't combine cleanly.

- grid.svelte.ts: worker-backed formats (JSON/Parquet/Arrow/Excel) never
  populate `_csvAllRows`, so the CSV/raw-rows auto-width pass never ran for them
  and their columns fell back to type-default widths. Fit column widths once
  from the first chunk on worker READY so they size to their content like CSV
  already does. Guarded by a flag (reset on each READY) so filtering or sorting,
  which re-requests chunk 0, doesn't re-fit.

The fill behaviour applies to every file type, so narrow CSVs that previously
showed the same trailing gap now fill the pane as well.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@singularitti

Copy link
Copy Markdown
Contributor Author

I made this change because I want to see all columns span the full window width, without any "empty column" gaps if the columns' total width is shorter than the window width. See examples below:

Before

before

After

after

@sciro24 sciro24 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the grid now fills the available width cleanly and the worker-backed auto-fit makes the initial column sizing much better.

@sciro24 sciro24 merged commit 4c81ca2 into sciro24:main Jul 4, 2026
1 check passed
@singularitti singularitti deleted the fix/grid-fill-and-autofit-columns branch July 4, 2026 10:48
@singularitti

Copy link
Copy Markdown
Contributor Author

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants