Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ide): link only commits GitHub has from a folded-open branch

rubenluetke10-beep92143ce72a57
diff --git a/jarvis/agentic_ide/branch_contents.py b/jarvis/agentic_ide/branch_contents.py
index ade0e75942..c5e1688a15 100644
--- a/jarvis/agentic_ide/branch_contents.py
+++ b/jarvis/agentic_ide/branch_contents.py
@@ -33,6 +33,9 @@ class BranchCommit:
subject: str
author: str
committed_at: int
+ #: Reachable from an ``origin/*`` ref this clone knows, so GitHub can show it.
+ #: False for commits only on this computer: a GitHub link would be a 404.
+ on_github: bool = False
@dataclass(slots=True)
@@ -91,7 +94,16 @@ def _short(ref: str) -> str:
return ref.removeprefix("refs/heads/").removeprefix("refs/remotes/")
-def _commits(root: Path, spec: str) -> tuple[list[BranchCommit], bool]:
+def _local_only(root: Path, ref: str) -> set[str]:
+ """Commits of ``ref`` that no ``origin/*`` ref contains (full SHAs)."""
+ result = _git(["rev-list", "--max-count=5000", ref, "--not", "--remotes=origin"], root)
+ if result is None or result.returncode != 0:
+ return set()
+ return {line.strip() for line in result.stdout.splitlines() if line.strip()}
+
+
+def _commits(root: Path, spec: str, ref: str) -> tuple[list[BranchCommit], bool]:
+ local_only = _local_only(root, ref)
result = _git(
[
"log",
@@ -114,6 +126,7 @@ def _commits(root: Path, spec: str) -> tuple[list[BranchCommit], bool]:
subject=subject,
author=author,
committed_at=int(stamp) if stamp.isdigit() else 0,
+ on_github=sha not in local_only,
)
)
return commits[:MAX_COMMITS], len(commits) > MAX_COMMITS
@@ -169,10 +182,10 @@ def branch_contents(
base = _base_ref(root, default_branch)
if base is None or _short(base) in {branch, f"origin/{branch}"}:
# The default branch itself (or no base at all): its latest commits.
- out.commits, out.commits_truncated = _commits(root, ref)
+ out.commits, out.commits_truncated = _commits(root, ref, ref)
return out
out.base = _short(base)
- out.commits, out.commits_truncated = _commits(root, f"{base}..{ref}")
+ out.commits, out.commits_truncated = _commits(root, f"{base}..{ref}", ref)
out.files, out.files_truncated = _files(root, f"{base}...{ref}")
return out
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
index aa04d0309a..0f1b6fb45c 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.test.tsx
@@ -99,8 +99,8 @@ const CONTENTS = {
branch: "feature/wip",
base: "origin/main",
commits: [
- { sha: "aaaaaaaaaaaa", subject: "Add the widget", author: "Ada", committed_at: 1_790_000_000 },
- { sha: "bbbbbbbbbbbb", subject: "Start the widget", author: "Ada", committed_at: 1_789_000_000 },
+ { sha: "aaaaaaaaaaaa", subject: "Add the widget", author: "Ada", committed_at: 1_790_000_000, on_github: false },
+ { sha: "bbbbbbbbbbbb", subject: "Start the widget", author: "Ada", committed_at: 1_789_000_000, on_github: true },
],
commits_truncated: false,
files: [
@@ -373,6 +373,12 @@ describe("GitOverviewTab", () => {
expect(within(local).queryByTestId("git-open-github")).toBeNull();
// The branch is readable in place: its commits and files, each file's diff one click away.
+ // A commit only on this computer gets no GitHub link (that page would be a 404).
+ const commit = (sha: string) => within(details).getAllByTestId("git-branch-commit").find((el) => el.dataset.sha === sha)!;
+ expect(within(commit("aaaaaaaaaaaa")).queryByTestId("git-commit-link")).toBeNull();
+ expect(within(commit("aaaaaaaaaaaa")).getByTestId("git-commit-local")).toBeTruthy();
+ fireEvent.click(within(commit("bbbbbbbbbbbb")).getByTestId("git-commit-link"));
+ expect(openExternalUrl).toHaveBeenCalledWith("https://github.com/o/r/commit/bbbbbbbbbbbb");
expect(within(details).getByTestId("git-branch-commits").textContent).toContain("Add the widget");
expect(within(details).getByTestId("git-branch-commits").textContent).toContain("2 commits not in origin/main");
const file = within(details).getAllByTestId("git-branch-file").find((el) => el.dataset.path === "src/widget.ts")!;
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
index 4dc19959bc..7706266dcb 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/GitOverviewTab.tsx
@@ -593,17 +593,24 @@ function BranchDetails({
) : (
<ol className="space-y-0.5">
{contents.commits.map((commit) => (
- <li key={commit.sha} className="flex min-w-0 items-baseline gap-2">
- {url ? (
+ <li key={commit.sha} data-testid="git-branch-commit" data-sha={commit.sha} className="flex min-w-0 items-baseline gap-2">
+ {/* Only a commit GitHub has gets a link; one still only here would open a 404. */}
+ {repoUrl && commit.on_github ? (
<button
type="button"
+ data-testid="git-commit-link"
onClick={() => void openExternalUrl(`${repoUrl}/commit/${encodeURIComponent(commit.sha)}`)}
className="shrink-0 font-mono text-[10.5px] text-info hover:underline"
>
{commit.sha.slice(0, 7)}
</button>
) : (
- <span className="shrink-0 font-mono text-[10.5px] text-muted-foreground">{commit.sha.slice(0, 7)}</span>
+ <QuickTooltip content={t("ide_side_panel.git.local_only_tip")} side="bottom" className="inline-flex shrink-0">
+ <span data-testid="git-commit-local" className="inline-flex items-center gap-1 font-mono text-[10.5px] text-warning">
+ <Laptop className="h-3 w-3" aria-hidden />
+ {commit.sha.slice(0, 7)}
+ </span>
+ </QuickTooltip>
)}
<QuickTooltip content={`${commit.subject}\n${commit.author} · ${dateOf(commit.committed_at)}`} side="bottom" className="flex min-w-0 flex-1">
<span className="truncate text-foreground">{commit.subject}</span>
diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitOverviewApi.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitOverviewApi.ts
index 6d5ef6c51e..b5b4605552 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitOverviewApi.ts
+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/git/gitOverviewApi.ts
@@ -187,6 +187,8 @@ export interface BranchCommit {
subject: string;
author: string;
committed_at: number;
+ /** GitHub has this commit; false while it exists only on this computer. */
+ on_github: boolean;
}
export interface BranchFile {
diff --git a/tests/unit/agentic_ide/test_branch_contents.py b/tests/unit/agentic_ide/test_branch_contents.py
index 8fc82ff0cd..424a8a7197 100644
--- a/tests/unit/agentic_ide/test_branch_contents.py
+++ b/tests/unit/agentic_ide/test_branch_contents.py
@@ -75,6 +75,17 @@ def test_the_default_branch_shows_its_latest_commits(repo: Path) -> None:
assert contents.files == []
+@needs_git
+def test_only_commits_github_has_are_marked_linkable(repo: Path) -> None:
+ # origin knows main up to "start"; "main work" exists only on this computer.
+ _git(repo, "update-ref", "refs/remotes/origin/main", "main~1")
+ contents = branch_contents(repo, "main", "main")
+ assert [(c.subject, c.on_github) for c in contents.commits] == [
+ ("main work", False),
+ ("start", True),
+ ]
+
+
@needs_git
def test_a_file_diff_shows_the_branch_change(repo: Path) -> None:
diff = branch_file_diff(repo, "feature/x", "main", "a.txt")