Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6a14716
Ask Optiq: reliability, accuracy and speed fixes
Sajeeth-Wimalasuriyan Nov 17, 2026
55fdf31
Ask Optiq: harden API key handling and script approval
Sajeeth-Wimalasuriyan Nov 17, 2026
dcb0ddd
Ask Optiq: survive connection resets and keep cancel off the UI thread
Sajeeth-Wimalasuriyan Nov 17, 2026
a586b4e
Ask Optiq: end-to-end test suite with golden tool outputs
Sajeeth-Wimalasuriyan Nov 17, 2026
4108187
Merge remote-tracking branch 'origin/main' into sw-fable-review
Sajeeth-Wimalasuriyan Nov 17, 2026
c9800b2
Merge remote-tracking branch 'origin/sw-fable-review' into sw-fable-r…
Sajeeth-Wimalasuriyan Nov 17, 2026
aa1dce3
Ask Optiq: review fixes that leave tool output unchanged
Sajeeth-Wimalasuriyan Nov 17, 2026
9367008
Ask Optiq: deterministic tie order and grouped default sort
Sajeeth-Wimalasuriyan Nov 17, 2026
772fb96
Ask Optiq: remove the end-to-end test suite from this branch
Sajeeth-Wimalasuriyan Nov 17, 2026
92893d1
Ask Optiq: simplify the branch and keep it to the assistant
Sajeeth-Wimalasuriyan Nov 17, 2026
d573dae
Revert non-assistant changes to main
Sajeeth-Wimalasuriyan Nov 17, 2026
1609d15
Ask Optiq: do not report a pill's statistics or a loaded file as the …
Sajeeth-Wimalasuriyan Nov 19, 2026
b6e120a
Merge remote-tracking branch 'origin/main' into sw-fable-review
Sajeeth-Wimalasuriyan Nov 19, 2026
d46d8cd
Ask Optiq: add Stop, and stop goto, the track pill and the Script tab…
Sajeeth-Wimalasuriyan Nov 19, 2026
e56132b
Ask Optiq: keep the key off the screen, out of the settings file and …
Sajeeth-Wimalasuriyan Nov 19, 2026
2aca4ac
Ask Optiq: stop tools telling the model things that are not so, and f…
Sajeeth-Wimalasuriyan Nov 19, 2026
a2aca73
Ask Optiq: skip the discarded draft round, cap the summary preload, a…
Sajeeth-Wimalasuriyan Nov 19, 2026
4383bc5
Ask Optiq: remove branches nothing reaches.
Sajeeth-Wimalasuriyan Nov 19, 2026
8e30a59
Ask Optiq: make four prompt and schema sentences match what the tools…
Sajeeth-Wimalasuriyan Nov 19, 2026
94cbb39
Ask Optiq: ignore a Run press that began before the script offer was …
Sajeeth-Wimalasuriyan Nov 19, 2026
6ddb24c
Ask Optiq: review fixes to what get_summary, goto, flow_arrows and a …
Sajeeth-Wimalasuriyan Nov 19, 2026
801ffae
Ask Optiq: cut the comments the review commits added to two lines.
Sajeeth-Wimalasuriyan Nov 19, 2026
0d5a582
Ask Optiq: keep an offered script out of the user's saved file, and a…
Sajeeth-Wimalasuriyan Nov 19, 2026
1454cae
Ask Optiq: honour a cancel that lands before the request is under way…
Sajeeth-Wimalasuriyan Nov 19, 2026
033a58a
Ask Optiq: cut long tool results on a character boundary, with the on…
Sajeeth-Wimalasuriyan Nov 19, 2026
9374e49
Merge remote-tracking branch 'origin/main' into sw-fable-review
tomk-amd Nov 26, 2026
d78d936
Ask Optiq: give the model list the checks a chat request gets.
tomk-amd Nov 26, 2026
b885439
Ask Optiq: retry only a request that could not be sent.
tomk-amd Nov 26, 2026
5dcea3d
Ask Optiq: refuse __uuid for group_by as well as filters
tomk-amd Nov 26, 2026
37c5b02
Ask Optiq: keep per-turn limits in the panel and share one UTF-8 cut.
tomk-amd Nov 26, 2026
8e8911d
Ask Optiq: correct three comments that no longer match the code.
tomk-amd Nov 26, 2026
9004ee2
Ask Optiq: test key redaction, cleartext detection, inline calls and …
tomk-amd Nov 26, 2026
39f3741
missed addiing / committing new url helper file s
tomk-amd Nov 27, 2026
aac8e2c
Ask Optiq: ignore dummy key fixtures in the gitleaks scan.
tomk-amd Nov 27, 2026
d8430e9
Ask Optiq: build the client tests on MSVC, and fix four review findings.
Sajeeth-Wimalasuriyan Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions .agents/SCRIPTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,21 +460,26 @@ mutation still belongs to `OptiqActions`. Four things it relies on:
chain as every other UI action, so nothing in `agenticprofiling/`
keeps a pointer to a view that a closing tab could take away.
- **The wait is on a person, so it gets its own deadline.**
`AssistantToolStartResult::timeout_seconds` overrides the 45s a fetch
runs under; the script tool asks for 300. The panel also routes a
timed-out `kScript` fetch back through
`AssistantToolStartResult::timeout_seconds` overrides the 350s a fetch
runs under; the script tool asks for 300. Pressing Run starts that
deadline again (`AssistantScriptRunning`), so a run approved late in
the reading time is not reported unfinished seconds after it began.
The panel also routes a timed-out `kScript` fetch back through
`FinishAssistantScriptFetch` rather than reporting a generic timeout,
because only that side knows whether the user never answered or the
run was abandoned, and it has an outstanding offer to clear.
- **`ScriptApproval` is the whole state machine.** `kPending` ->
`kRunning` -> `kFinished` on approval, `kRejected` on refusal, and
`kFailedToStart` when an approved run could not begin - which exists
`kRunning` -> `kFinished` on approval, `kRejected` on refusal or when
the user stops the approved run (so the model hears it was their
decision and is not asked to fix a failure), and `kFailedToStart`
when an approved run could not begin - which exists
so a script that never started still answers the assistant instead of
waiting out the full five minutes. `AssistantScriptFetchPending` is
true for `kPending` and `kRunning` only.
- **An offer is pinned to its trace.** `Run` refuses when the tab in
front is not the trace the script was written against, the same
mistake `m_turn_project_id` guards elsewhere.
- **An offer is pinned to its trace.** There is one editor per trace
and the tool offers into the turn's own, refusing when that trace is
not in front, so `Run` can only start the script on the trace it was
written against.
- **Events are filtered by source id.** Every editor hears every
`ScriptExecuteCompleteEvent`, and there is one editor per trace, so
each answers only events carrying the trace it started a run on.
Expand Down Expand Up @@ -779,25 +784,17 @@ reasoning moved to the section it belongs to.
`m_running_source_id` set and the request in flight. The old run's
completion event still matches that id, so it overwrites the new
offer's output while approval stays `kPending` and Ask Optiq waits
out its deadline. It also discards an unsaved draft without asking.
Cancel or refuse the propose while a run is live, and clear
`m_running_source_id` on every path that leaves Running.
out its deadline. Cancel or refuse the propose while a run is live,
and clear `m_running_source_id` on every path that leaves Running.
- **File dialogs capture raw `this`.** `LoadFromFile` / `SaveToFile`
hand `[this](std::string path)` to `AppWindow::ShowOpenFileDialog` /
hand callbacks that capture `this` to `AppWindow::ShowOpenFileDialog` /
`ShowSaveFileDialog`, which hold the callback until the user
confirms. Closing the trace tab destroys the `ScriptEditor` first,
and `UpdateNativeFileDialog` can then call into freed memory; tab
close does not clear `m_file_dialog_callback`. Wants a `weak_ptr` or
a generation token, or cancelling pending dialogs on teardown. It is
the same shape §3's run generation solves on the binding side: a
callback outliving the thing it points at.
- **A cancelled run is reported to the model as a failure.**
`GetLastScriptResult` returns false for "never ran", "failed" and
"cancelled" alike, and `FinishAssistantScriptFetch` turns that into
*"The script failed:"*, so the assistant may try to fix and re-offer
a script the user deliberately stopped. It handles `kRejected`,
`kFailedToStart`, `kPending` and `kRunning` separately already;
cancel needs the same treatment.

