Add a variables screen - #367
Open
andreisuslov wants to merge 1 commit into
Open
Conversation
Refs darrenburns#279. Posting resolves $VARIABLES into requests, but there is no way to see what is currently defined without opening the .env file, and no way at all to see variables a script set through set_variable, which exist only in memory. This adds a screen listing every variable a request can resolve, with its value and where it came from, and lets you change them from there. ctrl+p -> "variables: Show variables", or ctrl+shift+v / filter e edit value a add variable s show secrets d revert override c copy value u undo ctrl+r redo $ copy $NAME Source column. A session variable hides an environment file variable of the same name. Nothing surfaces that today, so a value that looks stale gives you no way to tell which one you are reading. Edits are session only. Environment files are never written to, which keeps the behaviour the same as set_variable and avoids two problems that would need solving first: load_variables flattens provenance, so with several --env files there is no way to know which one an edit belongs to, and rewriting a dotenv file does not reliably preserve comments. Reverting an override reloads the files and re-overlays the rest of the session, the same way the file watcher already does. Masking. Values whose names contain secret, password, token or api_key are masked until you press 's', so opening the screen during a screen share does not put a token on the wall. The mask is a fixed width, so it does not leak the length either, and copy always copies the real value. Undo history lives on the app beside session_env, so closing and reopening the screen keeps it. It is capped at 50 entries. Renaming is not offered: it would break every request that still referenced the old name, and nothing would report it until the next send. The three command palette snapshots change because the palette now lists one more entry.
Author
|
@darrenburns Sir, any chance you could look into that? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #279.
Posting resolves
$VARIABLESinto requests, but there is no way to see what is currently defined without opening the.envfile, and no way at all to see variables a script set throughset_variable, since those exist only in memory.This adds a screen that lists every variable a request can resolve, shows where each one came from, and lets you change them without dropping into a post-response script.
Open it with
ctrl+p->variables: Show variables, orctrl+shift+v./eadsc$$NAMEu/ctrl+rNotes on the design
Source column. A session variable hides an environment file variable of the same name. Nothing surfaces that today, so a value that looks stale gives you no way to tell which one you are reading. Each row says
sessionorenv file.Edits are session only. Environment files are never written to. That keeps the behaviour identical to
set_variable, and it avoids two problems that would need solving first:load_variablesflattens provenance, so with several--envfiles there is no way to know which file an edit belongs to, and rewriting a dotenv file does not reliably preserve comments. Reverting an override reloads the files and re-overlays the rest of the session, the same way the file watcher already does.Happy to add write-back if you want it, but it seemed worth keeping out of a first pass.
Masking. Values whose names contain
secret,password,tokenorapi_keyare masked until you presss, so opening the screen during a screen share or a recording does not put a token on the wall. The mask is a fixed width so it does not disclose the length either, and copy always copies the real value rather than the mask.Renaming is not offered. It would break every request that still referenced the old name, and nothing would report it until the next send.
Undo history lives on the app beside
session_env, so closing and reopening the screen keeps it. Capped at 50 entries.Tests
tests/test_variables_modal.pycovers the masking, filtering, sorting and source labelling rules as plain sync tests, matching the style of the existing suite. The row building is a pure function so those rules can be checked without starting an app.I also drove the screen through
run_test()while developing to check the key handling, clipboard, undo and redo, and the empty state.Three command palette snapshots change because the palette now lists one more entry.
202 passed, 4 skippedlocally.Open questions
ctrl+shift+vfor the global binding is a guess, and some terminals swallow it. Happy to drop the binding and leave it palette only, or take whatever you prefer.escapeandj/kare hidden from the footer, matchingKeyValueCopyModal. Say the word if you would rather they showed.