Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .changeset/simplify-session-cli-dispatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
67 changes: 67 additions & 0 deletions src/app/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@ describe("parseCli", () => {
});
});

test("parses session context by direct session id", async () => {
expect(await parseCli(["bun", "hunk", "session", "context", "session-1", "--json"])).toEqual({
kind: "session",
action: "context",
selector: { sessionId: "session-1" },
output: "json",
});
});

test("keeps --repo provider-neutral while canonicalizing the selected subdirectory", async () => {
const repoRoot = realpathSync.native(createTempDir("hunk-cli-repo-"));
mkdirSync(join(repoRoot, ".git"));
Expand Down Expand Up @@ -1405,6 +1414,12 @@ describe("parseCli command help text", () => {
test("renders help for each session subcommand", async () => {
expect(await expectHelp(["session", "list", "--help"])).toContain("list live Hunk sessions");
expect(await expectHelp(["session", "get", "--help"])).toContain("show one live Hunk session");
expect(await expectHelp(["session", "context", "--help"])).toContain(
"show the selected file and hunk",
);
expect(await expectHelp(["session", "review", "--help"])).toContain(
"export the live review model",
);
expect(await expectHelp(["session", "navigate", "--help"])).toContain(
"move a live Hunk session to one diff hunk",
);
Expand Down Expand Up @@ -1443,6 +1458,18 @@ describe("parseCli command help text", () => {
"clear inline review notes",
);
});

test("renders the highlight overview and per-highlight-subcommand help", async () => {
const overview = await expectHelp(["session", "highlight"]);
expect(overview).toContain("hunk session highlight add");
expect(overview).toBe(await expectHelp(["session", "highlight", "--help"]));
expect(await expectHelp(["session", "highlight", "add", "--help"])).toContain(
"paint one attention mark",
);
expect(await expectHelp(["session", "highlight", "clear", "--help"])).toContain(
"clear agent attention marks",
);
});
});

describe("parseCli argument validation", () => {
Expand Down Expand Up @@ -1603,6 +1630,46 @@ describe("parseCli argument validation", () => {
});

describe("parseCli session reload validation", () => {
test("scopes reload help flags around the nested command separator", async () => {
const outerHelp = await parseCli([
"bun",
"hunk",
"session",
"reload",
"--help",
"--",
"show",
"--help",
]);
expect(outerHelp).toMatchObject({
kind: "help",
text: expect.stringContaining("replace the contents of one live Hunk session"),
});

await expect(
parseCli(["bun", "hunk", "session", "reload", "session-1", "--", "show", "--help"]),
).rejects.toThrow("Session reload requires a Hunk review command after --");

expect(
await parseCli([
"bun",
"hunk",
"session",
"reload",
"session-1",
"--",
"show",
"HEAD",
"--",
"--help",
]),
).toMatchObject({
kind: "session",
action: "reload",
nextInput: { kind: "show", ref: "HEAD", pathspecs: ["--help"] },
});
});

test("rejects a reload with the `--` separator but no nested command", async () => {
await expect(parseCli(["bun", "hunk", "session", "reload", "session-1", "--"])).rejects.toThrow(
"Pass the replacement Hunk command after `--`",
Expand Down
Loading
Loading