feat(dag): insert a change before or after a revision (jj new -B / -A) - #185
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b86121225b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
52d42cc to
9814ad9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9814ad94a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
9814ad9 to
b83c6fc
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b83c6fc6fc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b83c6fc to
d797c3c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d797c3cbf3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
d797c3c to
f9edf0e
Compare
Adds Repo::new_change_inserted with InsertPosition::{Before, After}: the new empty change takes the target's parents (Before) or the target (After) as parents, the displaced commits are rebased through it in the same transaction, and the working copy moves onto it. Inserting before the first commit lands the new change directly on the root.
Menu eligibility is computed in core as ChangeInfo::new_change { on_top, before, after }: before needs a mutable target, after needs a child and no immutable child (from parents(immutable()) and the view heads, so filtered revsets cannot mislead the gate), and on top hides on a discardable working copy (empty, undescribed head with no local or remote bookmarks, tags, or other-workspace checkouts). Shells render the record.
Mutations follow rewrites: a hidden target (e.g. rewritten by the pre-mutation snapshot) is mapped through the operation log's predecessor records to its visible successor, refusing forks.
The DAG context menu gains New change before / New change after next to New change on top, with a separator after the group; selection follows the inserted change.
Refs #164
Adds New change before / New change after to the GPUI change menu with the same gates as the SwiftUI shell, dispatching Repo::new_change_inserted and selecting the inserted working copy. The context menu gains separator items to group the new-change actions. Refs #164
f9edf0e to
4550fac
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4550fac9de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Closes #164
Adds the jj tutorial's edit-workflow primitive to the DAG: insert an empty change before a revision (
jj new -B) or between it and its children (jj new -A), with the working copy moving onto the inserted change.Core
Repo::new_change_inserted(rev, InsertPosition::{Before, After}, message)inrepo/mutations.rs, built on jj-lib in a single transaction: the new commit takes the target's parents (Before) or the target (After) as parents, the displaced commits are rebased through it (a merge child keeps its other parents), descendants follow, and@moves onto it. One op-log entry, so ⌘⇧U undoes it.root()).ChangeInfo.new_change { on_top, before, after }, computed per log load in core:beforeneeds a mutable target;afterneeds a child and no immutable child (fromparents(immutable())— ancestor-closed — and the view heads, so a filtered revset cannot mislead the gate);on_tophides on a discardable working copy — an empty, undescribed head with no bookmarks (local or remote), tags, or other-workspace checkouts. Both shells just render the record.with_resolved_commit_transaction(andrebase), so every mutation gets it.InsertPositionlives injayjay-primitivesand is bridged through UniFFI; the sharedchange_by_descriptiontest helper moved intojj-test.SwiftUI
new_change, with a separator after the new-change group. Selection follows the inserted change and the commit-box draft is cleared like New change on top.GPUI (second change in the stack)
ChangeAction::Insert { rev, at }→RepoViewModel::insert_change; the change menu gets the same two entries and gates, and the context menu gains separator items (ContextMenuItem::separator()).Tests
tests/insert_change.rs(Before keeps the target's content and drops it from disk,@is the new change, +1 op; After reparents both children and a merge child keeps its unrelated parent;has_immutable_childstays true when the revset hides the child) and both gates inmutations_immutable.rs.InsertChangeScene(own fixture copy) covers the insert-before flow;NewChangeScenekeeps the draft-clearing flow on its own fixture.change_context_action_inserts_change_before_target; the menu-label test lists both entries.Not in this PR: drag-to-rebase drop zones between rows (Roadmap), command-palette entries, user docs (release pass).
Screenshots
DAG context menu on
@(taken before the gate polish — New change after is now hidden on childless targets like this one, and a separator follows the group):After New change before on
@: the old working copy keeps its change id on top, the inserted empty change is the new@and is selected: