Skip to content

Conversation

@gadenbuie
Copy link
Contributor

@gadenbuie gadenbuie commented Dec 3, 2025

Closes #120

Summary

Adds support for controlling whether tool detail cards (SQL query and results) are shown expanded or collapsed by default through an R option and environment variable.

Changes

R Package

  • Added querychat.tool_details option and QUERYCHAT_TOOL_DETAILS environment variable
  • Option takes precedence over environment variable
  • Added querychat_tool_details_option() helper function in pkg-r/R/utils-ellmer.R
  • Added querychat_tool_starts_open() function in pkg-r/R/querychat_tools.R
  • Updated querychat_tool_result() to use the new function
  • Added comprehensive tests in pkg-r/tests/testthat/test-querychat_tools.R

Python Package

  • Added QUERYCHAT_TOOL_DETAILS environment variable support
  • Added get_tool_details_setting() and querychat_tool_starts_open() functions in pkg-py/src/querychat/_utils.py
  • Updated all three tool functions (tool_update_dashboard, tool_reset_dashboard, tool_query) to respect the setting
  • Added comprehensive tests in pkg-py/tests/test_tools.py

API

Valid values:

  • "expanded" - Tool cards are always shown expanded
  • "collapsed" - Tool cards are always shown collapsed
  • "default" - Uses tool-specific behavior (query/update expanded, reset collapsed)

When not set, behavior defaults to tool-specific (equivalent to "default").

Usage (R):

# Set for the session
options(querychat.tool_details = "collapsed")

# Or set via environment variable in .Renviron
QUERYCHAT_TOOL_DETAILS=collapsed

Usage (Python):

# Set via environment variable
import os
os.environ["QUERYCHAT_TOOL_DETAILS"] = "collapsed"

Implementation Notes

The setting is applied uniformly to all tool result cards regardless of whether the operation succeeded or failed, giving users complete control over the display state.

Adds support for controlling whether tool detail cards (SQL query and
results) are shown expanded or collapsed by default.

**R package:**
- Option: `querychat.tool_details`
- Environment variable: `QUERYCHAT_TOOL_DETAILS`

**Python package:**
- Environment variable: `QUERYCHAT_TOOL_DETAILS`

**Valid values:**
- `"expanded"` - Tool cards are always shown expanded
- `"collapsed"` - Tool cards are always shown collapsed
- `"default"` - Uses tool-specific behavior (some expanded, some
  collapsed based on tool type)

**Usage:**

```r
# Set for the session
options(querychat.tool_details = "collapsed")

# Or set via environment variable in .Renviron
QUERYCHAT_TOOL_DETAILS=collapsed
```

The option takes precedence over the environment variable in R.

Closes #120
Remove special handling for error states. The tool details setting
now applies uniformly regardless of whether an error occurred.

This simplifies the implementation and gives users full control
over the display state in all cases.
Rename function in both R and Python packages for better clarity.
The new name more directly describes what the function returns.
- R: Move querychat_tool_details_option() to querychat_tools.R adjacent to querychat_tool_starts_open()
- R: Move validation logic into querychat_tool_details_option()
- Python: Move validation logic into get_tool_details_setting()
- Simplify querychat_tool_starts_open() in both packages to just apply validated settings

Addresses review comments in PR #137
@gadenbuie gadenbuie requested a review from cpsievert December 3, 2025 19:16
Remove self-explanatory comments that don't add value beyond
what the code clearly expresses.
Co-authored-by: Carson Sievert <[email protected]>
gadenbuie added a commit that referenced this pull request Dec 3, 2025
Add entries to R NEWS.md and Python CHANGELOG.md documenting the new
querychat.tool_details option and QUERYCHAT_TOOL_DETAILS environment
variable introduced in PR #137.
Add entries to R NEWS.md and Python CHANGELOG.md documenting the new
querychat.tool_details option and QUERYCHAT_TOOL_DETAILS environment
variable introduced in PR #137.
@gadenbuie gadenbuie merged commit 4ef8a28 into main Dec 3, 2025
16 checks passed
@gadenbuie gadenbuie deleted the cc-120 branch December 3, 2025 20:53
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.

Feature Request: Collapsible Query Details Section

3 participants