Skip to content

Order PR stack tables by base chain#20

Open
fjord-oai wants to merge 3 commits into
magus:masterfrom
fjord-oai:fjord/stack-table-ordering
Open

Order PR stack tables by base chain#20
fjord-oai wants to merge 3 commits into
magus:masterfrom
fjord-oai:fjord/stack-table-ordering

Conversation

@fjord-oai
Copy link
Copy Markdown
Contributor

@fjord-oai fjord-oai commented Apr 28, 2026

Summary

Order PR stack tables from the explicit base chain instead of relying on the current commit_range.group_list order.

This fixes the concrete pre-push fixup failure mode where SyncGithub starts with an ordered range from ManualRebase, but then --pre-push-fixup folds hook-created changes and replaces that range with a fresh CommitMetadata.range(...). That fresh range is in git-log/display order, which can be tip-before-base. When the existing PR body also has stale preserved stack rows, the table can become:

  1. stale old PR
  2. current tip PR
  3. current base PR

The stack table should always render the current stack in base-to-tip order, regardless of the incidental array order returned by range().

Details

  • Updates CommitMetadata.stack_order(...) to derive canonical stack order from group.base relationships.
  • Uses that canonical order when building the PR URL list rendered into stack tables.
  • Preserves all groups even if a base link is missing or incomplete, falling back to the original input order for disconnected groups.
  • Aligns ManualRebase and rebase_order() with the new canonical ordering semantics so callers do not reinterpret stack_order() inconsistently.
  • Adds regression coverage for the real bug shape: stale rows from the previous PR body are preserved, while the current stack is rendered in base-chain order even when group_list is tip-before-base.

Test plan

  • bun test src/app/SyncGithub.test.ts src/core/CommitMetadata.order.test.ts src/core/StackSummaryTable.test.ts
  • ./node_modules/.bin/tsc
  • pnpm run build

magus added a commit that referenced this pull request Apr 29, 2026
@fjord-oai fjord-oai force-pushed the fjord/stack-table-ordering branch from 150172b to 8ae3932 Compare May 12, 2026 19:59
@fjord-oai fjord-oai force-pushed the fjord/stack-table-ordering branch from 8ae3932 to 92efd2c Compare May 12, 2026 21:16
@magus
Copy link
Copy Markdown
Owner

magus commented May 17, 2026

Do you have a repro? I spent some time thinking about this and I don't think it's possible for things to ever be out of order actually they are always the order of the commits in the local branch.

a7b8d27
ca13756
5b3b3ef

I added some instructions for running locally, maybe you move your fork to master briefly, build it and run it locally for awhile and see

2e966d5

Either we will get a repro or we might have confidence the coverage landed is sufficient now.

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