summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-13 12:12:24 -0600
committert <t@tjp.lol>2026-06-15 15:08:32 -0600
commit0247f43f68dcb1f123715b655397268a093a20ed (patch)
treea6dc83dbbdbe3520fb9ff89c19ff5d2c25e1cd88 /src/main.zig
parent73324a15aa524cf75deebc4172f5a1f0d0051bc6 (diff)
auth: turn-time resolution in the TUI (inline login + 401 retry)
Resolve the active provider's auth before each turn via the AuthManager, rendering an inline device-code prompt when login is needed, and force a single refresh/exchange retry on a provider auth failure. Wire the manager through RunOptions from main.zig.
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index dc611b4..58502ad 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -569,6 +569,20 @@ pub fn main(init: std.process.Init) !void {
// loop so the final frame and teardown sequences reach the terminal.
defer tui_file.interface.flush() catch {};
+ // Turn-time auth resolution. The manager resolves the active provider's
+ // named auth session (api_key: no-op; oauth_device: refresh/exchange or an
+ // interactive device login) into the live config before each turn.
+ var home_layout = try panto_home.resolve(alloc, init.environ_map);
+ defer home_layout.deinit();
+ var auth_mgr = auth_manager.AuthManager.init(
+ alloc,
+ io,
+ panto.httpClient(),
+ home_layout.auth_dir,
+ &app_config,
+ );
+ defer auth_mgr.deinit();
+
tui_app.runLoop(&app, &term, .{
.agent = agent,
.cmd_registry = &cmd_registry,
@@ -578,6 +592,7 @@ pub fn main(init: std.process.Init) !void {
.cwd = cwd,
.io = io,
.environ = init.environ_map,
+ .auth_mgr = &auth_mgr,
}) catch |err| switch (err) {
// Clean user-initiated exit (Ctrl+C / Ctrl+D). Not an error.
error.UserExit => {},