Fix PAP-576 settings toggles and transcript default
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
30
ui/src/adapters/transcript.test.ts
Normal file
30
ui/src/adapters/transcript.test.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { buildTranscript, type RunLogChunk } from "./transcript";
|
||||||
|
|
||||||
|
describe("buildTranscript", () => {
|
||||||
|
const ts = "2026-03-20T13:00:00.000Z";
|
||||||
|
const chunks: RunLogChunk[] = [
|
||||||
|
{ ts, stream: "stdout", chunk: "opened /Users/dotta/project\n" },
|
||||||
|
{ ts, stream: "stderr", chunk: "stderr /Users/dotta/project" },
|
||||||
|
];
|
||||||
|
|
||||||
|
it("defaults username censoring to off when options are omitted", () => {
|
||||||
|
const entries = buildTranscript(chunks, (line, entryTs) => [{ kind: "stdout", ts: entryTs, text: line }]);
|
||||||
|
|
||||||
|
expect(entries).toEqual([
|
||||||
|
{ kind: "stdout", ts, text: "opened /Users/dotta/project" },
|
||||||
|
{ kind: "stderr", ts, text: "stderr /Users/dotta/project" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("still redacts usernames when explicitly enabled", () => {
|
||||||
|
const entries = buildTranscript(chunks, (line, entryTs) => [{ kind: "stdout", ts: entryTs, text: line }], {
|
||||||
|
censorUsernameInLogs: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(entries).toEqual([
|
||||||
|
{ kind: "stdout", ts, text: "opened /Users/d****/project" },
|
||||||
|
{ kind: "stderr", ts, text: "stderr /Users/d****/project" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -29,7 +29,7 @@ export function buildTranscript(
|
|||||||
): TranscriptEntry[] {
|
): TranscriptEntry[] {
|
||||||
const entries: TranscriptEntry[] = [];
|
const entries: TranscriptEntry[] = [];
|
||||||
let stdoutBuffer = "";
|
let stdoutBuffer = "";
|
||||||
const redactionOptions = { enabled: opts?.censorUsernameInLogs ?? true };
|
const redactionOptions = { enabled: opts?.censorUsernameInLogs ?? false };
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
if (chunk.stream === "stderr") {
|
if (chunk.stream === "stderr") {
|
||||||
|
|||||||
@@ -83,15 +83,15 @@ export function InstanceExperimentalSettings() {
|
|||||||
aria-label="Toggle isolated workspaces experimental setting"
|
aria-label="Toggle isolated workspaces experimental setting"
|
||||||
disabled={toggleMutation.isPending}
|
disabled={toggleMutation.isPending}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60",
|
"relative inline-flex h-5 w-9 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60",
|
||||||
enableIsolatedWorkspaces ? "bg-green-600" : "bg-muted",
|
enableIsolatedWorkspaces ? "bg-green-600" : "bg-muted",
|
||||||
)}
|
)}
|
||||||
onClick={() => toggleMutation.mutate(!enableIsolatedWorkspaces)}
|
onClick={() => toggleMutation.mutate(!enableIsolatedWorkspaces)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-block h-4.5 w-4.5 rounded-full bg-white transition-transform",
|
"inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",
|
||||||
enableIsolatedWorkspaces ? "translate-x-6" : "translate-x-0.5",
|
enableIsolatedWorkspaces ? "translate-x-4.5" : "translate-x-0.5",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -82,15 +82,15 @@ export function InstanceGeneralSettings() {
|
|||||||
aria-label="Toggle username log censoring"
|
aria-label="Toggle username log censoring"
|
||||||
disabled={toggleMutation.isPending}
|
disabled={toggleMutation.isPending}
|
||||||
className={cn(
|
className={cn(
|
||||||
"relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60",
|
"relative inline-flex h-5 w-9 items-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-60",
|
||||||
censorUsernameInLogs ? "bg-green-600" : "bg-muted",
|
censorUsernameInLogs ? "bg-green-600" : "bg-muted",
|
||||||
)}
|
)}
|
||||||
onClick={() => toggleMutation.mutate(!censorUsernameInLogs)}
|
onClick={() => toggleMutation.mutate(!censorUsernameInLogs)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-block h-4.5 w-4.5 rounded-full bg-white transition-transform",
|
"inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform",
|
||||||
censorUsernameInLogs ? "translate-x-6" : "translate-x-0.5",
|
censorUsernameInLogs ? "translate-x-4.5" : "translate-x-0.5",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user