From 34530777eea308eb85dae2be4a7e2aa34384c38c Mon Sep 17 00:00:00 2001 From: HoshizukiMio Date: Tue, 17 Nov 2026 19:32:26 +0800 Subject: [PATCH] Start local TUI without account login --- .../hoshizukimio-mio-pager/src/acp/mod.rs | 30 +++++++++++-------- .../src/app/effects/mod.rs | 4 ++- tests/smoke.py | 23 +++++++++----- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/crates/codegen/hoshizukimio-mio-pager/src/acp/mod.rs b/crates/codegen/hoshizukimio-mio-pager/src/acp/mod.rs index e853621c..d18cf844 100644 --- a/crates/codegen/hoshizukimio-mio-pager/src/acp/mod.rs +++ b/crates/codegen/hoshizukimio-mio-pager/src/acp/mod.rs @@ -26,6 +26,7 @@ pub use model_state::ModelState; use std::io::Write; use tokio_util::sync::CancellationToken; use hoshizukimio_acp_lib::{AcpAgentTx, AcpClientRx, acp_send}; +use hoshizukimio_mio_config::{Capability, Distribution}; use hoshizukimio_mio_shell::agent::auth_method::AuthMethodKind; use hoshizukimio_mio_shell::agent::config::Config as AgentConfig; use hoshizukimio_mio_shell::sampling::types::ReasoningEffort; @@ -242,20 +243,25 @@ pub(in crate::acp) async fn initialize_connection( }; startup::enter(StartupPhase::AcpInitialize); let agent = initialize(&tx, flags).await?; - let (needs_login, login_label, login_method_id, auth_start_mode) = - startup_auth_metadata(&agent.auth_methods); startup::enter(StartupPhase::EagerAuth); let (needs_login, login_label, login_method_id, auth_start_mode, auth_meta) = - bounded_eager_auth( - &tx, - &agent.auth_methods, - agent.default_auth_method_id.as_ref(), - needs_login, - login_label, - login_method_id, - auth_start_mode, - ) - .await; + if agent.is_mio_shell && !Distribution::current().allows(Capability::AccountLogin) { + // The local shell resolves credentials at the model endpoint and advertises no account methods. + (false, None, None, AuthStartMode::Pending, None) + } else { + let (needs_login, login_label, login_method_id, auth_start_mode) = + startup_auth_metadata(&agent.auth_methods); + bounded_eager_auth( + &tx, + &agent.auth_methods, + agent.default_auth_method_id.as_ref(), + needs_login, + login_label, + login_method_id, + auth_start_mode, + ) + .await + }; Ok(AcpConnection { tx, rx, diff --git a/crates/codegen/hoshizukimio-mio-pager/src/app/effects/mod.rs b/crates/codegen/hoshizukimio-mio-pager/src/app/effects/mod.rs index 4d4c89e2..e0a9cab0 100644 --- a/crates/codegen/hoshizukimio-mio-pager/src/app/effects/mod.rs +++ b/crates/codegen/hoshizukimio-mio-pager/src/app/effects/mod.rs @@ -30,6 +30,7 @@ use std::path::Path; use agent_client_protocol as acp; use tokio::task::JoinSet; use hoshizukimio_acp_lib::{AcpAgentTx, acp_send}; +use hoshizukimio_mio_config::{Capability, Distribution}; use hoshizukimio_mio_telemetry::startup::{self, StartupPhase}; use actions::{ ClipboardPasteTarget, Effect, SubagentKillOutcome, SwitchModelError, TaskResult, @@ -2100,7 +2101,7 @@ pub(crate) fn execute( } }); } - Effect::FetchChangelog => { + Effect::FetchChangelog if Distribution::current().allows(Capability::RemoteFetch) => { tasks .spawn(async move { let changelog = tokio::task::spawn_blocking(|| { @@ -2121,6 +2122,7 @@ pub(crate) fn execute( } }); } + Effect::FetchChangelog => {} Effect::PersistAnnouncementsHidden { hidden_ids } => { tasks .spawn(async move { diff --git a/tests/smoke.py b/tests/smoke.py index c6a3f9a0..bfba3a9e 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -171,12 +171,12 @@ def verify_acp(binary, root, env): @contextlib.contextmanager def terminal(binary, root, env): - args = [binary, "--no-leader"] + args = [binary, "--no-leader", "Respond with the test phrase."] if os.name == "nt": from winpty import PtyProcess process = PtyProcess.spawn(args, cwd=str(root), env=env, dimensions=(32, 110)) try: - yield lambda: process.read(16384), process.isalive + yield lambda: process.read(16384) finally: if process.isalive(): with contextlib.suppress(EOFError): @@ -202,7 +202,7 @@ def terminal(binary, root, env): with subprocess.Popen(args, cwd=root, env=env, stdin=slave, stdout=slave, stderr=slave, start_new_session=True) as process: try: - yield lambda: os.read(master, 16384).decode("utf-8", "replace"), lambda: process.poll() is None + yield lambda: os.read(master, 16384).decode("utf-8", "replace") finally: process.terminate() try: @@ -217,16 +217,20 @@ def terminal(binary, root, env): def verify_tui(binary, root, env): output = queue.SimpleQueue() screen = "" - with terminal(binary, root, env) as (reader, is_alive): + with terminal(binary, root, env) as reader: threading.Thread(target=read_stream, args=(reader, output), daemon=True).start() stop = time.monotonic() + 45 while (remaining := stop - time.monotonic()) > 0: - data = output.get(timeout=remaining) + try: + data = output.get(timeout=remaining) + except queue.Empty: + break assert data is not None, screen screen = (screen + data)[-64000:] - if "\x1b[" in screen and "mio" in screen.lower() and is_alive(): + assert "preferred_method=api_key" not in screen and "Login with mio.invalid" not in screen, screen + if TEXT in screen: return - raise TimeoutError(f"TUI did not render: {screen}") + raise TimeoutError(f"TUI did not display a model response: {screen}") def verify(binary, tui): @@ -314,7 +318,10 @@ def verify(binary, tui): print("Passed ACP initialization and session creation") if tui: verify_tui(binary, root, env) - print("Passed TUI startup") + while not requests.empty(): + requests.get_nowait() + assert unexpected.empty(), unexpected.get_nowait() + print("Passed interactive TUI inference") settings.write_text( f'[model.smoke]\nmodel = "{MODEL}"\nbase_url = "{api}/redirect/v1"\n'