Skip to content

feat(staged): add timeline row context menu actions#668

Open
matt2e wants to merge 6 commits intomainfrom
right-click-copy-sha
Open

feat(staged): add timeline row context menu actions#668
matt2e wants to merge 6 commits intomainfrom
right-click-copy-sha

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented Apr 30, 2026

Summary

  • Add a shared timeline row context menu with Copy SHA, Revert commit, and New session referring to this actions.
  • Wire commit revert through Tauri for local and workspace-backed branches.
  • Keep hashtag input focus at the end after inserting references.

matt2e and others added 6 commits April 28, 2026 17:23
…ine rows

Right-clicking a commit row in the BranchCard timeline now shows a
context menu with a "Copy SHA" option that copies the full commit SHA
to the clipboard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eline items

Right-clicking any completed timeline item (commit, note, review, or
project note) now shows a "New session referring to this" option that
opens the new session dialog pre-filled with `Re: #<type>:<id>`. If the
dialog is already open with user content, the hashtag reference is
appended on a new line instead. For project-level notes, the reference
is inserted into the project prompt input.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…g reference

For project-level notes, await tick() before focusing the prompt input
and use Selection/Range API to position the cursor at the end of the
contenteditable element after the reference text is inserted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract focusAtEnd() utility to reduce duplication between
  ProjectSection and HashtagInput cursor-positioning logic.

- Lift context menu state from per-TimelineRow instances into a single
  TimelineContextMenu component rendered once per timeline. This
  eliminates N window-level click/keydown listeners (one per row) and
  replaces them with a single set of listeners.

- Add viewport boundary clamping so the context menu never overflows
  off-screen (measures the menu element after render and adjusts
  position with an 8px margin).

- Fix: right-clicking another row now correctly closes any existing
  context menu via the window oncontextmenu handler, since only one
  menu instance exists per timeline.
- Extract focusAtEndSync() for use in $effect where DOM is already
  fresh, avoiding fire-and-forget async in synchronous effects.
  focusAtEnd() now delegates to focusAtEndSync() after tick().

- Normalize hashtagRef assignment in BranchTimeline to consistently
  use the derived `type` check (`type === 'commit'`) rather than
  mixing data-availability checks (`commit.sha ?`) with type checks.

- Fix rAF race in TimelineContextMenu.open(): track pendingRaf and
  cancel any in-flight animation frame before scheduling a new one,
  preventing stale coordinates from clobbering on rapid right-clicks.

- Keep <svelte:window> listeners at top level with early-return guards
  (Svelte disallows <svelte:window> inside {#if} blocks).
Right-clicking a commit row in the BranchCard timeline now shows a
"Revert commit" option that runs `git revert --no-edit <sha>` to create
a new commit undoing the selected commit's changes. Supports both local
worktrees and remote workspaces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners April 30, 2026 02:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4af648cf8b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

function handleContextMenu(e: MouseEvent) {
if (!hasContextMenu || !onContextMenu) return;
e.preventDefault();
e.stopPropagation();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Let right-click events reach window-level menu handlers

Because each BranchTimeline mounts its own TimelineContextMenu instance (apps/staged/src/lib/features/timeline/BranchTimeline.svelte:695), stopping propagation here prevents other open menus from seeing the new contextmenu event and closing. In projects with multiple branch cards, right-clicking a row in branch B after opening branch A’s menu can leave both menus open at once, which is a visible UI regression and makes actions ambiguous.

Useful? React with 👍 / 👎.


/// Revert a commit by creating a new commit that undoes its changes.
pub fn revert_commit(worktree: &Path, commit_sha: &str) -> Result<(), GitError> {
cli::run(worktree, &["revert", "--no-edit", commit_sha])?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle merge commits in revert command

This implementation always runs git revert --no-edit <sha>, which fails for merge commits because Git requires selecting a mainline parent (-m). The new context menu exposes “Revert commit” for any commit row, so branches containing merge commits will consistently hit a backend error instead of reverting. The same issue also exists in the workspace path (apps/staged/src-tauri/src/timeline.rs:475).

Useful? React with 👍 / 👎.

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.

1 participant