Skip to content

Commit d238d86

Browse files
committed
fix: hide token in Python example until editor is focused
1 parent 6c4e8b1 commit d238d86

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

frontend/src/pages/RequestsPage.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function RequestsPage() {
4949
const sharedRequest = useUiStore((s) => s.sharedRequest);
5050

5151
const [copied, setCopied] = useState(false);
52+
const [editorFocused, setEditorFocused] = useState(false);
5253

5354
// Use shared request if available, otherwise find from session requests
5455
const selectedRequest =
@@ -165,9 +166,19 @@ export function RequestsPage() {
165166
theme={resolvedTheme === "dark" ? "vs-dark" : "light"}
166167
value={PYTHON_EXAMPLE.replace(
167168
/TOKEN_HERE/g,
168-
session?.token || "<your_token>",
169+
session?.token
170+
? editorFocused
171+
? session.token
172+
: "********************************"
173+
: "<your_token>",
169174
).replace(/SUBDOMAIN_HERE/g, subdomain)}
170-
loading={<div className="p-4 text-default-500">Loading editor...</div>}
175+
loading={
176+
<div className="p-4 text-default-500">Loading editor...</div>
177+
}
178+
onMount={(editor) => {
179+
editor.onDidFocusEditorText(() => setEditorFocused(true));
180+
editor.onDidBlurEditorText(() => setEditorFocused(false));
181+
}}
171182
options={{
172183
readOnly: true,
173184
minimap: { enabled: false },

frontend/src/pages/ResponseEditorPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ export function ResponseEditorPage() {
358358
theme={resolvedTheme === "dark" ? "vs-dark" : "light"}
359359
value={content}
360360
onChange={(value) => setContent(value ?? "")}
361-
loading={<div className="p-4 text-default-500">Loading editor...</div>}
361+
loading={
362+
<div className="p-4 text-default-500">Loading editor...</div>
363+
}
362364
options={{
363365
minimap: { enabled: false },
364366
fontSize: 13,

0 commit comments

Comments
 (0)