Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Stdin mode is selected with intent-first rules:
| `--keep-alive` | false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
| `--background` | false | Keep the server running in the background and output JSON connection info |
| `--context <lines>` | git default (3) | Limit surrounding context lines per change (`0` shows changes only; not available with `--pr` or stdin) |
| `--title <title>` | - | Custom browser tab title, to tell review sessions apart when several difit instances are open |

## 💬 Comment System

Expand Down
4 changes: 4 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ interface CliOptions {
background?: boolean;
context?: number;
mergeBase?: boolean;
title?: string;
}

const program = new Command();
Expand Down Expand Up @@ -128,6 +129,7 @@ program
'--merge-base',
'resolve the base revision with git merge-base before diffing (Git revision mode only)',
)
.option('--title <title>', 'custom browser tab title for this review session')
.action(async (commitish: string, compareWith: string | undefined, options: CliOptions) => {
try {
const isBackgroundChild = process.env[BACKGROUND_CHILD_ENV] === '1';
Expand Down Expand Up @@ -234,6 +236,7 @@ program
openBrowser: options.open,
clearComments: options.clean,
keepAlive: options.keepAlive,
title: options.title,
...(commentImports.length > 0 ? { commentImports } : {}),
});

Expand Down Expand Up @@ -297,6 +300,7 @@ program
contextLines: options.context,
diffMode: determineDiffMode(selection, compareWith),
repoPath,
title: options.title,
...(commentImports.length > 0 ? { commentImports } : {}),
});

Expand Down
18 changes: 18 additions & 0 deletions src/client/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1078,3 +1078,21 @@ describe('App Component - Mobile sidebar auto-close', () => {
});
});
});

describe('App Component - Custom tab title', () => {
beforeEach(() => {
vi.clearAllMocks();
mockComments = [];
mockConfirm.mockReturnValue(false);
});

it('sets document.title from the diff response when --title is provided', async () => {
mockFetch({ ...mockDiffResponse, title: 'DEV-1234 review' });

renderApp();

await waitFor(() => {
expect(document.title).toBe('DEV-1234 review');
});
});
});
1 change: 1 addition & 0 deletions src/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ function App() {
}
setDiffData(data);
setDiffDataVersion((prev) => prev + 1);
if (data.title) document.title = data.title;

// Update resolved revision state from server response
setResolvedBaseRevision(
Expand Down
15 changes: 15 additions & 0 deletions src/server/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,21 @@ describe('Server Integration Tests', () => {
expect(data).toHaveProperty('requestedTargetCommitish', 'HEAD');
});

it('GET /api/diff includes the custom title when --title is set', async () => {
const result = await startServer({
selection: { targetCommitish: 'HEAD', baseCommitish: 'HEAD^' },
preferredPort: 9035,
title: 'DEV-1234 review',
});
servers.push(result.server);

const response = await fetch(`http://localhost:${result.port}/api/diff`);
const data = (await response.json()) as any;

expect(response.ok).toBe(true);
expect(data).toHaveProperty('title', 'DEV-1234 review');
});

it('GET /api/diff returns a JSON 500 on parse failure and does not poison subsequent requests', async () => {
const parser = parserInstances.at(-1);
parser?.parseDiff.mockClear();
Expand Down
2 changes: 2 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ interface ServerOptions {
diffMode?: DiffMode;
repoPath?: string;
contextLines?: number;
title?: string;
}

const GENERATED_STATUS_CACHE_TTL_MS = 60_000;
Expand Down Expand Up @@ -364,6 +365,7 @@ export async function startServer(
requestedBaseMode,
clearComments: options.clearComments,
repositoryId,
title: options.title,
commentImports: shouldIncludeCommentImports ? initialCommentImports : undefined,
commentImportId: shouldIncludeCommentImports ? commentImportId : undefined,
});
Expand Down
1 change: 1 addition & 0 deletions src/types/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface DiffResponse {
repositoryId?: string;
commentImports?: CommentImport[];
commentImportId?: string;
title?: string;
}

export interface GeneratedStatusResponse {
Expand Down