Skip to content

feat(code): Aligning review page for local and cloud#1829

Open
VojtechBartos wants to merge 2 commits intomainfrom
vojtab/sandbox-git-commands
Open

feat(code): Aligning review page for local and cloud#1829
VojtechBartos wants to merge 2 commits intomainfrom
vojtab/sandbox-git-commands

Conversation

@VojtechBartos
Copy link
Copy Markdown
Member

The idea

The desktop already talks to cloud sandboxes through POST /command on the agent server (proxied via the PostHog API).

We extend this with git/* and fs/* commands that query the sandbox's real git state — diffs, changed files, branches, file content — bypassing the agent session entirely. No new endpoints, no new auth. The sandbox commands return the same shapes as local tRPC git queries, so the desktop can use the same UI for both.

Desktop ── POST /command { method: "git/diff_stats" } ──▶ PostHog API ──▶ Sandbox
Desktop ◀── { filesChanged: 2, linesAdded: 15, … } ─────────────────────┘

What changed

Agent server — 13 new commands (git/changed_files, git/diff_cached, git/diff_unstaged, git/diff_stats, git/current_branch, git/file_at_head, git/stage_files, git/unstage_files, git/discard_file, git/sync_status, git/repo_info, git/diff_head, fs/read_file) with Zod validation, path traversal protection, and 28 tests.

Desktop app — A ReviewGitProvider context abstracts the transport. Components call useReviewGit() and get diffs, stats, and file content without knowing whether the task is local or cloud. ReviewPage and CloudReviewPage are merged into a single component. DiffStatsBadge works for both execution types.

PostHog backendSerializer allowlist and param validation updated to proxy the new commands.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/agent/src/server/schemas.test.ts
Line: 241-256

Comment:
**Prefer `it.each` over a `for` loop inside a single test**

A `for` loop inside one `it` block collapses all five assertions into a single test result, hiding which status value fails. Prefer a parameterised test:

```suggestion
    it.each(["modified", "added", "deleted", "renamed", "untracked"])(
      "accepts git/discard_file with status %s",
      (status) => {
        expect(
          validateCommandParams("git/discard_file", {
            filePath: "test.ts",
            fileStatus: status,
          }).success,
        ).toBe(true);
      },
    );
```

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

---

This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/hooks/useSandboxGit.ts
Line: 128-135

Comment:
**`method` cast loses type safety**

`sendSandboxCommand` accepts `method: string` and then passes it as `method as "git/changed_files"` to the mutate call. This silently bypasses the literal-union validation enforced by `sendCommandInput`, so a caller that passes a typo'd or unknown method name won't get a TypeScript error. Typing the parameter as `SandboxCommandMethod` (already exported from `schemas.ts`) would let the compiler catch mismatches at call sites.

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

Reviews (1): Last reviewed commit: "feat(code): unified ReviewPage with Revi..." | Re-trigger Greptile

Comment on lines +241 to +256
it("accepts git/discard_file with valid status", () => {
for (const status of [
"modified",
"added",
"deleted",
"renamed",
"untracked",
]) {
expect(
validateCommandParams("git/discard_file", {
filePath: "test.ts",
fileStatus: status,
}).success,
).toBe(true);
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Prefer it.each over a for loop inside a single test

A for loop inside one it block collapses all five assertions into a single test result, hiding which status value fails. Prefer a parameterised test:

Suggested change
it("accepts git/discard_file with valid status", () => {
for (const status of [
"modified",
"added",
"deleted",
"renamed",
"untracked",
]) {
expect(
validateCommandParams("git/discard_file", {
filePath: "test.ts",
fileStatus: status,
}).success,
).toBe(true);
}
});
it.each(["modified", "added", "deleted", "renamed", "untracked"])(
"accepts git/discard_file with status %s",
(status) => {
expect(
validateCommandParams("git/discard_file", {
filePath: "test.ts",
fileStatus: status,
}).success,
).toBe(true);
},
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/server/schemas.test.ts
Line: 241-256

Comment:
**Prefer `it.each` over a `for` loop inside a single test**

A `for` loop inside one `it` block collapses all five assertions into a single test result, hiding which status value fails. Prefer a parameterised test:

```suggestion
    it.each(["modified", "added", "deleted", "renamed", "untracked"])(
      "accepts git/discard_file with status %s",
      (status) => {
        expect(
          validateCommandParams("git/discard_file", {
            filePath: "test.ts",
            fileStatus: status,
          }).success,
        ).toBe(true);
      },
    );
```

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

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +128 to +135
export function useSandboxDiffUnstaged(
taskId: string | undefined,
options?: { enabled?: boolean; ignoreWhitespace?: boolean },
) {
const ctx = useCloudCommandContext(taskId);

return useQuery<string>({
queryKey: [
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 method cast loses type safety

sendSandboxCommand accepts method: string and then passes it as method as "git/changed_files" to the mutate call. This silently bypasses the literal-union validation enforced by sendCommandInput, so a caller that passes a typo'd or unknown method name won't get a TypeScript error. Typing the parameter as SandboxCommandMethod (already exported from schemas.ts) would let the compiler catch mismatches at call sites.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/code-review/hooks/useSandboxGit.ts
Line: 128-135

Comment:
**`method` cast loses type safety**

`sendSandboxCommand` accepts `method: string` and then passes it as `method as "git/changed_files"` to the mutate call. This silently bypasses the literal-union validation enforced by `sendCommandInput`, so a caller that passes a typo'd or unknown method name won't get a TypeScript error. Typing the parameter as `SandboxCommandMethod` (already exported from `schemas.ts`) would let the compiler catch mismatches at call sites.

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

@VojtechBartos VojtechBartos changed the title chore(code): show live diffs during cloud runs before PR exists feat(code): Aligning review page for local and cloud Apr 22, 2026
@VojtechBartos VojtechBartos force-pushed the vojtab/sandbox-git-commands branch from 3522138 to 4544d7b Compare April 22, 2026 12:24
@VojtechBartos VojtechBartos requested a review from a team April 22, 2026 12:29
@adboio adboio self-requested a review April 22, 2026 14:55
Copy link
Copy Markdown
Contributor

adboio commented Apr 23, 2026

yo yo i think this looks good to me - fixing merge conflicts rn and i'll stack on top with some of my work!

@VojtechBartos
Copy link
Copy Markdown
Member Author

@adboio when you plan to get this stuff out, before or after beta release?

@tatoalo any thought about the commands?

@adboio adboio force-pushed the vojtab/sandbox-git-commands branch from 4544d7b to 7fb7b59 Compare April 23, 2026 13:24
Copy link
Copy Markdown
Contributor

adboio commented Apr 23, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

adboio commented Apr 23, 2026

@VojtechBartos today i'm working on bringing some of the PR actions we have for cloud over to local tasks and ideally those go out before beta release

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.

2 participants