Skip to content

Commit e8bf3f0

Browse files
committed
Go to the next file when viewed
1 parent bd5944d commit e8bf3f0

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Use `bun` for everything - package management, tests.
1515

1616
Tests should be minimal, not conflict with each other, and not be race-prone.
1717

18+
If you make changes to a file that has tests, you should ensure the tests pass and add a test-case if one does not already exist covering it.
19+
We do not want duplicative tiny tests, but we want cases to be covered.
20+
1821
Good:
1922

2023
- `import { test } from "bun:test"`

src/browser/contexts/pr-review/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ test("toggleViewed unmarks viewed file", () => {
224224
expect(store.getSnapshot().viewedFiles.has("src/index.ts")).toBe(false);
225225
});
226226

227+
test("toggleViewed navigates to next file when marking current file as viewed", () => {
228+
const store = createStore();
229+
store.selectFile("src/index.ts");
230+
231+
store.toggleViewed("src/index.ts");
232+
233+
expect(store.getSnapshot().viewedFiles.has("src/index.ts")).toBe(true);
234+
expect(store.getSnapshot().selectedFile).toBe("src/utils.ts");
235+
});
236+
227237
test("toggleViewedMultiple marks multiple files", () => {
228238
const store = createStore();
229239

src/browser/contexts/pr-review/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,19 @@ export class PRReviewStore {
524524

525525
toggleViewed = (filename: string) => {
526526
const next = new Set(this.state.viewedFiles);
527-
if (next.has(filename)) {
527+
const wasViewed = next.has(filename);
528+
if (wasViewed) {
528529
next.delete(filename);
529530
} else {
530531
next.add(filename);
531532
}
532533
this.persistViewedFiles(next);
533534
this.set({ viewedFiles: next });
535+
536+
// When marking a file as viewed, navigate to the next file
537+
if (!wasViewed && filename === this.state.selectedFile) {
538+
this.navigateToFile("next");
539+
}
534540
};
535541

536542
toggleViewedMultiple = (filenames: string[]) => {

0 commit comments

Comments
 (0)