Detect sandbox mode and network in statusline example#322
Open
raybell-md wants to merge 3 commits into
Open
Conversation
`agy --sandbox` enables the terminal sandbox but does not populate .sandbox.enabled in the statusLine payload (it stays false as of 1.0.6), so the example's sandbox badge always reads "off" under --sandbox. The flag is not exported to the statusLine process's environment, and the process is reparented to init, so neither env nor the parent command line can be inspected. The only reliable signal is the session log line "--sandbox: enabling terminal sandbox for this session", which cli.log symlinks to. Keep .sandbox.enabled as the primary source and fall back to grepping the session log, so the badge self-corrects once the payload field is fixed upstream (see google-antigravity#321).
|
Hi @raybell-md! I also addressed sandbox state formatting in my responsive statusline script, providing distinct badges for
Feel free to check out the implementation or use it as a reference: Community discussion: #397 |
The sandbox badge only showed ON/off, giving no indication of whether sandboxAllowNetwork was in effect — a frequent source of confusion (google-antigravity#399). The payload's sandbox object only carries .enabled; there is no .sandbox.allow_network field, so it can't drive the badge on its own. The session log has no network-specific line either. Mirror the existing .enabled workaround: read sandboxAllowNetwork from settings.json as the authoritative source, while still preferring .sandbox.allow_network from the payload when present, so it self-corrects once that field is populated upstream (google-antigravity#321). The badge now reads "sandbox ON (net)" or "sandbox ON (no-net)". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Makes the example statusline detect terminal sandbox mode even though the statusLine payload doesn't currently report it.
Why
As of agy 1.0.6,
agy --sandboxenables the terminal sandbox but does not set.sandbox.enabledin the statusLine payload — it staysfalse. As a result the example's sandbox badge always readssandbox offeven when running under--sandbox.I confirmed there's no other clean signal available to a statusLine script:
.sandbox.enabledstaysfalse; no populatedexecution_modefield either._AGY_SBOXSERVE,SANDBOX) are not exported to the statusLine process.init, so its parent command line can't be inspected.The only reliable signal is the session log line
--sandbox: enabling terminal sandbox for this session, which~/.gemini/antigravity-cli/cli.logsymlinks to.How
Keep
.sandbox.enabledas the primary source and, only when it's not alreadytrue, fall back to grepping the current session log. This means the workaround self-corrects automatically once the payload field is populated upstream — no follow-up change needed.Caveat
This is an interim workaround, not a real fix.
cli.logalways points at the newest session, so a stale refresh from an older non-sandbox terminal could theoretically read a newer sandbox session's log. The proper fix is for agy to populatesandbox.enabled(and/orexecution_mode) in the payload — tracked in #321. Happy to drop this if you'd prefer to fix it at the source instead.Testing
bash -npasses.sandbox.enabled=false→ renderssandbox ON.sandbox off.Update: also show sandbox network mode (closes #399)
Added a second commit that surfaces the network mode in the badge, addressing the confusion reported in #399 where users couldn't tell whether
sandboxAllowNetworkhad taken effect.Same shape as the
.enabledworkaround above. The payload'ssandboxobject only carries.enabled— there is no.sandbox.allow_networkfield — and the session log has no network-specific line. So the badge reads the authoritativesandboxAllowNetworkfromsettings.json, while still preferring.sandbox.allow_networkfrom the payload when present (self-corrects upstream, #321).The badge now reads
sandbox ON (net)orsandbox ON (no-net).Testing
bash -npasses.allow_network=true/false→(net)/(no-net).sandboxAllowNetwork:truein settings.json →(net);false→(no-net).allow_network=trueoverrides settings →(net).set -euo pipefail.