Trace UI - Update session ID pills to link to the chat session and scroll to the turn corresponding turn#18985
Conversation
| export const shouldEnableChatSessionsTab = () => { | ||
| return false; | ||
| }; |
There was a problem hiding this comment.
Seems like this was a bug / problem with the Databricks -> MLflow UI sync. As a result of this returning false, the session ID link in the traces table was broken
| }; | ||
|
|
||
| export const shouldEnableChatSessionsTab = () => { | ||
| return false; |
There was a problem hiding this comment.
Similar bug in Databricks -> MLflow UI sync
| export const shouldEnableChatSessionsTab = () => { | ||
| return true; | ||
| }; |
There was a problem hiding this comment.
I don't believe we need these flags / gates for "should enable chat session" anymore. Looks like they had some unintended consequences - https://github.com/mlflow/mlflow/pull/18985/files#r2554699617.
There was a problem hiding this comment.
i'm guessing it's fine if we remove the flag from databricks as well given it's fully released anyway?
| <Tooltip | ||
| componentId="mlflow.chat-sessions.copy-session-id" | ||
| content={ | ||
| showCopyTooltip ? ( | ||
| <FormattedMessage defaultMessage="Copied!" description="Tooltip after copying session ID" /> | ||
| ) : ( | ||
| <FormattedMessage defaultMessage="Copy session ID" description="Tooltip for copy session ID button" /> | ||
| ) | ||
| } | ||
| open={showCopyTooltip ? true : undefined} | ||
| > | ||
| <CopyIcon | ||
| onClick={handleCopySessionId} | ||
| css={{ | ||
| cursor: 'pointer', | ||
| color: theme.colors.textSecondary, | ||
| fontSize: 16, | ||
| '&:hover': { | ||
| color: theme.colors.textPrimary, | ||
| }, | ||
| }} | ||
| /> | ||
| </Tooltip> |
There was a problem hiding this comment.
let's reuse <CopyActionButton> for this! import from @databricks/web-shared/copy
There was a problem hiding this comment.
Awesome - reused!
| return <div />; | ||
| } | ||
| useEffect(() => { | ||
| if (selectedTraceIdFromUrl && traces && traces.length > 0 && !isLoadingTraceDatas) { |
There was a problem hiding this comment.
Not sure if all of these conditions are needed... @daniellok-db , can you advise?
There was a problem hiding this comment.
i think they are needed because if the traces aren't loaded there won't be anything to scroll to. plus we are using the traces array and searching through to find the selected trace so it makes sense to require them to be defined / contentful
There was a problem hiding this comment.
Got it - thanks! :)
|
Documentation preview for f0b0c01 is available at: More info
|
| }: { | ||
| sessionId: string; | ||
| experimentId: string; | ||
| traceId?: string; |
There was a problem hiding this comment.
would this ever be null? this is rendered in the trace table so i suppose a trace would have to exist
| traceId?: string; | |
| traceId: string; |
There was a problem hiding this comment.
ah... i see the typescript types are kind of messed up in the trace table. i guess it's fine to leave it like this then
There was a problem hiding this comment.
Thanks - yeah, I think this can probably be addressed in our upcoming trace table refactor?
| const url = traceId | ||
| ? `${MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId)}?selectedTraceId=${encodeURIComponent( | ||
| traceId, | ||
| )}` | ||
| : MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId); |
There was a problem hiding this comment.
related to above can we use URLSearchParams and get rid of the ternary if traceId doesn't have to be nullable? also nit: maybe define and export a const for selectedTraceId so it can be imported and used in the sessions tab as well.
| const url = traceId | |
| ? `${MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId)}?selectedTraceId=${encodeURIComponent( | |
| traceId, | |
| )}` | |
| : MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId); | |
| const searchParams = new URLSearchParams({ selectedTraceId: traceId } ); | |
| const url = `${MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId)}?${searchParams.toString()}` |
There was a problem hiding this comment.
just saw that it's nullable to satisfy typescript. i think it's fine to keep the ternary then but let's still use URLSearchParams rather than calling encodeURIComponent. they are effectively the same but URLSearchParams is more canonical
| content={<FormattedMessage defaultMessage="View chat session" description="Tooltip for the session id tag" />} | ||
| > | ||
| <Link to={getExperimentChatSessionPageRoute(experimentId, sessionId)} target="_blank" rel="noopener noreferrer"> | ||
| <Link to={sessionPageUrl}> |
There was a problem hiding this comment.
was it intentional to remove the open in new tab behavior? i imagine it might be useful to default to new tab if the user is browsing through the trace and wants to view the session later.
There was a problem hiding this comment.
Just personal preference - I found it a bit confusing that the session always opened in a new tab, whereas other links in the MLflow UI don't create new tabs. If the dev wants a new tab, they can command + click
daniellok-db
left a comment
There was a problem hiding this comment.
overall LGTM but let's address the comments before merge
| @@ -0,0 +1,58 @@ | |||
| import { render, screen } from '@testing-library/react'; | |||
| import { IntlProvider } from 'react-intl'; | |||
| import { MemoryRouter } from 'react-router-dom'; | |||
There was a problem hiding this comment.
use TestRouter from here:
There was a problem hiding this comment.
Awesome - done :)
dbczumar
left a comment
There was a problem hiding this comment.
Thanks for the review, @daniellok-db :). Will merge when tests pass
| <Tooltip | ||
| componentId="mlflow.chat-sessions.copy-session-id" | ||
| content={ | ||
| showCopyTooltip ? ( | ||
| <FormattedMessage defaultMessage="Copied!" description="Tooltip after copying session ID" /> | ||
| ) : ( | ||
| <FormattedMessage defaultMessage="Copy session ID" description="Tooltip for copy session ID button" /> | ||
| ) | ||
| } | ||
| open={showCopyTooltip ? true : undefined} | ||
| > | ||
| <CopyIcon | ||
| onClick={handleCopySessionId} | ||
| css={{ | ||
| cursor: 'pointer', | ||
| color: theme.colors.textSecondary, | ||
| fontSize: 16, | ||
| '&:hover': { | ||
| color: theme.colors.textPrimary, | ||
| }, | ||
| }} | ||
| /> | ||
| </Tooltip> |
There was a problem hiding this comment.
Awesome - reused!
| @@ -0,0 +1,58 @@ | |||
| import { render, screen } from '@testing-library/react'; | |||
| import { IntlProvider } from 'react-intl'; | |||
| import { MemoryRouter } from 'react-router-dom'; | |||
There was a problem hiding this comment.
Awesome - done :)
| }: { | ||
| sessionId: string; | ||
| experimentId: string; | ||
| traceId?: string; |
There was a problem hiding this comment.
Thanks - yeah, I think this can probably be addressed in our upcoming trace table refactor?
| const url = traceId | ||
| ? `${MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId)}?selectedTraceId=${encodeURIComponent( | ||
| traceId, | ||
| )}` | ||
| : MlflowUtils.getExperimentChatSessionPageRoute(experimentId, sessionId); |
| content={<FormattedMessage defaultMessage="View chat session" description="Tooltip for the session id tag" />} | ||
| > | ||
| <Link to={getExperimentChatSessionPageRoute(experimentId, sessionId)} target="_blank" rel="noopener noreferrer"> | ||
| <Link to={sessionPageUrl}> |
There was a problem hiding this comment.
Just personal preference - I found it a bit confusing that the session always opened in a new tab, whereas other links in the MLflow UI don't create new tabs. If the dev wants a new tab, they can command + click
| return <div />; | ||
| } | ||
| useEffect(() => { | ||
| if (selectedTraceIdFromUrl && traces && traces.length > 0 && !isLoadingTraceDatas) { |
There was a problem hiding this comment.
Got it - thanks! :)

🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
Trace UI - Update session ID pills to link to the chat session and scroll to the turn corresponding turn
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.