Skip to content

Commit 15824bc

Browse files
committed
address review: fail fast on missing sidecar, bound stderr buffer
1 parent 0e4d227 commit 15824bc

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

desktop/src-tauri/build.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,26 @@ fn main() {
7373
.unwrap_or_else(|_| "x86_64-pc-windows-msvc".to_string());
7474
let src =
7575
std::path::Path::new(&manifest_dir).join(format!("binaries/spacebot-{triple}.exe"));
76-
let needs_copy = src.exists()
77-
&& (!dest.exists()
78-
|| src.metadata().and_then(|s| s.modified()).ok()
79-
> dest.metadata().and_then(|d| d.modified()).ok());
76+
if !src.exists() {
77+
panic!(
78+
"sidecar binary not found at {}. Build the server first \
79+
(`cargo build -p spacebot`) then copy it to binaries/.",
80+
src.display()
81+
);
82+
}
83+
84+
let needs_copy = !dest.exists()
85+
|| src.metadata().and_then(|s| s.modified()).ok()
86+
> dest.metadata().and_then(|d| d.modified()).ok();
8087
if needs_copy {
8188
println!("cargo:warning=Copying sidecar to {}", dest.display());
82-
let _ = std::fs::copy(&src, &dest);
89+
std::fs::copy(&src, &dest).unwrap_or_else(|error| {
90+
panic!(
91+
"failed to copy sidecar from {} to {}: {error}",
92+
src.display(),
93+
dest.display()
94+
)
95+
});
8396
}
8497
println!("cargo:rerun-if-changed={}", src.display());
8598
}

interface/src/components/ConnectionScreen.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function ConnectionScreen() {
5757
if (!sawReady || data.code === null || data.code !== 0) {
5858
const stderr =
5959
stderrLines.length > 0
60-
? `\n\nstderr:\n${stderrLines.slice(-20).join("\n")}`
60+
? `\n\nstderr:\n${stderrLines.join("\n")}`
6161
: "";
6262
setSidecarState("error");
6363
setSidecarError(
@@ -82,6 +82,9 @@ export function ConnectionScreen() {
8282
onStderr: (line) => {
8383
console.log("[sidecar stderr]", line);
8484
stderrLines.push(line);
85+
if (stderrLines.length > 20) {
86+
stderrLines.splice(0, stderrLines.length - 20);
87+
}
8588
},
8689
},
8790
);
@@ -204,7 +207,9 @@ export function ConnectionScreen() {
204207
)}
205208

206209
{sidecarState === "error" && sidecarError && (
207-
<p className="text-xs text-red-400">{sidecarError}</p>
210+
<p className="whitespace-pre-wrap text-xs text-red-400">
211+
{sidecarError}
212+
</p>
208213
)}
209214
</div>
210215
</>

0 commit comments

Comments
 (0)