Skip to content

Conversation

@tennox
Copy link

@tennox tennox commented Sep 1, 2025

Disclaimer: This PR has been developed with the help of Claude, but I've tested and reviewed manually.

Summary

  • Added query-pane-info CLI command to retrieve structured information about the current pane and its containing
    tab
  • Returns JSON-formatted output including tab name, tab index, pane ID, pane type, and pane name
  • Enables programmatic inspection of zellij session state for automation and scripting

Changes

  • New CLI Command: Added QueryPaneInfo action that uses ZELLIJ_PANE_ID environment variable
  • JSON Output: Structured information format for easy parsing by external tools
  • Searches across all tabs to locate the target pane
  • Error Handling: Graceful handling of invalid/missing pane IDs with clear error messages
  • Plugin API: Complete protobuf integration with QueryPaneInfoPayload
  • Backward Compatible: No changes to existing functionality

Usage

# Get information about current pane (must be run within zellij session)
zellij action query-pane-info

Example Output:

{
  "tab_name": "Zellij Fork",
  "tab_index": 1,
  "pane_id": 42,
  "pane_type": "terminal",
  "pane_name": "hx src/main.rs"
}

Architecture

Follows the established pattern of QueryTabNames:

  • Uses ZELLIJ_PANE_ID environment variable (consistent with other pane operations)
  • Routes through standard CLI → Action → Route → Screen → ServerInstruction::Log flow
  • Leverages existing tab iteration and pane lookup mechanisms
  • JSON serialization using serde for structured output

Error Handling

  • Missing Pane: Clear error message when pane ID not found in any tab
  • Invalid Environment: Proper error when ZELLIJ_PANE_ID not set or malformed
  • Type Safety: Converts between raw u32 and internal PaneId enum safely

Adds a new CLI action `zellij action query-pane-info` that returns information
about the current pane and its tab, including:
- ZELLIJ_TAB_NAME: Current tab name
- ZELLIJ_TAB_INDEX: Current tab index
- ZELLIJ_PANE_ID: Current pane ID
- ZELLIJ_PANE_NAME: Current pane name/title

This provides a way to query the current context without relying on environment
variables that could become stale when tabs are renamed or reordered.
- Add QueryPaneInfoPayload to protobuf imports
- Fix dereference error: pane_id is already u32, not &u32
- Add wildcard pattern to handle exhaustive match
- Implementation now compiles successfully
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.

1 participant