-
Notifications
You must be signed in to change notification settings - Fork 293
fix: credentials: block output while running credential tools #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: credentials: block output while running credential tools #261
Conversation
Signed-off-by: Grant Linville <[email protected]>
Talked with Darren and I'm gonna refactor this a bit. (Edit: refactor complete.) |
Signed-off-by: Grant Linville <[email protected]>
pause := context2.GetPauseFuncFromCtx(ctx) | ||
unpause := pause() | ||
defer unpause() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could technically be simplified down to defer context2.GetPauseFuncFromCtx(ctx)()()
but I was afraid that would be too confusing, so I split it into three lines to make it clearer what is happening here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of me would love to see this as defer context2.GetPauseFuncFromCtx(ctx)()()
, but I think the split is the right idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then you'd be a terrible person. What maniac would do a chained function call in a single line defer :)
pause := context2.GetPauseFuncFromCtx(ctx) | ||
unpause := pause() | ||
defer unpause() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of me would love to see this as defer context2.GetPauseFuncFromCtx(ctx)()()
, but I think the split is the right idea.
for #256
One of the goals of the credentials framework was to block output to the terminal while running
sys.prompt
, since it prompts the user directly in the terminal. I originally implemented this by storing the Monitor into the Context and then pulling it out of the Context and running itsPause
function in the implementation ofsys.prompt
. However, this does not work, as credential tools pretty much always have to callsys.prompt
with a new gptscript subprocess.This new implementation instead stores the Pause function inside of the context and calls it within the Engine code prior to running a credential tool. This way, the Monitor is paused in the correct process.