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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added commit history viewer to code browser. [#1150](https://github.com/sourcebot-dev/sourcebot/pull/1150)
- Added commit diff viewer to code browser. [#1154](https://github.com/sourcebot-dev/sourcebot/pull/1154)
- Added `/api/commits/authors` to the public API to allow fetching a list of authors for a given path and revision. [#1150](https://github.com/sourcebot-dev/sourcebot/pull/1150)
- Added optional `path` query parameter to the `/api/diff` endpoint and `get_diff` MCP tool to restrict diffs to changes touching a specific file. [#1154](https://github.com/sourcebot-dev/sourcebot/pull/1154)

### Fixed
- Bumped `postcss` to `8.5.10`. [#1155](https://github.com/sourcebot-dev/sourcebot/pull/1155)
Expand Down
10 changes: 10 additions & 0 deletions docs/api-reference/sourcebot-public.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,16 @@
"description": "The head git ref (branch, tag, or commit SHA) to diff to.",
"name": "head",
"in": "query"
},
{
"schema": {
"type": "string",
"description": "Restrict the diff to changes touching this file path. Omit to diff all changes between the two refs."
},
"required": false,
"description": "Restrict the diff to changes touching this file path. Omit to diff all changes between the two refs.",
"name": "path",
"in": "query"
}
],
"responses": {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ const options = {

DEBUG_WRITE_CHAT_MESSAGES_TO_FILE: booleanSchema.default('false'),
DEBUG_ENABLE_REACT_SCAN: booleanSchema.default('false'),
DEBUG_ENABLE_REACT_GRAB: booleanSchema.default('false'),

LANGFUSE_SECRET_KEY: z.string().optional(),

Expand Down
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@codemirror/language": "^6.0.0",
"@codemirror/language-data": "^6.5.1",
"@codemirror/legacy-modes": "^6.4.2",
"@codemirror/merge": "^6.12.1",
"@codemirror/search": "^6.5.6",
"@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.33.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import { getRepoInfoByName } from "@/actions";
import { PathHeader } from "@/app/(app)/components/pathHeader";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { cn, getCodeHostInfoForRepo, isServiceError } from "@/lib/utils";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn, getCodeHostInfoForRepo, isServiceError, truncateSha } from "@/lib/utils";
import { X } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { getBrowsePath } from "../../../hooks/utils";
import { PureCodePreviewPanel } from "./pureCodePreviewPanel";
import { getFileSource } from '@/features/git';

interface CodePreviewPanelProps {
path: string;
repoName: string;
revisionName?: string;
// When set, the file's content is fetched at this ref while the
// surrounding browse context (path header) stays at `revisionName`.
previewRef?: string;
}

export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePreviewPanelProps) => {
export const CodePreviewPanel = async ({ path, repoName, revisionName, previewRef }: CodePreviewPanelProps) => {
const contentRef = previewRef ?? revisionName;

const [fileSourceResponse, repoInfoResponse] = await Promise.all([
getFileSource({
path,
repo: repoName,
ref: revisionName,
ref: contentRef,
}, { source: 'sourcebot-web-client' }),
getRepoInfoByName(repoName),
]);
Expand Down Expand Up @@ -53,7 +63,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
displayName: repoInfoResponse.displayName,
externalWebUrl: repoInfoResponse.externalWebUrl,
}}
revisionName={revisionName}
revisionName={contentRef}
/>

{fileWebUrl && (
Expand All @@ -74,12 +84,54 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
)}
</div>
<Separator />
{previewRef && (
<div className="flex flex-row items-center justify-between gap-2 px-4 py-2 border-b shrink-0">

@softlight softlight Bot Jun 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Before/after suggested changes

'Previewing an older version' banner is indented from the file header

The banner shown when you preview a file at an older revision starts further in than the file path header directly above it, so its left edge looks misaligned with the rest of the view. Matching the edge lets the banner read as a calm, deliberate part of the page.

Prompt to fix with AI
This is a comment left during a design review.

Comment:
**'Previewing an older version' banner is indented from the file header**
The banner shown when you preview a file at an older revision starts further in than the file path header directly above it, so its left edge looks misaligned with the rest of the view. Matching the edge lets the banner read as a calm, deliberate part of the page.

Issue:
The 'Previewing file at revision' banner uses px-4 (16px) horizontal padding, while the PathHeader row directly above it uses py-1 px-2 (8px). The banner text starts 8px to the right of the file path header, so the banner's left edge is misaligned with the header it belongs under.

Suggested fix:
Change the preview banner's horizontal padding from px-4 to px-2 so its left edge matches the PathHeader row above it (py-1 px-2). Keep py-2.

Screenshots:
- Before: https://drive.orianna.ai/d7127273a17983df230b78c1b1dc18fa.png
- After: https://drive.orianna.ai/2c757e11f9176f52289e991cb15ac7dc.png
Use these screenshot URLs as visual evidence if your environment can open remote images.

How can I resolve this? Keep the fix scoped to the PR-touched UI and preserve existing design-system patterns.
Developer output
  • Crop source: goal crop locator
  • Before crop: x1=285, y1=44, x2=815, y2=150
  • After crop: x1=285, y1=44, x2=815, y2=150

Gridded crops

Before

Before gridded detail

After

After gridded detail

Full gridded screenshots

Before

Before full gridded screenshot

After

After full gridded screenshot

<span className="text-sm">
Previewing file at revision{" "}
<Link
href={getBrowsePath({
repoName,
revisionName,
path: '',
pathType: 'commit',
commitSha: previewRef,
})}
className="font-mono text-link hover:underline"
>
{truncateSha(previewRef)}
</Link>
</span>
<Tooltip key={previewRef}>
<TooltipTrigger>
<Button
asChild
variant="ghost"
size="icon"
className="h-6 w-6 text-muted-foreground"
>
<Link
href={getBrowsePath({
repoName,
revisionName,
path,
pathType: 'blob',
})}
aria-label="Close preview"
>
<X className="h-4 w-4" />
</Link>
</Button>
</TooltipTrigger>
<TooltipContent>Close preview</TooltipContent>
</Tooltip>
</div>
)}
<PureCodePreviewPanel
source={fileSourceResponse.source}
language={fileSourceResponse.language}
repoName={repoName}
path={path}
revisionName={revisionName ?? 'HEAD'}
revisionName={contentRef ?? 'HEAD'}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam";
import { search } from "@codemirror/search";
import CodeMirror, { EditorSelection, EditorView, ReactCodeMirrorRef, SelectionRange, ViewUpdate } from "@uiw/react-codemirror";
import { useEffect, useMemo, useState } from "react";
import { EditorContextMenu } from "../../../components/editorContextMenu";
import { BrowseHighlightRange, HIGHLIGHT_RANGE_QUERY_PARAM } from "../../hooks/utils";
import { EditorContextMenu } from "@/app/(app)/components/editorContextMenu";
import { BrowseHighlightRange, HIGHLIGHT_RANGE_QUERY_PARAM } from "@/app/(app)/browse/hooks/utils";
import { rangeHighlightingExtension } from "./rangeHighlightingExtension";

interface PureCodePreviewPanelProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { StateField, Range } from "@codemirror/state";
import { Decoration, DecorationSet, EditorView } from "@codemirror/view";
import { BrowseHighlightRange } from "../../hooks/utils";
import { BrowseHighlightRange } from "@/app/(app)/browse/hooks/utils";

const markDecoration = Decoration.mark({
class: "searchMatch-selected",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use client';

import { CopyIconButton } from "@/app/(app)/components/copyIconButton";
import { useToast } from "@/components/hooks/use-toast";
import Link from "next/link";
import { Fragment, useCallback } from "react";
import { getBrowsePath } from "../../../hooks/utils";

interface CommitHashLineProps {
repoName: string;
commitHash: string;
parents: string[];
}

export const CommitHashLine = ({ repoName, commitHash, parents }: CommitHashLineProps) => {
const { toast } = useToast();

const onCopyHash = useCallback(() => {
navigator.clipboard.writeText(commitHash).then(() => {
toast({ description: "✅ Copied commit SHA to clipboard" });
});
return true;
}, [commitHash, toast]);

return (
<div className="text-xs font-mono text-muted-foreground flex flex-row items-center gap-1">
{parents.length > 0 && (
<>
<span>
{parents.length} parent{parents.length > 1 ? 's' : ''}
</span>
{parents.map((parent, i) => (
<Fragment key={parent}>
{i > 0 && <span>+</span>}
<Link
href={getBrowsePath({
repoName,
path: '',
pathType: 'commit',
commitSha: parent,
})}
className="underline hover:text-foreground"
title={parent}
>
{parent.slice(0, 7)}
</Link>
</Fragment>
))}
</>
)}
<span>commit {commitHash.slice(0, 7)}</span>
<CopyIconButton onCopy={onCopyHash} />
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import { CommitBody, CommitBodyToggle } from "@/app/(app)/browse/components/commitParts";
import { useState } from "react";

interface CommitMessageProps {
subject: string;
body: string;
}

export const CommitMessage = ({ subject, body }: CommitMessageProps) => {
const [isBodyExpanded, setIsBodyExpanded] = useState(false);
const hasBody = body.trim().length > 0;

return (
<>
<div className="flex flex-row items-center gap-2">
<h1 className="text-lg font-semibold">{subject}</h1>
{hasBody && (
<CommitBodyToggle
pressed={isBodyExpanded}
onPressedChange={setIsBodyExpanded}
/>
)}
</div>
{hasBody && isBodyExpanded && (
<CommitBody body={body} className="rounded max-h-[40vh] overflow-y-auto" />

This comment was marked as outdated.

This comment was marked as outdated.

@softlight softlight Bot Jun 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Before/after suggested changes

Commit description sits too tight under its title

When you expand a commit's description, it butts right up against the title with no space between them, so the two run together as one dense block. A little breathing room lets the description read clearly as its own section.

Prompt to fix with AI
This is a comment left during a design review.

Comment:
**Commit description sits too tight under its title**
When you expand a commit's description, it butts right up against the title with no space between them, so the two run together as one dense block. A little breathing room lets the description read clearly as its own section.

Issue:
When the body is expanded, the CommitBody block renders as a direct sibling of the title row inside a plain (non-gap) container, so there is no vertical space between the commit subject and the description. The two sit flush, making the description feel crammed against the title rather than reading as its own block.

Suggested fix:
Add mt-2 to the expanded CommitBody in commitMessage.tsx so the description is separated from the title by the same 8px step used elsewhere in the header (gap-2).

Screenshots:
- Before: https://drive.orianna.ai/6207815f09ae80ad66b95a64a3246205.png
- After: https://drive.orianna.ai/58c757a3f9b3ed14ff012ac98fa7c104.png
Use these screenshot URLs as visual evidence if your environment can open remote images.

How can I resolve this? Keep the fix scoped to the PR-touched UI and preserve existing design-system patterns.
Developer output
  • Crop source: goal crop locator
  • Before crop: x1=300, y1=55, x2=880, y2=145
  • After crop: x1=300, y1=55, x2=880, y2=145

Gridded crops

Before

Before gridded detail

After

After gridded detail

Full gridded screenshots

Before

Before full gridded screenshot

After

After full gridded screenshot

)}
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { FileDiff } from "@/features/git";

const TOTAL_SQUARES = 5;

// Count `+`/`-` lines across all hunks in a file.
export const computeChangeCounts = (file: FileDiff) => {
let additions = 0;
let deletions = 0;
for (const hunk of file.hunks) {
for (const raw of hunk.body.split('\n')) {
if (raw.startsWith('+')) {
additions++;
} else if (raw.startsWith('-')) {
deletions++;
}
}
}
return { additions, deletions };
};

// Sum line-level change counts across multiple files.
export const computeTotalChangeCounts = (files: FileDiff[]) => {
let additions = 0;
let deletions = 0;
for (const file of files) {
const counts = computeChangeCounts(file);
additions += counts.additions;
deletions += counts.deletions;
}
return { additions, deletions };
};

// Map a total change count to a number of filled squares (0–5) using a
// log-ish scale so tiny diffs still show one square and huge diffs cap out.
// Mirrors GitHub's diffstat indicator behavior.
const filledSquaresForTotal = (total: number): number => {
if (total === 0) {
return 0;
}
if (total < 5) {
return 1;
}
if (total < 10) {
return 2;
}
if (total < 30) {
return 3;
}
if (total < 100) {
return 4;
}
return 5;
};

interface DiffStatProps {
additions: number;
deletions: number;
}

export const DiffStat = ({ additions, deletions }: DiffStatProps) => {
const total = additions + deletions;

// Skip rendering when there are no line-level changes (e.g. pure renames).
if (total === 0) {
return null;
}

const filled = filledSquaresForTotal(total);
const greenCount = Math.round((filled * additions) / total);
const redCount = filled - greenCount;
const emptyCount = TOTAL_SQUARES - filled;

return (
<div
className="flex flex-row items-center gap-2 text-xs flex-shrink-0 font-mono"
title={`${additions} additions, ${deletions} deletions`}
>
{additions > 0 && (
<span className="text-green-700 dark:text-green-400">+{additions}</span>
)}
{deletions > 0 && (
<span className="text-red-700 dark:text-red-400">-{deletions}</span>
)}
<div className="flex flex-row gap-px">
{Array.from({ length: greenCount }).map((_, i) => (
<span key={`g-${i}`} className="w-2 h-2 bg-green-500 dark:bg-green-400 rounded-[1px]" />
))}
{Array.from({ length: redCount }).map((_, i) => (
<span key={`r-${i}`} className="w-2 h-2 bg-red-500 dark:bg-red-400 rounded-[1px]" />
))}
{Array.from({ length: emptyCount }).map((_, i) => (
<span key={`e-${i}`} className="w-2 h-2 bg-border rounded-[1px]" />
))}
</div>
</div>
);
};
Loading