Fix test corrupting production sessions.json

The test 'falls back to most recent session when no to is provided' was
using resolveStorePath() which returns the real ~/.warelay/sessions.json.
This overwrote production session data with test values, causing session
fragmentation issues.

Changed to use a temp directory like other tests.
This commit is contained in:
Peter Steinberger
2025-12-02 05:54:31 +00:00
parent c5ab442f46
commit d107b79c63
5 changed files with 412 additions and 38 deletions

View File

@@ -259,8 +259,11 @@ export async function runCommandReply(
console.error(
`Command auto-reply exited with code ${code ?? "unknown"} (signal: ${signal ?? "none"})`,
);
// Include any partial output or stderr in error message
const partialOut = trimmed ? `\n\nOutput: ${trimmed.slice(0, 500)}${trimmed.length > 500 ? "..." : ""}` : "";
const errorText = `⚠️ Command exited with code ${code ?? "unknown"}${signal ? ` (${signal})` : ""}${partialOut}`;
return {
payload: undefined,
payload: { text: errorText },
meta: {
durationMs: Date.now() - started,
queuedMs,
@@ -278,8 +281,9 @@ export async function runCommandReply(
console.error(
`Command auto-reply process killed before completion (exit code ${code ?? "unknown"})`,
);
const errorText = `⚠️ Command was killed before completion (exit code ${code ?? "unknown"})`;
return {
payload: undefined,
payload: { text: errorText },
meta: {
durationMs: Date.now() - started,
queuedMs,
@@ -379,8 +383,11 @@ export async function runCommandReply(
};
}
logError(`Command auto-reply failed after ${elapsed}ms: ${String(err)}`);
// Send error message to user so they know the command failed
const errMsg = err instanceof Error ? err.message : String(err);
const errorText = `⚠️ Command failed: ${errMsg}`;
return {
payload: undefined,
payload: { text: errorText },
meta: {
durationMs: elapsed,
queuedMs,