Skip to content

test(pty): cover add-note context rows#351

Merged
benvinegar merged 1 commit into
mainfrom
test/add-note-context-rows
May 23, 2026
Merged

test(pty): cover add-note context rows#351
benvinegar merged 1 commit into
mainfrom
test/add-note-context-rows

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Summary

  • add Tuistory coverage showing context/unchanged rows expose [+]
  • verify a clicked context-row draft can be saved with Ctrl-S

Tests

  • bun test test/pty/ui-integration.test.ts -t "context-row add-note" ×5
  • bun test test/pty/ui-integration.test.ts -t "add-note|add-note drafts"
  • bun run typecheck
  • bun run lint

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR adds a single PTY integration test verifying that context/unchanged rows in a deletion-only diff expose the [+] add-note affordance and that a note drafted from such a row can be saved with Ctrl-S.

  • The new test mirrors the existing deletion-row and stack-row coverage, reusing createDeletionOnlyFilePair and targeting the unchanged keep = true line as the context row under test.
  • The fixture and session parameters (cols: 120, rows: 16) are identical to the adjacent deletion-only test, keeping the setup consistent.

Confidence Score: 4/5

Safe to merge — change is test-only and introduces no production code paths.

The test correctly covers the intended context-row scenario and follows established patterns throughout the file. The one concern is that revealAddNoteNear's row-fallback logic could allow the test to pass even if the context-row affordance is broken, since the adjacent deletion row would satisfy the [+] check. This doesn't affect the production build, but leaves the new coverage weaker than it appears.

test/pty/ui-integration.test.ts — specifically the hover-fallback logic in the new test block.

Important Files Changed

Filename Overview
test/pty/ui-integration.test.ts Adds one new PTY integration test targeting context/unchanged rows in a deletion-only diff; follows the established pattern of nearby tests closely with no structural defects.

Sequence Diagram

sequenceDiagram
    participant T as Test
    participant S as PTY Session (hunk)
    participant H as Harness

    T->>H: createDeletionOnlyFilePair()
    T->>H: launchHunk(diff, split, 120x16)
    H-->>T: session

    T->>S: "waitForText(/keep = true/, 15s)"
    S-->>T: initial snapshot

    T->>T: "lineIndexOf(initial, "keep = true") → targetRow"

    loop revealAddNoteNear(targetRow)
        T->>S: moveMouse(x, y) near targetRow
        S-->>T: waitForText(/[+]/, 200ms)
    end

    T->>S: click(/[+]/)
    S-->>T: waitForText(/Draft note/)

    T->>S: type("Save this context draft.")
    T->>S: press(ctrl+s)
    S-->>T: waitForText(/Your note/)

    T->>T: expect(saved).toContain("Save this context draft.")
    T->>S: session.close()
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
test/pty/ui-integration.test.ts:742-768
**Hover fallback may mask a broken context-row `[+]`**

`revealAddNoteNear` probes the exact `targetRow` first, but if no `[+]` appears there it silently falls through to `targetRow ± 1` — which in this fixture is the `removeMe` deletion row, a row that is already known to surface `[+]` from the previous test. If the context-row affordance were broken (i.e., hovering `keep = true` never shows `[+]`), the helper would succeed against the adjacent deletion row, the test would still pass, and the regression would go undetected. Consider either (a) asserting that the `[+]` was found without falling back, or (b) calling `moveMouse` directly at the `targetRow` and asserting `[+]` appears before proceeding to `session.click`.

Reviews (1): Last reviewed commit: "test(pty): cover add-note context rows" | Re-trigger Greptile

Comment on lines +742 to +768
test("clicking context-row add-note affordances can save draft notes", async () => {
const fixture = harness.createDeletionOnlyFilePair();
const session = await harness.launchHunk({
args: ["diff", fixture.before, fixture.after, "--mode", "split"],
cols: 120,
rows: 16,
});

try {
const initial = await session.waitForText(/keep = true/, {
timeout: 15_000,
});
const targetRow = lineIndexOf(initial, "keep = true");
expect(targetRow).toBeGreaterThan(0);

await revealAddNoteNear(session, targetRow);
await session.click(/\[\+\]/);
await session.waitForText(/Draft note/, { timeout: 5_000 });
await session.type("Save this context draft.");
await session.press(["ctrl", "s"]);
const saved = await session.waitForText(/Your note/, { timeout: 5_000 });

expect(saved).toContain("Save this context draft.");
} finally {
session.close();
}
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Hover fallback may mask a broken context-row [+]

revealAddNoteNear probes the exact targetRow first, but if no [+] appears there it silently falls through to targetRow ± 1 — which in this fixture is the removeMe deletion row, a row that is already known to surface [+] from the previous test. If the context-row affordance were broken (i.e., hovering keep = true never shows [+]), the helper would succeed against the adjacent deletion row, the test would still pass, and the regression would go undetected. Consider either (a) asserting that the [+] was found without falling back, or (b) calling moveMouse directly at the targetRow and asserting [+] appears before proceeding to session.click.

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/pty/ui-integration.test.ts
Line: 742-768

Comment:
**Hover fallback may mask a broken context-row `[+]`**

`revealAddNoteNear` probes the exact `targetRow` first, but if no `[+]` appears there it silently falls through to `targetRow ± 1` — which in this fixture is the `removeMe` deletion row, a row that is already known to surface `[+]` from the previous test. If the context-row affordance were broken (i.e., hovering `keep = true` never shows `[+]`), the helper would succeed against the adjacent deletion row, the test would still pass, and the regression would go undetected. Consider either (a) asserting that the `[+]` was found without falling back, or (b) calling `moveMouse` directly at the `targetRow` and asserting `[+]` appears before proceeding to `session.click`.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch. I added a same-row-only helper for this context-row case, so the test can try nearby columns but no longer falls back to adjacent rows and cannot pass by hitting the deletion row. Re-ran the context test 5x plus the add-note PTY subset, typecheck, and lint.

Responded by pi using GPT-5.

@benvinegar benvinegar force-pushed the test/add-note-context-rows branch from 0f95d07 to fcf5eca Compare May 23, 2026 16:13
@benvinegar benvinegar merged commit 967d747 into main May 23, 2026
3 checks passed
@benvinegar benvinegar deleted the test/add-note-context-rows branch May 23, 2026 16:23
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