Commit Graph

3 Commits

Author SHA1 Message Date
Saxon Fletcher
ee6961beb0 fix(studio): clarify assistant tool terminal states (#49364)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Small Assistant terminal-state fixes.

## Stack context

This stack is based on #49352 (`chore/assistant-tool-outcomes`) and
assumes #49350–#49352 merge first.

Review bottom to top:

1. #49361 — assistant notebook run tool
2. #49362 — assistant notebook run UI
3. #49364 — terminal-state polish

## What is the current behavior?

Completed notebook updates can be re-diffed against newer live content,
and log-query failures can use SQL-specific or empty fallback UI.

## What is the new behavior?

- Replaces completed notebook update previews with a stable
success/error/skipped summary.
- Keeps the Open notebook action on successful updates.
- Uses logs-specific failure copy for Assistant log queries.
- Shows an explicit fallback when a failed log tool input or output
cannot be parsed.

## How to test manually

### Notebook update terminal states

1. Ask the AI Assistant to update an existing notebook, then approve the
proposal.
2. Confirm the proposal becomes a compact **Notebook updated: [name]**
summary instead of re-diffing against the newly saved notebook.
3. Click **Open notebook** and confirm it opens the updated notebook.
4. Request another notebook update and click **Skip**. Confirm the
terminal summary says **Skipped notebook update**.
5. Refresh or reopen the conversation and confirm both summaries remain
stable.

### Logs failure copy

1. Ask the Assistant to query Logs with an intentionally invalid table
or column and approve the query.
2. Confirm the failed result says **Failed to query logs**, not **Failed
to execute SQL**.
3. Confirm the failed tool remains visible rather than disappearing when
its result cannot be rendered.

## Automated test

The focused top-of-stack suite passes 9 test files and 85 tests.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added clearer failure messaging when query logs contain invalid input,
missing results, or errors.
- Added compact summaries for completed, failed, and skipped notebook
updates.
- Notebook update summaries include an “Open notebook” link when
applicable.

- **Bug Fixes**
- Improved handling and display of query-log failures instead of showing
blank content.
- Preserved detailed previews for notebook updates that are still in
progress.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-25 18:16:34 +10:00
Saxon Fletcher
f0cb024139 feat(studio): preserve assistant tool previews after completion (#49352)
<img width="2337" height="1005" alt="image"
src="https://github.com/user-attachments/assets/08298850-715e-4b31-866d-186d73266305"
/>


## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Assistant execution feedback improvement.

## Stack context

Builds on #49351.

## What is the current behavior?

When an Assistant query, notebook, Edge Function deployment, or log
query completes or fails, the preview can be replaced by a terse text
result.

## What is the new behavior?

- Retains the original query, log-query, notebook, and Edge Function
preview after the tool resolves.
- Replaces confirmation actions with a success, error, or skipped footer
state.
- Keeps the Open notebook action available after a successful notebook
creation or update.

## To test

1. Ask the Assistant to run a valid SQL query, approve it, and confirm
the query cell remains visible with a Query executed footer.
2. Trigger a failed SQL or log query and confirm the original preview
remains visible with an error footer and error result.
3. Ask the Assistant to create or update a notebook, approve it, and
confirm the preview remains visible with a completed footer and Open
notebook action.
4. Skip any approval and confirm the preview remains visible with a
skipped footer instead of being replaced by plain text.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Assistant actions now show clear success, error, or denied-status
messages.
* Completed actions retain relevant previews and provide follow-up
actions, such as opening a created notebook.
* SQL, log-query, Edge Function, and notebook errors appear within their
respective result views.
* Status updates are announced more clearly as actions progress and
complete.

* **Bug Fixes**
* Preserved submitted tool details when execution fails or original
input is unavailable.
* Improved handling of failed and denied operations across assistant
workflows.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-21 10:12:00 +00:00
Saxon Fletcher
e605178a63 feat(studio): render assistant log query results (#49293)
<img width="1510" height="862" alt="image"
src="https://github.com/user-attachments/assets/f7157bad-9b23-4d73-a9aa-2a7a7c179318"
/>


## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Feature and bug fix.

## What is the current behavior?

`query_logs` can return rows to the assistant, but the chat UI does not
hydrate those rows into the query result by default. The query only
becomes visible after clicking **Run query**, even though the same SQL
and time range work when rerun manually.

## What is the new behavior?

- Renders `query_logs` tool output through a dedicated logs message part
using the shared assistant query cell.
- Parses the exact MCP untrusted-data envelope into the initial query
result, without changing what the assistant model receives.
- Preserves the logs source and time range for manual reruns.
- Infers a useful table or chart presentation from the returned rows
while retaining explicit display settings.
- Adds focused tests for MCP result parsing, timestamps, errors, query
source handling, and visualization inference.

## How to test

1. Check out this PR and run Studio against a project that has recent
logs. Generate some project activity first, such as an API request, if
needed.
2. Open the AI Assistant and ask: `Show log counts by minute for the
last 15 minutes and summarize any spikes.`
3. Wait for `query_logs` to finish. Verify the query cell appears with
results already populated; do not click **Run query** first.
4. Verify the aggregate result opens as a chart, then switch to the
table view and confirm the underlying rows are present.
5. Click **Run query** and verify the query runs successfully again
using the same logs source and 15-minute time range.
6. Ask: `Show the 20 most recent log entries from the last 15 minutes.`
Verify this non-aggregate result opens as a table with rows already
populated.
7. Confirm the assistant's written summary agrees with the displayed
rows and does not report zero rows when results are visible.

## Additional context

This is the top PR in stack #49294 and depends on the back-end knowledge
change in #49292.

Verified with 59 focused tests across assistant context, Studio/MCP
tools, query display, and logs result parsing.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added AI Assistant support for querying and displaying application
logs.
* Added automatic visualization selection, including charts for
time-based and categorical data.
* Added source-aware query handling with dedicated titles, time ranges,
and result displays.
  * Added clearer loading, parsing, and error states for log queries.

* **Bug Fixes**
* Improved handling of streamed results, source changes, and query
display updates.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-21 09:30:55 +10:00