### Sandbox

Expand Down
66 changes: 56 additions & 10 deletions .agents/UI.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,14 @@ Ask Optiq offers a script through `OptiqActions::ProposeScript`, which
fills this tab and selects it; nothing runs until the user presses Run
or Reject. `ScriptApproval` is that state machine, and
`ScriptExecuteCompleteEvent` is filtered by trace source id because
every editor hears every one of them.
every editor hears every one of them. The source is read-only while an
offer waits, and Run is disabled for `SCRIPT_OFFER_MIN_READ_SECONDS`
after the offer first draws: it lands under a Run button that was
already there, so a click aimed at the user's own script must not run
the new one. A press that began before the offer drew is ignored for the
same reason, however long it was held. Save writes the text as it was
when Save was pressed, so an offer that lands while the dialog is open
is not saved under the name the user picked for their own script.

## 8. Track Item Hierarchy

Expand Down Expand Up @@ -2689,7 +2696,10 @@ Layered, transport at the bottom and the panel at the top:
operator whitelists rather than escaping, quoted string literals, and
escaped `LIKE` wildcards paired with an explicit `ESCAPE` clause. Its
columns must be names the returned rows carry (`node`, not the SQL
`nodeId`), since a filter on any other name matches nothing.
`nodeId`), since a filter on any other name matches nothing. `__uuid`
is refused for filters and `group_by` before the list is checked: the
table compares and groups through a `double`, which cannot hold a uuid
exactly, so neighbouring events would match or merge.
- `rocprofvis_ai_tools.{h,cpp}` - the public executor surface plus
`StartAssistantTool`, which parses the arguments, refuses everything
but `offer_next_steps` when no trace is ready, parks while a trace is
Expand Down Expand Up @@ -2752,7 +2762,9 @@ Layered, transport at the bottom and the panel at the top:
would). Every summary list is trimmed to the busiest names plus
"Others", so the tools point at `top_events` for a full ranking.
`AssistantSummaryLoaded` is the one "is the summary there" check,
shared with the panel's summary warmup. `BuildAssistantBriefing`
shared with the panel's summary warmup. A summary that loaded with
nothing in it (`AssistantSummaryCurrent`) is reported as empty by the
briefing and by `get_summary`, not fetched again. `BuildAssistantBriefing`
lives here too and hands a compute trace straight to
`BuildAssistantComputeBriefing`, so nothing system-shaped describes a
workload.
Expand Down Expand Up @@ -2861,7 +2873,7 @@ Integration points:
same. When the endpoint lists models, the arrow beside the name opens
that list.
- `TraceView` and `AnalysisView` expose the plain accessors
`OptiqActions` needs (`ZoomToRange`, `SelectAnalysisTab`,
`OptiqActions` needs (`ResetView`, `SelectAnalysisTab`,
`ListBookmarks`, and friends). Reuse those rather than reaching into
their members.

Expand All @@ -2879,7 +2891,17 @@ Rules that are easy to get wrong here:
- **Tool rounds and the answer are separate HTTP calls.** When the
model stops calling tools, `BeginFinalAnswer` discards that draft and
spends one more round with tools off, which is the only prose the
user reads.
user reads. The draft round is skipped when a batch offered next steps
and everything else in it was a UI action carried out as asked
(`AssistantToolStartResult::settled`): nothing in those replies calls
for another tool, so `ContinueAfterTools` goes straight to the
tools-off round. A batch that read data, or in which an action
missed, still gets its round. A UI tool sets `settled` only on the
path where it did exactly what was asked.
- **The summary preload waits ten seconds, not for the summary.** Past
`ASSISTANT_WARMUP_TIMEOUT_SECONDS` the question goes out, the briefing
says the summary is still loading instead of printing zero totals,
and `get_summary` parks on the request already in flight.
- **The prompt is a shared base plus one body per trace kind.**
`AssistantSystemPrompt(is_compute)` concatenates
`ASSISTANT_SHARED_OPENING`, then either
Expand Down Expand Up @@ -3009,7 +3031,10 @@ Rules that are easy to get wrong here:
against the original timeout deadline. It returns a timeout rather
than treating the other query's rows as its own.
- **HTTP runs on a worker via `std::async`, and must stay cancellable.**
`AssistantChatCall::Cancel()` closes the socket. Clear and tab close move
`AssistantChatCall::Cancel()` closes the socket. One that lands before
httplib has a request in flight finds no socket to close, so `Send`
also passes an upload-progress callback that stops the body write
once `Cancel()` has been called. Clear and tab close move
the cancelled future to `m_abandoned`, which `Update()` reaps when ready,
rather than destroy a `std::async` future and block the UI; final panel
destruction cancels and joins every remaining worker.
Expand All @@ -3036,10 +3061,31 @@ Rules that are easy to get wrong here:
clients cannot enter the reserved band below it.
- **The API key lives in `SecretStore`, never in settings JSON and
never in a log line.** `AssistantProvider` is the saved record in
`UserSettings::assistant`, and holds only name, URL, and model.
A draft URL receives the stored key only while it has the saved URL's
origin. Accepting another origin clears the old key before saving the
new URL; if that clear fails, the URL change is rejected.
`UserSettings::assistant`, and holds only name, URL, and model. A key
pasted into the URL is kept out too: `AssistantStorableUrl` drops
userinfo, a fragment, and every query parameter but an API version,
when the file is read, when OK is pressed, and when it is written, and
the hover cards show the URL without its query.
- **Two layers keep a key with its host.** The stored value records the
origin the key was saved for, and `GetAssistantToken` hands the key
out only while the endpoint's URL still has that origin. A key saved
before keys were bound is bound at its first read, and not handed out
while the store refuses that write: left unbound, it would follow an
edited URL. In Preferences, a draft URL receives the stored key only
while it has the saved URL's origin, and accepting another origin
clears the old key before saving the new URL; if that clear fails, the
URL change is rejected.
- **Nothing the model reads, and nothing it sends back, may carry the
key.** `AssistantRedactKey` blanks the turn's key in the question
before it is shown or kept (`SendCurrentInput`), in every tool reply
before it is logged or kept (`AppendToolReply`), in every message as
the client serializes it, and in the reply, error text and tool calls
an endpoint returns. A new path that puts text in front of the model
or on screen has to pass one of those points.
- **A next step is shown as it is sent.** A click sends the step as the
user's own message, which is what unlocks notes, bookmarks and tab
switches, so `PrintableStep` removes the `##` that would hide part of
a button label.
- **One model list, two pickers.** The panel owns the
`AssistantModelCatalog` and polls it in `Update()`, requesting a render
while a lookup runs, since the app draws on demand. The header asks for
Expand Down
10 changes: 10 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
#
# One-off gitleaks false positives. Each line is a finding fingerprint:
# commit:file:rule:line
# See .github/scan_tools_configs/gitleaks.toml.

# Ask Optiq unit tests. Dummy key and subscription-key fixtures, not credentials.
9004ee29262f5f5b41db4e735f5a6b0e4c36c0f0:src/view/test/rocprofvis_ai_client_tests.cpp:generic-api-key:233
9004ee29262f5f5b41db4e735f5a6b0e4c36c0f0:src/view/test/rocprofvis_ai_assistant_tests.cpp:generic-api-key:430
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ set(VIEW_FILES
src/view/src/rocprofvis_timeline_arrow.cpp
src/view/src/rocprofvis_events_view.cpp
src/view/src/rocprofvis_settings_manager.cpp
src/view/src/rocprofvis_assistant_url.cpp
src/view/src/rocprofvis_font_manager.cpp
src/view/src/rocprofvis_annotations.cpp
src/view/src/rocprofvis_settings_panel.cpp
Expand Down Expand Up @@ -537,13 +538,15 @@ if(BUILD_TESTING)
target_link_libraries(${ISA_DATA_TEST_NAME} PRIVATE Catch2::Catch2WithMain)
add_test(NAME ${ISA_DATA_TEST_NAME} COMMAND ${ISA_DATA_TEST_NAME})

# The trace link store and run diff behind compare_traces need no GPU,
# trace, UI, endpoint, or feature define, so every test build covers them.
# The trace link store, the run diff behind compare_traces, and what of an
# endpoint URL may be saved need no GPU, trace, UI, endpoint, or feature
# define, so every test build covers them.
set(ASSISTANT_TEST_NAME ${TARGET_NAME}-assistant-tests)
add_executable(${ASSISTANT_TEST_NAME}
src/view/test/rocprofvis_ai_assistant_tests.cpp
src/view/src/agenticprofiling/rocprofvis_ai_trace_compare.cpp
src/view/src/agenticprofiling/rocprofvis_ai_trace_links.cpp
src/view/src/rocprofvis_assistant_url.cpp
src/view/src/rocprofvis_json_utils.cpp)
target_include_directories(${ASSISTANT_TEST_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/view/src)
Expand Down
33 changes: 33 additions & 0 deletions src/core/inc/rocprofvis_core_string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,39 @@ namespace String
return s;
}

// ---- UTF-8 boundaries ----

// Whether a cut at pos would split a UTF-8 character: the byte there
// continues one rather than starting it.
inline bool is_utf8_continuation(const std::string& s, size_t pos)
{
constexpr unsigned char UTF8_CONTINUATION_MASK = 0xC0;
constexpr unsigned char UTF8_CONTINUATION_BITS = 0x80;
return pos < s.size() &&
(static_cast<unsigned char>(s[pos]) & UTF8_CONTINUATION_MASK) ==
UTF8_CONTINUATION_BITS;
}

// The nearest character boundary at or before pos, where s can be cut short.
inline size_t utf8_floor(const std::string& s, size_t pos)
{
while(pos > 0 && is_utf8_continuation(s, pos))
{
--pos;
}
return pos;
}

// The nearest character boundary at or after pos, where a tail can start.
inline size_t utf8_ceil(const std::string& s, size_t pos)
{
while(pos < s.size() && is_utf8_continuation(s, pos))
{
++pos;
}
return pos;
}

} // namespace String
} // namespace Core
} // namespace RocProfVis
48 changes: 32 additions & 16 deletions src/view/src/agenticprofiling/rocprofvis_ai_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ StripPanelFiller(const std::string& key)
OptiqPanel
PanelFromKey(const std::string& key)
{
if(key == "minimap" || key == "map" || key == "overview" ||
key == "birdseye" || key == "thumbnail")
if(key == "minimap" || key == "map" || key == "birdseye" || key == "thumbnail")
{
return OptiqPanel::kMinimap;
}
if(key == "histogram" || key == "activity" || key == "activitybar" ||
key == "activitygraph" || key == "activitychart" || key == "density")
// The View menu calls this strip "Timeline Overview", so "overview" means
// the histogram and not the minimap.
if(key == "histogram" || key == "overview" || key == "timelineoverview" ||
key == "activity" || key == "activitybar" || key == "activitygraph" ||
key == "activitychart" || key == "density")
{
return OptiqPanel::kHistogram;
}
Expand Down Expand Up @@ -197,7 +199,7 @@ OptiqActions::PanelName(OptiqPanel panel)
std::string
OptiqActions::PanelNameList()
{
return "minimap (map, overview), histogram (activity), topology (sidebar, "
return "minimap (map), histogram (timeline overview, activity), topology (sidebar, "
"navbar, tree, tracks, left panel), details (analysis, tables, event "
"table, bottom), summary (stats), log (console, output), toolbar (top "
"bar), annotations (notes, sticky notes). Whatever the user called it "
Expand Down Expand Up @@ -248,6 +250,12 @@ OptiqActions::ShowPanel(OptiqPanel panel, bool visible)
}
case OptiqPanel::kSummary:
{
// Compare projects have no summary, so opening it there would
// report a panel that cannot appear.
if(visible && m_trace_view != nullptr && !m_trace_view->SummarySupported())
{
return false;
}
app_settings.show_summary = visible;
return true;
}
Expand Down Expand Up @@ -407,6 +415,12 @@ OptiqActions::ProposeScript(const std::string& source)
return true;
}

