From 4289796d20eb0388b17de0984cea8ea6cc1cccac Mon Sep 17 00:00:00 2001 From: mubeda <1380447+mubeda@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:06:12 -0300 Subject: [PATCH 01/16] fix(scripts): read the desktop bundle from CARGO_TARGET_DIR The wrapper looked for the bundle under the repository's own target folder, so a build with CARGO_TARGET_DIR set finished and then failed with TauriDesktopBuildDirectoryMissingError before copying the artifact. The bundle, the updater app and the symbol paths now come from one release folder that follows CARGO_TARGET_DIR. A relative value is rejected up front, because Cargo resolves it against its own working folder and the two could disagree. Closes #371 Co-Authored-By: Claude Fable 5.2 --- docs/reference/scripts.md | 3 +- scripts/build-desktop-artifact.test.ts | 48 ++++++++++++++++++++++++++ scripts/build-desktop-artifact.ts | 26 ++++++++------ 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/docs/reference/scripts.md b/docs/reference/scripts.md index fd4a04485..fbf5a93d1 100644 --- a/docs/reference/scripts.md +++ b/docs/reference/scripts.md @@ -165,7 +165,8 @@ PowerShell; on other platforms it exits 0 without doing anything. The wrapper, `scripts/build-desktop-artifact.ts`, rejects cross-platform builds by default, invokes the canonical `@bibcode/desktop` Tauri package, and copies bundle output under `release/desktop/-` unless an output -directory is supplied. It compiles with `tauri build --no-bundle` and then +directory is supplied. It reads the bundle from `target/`, or from +`CARGO_TARGET_DIR` when that is set, which must then be an absolute path. It compiles with `tauri build --no-bundle` and then packages that binary with `tauri bundle` (the desktop package's `build` and `bundle` scripts); the Tauri CLI's bundle step does not run Cargo. Each step runs with at most three attempts. Every failed attempt is reported with its exit diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts index 2f43f4481..8bcb82c3e 100644 --- a/scripts/build-desktop-artifact.test.ts +++ b/scripts/build-desktop-artifact.test.ts @@ -403,6 +403,54 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { }), ); + it.effect("looks for the bundle, the updater app and the symbols in CARGO_TARGET_DIR", () => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const repoRoot = yield* fs.makeTempDirectoryScoped({ prefix: "bibcode-build-target-dir-" }); + yield* fs.makeDirectory(path.join(repoRoot, "apps", "desktop"), { recursive: true }); + yield* fs.writeFileString( + path.join(repoRoot, "apps", "desktop", "package.json"), + JSON.stringify({ version: "1.2.3" }), + ); + const cargoTargetDir = path.resolve(repoRoot, "..", "shared-cargo-target"); + const release = path.join(cargoTargetDir, "aarch64-apple-darwin", "release"); + const plan = yield* resolveTauriBuildPlan( + { platform: "mac", target: "dmg", arch: "arm64", updater: true, symbols: true }, + { CARGO_TARGET_DIR: cargoTargetDir }, + { platform: "darwin", arch: "arm64" }, + repoRoot, + ); + + assert.equal(plan.bundleDir, path.join(release, "bundle", "dmg")); + assert.equal(plan.updaterBundleDir, path.join(release, "bundle", "macos")); + assert.equal(plan.symbols?.binary, path.join(release, "bibcode-desktop")); + + // An empty value means unset, as it does for Cargo. + const unset = yield* resolveTauriBuildPlan( + { platform: "mac", target: "dmg", arch: "arm64" }, + { CARGO_TARGET_DIR: "" }, + { platform: "darwin", arch: "arm64" }, + repoRoot, + ); + assert.equal( + unset.bundleDir, + path.join(repoRoot, "target", "aarch64-apple-darwin", "release", "bundle", "dmg"), + ); + + // Cargo resolves a relative value against its own working folder, which this wrapper + // does not control, so the two could disagree. + const error = yield* resolveTauriBuildPlan( + { platform: "mac", target: "dmg", arch: "arm64" }, + { CARGO_TARGET_DIR: "relative-target" }, + { platform: "darwin", arch: "arm64" }, + repoRoot, + ).pipe(Effect.flip); + assert.instanceOf(error, TauriDesktopBuildConfigurationError); + assert.include(error.message, "CARGO_TARGET_DIR must be an absolute path"); + }).pipe(Effect.provide(NodeServices.layer)), + ); + it.effect("copies Tauri bundle outputs into the artifact directory", () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index 84ac4dde9..33419db9e 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -136,7 +136,7 @@ export interface TauriBuildPlan { readonly verbose: boolean; /** `tauri build --no-bundle`: compiles the app. */ readonly buildCommand: SpawnPlan; - /** `tauri bundle`: packages the binary the build left in `target//release`. */ + /** `tauri bundle`: packages the binary the build left in `//release`. */ readonly bundleCommand: SpawnPlan; readonly symbols: TauriSymbolsPlan | undefined; } @@ -489,20 +489,27 @@ export const resolveTauriBuildPlan = Effect.fn("resolveTauriBuildPlan")(function path.join("release", "desktop", `${platform}-${arch}`), ); const bundleDirectoryName = target === "app" ? "macos" : target; - const bundleDir = path.join( - repoRoot, - "target", + // Cargo writes to CARGO_TARGET_DIR when it is set, so the bundle is there and not in `target`. + const cargoTargetDir = env.CARGO_TARGET_DIR || undefined; + if (cargoTargetDir !== undefined && !path.isAbsolute(cargoTargetDir)) { + return yield* Effect.fail( + new TauriDesktopBuildConfigurationError( + `CARGO_TARGET_DIR must be an absolute path, because Cargo resolves a relative one against its own working folder: ${cargoTargetDir}.`, + ), + ); + } + const releaseDir = path.join( + cargoTargetDir ?? path.join(repoRoot, "target"), rustTarget, "release", - "bundle", - bundleDirectoryName, ); + const bundleDir = path.join(releaseDir, "bundle", bundleDirectoryName); const updaterManifestTarget = updater ? yield* tryBuildConfiguration(() => resolveTauriUpdaterManifestTarget(platform, arch)) : undefined; const updaterBundleDir = updater && platform === "mac" && target === "dmg" - ? path.join(repoRoot, "target", rustTarget, "release", "bundle", "macos") + ? path.join(releaseDir, "bundle", "macos") : undefined; // The DMG bundler deletes the app it builds unless `app` is requested too. Updater builds // publish that app's archive, and symbol builds check the binary inside it. @@ -560,7 +567,7 @@ export const resolveTauriBuildPlan = Effect.fn("resolveTauriBuildPlan")(function buildCommand: tauriCommand("build"), bundleCommand: tauriCommand("bundle"), symbols: - input.symbols === true ? yield* planSymbols(platform, arch, rustTarget, repoRoot) : undefined, + input.symbols === true ? yield* planSymbols(platform, arch, releaseDir, repoRoot) : undefined, }; }); @@ -571,7 +578,7 @@ const decodeDesktopPackageVersion = Schema.decodeEffect( const planSymbols = Effect.fn("planTauriSymbols")(function* ( platform: TauriBuildPlatform, arch: TauriBuildArch, - rustTarget: string, + release: string, repoRoot: string, ) { const fs = yield* FileSystem.FileSystem; @@ -580,7 +587,6 @@ const planSymbols = Effect.fn("planTauriSymbols")(function* ( const { version } = yield* fs .readFileString(path.join(repoRoot, "apps", "desktop", "package.json")) .pipe(Effect.flatMap(decodeDesktopPackageVersion)); - const release = path.join(repoRoot, "target", rustTarget, "release"); // Tauri ships the binary under Cargo's name (no mainBinaryName override). const binary = path.join(release, platform === "win" ? "bibcode-desktop.exe" : "bibcode-desktop"); const archive = path.join( From 1bd80b7a60c4c574644e7db3497c516200f44537 Mon Sep 17 00:00:00 2001 From: mubeda <1380447+mubeda@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:07:37 -0300 Subject: [PATCH 02/16] feat(web): show Source Control's Review as a labelled primary button The review control was a 24 px ghost icon with no visible text, so it was easy to miss. It now shows "Review" with a bot icon in the size and color of Stage All. The action, the tooltip, the accessible name and the dimmed disabled state are unchanged. Closes #375 Co-Authored-By: Claude Fable 5.2 --- .../e2e/specs/source-control-review.e2e.ts | 26 ++++++++++++++ .../components/SourceControlPanel.test.tsx | 34 +++++++++++++++++++ .../web/src/components/SourceControlPanel.tsx | 8 ++--- docs/user/workspace-ui.md | 2 +- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/apps/desktop/e2e/specs/source-control-review.e2e.ts b/apps/desktop/e2e/specs/source-control-review.e2e.ts index 7b84ea4f9..272e5a6ba 100644 --- a/apps/desktop/e2e/specs/source-control-review.e2e.ts +++ b/apps/desktop/e2e/specs/source-control-review.e2e.ts @@ -248,6 +248,32 @@ describe("packaged Source Control review", () => { modifyTrackedFile(); await openSourceControl(); + // #375: at a narrow window the button keeps its whole "Review" label and is as tall as + // Stage All. + await setDesktopUiWindowSize(960, 900); + const reviewLayout = await browser.execute(() => { + const review = document.querySelector('button[aria-label="Review changes"]'); + const stageAll = [...document.querySelectorAll("button")].find((button) => + button.textContent?.startsWith("Stage All Changes"), + ); + const panel = review?.closest(".surface-subheader"); + if (!review || !stageAll || !panel) return null; + const bounds = review.getBoundingClientRect(); + return { + text: review.textContent?.trim(), + clipped: review.scrollWidth > review.clientWidth, + insideHeader: bounds.right <= panel.getBoundingClientRect().right, + height: bounds.height, + stageAllHeight: stageAll.getBoundingClientRect().height, + }; + }); + expect(reviewLayout).toMatchObject({ text: "Review", clipped: false, insideHeader: true }); + expect(reviewLayout!.height).toBeGreaterThanOrEqual(reviewLayout!.stageAllHeight); + await browser.saveScreenshot( + NodePath.join(preparedArtifactDirectory, "review-button-narrow.png"), + ); + await setDesktopUiWindowSize(1_280, 900); + const baseline = readProviderInputLog(preparedProviderInputLogPath).length; // The saved reviewer is the default, chat Codex. await browser.$('button[aria-label="Review changes"]').click(); diff --git a/apps/web/src/components/SourceControlPanel.test.tsx b/apps/web/src/components/SourceControlPanel.test.tsx index 0abe752ea..9b203a7f5 100644 --- a/apps/web/src/components/SourceControlPanel.test.tsx +++ b/apps/web/src/components/SourceControlPanel.test.tsx @@ -150,6 +150,8 @@ interface CapturedButtonProps { "aria-label"?: string; "aria-pressed"?: boolean; className?: string; + size?: string; + variant?: string; } interface CapturedMenuItemProps { @@ -1147,6 +1149,38 @@ describe("SourceControlPanel", () => { match[1]!.replaceAll("'", "'"), ); + it("is a labelled button with Stage All's size and color and a bot icon (#375)", () => { + testState.statusQuery.data = stagingStatus({ + refName: "main", + isDefaultRef: true, + defaultRefName: "main", + aheadOfDefaultCount: 0, + hasWorkingTreeChanges: true, + workingTree: { files: [UNSTAGED_FILE], insertions: 1, deletions: 0 }, + }); + const onStart = vi.fn(); + const markup = render(reviewProps(null, onStart)); + const review = reviewButton()!; + const stageAll = buttonsByText("Stage All Changes (1)")[0]!; + + expect(flattenText(review.children)).toBe("Review"); + expect(review.size).toBe("sm"); + expect(review.size).toBe(stageAll.size); + expect(review.variant).toBe(stageAll.variant); + expect(markup).toMatch(/]*lucide-bot[^>]*aria-hidden="true"/); + + review.onClick!(); + expect(onStart).toHaveBeenCalledTimes(1); + expect(testState.runStage).not.toHaveBeenCalled(); + }); + + it("stays dimmed while disabled, so it does not look like an enabled Stage All (#375)", () => { + testState.statusQuery.data = status(); + render(reviewProps()); + expect((reviewButton() as Record)["aria-disabled"]).toBe(true); + expect(reviewButton()!.className).toContain("opacity-64"); + }); + it("is absent without a review handler", () => { render(buildProps()); expect(reviewButton()).toBeUndefined(); diff --git a/apps/web/src/components/SourceControlPanel.tsx b/apps/web/src/components/SourceControlPanel.tsx index d38336dcc..fdeaa25d8 100644 --- a/apps/web/src/components/SourceControlPanel.tsx +++ b/apps/web/src/components/SourceControlPanel.tsx @@ -23,6 +23,7 @@ import { useAtomValue } from "@effect/atom-react"; import * as Cause from "effect/Cause"; import * as Schema from "effect/Schema"; import { + BotIcon, ChevronDownIcon, CloudUploadIcon, DownloadIcon, @@ -30,7 +31,6 @@ import { GitCommitIcon, ListChecksIcon, ListIcon, - ScanSearchIcon, SparklesIcon, SquareIcon, Undo2Icon, @@ -1168,8 +1168,7 @@ export default function SourceControlPanel({ aria-disabled={codeReviewButton.disabled} aria-label="Review changes" className={cn("ml-auto shrink-0", codeReviewButton.disabled && "opacity-64")} - size="icon-xs" - variant="ghost" + size="sm" onClick={() => { if (!codeReviewButton.disabled && codeReviewScope) { codeReview.onStart(codeReviewScope); @@ -1178,7 +1177,8 @@ export default function SourceControlPanel({ /> } > -