Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@
"deploy": "bun run scripts/deploy.ts"
},
"dependencies": {
"@mattstack/rt-client": "^0.3.0",
"@mattstack/rt-client": "^0.10.1",
"@mattstack/tui-kit": "file:../tui-kit",
"react": "19.2.8",
"react-dom": "19.2.8"
Expand Down
27 changes: 27 additions & 0 deletions src/api/dev-mode.test.ts
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
import { test, expect, beforeEach } from "bun:test";
import { mkdtempSync } from "fs";
import { tmpdir } from "os";
import { join } from "path";
import { setSetting } from "@mattstack/rt-client";
import { isDevMode, resetDevModeCache } from "./dev-mode.ts";

beforeEach(() => resetDevModeCache());
Expand All@@ -18,3 +22,26 @@ test("unset value is production (fail closed)", () => {
test("a throwing read is production (fail closed)", () => {
expect(isDevMode({ read: () => { throw new Error("no daemon"); } })).toBe(false);
});

// The real getSetting path (no injected read), which the cases above bypass.
// Regression guard for the rt-client bump: `mattstack.mode` must be a registered
// key, or getSetting throws unknownKey and the gate is stuck fail-closed to prod.
test("real rt-client path reads mattstack.mode from the store", () => {
const origHome = process.env.HOME;
process.env.HOME = mkdtempSync(join(tmpdir(), "devmode-real-"));
try {
resetDevModeCache();
expect(isDevMode()).toBe(false); // unset -> prod

setSetting("mattstack.mode", "prod", "machine");
resetDevModeCache();
expect(isDevMode()).toBe(false);

setSetting("mattstack.mode", "dev", "machine");
resetDevModeCache();
expect(isDevMode()).toBe(true);
} finally {
process.env.HOME = origHome;
resetDevModeCache();
}
});