Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from "react";
import { expect, it } from "vitest";
import userEvent from "@testing-library/user-event";
import { createTestRepo, openRepo } from "../../../test/utils";
import { render, screen } from "../../../test/test-utils";
import { Dashboard } from "../../../src/components/Dashboard";
import { captureDocument } from "../capture";

it("captures the stack comments toggle defaulting on and saving off", async () => {
const { repoPath } = createTestRepo(false);
openRepo(repoPath);

const user = userEvent.setup();
render(<Dashboard />);

await user.click(await screen.findByLabelText("Settings"));
await screen.findByRole("tab", { name: /repository/i, selected: true });

const toggle = await screen.findByRole("switch", {
name: /post stack comments on pull requests/i,
});
expect(toggle).toHaveAttribute("aria-checked", "true");

await captureDocument(document, {
name: "repository-settings-stack-comments-01-default-on",
viewport: { width: 1440, height: 1200 },
expectations: [
"The Repository tab shows a 'Post stack comments on pull requests' row below 'Ignore generated Treq paths'.",
"The row's description says the comment lists the merge order and is visible to everyone on GitHub.",
"The Post stack comments switch is in the on (checked) position.",
],
});

await user.click(toggle);
expect(toggle).toHaveAttribute("aria-checked", "false");
await user.click(screen.getByRole("button", { name: /save settings/i }));
await screen.findByText("Settings saved");

await captureDocument(document, {
name: "repository-settings-stack-comments-02-off-and-saved",
viewport: { width: 1440, height: 1200 },
expectations: [
"The Post stack comments switch is in the off (unchecked) position.",
"A 'Settings saved' toast is visible confirming the save.",
],
});
}, 60000);
25 changes: 25 additions & 0 deletions src-tauri/src/commands/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,31 @@ pub async fn gh_create_pr(
.map_err(|e| format!("Failed to join gh_create_pr task: {}", e))?
}

/// Post or refresh the stack comment on every open PR in `head_branch`'s
/// stack. The frontend calls this only after `gh_create_pr` has returned,
/// so a failure here cannot fail PR creation.
#[tauri::command]
pub async fn gh_sync_stack_comments(
repo_path: String,
repo_full_name: String,
head_branch: String,
) -> Result<crate::core::stack_comments::StackCommentOutcome, String> {
// A missing `gh` is only an error once the core finds a stack to comment on.
let gh = gh_bin().ok();
let extended_path = get_extended_path();
tauri::async_runtime::spawn_blocking(move || {
crate::core::stack_comments::sync_stack_comments(
&repo_path,
&repo_full_name,
&head_branch,
gh.as_deref(),
&extended_path,
)
})
.await
.map_err(|e| format!("Failed to join gh_sync_stack_comments task: {e}"))?
}

#[cfg(test)]
mod tests {
use std::fs;
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub mod repo;
pub mod resolve;
pub mod sessions;
pub mod skills;
pub mod stack_comments;
pub mod stash;
pub mod submodules;
pub mod workspaces;
Expand Down
Loading
Loading