Skip to content

fix(but): never use askpass broker for cli#12463

Draft
slarse wants to merge 1 commit intomasterfrom
GB-1075/dont-use-askpass-broker-for-cli
Draft

fix(but): never use askpass broker for cli#12463
slarse wants to merge 1 commit intomasterfrom
GB-1075/dont-use-askpass-broker-for-cli

Conversation

@slarse
Copy link
Contributor

@slarse slarse commented Feb 20, 2026

🧢 Changes

Removes the askpass feature flag and instead figures out at runtime if the askpass broker is active or not.

This is just turning into more of a mess so I'm trying to figure out if we can simplify it. I really don't like how this turned out ...

☕️ Reasoning

When running but as a symlink to gitbutler-tauri, the feature flag will obviously have been set to include the askpass broker. However, the codepath never initializes it. And it doesn't really matter if it does because there's no good mechanism to respond. The CLI should delegate credentials input to whatever the terminal is configured to use (unless we want to build a full on TUI for everything, but we're not there yet).

@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 20, 2026 2:42pm

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Feb 20, 2026
@slarse slarse force-pushed the GB-1075/dont-use-askpass-broker-for-cli branch 2 times, most recently from 2df7010 to e8a3da1 Compare February 20, 2026 14:15
@slarse slarse force-pushed the GB-1075/dont-use-askpass-broker-for-cli branch from e8a3da1 to e632dcd Compare February 20, 2026 14:42
@github-actions github-actions bot added the CLI The command-line program `but` label Feb 20, 2026
Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a first look and like where this is going! Thanks for tackling this.

There are a few actionable items as well.

async fn handle_git_prompt_clone(prompt: String, url: String) -> Option<String> {
tracing::info!("received prompt for clone of {url}: {prompt:?}");
askpass::get_broker()
.expect("failed to get askpass broker")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the recent improvements, panics (that this line could introduce) are safer as they are turned into errors.
We still have to be careful about them if they could run outside of GUI triggers, like in the filewatcher, but this isn't the case here.
(no action needed, just sharing some insights)

but-llm.workspace = true

# this crate is only required so we can disable the askpass broker
gitbutler-repo-actions.workspace = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy crates have to be behind the legacy feature toggle, and be optional dependencies.
Should also obey the grouping and move down to the reset of 'em.

Comment on lines -389 to +380
on_prompt: F,
extra: Extra,
on_prompt: Option<F>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this.

Comment on lines +428 to +429
/// If `on_prompt` is provided, the custom askpass broker machinery is used, which MUST have been
/// properly initialized. It should return the user's response or `None` if the operation should be
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it be initialised? You could link the initialisation function via [crate::init()] or something like it.

/// This function is **NOT** thread safe.
#[expect(static_mut_refs)]
pub unsafe fn init(submit_prompt: impl Fn(PromptEvent<Context>) + Send + Sync + 'static) {
unsafe {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

if let Some(branch_id) = askpass {
tracing::info!("received prompt for branch push {branch_id:?}: {prompt:?}");
askpass::get_broker()
.expect("failed to get askpass broker")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than stating the obvious, it would be better to state what would be expected here. Maybe init() was called. In other words, call out the requirement or expectations as it would help fixing the panic if we'd hit it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants