Synced from monorepo
Synced from monorepo Changes: - Shell: accept target response id on rewind execute - Shell: stamp response id on chat user message chunks - Worktree: optional rebuild and stale git registration cleanup in auto-GC - Worktree: kind-aware auto-GC TTLs and config knobs - Worktree: macOS process CWD scan and Unix PID liveness for GC guards - Worktree: automatic throttled GC on startup (Linux age-based; non-Linux dead-only) - Pager: add `[ui].combine_queued_prompts` to batch queued follow-ups - Shell: stop overwriting user skills - Tools: read markdown in `skills/` directories untruncated - `/usage` shows per-session token and dollar usage in the TUI - Security: prompt on environment-dumping `ps` variants - Security: always-safe `kubectl` no longer runs arbitrary kubeconfig credential plugins without permission - Tools: make scheduler deletion durable - Shell: add relocation storage primitives - Shell: give side model calls their own conversation ids - Fix five workflow-runtime bugs (budget, pause, cancel, reconnect) - Security: peel `env -S` / `--split-string` operands in the Bash permission gate (managed deny/ask) - Pager: expose doctor in the TUI - Security: block unauthorized RCE via abused safe commands - Pager idle watcher cue: "1 subagent still running" instead of "watching · 1 subagent" - Security: block `rg --pre` arbitrary code execution in auto-mode - Voice: diagnose silent-mic failures (macOS permission) and add doctor/terminal-setup Voice section - App builder deployer: `allow_forking` and `show_built_with_grok` - Pager: stop stacking duplicate "Worked for" markers on parked turns - Shell: support `max` as a distinct reasoning effort tier - Tools: serialize background `/loop` fires on the whole work unit - Shell: add working-directory relocation state primitives - Proto: `ClientToolResult` and `ChatConfig` client-side tools - Shell: model providers - Chat: select App Builder product on the Build path - Shell: attach author identity to feedback when the deployment opts in - Doctor: fix for SSH wrap setup - Workflow authoring skills: create-workflow and import-claude-workflow docs - Add read-only grok doctor - Sandbox: apply Landlock without a controlling TTY - Pager: recover image paste over grok wrap on headless remotes - Pager: make actions screen-mode aware - Shell: resume sessions when the working directory moves - Pager: centralize terminal diagnostics - Workspace: gate inline shell file access - Pager: centralize terminal probes - Pager: edit minimal prompts in an external editor - Pager: standardize backgrounding on Ctrl+B - Shell: recap rides the parent turn's prompt cache - Tools: add scheduler lifecycle version clock Source-Revision: 0f4d7c91b8b2b408333f6de1e8a76cb8eaa71899
This commit is contained in:
parent
a881e6703f
commit
3af4d5d398
556 changed files with 56609 additions and 21892 deletions
|
|
@ -1,5 +1,7 @@
|
|||
//! Session status, sharing, privacy, usage, and info dispatchers.
|
||||
|
||||
use agent_client_protocol as acp;
|
||||
|
||||
use super::ctx::get_active_agent;
|
||||
use super::settings::ui::refresh_open_settings_modals;
|
||||
use crate::app::actions::Effect;
|
||||
|
|
@ -253,18 +255,60 @@ pub(super) fn dispatch_show_context_info(app: &mut AppView) -> Vec<Effect> {
|
|||
}]
|
||||
}
|
||||
|
||||
/// Show credit usage: fetch billing data and display inline.
|
||||
///
|
||||
/// When the remote settings `grok_build_usage_redirect_url` flag is set (delivered via
|
||||
/// RemoteSettings, targeted at personal-team users), skip the backend fetch and
|
||||
/// just point the user at that URL instead. This is a kill switch for the
|
||||
/// personal-team billing path while it is unreliable.
|
||||
/// `/usage` — session token/cost, then consumer credits when visible.
|
||||
/// Credits are chained after the session block so layout stays ordered.
|
||||
pub(super) fn dispatch_show_usage(app: &mut AppView) -> Vec<Effect> {
|
||||
let ActiveView::Agent(id) = app.active_view else {
|
||||
return vec![];
|
||||
};
|
||||
let session_id = {
|
||||
let Some(agent) = app.agents.get_mut(&id) else {
|
||||
return vec![];
|
||||
};
|
||||
agent.session.session_id.clone()
|
||||
};
|
||||
match session_id {
|
||||
Some(session_id) => vec![Effect::FetchSessionUsage {
|
||||
agent_id: id,
|
||||
session_id,
|
||||
}],
|
||||
None => {
|
||||
if let Some(agent) = app.agents.get_mut(&id) {
|
||||
agent.scrollback.push_block(RenderBlock::system(
|
||||
"Session usage is unavailable until the session starts.".to_string(),
|
||||
));
|
||||
}
|
||||
append_consumer_billing_surface(app, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Commit a session-usage block if still on `session_id`, then consumer credits.
|
||||
pub(super) fn commit_session_usage_block(
|
||||
app: &mut AppView,
|
||||
agent_id: AgentId,
|
||||
session_id: &acp::SessionId,
|
||||
text: String,
|
||||
) -> Vec<Effect> {
|
||||
let Some(agent) = app.agents.get_mut(&agent_id) else {
|
||||
return vec![];
|
||||
};
|
||||
if agent.session.session_id.as_ref() != Some(session_id) {
|
||||
return vec![];
|
||||
}
|
||||
agent.scrollback.push_block(RenderBlock::system(text));
|
||||
append_consumer_billing_surface(app, agent_id)
|
||||
}
|
||||
|
||||
/// Consumer credit follow-up for `/usage` (redirect or non-silent billing fetch).
|
||||
pub(super) fn append_consumer_billing_surface(app: &mut AppView, agent_id: AgentId) -> Vec<Effect> {
|
||||
if !app.usage_visible {
|
||||
return vec![];
|
||||
}
|
||||
// Remote-settings kill switch (`grok_build_usage_redirect_url`): link out
|
||||
// instead of fetching billing from the backend.
|
||||
if let Some(url) = app.usage_billing_redirect_url.clone() {
|
||||
if let Some(agent) = app.agents.get_mut(&id) {
|
||||
if let Some(agent) = app.agents.get_mut(&agent_id) {
|
||||
agent.scrollback.push_block(RenderBlock::System(
|
||||
crate::scrollback::blocks::SystemMessageBlock::new(format!(
|
||||
"Please check your usage on {url}"
|
||||
|
|
@ -273,14 +317,28 @@ pub(super) fn dispatch_show_usage(app: &mut AppView) -> Vec<Effect> {
|
|||
}
|
||||
return vec![];
|
||||
}
|
||||
// Non-silent fetch: the effect also pulls the auto top-up rule so the
|
||||
// summary can render usage, prepaid credits, and auto top-up together.
|
||||
if !app.agents.contains_key(&agent_id) {
|
||||
return vec![];
|
||||
}
|
||||
// Non-silent: the effect also pulls the auto top-up rule so the summary
|
||||
// renders usage, prepaid credits, and auto top-up together.
|
||||
vec![Effect::FetchBilling {
|
||||
agent_id: id,
|
||||
agent_id,
|
||||
silent: false,
|
||||
}]
|
||||
}
|
||||
|
||||
/// `/usage manage` — open consumer billing. No-op when the surface is hidden.
|
||||
pub(super) fn dispatch_manage_billing(app: &mut AppView) -> Vec<Effect> {
|
||||
if !app.usage_visible {
|
||||
return vec![];
|
||||
}
|
||||
super::router::dispatch(
|
||||
crate::app::actions::Action::OpenUrl("https://grok.com/?_s=usage".to_string()),
|
||||
app,
|
||||
)
|
||||
}
|
||||
|
||||
/// Commit a one-line "update available" notice into the active agent's
|
||||
/// scrollback. Minimal mode has no welcome screen (the full TUI's update
|
||||
/// surface), so the background update check's result is shown here instead
|
||||
|
|
|
|||
Loading…
Reference in a new issue