Skip to content

feat(cli): add context show and session status commands#3096

Open
atharvalade wants to merge 5 commits intoapache:masterfrom
atharvalade:cli-context-show-session-status
Open

feat(cli): add context show and session status commands#3096
atharvalade wants to merge 5 commits intoapache:masterfrom
atharvalade:cli-context-show-session-status

Conversation

@atharvalade
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #3000

Rationale

The CLI lacked observability into context configuration and login session state, forcing users to manually read ~/.iggy/contexts.toml or run authenticated commands to check connectivity.

What changed?

Previously there was no way to inspect what a context contains or whether a login session is active without workarounds. Users had to read raw TOML files or run iggy me and hope it worked.

This adds iggy context show <name> to display a named context's full configuration (transport, addresses, TLS, credentials with masking) and iggy session status to check the local keyring for an active login session and show which server it targets — both without requiring a server connection.

Local Execution

  • Passed
  • Pre-commit hooks ran

AI Usage

  1. Opus 4.6
  2. Minimal AI used
  3. Yes all code can be explained

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 47.94521% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.11%. Comparing base (eb20ac5) to head (636c962).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...re/cli/src/commands/binary_context/show_context.rs 66.00% 4 Missing and 13 partials ⚠️
...e/cli/src/commands/binary_system/session_status.rs 0.00% 16 Missing ⚠️
core/cli/src/main.rs 28.57% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3096       +/-   ##
=============================================
- Coverage     74.08%   53.11%   -20.98%     
  Complexity      943      943               
=============================================
  Files          1159     1150        -9     
  Lines        102033    90218    -11815     
  Branches      79084    67422    -11662     
=============================================
- Hits          75593    47919    -27674     
- Misses        23770    39744    +15974     
+ Partials       2670     2555      -115     
Components Coverage Δ
Rust Core 46.90% <47.94%> (-28.41%) ⬇️
Java SDK 62.30% <ø> (+2.15%) ⬆️
C# SDK 69.30% <ø> (-0.08%) ⬇️
Python SDK 81.43% <ø> (ø)
Node SDK 91.53% <ø> (ø)
Go SDK 39.52% <ø> (+0.09%) ⬆️
Files with missing lines Coverage Δ
core/cli/src/args/context.rs 100.00% <ø> (ø)
core/cli/src/args/mod.rs 78.57% <ø> (ø)
core/cli/src/main.rs 90.97% <28.57%> (-1.25%) ⬇️
...e/cli/src/commands/binary_system/session_status.rs 0.00% <0.00%> (ø)
...re/cli/src/commands/binary_context/show_context.rs 66.00% <66.00%> (ø)

... and 280 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added stale Inactive issue or pull request and removed stale Inactive issue or pull request labels Apr 22, 2026

Ok(())
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing tests covering explain / login_required / connection_required. sibling delete_context.rs:67-83 has the pattern.


Ok(())
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same gap as show_context.rs - no unit tests for explain / login_required / connection_required. mirror delete_context.rs:67-83.

Comment on lines +51 to +77
if let Some(ref transport) = config.iggy.transport {
table.add_row(vec!["Transport", transport]);
}
if let Some(ref addr) = config.iggy.tcp_server_address {
table.add_row(vec!["TCP Server Address", addr]);
}
if let Some(ref url) = config.iggy.http_api_url {
table.add_row(vec!["HTTP API URL", url]);
}
if let Some(ref addr) = config.iggy.quic_server_address {
table.add_row(vec!["QUIC Server Address", addr]);
}
if let Some(tls) = config.iggy.tcp_tls_enabled {
table.add_row(vec!["TCP TLS Enabled", &tls.to_string()]);
}
if let Some(ref username) = config.username {
table.add_row(vec!["Username", username]);
}
if config.password.is_some() {
table.add_row(vec!["Password", MASKED_VALUE]);
}
if config.token.is_some() {
table.add_row(vec!["Token", MASKED_VALUE]);
}
if let Some(ref token_name) = config.token_name {
table.add_row(vec!["Token Name", token_name]);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

only displays the subset of ArgsOptional matching ContextCreateArgs flags. drops config.extra (BTreeMap of preserved unknown TOML keys, see common.rs:54-55 and the round-trip test common.rs:734-756), tcp_tls_domain, tcp_reconnection_*, http_retries, websocket_server_address, all quic_* tuning fields, encryption_key, credentials_username / credentials_password. doc at args/context.rs:67 claims "full configuration" - promise not kept. either iterate extra and append the remaining iggy.* fields, or trim the doc to match implementation.

#[async_trait]
impl CliCommand for ShowContextCmd {
fn explain(&self) -> String {
format!("show context \"{}\"", self.context_name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

quotes the name: format!("show context \"{}\"", ...). siblings delete_context.rs:41, use_context.rs, create_context.rs use unquoted form ("delete context {context_name}"). pick one.

}

async fn execute_cmd(&mut self, _client: &dyn Client) -> anyhow::Result<(), anyhow::Error> {
let is_active = self.server_session.is_active();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is_active() (session.rs:45-51) only checks whether the keyring entry exists. a stale or expired token still reports Active=Yes. either note this in the command output (e.g. "Session Active: Yes (token freshness not verified)") or document the limitation in the command's doc comment.

Comment on lines +75 to +79
for (key, value) in &self.expected_fields {
command_state = command_state
.stdout(contains(key.as_str()))
.stdout(contains(value.as_str()));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

asserts key and value substrings independently. the test passes even if the table renders rows in mismatched order (e.g. "Username" appearing without its value, or vice versa). use a row-aware predicate or a single combined substring like "Username | admin".

Comment on lines +60 to +64
if is_active {
table.add_row(vec!["Session Active", "Yes"]);
} else {
table.add_row(vec!["Session Active", "No"]);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

duplicates the add_row call. collapse to:

let active = if is_active { "Yes" } else { "No" };
table.add_row(vec!["Session Active", active]);

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): Add context show and session status commands to CLI

2 participants