bool
OptiqActions::ScriptHasUnsavedDraft() const
{
return m_trace_view != nullptr && m_trace_view->ScriptHasUnsavedDraft();
}

ScriptApproval
OptiqActions::ScriptProposalState() const
{
Expand All @@ -422,6 +436,15 @@ OptiqActions::ClearScriptProposal()
m_trace_view->ClearScriptProposal();
}
}

void
OptiqActions::RejectScriptProposal()
{
if(m_trace_view != nullptr)
{
m_trace_view->RejectScriptProposal();
}
}
#endif

bool
Expand Down Expand Up @@ -502,17 +525,6 @@ OptiqActions::ClearMeasurement()
return true;
}

bool
OptiqActions::ZoomToRange(double start_ns, double end_ns)
{
if(m_trace_view == nullptr || !is_usable_time_range(start_ns, end_ns))
{
return false;
}
m_trace_view->ZoomToRange(start_ns, end_ns);
return true;
}

bool
OptiqActions::AddNote(double time_ns, const std::string& title, const std::string& text,
double v_min, double v_max, uint64_t track_id)
Expand All @@ -533,6 +545,10 @@ OptiqActions::SelectRange(double start_ns, double end_ns)
return false;
}
m_timeline_selection->SelectTimeRange(start_ns, end_ns);
// The timeline applies this when the selection event is dispatched next
// frame. Applied now, a statistics read later in the same batch is not
// voided mid-flight by the range it was asked under.
m_data_provider->DataModel().GetAnalysis().SetAnalysisRange(start_ns, end_ns);
return true;
}

Expand Down
9 changes: 5 additions & 4 deletions src/view/src/agenticprofiling/rocprofvis_ai_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ class OptiqActions
// --- Scripts ----------------------------------------------------------

// Puts a script in the Script tab and brings the user to it. Nothing runs:
// they press Run or Reject, and ScriptProposalState reports which.
// they press Run or Reject, and ScriptProposalState reports which. Fails,
// changing nothing, when ScriptHasUnsavedDraft.
bool ProposeScript(const std::string& source);
bool ScriptHasUnsavedDraft() const;
ScriptApproval ScriptProposalState() const;
void ClearScriptProposal();
// Declines an offer on the user's behalf, for one they never answered.
void RejectScriptProposal();
#endif

// --- Timeline options -------------------------------------------------
Expand All @@ -105,9 +109,6 @@ class OptiqActions
bool SetFlowArrowsVisible(bool visible);
bool SetFlowRenderChained(bool chained);

// Zoom the visible window, rather than only selecting a range.
bool ZoomToRange(double start_ns, double end_ns);

// --- Leaving something behind ------------------------------------------

// Pins a sticky note on the timeline. Saved with the project, so this is
Expand Down
Loading
Loading