Skip to content

feat(ui): render ChartArtifact plots full-width on the work unit page - #710

Closed
AntonTyb wants to merge 3 commits into
feat/chart-artifact-examplefrom
feat/chart-artifact-ui-view
Closed

AntonTyb wants to merge 3 commits into
feat/chart-artifact-examplefrom
feat/chart-artifact-ui-view

Conversation

@AntonTyb

@AntonTyb AntonTyb commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Stacked on #676 (base branch feat/chart-artifact-example).

The chart artifact example from #676 works end to end, but the chart it produces is never
drawn. On the work unit Artifacts tab a ChartArtifact renders as a narrow card in one
of the three pipeline columns, listing its metric names and dumping its chart field as
JSON. This PR makes it plot.

Three defects had to be fixed, two on the server side and one on the client.

Experiment State Server (dashboard_observer.go)

1. The provisioned chart had no plots. OnArtifactCreated called CreateChart with only
Title, Xid and Wid. dataengine.FetchChartData iterates chart.GetPlots(), so a chart
with no plots yields no data no matter how many metrics the work unit logged — the chart is
not empty-looking, it is unqueryable.

The observer now derives plot specs from the artifact's metric_names: per metric, a
SUMMARY_BOX for the latest value and a step-indexed SCATTER curve, on a two-column GRID
layout. Metric names are path-like (chart_demo/loss), so they are slugified into plot IDs,
with a counter suffix disambiguating names that slugify alike (train/loss vs train_loss).
The number of metrics expanded is capped at 20 — the list is client-supplied and the data
engine runs one query per plot, so an unbounded list turns a single GetChartData into a
proportionally expensive fan-out.

2. The artifact never recorded which chart was provisioned for it. The CreateChart
response was discarded, so ChartArtifact.chart stayed empty and a reader was left holding a
list of metric names with no way to find the chart that draws them. The observer now stores
the created Chart (which carries the server-assigned resource name) on the artifact payload
before the Spanner write.

The alternative considered and rejected was a UI-side ListCharts on the work unit parent —
that is a by-parent heuristic, whereas this gives artifact → chart identity, and it is what
the OUTPUT_ONLY chart field in the proto was there for.

3. The CreateChart call was never authenticated. Found during manual testing of this
PR: every chart artifact came back FAILED with

rpc error: code = Unauthenticated desc = failed to authenticate user:
missing authentication token in metadata: rpc error: code = Unauthenticated desc = unauthenticated

The Dashboard Service connection is dialed insecure with no per-RPC credentials
(prod.go:initDashboardClient), and grpc-go does not carry incoming metadata onto outgoing
calls, so the observer's CreateChart arrived with no token at all and
createchart.go rejected it. The observer stored that in error_message and marked the
artifact FAILED.

An Experiment State Server identity would not have fixed it: CreateChart calls
authorizeExperimentWrite(ctx, user, xid), authorizing the user's WRITER role on the
experiment, so the user's own token is the one that has to make the trip. withForwardedAuth
copies x-goog-iap-jwt-assertion / authorization off the incoming context onto the outgoing
one. When there is nothing to copy it logs a warning and calls anyway — whether an anonymous
call is acceptable is the Dashboard Service's decision, not the observer's.

This defect predates the PR; it was simply invisible, because the narrow artifact card never
rendered error_message. The full-width view below does.

UI

New standalone component xmc-chart-artifact-view under
cmd/ui/app/common/components/artifacts_list/chart_artifact_view/:

  • Renders as a full-width band above the three-column pipeline on the Artifacts tab, one
    band per chart artifact. The narrow card stays in its pipeline column as the index entry.
    :host deliberately has no max-width, unlike chart_card.scss — the whole point is to
    use the width the pipeline column cannot give it. Summary boxes go side by side across the
    top; curves stack, so each gets the full width for its x axis.
  • Takes the plot specs from the artifact payload (the field the ESS change now populates) and
    the series data from DashboardService.getChartData, reusing xmc-plot-card and the
    PlotDataPipe already exported by chart_card.ts.
  • When there is nothing to draw it says which state the artifact is in — still provisioning,
    provisioning failed (surfacing the server's error_message), or provisioned with no plots —
    rather than showing an empty panel. A chart artifact is provisioned asynchronously, so it
    spends its first moments naming metrics it cannot yet plot.
  • Rendered on work unit pages only (artifacts_list.ts gates on parseWorkUnitName). An
    experiment page lists the artifacts of every one of its work units and each band costs one
    GetChartData, so drawing them all there would fan out to a request per work unit on a page
    that never asked for plots.

ChartArtifactPayload.chart is retyped from Record<string, unknown> to Chart.

Verification

Run locally, all green:

  • ng test --watch=false — 558 specs pass, 9 of them new
    (chart_artifact_view_test.ts).
  • tsc -p tsconfig.json --noEmit — clean.
  • eslint and prettier --check on the changed files — clean.
  • ./.githooks/pre-commit --check — buildifier, gofmt, golangci-lint, addlicense and ruff all
    pass. It still exits non-zero, but only because mypy/terraform/tflint/trivy are absent from
    this machine and the hook counts a skipped tool as a failure.
  • The chart artifact example was run end to end against a live deployment, which is how the
    Unauthenticated defect surfaced.

Not verified locally: the Go change could not be compiled or run. This checkout's Go
import paths are Bazel-mapped (xmanager_cloud/dashboard_service/proto/api_go_proto and
friends have no on-disk Go package) and Bazel is not installed here, so go build/go test
fail on every import. The new tests in dashboard_observer_test.go cover the derived plot
IDs, types, metrics and layout; that the artifact records the created chart; the empty
metric_names case; blank-name skipping; slug collisions; the placeholder slug for a name
with no usable characters; the cap; credential forwarding for both header names; that
non-credential headers are not forwarded; and that a call with no credentials is still issued.
CI is their first real run.

Also not verified: the rendered appearance. The band's look has not been seen in a browser.

Notes for the reviewer

  • Size. Over the 400-line threshold. Splitting the ESS fixes from the UI component was
    considered, but the UI half alone renders nothing (unauthenticated call, no chart on the
    artifact, no plots on the chart) and the ESS half alone is unobservable, so neither half is
    independently reviewable or testable. Happy to split if you would rather.
  • isSummaryBoxPlot duplicates the plot-type filtering in chart_card.ts. Both accept the
    proto JSON name and the integer tag. Left duplicated rather than refactoring chart_card.ts
    in a PR that is already over the size threshold; worth folding into a shared helper later.
  • Credential forwarding is hand-rolled. No PerRPCCredentials or interceptor pattern
    exists anywhere in this repo to reuse, and only one outbound call needs it. If more
    server-to-server hops appear this belongs in a client interceptor instead.
  • The narrow artifact card is untouched. artifact_card.ng.html still shows the raw chart
    JSON in a collapsible panel. Now that the payload actually carries a chart, that panel has
    real content in it; it seemed better to leave the raw-data view alone than to change two
    surfaces at once.
  • No SCSS added to artifacts_list. That component loads artifacts_list.css, which is a
    license-header-only stub, while artifacts_list.scss is the internal source — so styles
    added there would not apply in the OSS build. The new component carries its own spacing
    instead.

Screenshot

image

Review round 2

Six findings from review, four taken and two answered on the threads.

Finding Outcome
UpdateArtifact reuses the context that bounded CreateChart Fixed. If CreateChart spent the two minutes, the write failed before reaching Spanner, so FAILED never persisted and the artifact sat in PROVISIONING for good. Now writes under context.WithoutCancel with its own 15s deadline. Pre-existing (from #441), taken here because this PR is what makes the stuck state visible.
uniquePlotID collides on names ending in a number Fixed. ["foo", "foo_2", "foo"] handed out foo_2 twice; the UI keys plot data by ID, so both plots drew the same series. Now skips IDs already claimed.
notice() matches only the status' JSON names Fixed. A serializer emitting the enum tag sent FAILED through as a healthy chart, swallowing the error message. chartStatusName normalises both spellings, as isSummaryBoxPlot already did for PlotSpec.type.
getChartData called for a chart with no plots Fixed. Nothing would display the response, and the data engine runs a query per plot behind it.
.chart-artifact-title ellipsis never fires Fixed. white-space: nowrap added; without it the other two properties were dead.
Deterministic ChartId on CreateChart Not taken. Pre-existing, and it does not stop the orphan — there is no retry path here, so it would only make a future retry idempotent. Worth doing, but not in this PR.
toSignal needs initialValue or it throws NG0203 Not taken. Only requireSync: true throws, and with NG0601; without it toSignal returns Signal<T | undefined>. The existing chartData()?.plotsData typing already relies on that.
Initialise isLoading from the payload to avoid a first-render double mount Not taken — could not reproduce. Built it, then instrumented the component: toObservable's effect flushes within the same change-detection pass, so isLoading is already true by the end of the first pass and the two signals never diverge. Checked the DOM directly too: with a never-emitting source the first render shows the spinner and zero plot cards, against the unmodified code. Reverted rather than ship state I could not justify. Details on the thread.

Three tests added, each checked to fail against the old code: the ["foo", "foo_2", "foo"] collision, the status write surviving a finished context, and the notice surfacing errorMessage when the status arrives as the tag 3. Plus a unit test over the status mapping. Full Angular suite green at 561 specs.

TAG=agy
CONV=96ac94bd-c2b9-4753-b54f-b0b6b02d801f

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces full-width rendering of chart artifacts on the work unit page. On the backend, the experiment state server now derives plot specifications (summary boxes and scatter plots) from metric names, limits the metrics to prevent expensive fan-out, and records the assigned chart back to the artifact. On the frontend, a new ChartArtifactView component is added to fetch and display these plots. Feedback on the changes highlights a critical issue in ChartArtifactView where using toSignal on an asynchronous observable chain without an initialValue will cause a runtime crash (NG0203) when initialized with an already-provisioned chart; passing { initialValue: undefined } is recommended to resolve this.

// Record the chart the service assigned. It is the only link from the artifact to
// its plots: without the server-assigned resource name a reader holds a list of
// metric names and no way to find the chart that draws them.
cArtifact.Chart = created

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blocker] Detach context before Spanner status update

ctxBg is scoped to a 2-minute timeout (ctxBg, cancel := context.WithTimeout(ctxBg, 2*time.Minute)). If CreateChart times out or is cancelled, ctxBg.Err() is non-nil (context.DeadlineExceeded / context.Canceled).

Calling o.storage.UpdateArtifact(ctxBg, ...) below with this expired context causes the Spanner transaction to fail immediately with deadline exceeded. The failure status (cArtifact.Status = FAILED) is never persisted to Spanner, stranding the artifact in PROVISIONING permanently in the database and causing the UI to display "The chart for this artifact is still being provisioned. Reload in a moment." indefinitely.

Suggested Fix:

storeCtx, storeCancel := context.WithTimeout(context.WithoutCancel(ctxBg), 15*time.Second)
defer storeCancel()
if _, err := o.storage.UpdateArtifact(storeCtx, &storage.ArtifactUpdate{
    AID:        aid,
    Artifact:   artifactToProvision,
    UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"payload"}},
}); err != nil {
    logging.Error(storeCtx, "Failed to update ChartArtifact status in Spanner", "error", err)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and taken — thank you, this is the one that would actually have stranded users.

To be clear about scope for anyone reading: this is pre-existing rather than something this PR introduced (both the two-minute context.WithTimeout and the UpdateArtifact(ctxBg, ...) come from #441), but this PR is what makes the stuck state visible in the UI, so it belongs here.

Fixed as you suggested: context.WithoutCancel(ctxBg) with its own 15-second deadline. Test added that drives OnArtifactCreated with an already-finished context and asserts the write still arrives at storage with a live context and the FAILED status persists — it fails against the old code.

type dashboardObserver struct {
client *toollibs.DashboardToolClient
storage storage.Storage
wg *sync.WaitGroup
}

// uniquePlotID slugifies a metric name into a plot ID, disambiguating names that slugify to
// the same string ("train/loss" and "train_loss") with a counter suffix. seen is mutated.
func uniquePlotID(metric string, seen map[string]int) string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Slug collision on metric names with pre-existing numeric suffixes

uniquePlotID tracks counts of base slugs via seen[slug]++. If a work unit logs metric names that already carry numeric suffixes (e.g. ["foo", "foo_2", "foo"]):

  • Metric 1 ("foo"): seen["foo"] = 1 -> returns "foo"
  • Metric 2 ("foo_2"): seen["foo_2"] = 1 -> returns "foo_2"
  • Metric 3 ("foo"): seen["foo"] = 2 -> returns "foo_2" (Collision!)

Both Metric 2 and 3 receive PlotId: "foo_2_latest". In the Angular UI, plotDataMap keys by plotId, so one metric overwrites the other, and @for track plot.plotId triggers duplicate key errors.

Suggested Fix:
Use an existence set and loop until an unused slug candidate is found:

func uniquePlotID(metric string, seen map[string]bool) string {
    slug := strings.Trim(nonPlotIDChars.ReplaceAllString(strings.ToLower(metric), "_"), "_")
    if slug == "" {
        slug = "metric"
    }
    candidate := slug
    for i := 2; seen[candidate]; i++ {
        candidate = fmt.Sprintf("%s_%d", slug, i)
    }
    seen[candidate] = true
    return candidate
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and it was worse than a cosmetic duplicate — fixed.

You are right that counting occurrences of a slug is the bug: ["foo", "foo_2", "foo"] hands out foo_2 twice, because the generated suffix collides with a metric that already ends in a number. The consequence is not just a duplicate ID: the UI keys plot data by plot ID (plotDataMap in chart_artifact_view.ts), so both plots would have drawn the same series.

uniquePlotID now takes a map[string]bool of IDs already handed out and increments past any that are taken, as you suggest. Regression test added covering exactly your ["foo", "foo_2", "foo"] case, asserting both the expected IDs and that no ID repeats.

// Call Dashboard service.
_, err := o.client.CreateChart(ctxBg, &dashboard_pb.CreateChartRequest{
created, err := o.client.CreateChart(ctxAuth, &dashboard_pb.CreateChartRequest{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Pass deterministic ChartId for idempotency

CreateChartRequest omits ChartId. When omitted, Dashboard Service generates a random UUID (uuid.New().String()). If CreateChart succeeds but the subsequent Spanner write fails or the observer is retried, the initial chart is permanently orphaned in the Dashboard Service database without an artifact linking to it.

Suggested Fix:
Derive ChartId deterministically from the artifact ID (per AIP-133):

created, err := o.client.CreateChart(ctxAuth, &dashboard_pb.CreateChartRequest{
    Parent:  fmt.Sprintf("experiments/%d/workUnits/%d", xid, wid),
    ChartId: fmt.Sprintf("art-%d", aid),
    Chart: &dashboard_apipb.Chart{ ... },
})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferring this one, but not dismissing it — a deterministic ID is the right shape and AIP-133 is the right reference.

Two reasons it is not in this PR. First, it is pre-existing: origin/main omits ChartId on this same call, so it is not something introduced here.

Second, and more to the point, I do not think it fixes the orphan on its own. There is no retry path in this goroutine — if the Spanner write fails we log and return, and nothing comes back to try again. A deterministic ID makes a future retry idempotent, which is genuinely valuable, but the chart is equally orphaned either way until that retry exists. So the fix for the orphaning is a retry, and the deterministic ID is what makes that retry safe to write.

The related failure — the status write being refused because it inherited the CreateChart deadline — is fixed in this PR (thread above), and that was the one actually stranding artifacts in PROVISIONING.

Happy to do the deterministic ID plus a retry together as a follow-up. One thing to settle there: art-%d needs checking against whatever the Dashboard Service validates chart IDs with, since the server currently mints UUIDs for this field.

* A ChartArtifact is provisioned asynchronously, so it spends its first moments naming
* metrics it cannot yet plot. Saying which of those states it is in beats a blank panel.
*/
protected readonly notice = computed<string | null>(() => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Support proto numeric enum tags for status

While isSummaryBoxPlot accounts for numeric tags ((plot.type as unknown) === 1), notice only checks string literals:

if (payload.status === "FAILED") { ... }
if (!this.chartName()) {
  return payload.status === "SUCCESS" ? ... : "... still being provisioned ...";
}

When deserialized as numeric enum values (FAILED = 3), payload.status === "FAILED" evaluates to false. It falls through to !this.chartName() where status === "SUCCESS" is also false, resulting in "The chart for this artifact is still being provisioned. Reload in a moment.", completely masking the server error message.

Suggested Fix:

const isFailed = payload.status === "FAILED" || (payload.status as unknown) === 3;
const isSuccess = payload.status === "SUCCESS" || (payload.status as unknown) === 2;
const isProvisioning = payload.status === "PROVISIONING" || (payload.status as unknown) === 1;

if (isFailed) {
  return payload.errorMessage || "The server could not provision a chart for this artifact.";
}
if (isProvisioning) {
  return "The chart for this artifact is still being provisioned. Reload in a moment.";
}
if (!this.chartName()) {
  return "This artifact has no provisioned chart to draw.";
}
if (!this.plots().length) {
  return "The provisioned chart declares no plots, so there is nothing to draw.";
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed and fixed — this was the worst of the four UI ones, because the failure mode is silent.

Added chartStatusName, which normalises ChartArtifact.Status from either spelling to its proto JSON name, mirroring what isSummaryBoxPlot already does for PlotSpec.type two functions up. notice() now compares against the normalised value.

Two tests: one asserting the notice surfaces errorMessage when the status arrives as the tag 3, and a unit test over the mapping including an unknown tag (which stays undefined rather than being coerced to a wrong status). The first fails against the old code with the notice reading "still being provisioned" while the payload carried "dashboard service unavailable" — which is exactly the swallowed error you described.

private readonly dashboardService = inject(DashboardService);
private readonly refreshTrigger$ = new BehaviorSubject<void>(undefined);

protected readonly isLoading = signal<boolean>(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Major] Prevent initial render double-mounting & canvas flicker

toObservable(this.chartName) emits asynchronously in a microtask, while isLoading starts initialized to signal(false).
On initial mount:

  1. The template evaluates @else and mounts all <xmc-plot-card> components with plotData = undefined.
  2. In the microtask, toObservable fires, setting isLoading = true. Angular tears down the plot cards and mounts <mat-spinner>.
  3. When data arrives, isLoading = false, tearing down the spinner and mounting the plot cards a second time.

Suggested Fix:
Initialize isLoading to true when a chart name is present and has plots:

protected readonly isLoading = signal<boolean>(
  !!this.artifact().payload.chart?.name && (this.artifact().payload.chart?.plots?.length ?? 0) > 0,
);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to take this one and then backed it out, because I could not demonstrate the problem — flagging that rather than shipping the change on faith.

I did build it: a showSpinner computed that also went true whenever the data on hand was not the data for the current chart, so it did not depend on isLoading having been set yet. Then I instrumented the component to print both signals around change detection, and got:

PROBE before CD: isLoading=false showSpinner=false
PROBE after  CD: isLoading=true  showSpinner=true

toObservable's effect flushes within the same change-detection pass, so by the end of the first pass isLoading is already true and the two signals never diverge. I also checked the DOM directly: with a never-emitting source, the first render shows the spinner and zero plot cards — against the unmodified code. So there is no frame in which plot cards mount over empty data, at least not one I can produce.

That left me adding a second piece of state and a second computed to fix something I could not reproduce, so I reverted it. If you have seen the flicker in a real browser I will happily dig again — a zoneless or OnPush-with-manual-CD path might well schedule differently from TestBed, and that would be the interesting difference. But I did not want to claim a fix I could not back up.

The other five findings on this review are all fixed.

// GetChartData with an empty name would only turn the wait into an error message.
if (!name) {
this.isLoading.set(false);
return of(undefined);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] Skip network RPC when chart has no plots

When an artifact has a chart name but chart.plots is empty (plots: []), notice() computes "The provisioned chart declares no plots...", but switchMap still executes getChartData({ name }) over HTTP.

Suggested Fix:

switchMap(([name]) => {
  if (!name || this.plots().length === 0) {
    this.isLoading.set(false);
    return of(undefined);
  }
  return this.dashboardService.getChartData({ name }).pipe(...);
})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken — fixed. Added a fetchTarget computed that yields '' when the chart declares no plots, so the pipeline never reaches getChartData. Worth more than the one round trip, since the data engine runs a query per plot behind it.

Test added that swaps in a plotless chart under a different resource name, so the absent plots are the only thing standing between it and a request — with the name held constant the computed never re-emits and the assertion passes vacuously either way, which caught me out on the first attempt.

}

.chart-artifact-title {
margin: 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] Add white-space: nowrap for ellipsis truncation

.chart-artifact-title specifies overflow: hidden; text-overflow: ellipsis; without white-space: nowrap;. Under CSS specifications, text will wrap to multiple lines rather than truncating with an ellipsis.

Suggested Fix:

.chart-artifact-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct — fixed, white-space: nowrap added. Without it the other two properties were dead: the heading wrapped instead, so the ellipsis never appeared.

@AntonTyb
AntonTyb requested a review from janzak-dev September 7, 2026 10:36
@AntonTyb
AntonTyb force-pushed the feat/chart-artifact-example branch from 48931ca to 817a30d Compare September 7, 2026 11:11
A ChartArtifact showed up on the Artifacts tab as a narrow card listing its
metric names and a JSON dump of its chart field. Nothing was plotted, for two
reasons that had to be fixed on both sides of the wire.

Experiment State Server:

  - `dashboardObserver` provisioned the Chart with only a title, an xid and a
    wid. `FetchChartData` iterates `chart.GetPlots()`, so a chart with no plots
    returns no data however much the work unit logged. It now derives plot specs
    from the artifact's `metric_names`: per metric, a SUMMARY_BOX for the latest
    value and a step-indexed SCATTER curve, laid out on a two-column grid. The
    number of metrics expanded is capped, because the list is client-supplied
    and the data engine runs a query per plot.

  - The observer discarded the `CreateChart` response, so the artifact never
    recorded which chart was provisioned for it. It now stores the created Chart
    on the artifact payload, which is what gives a reader the server-assigned
    resource name to fetch data by.

UI:

  - New `xmc-chart-artifact-view`: a full-width band above the three-column
    pipeline on the work unit Artifacts tab, one per chart artifact, drawing the
    plot specs the artifact now carries with data from `GetChartData`. The
    narrow card stays in its pipeline column as the index entry. When there is
    nothing to draw the band says which state the artifact is in -- still
    provisioning, provisioning failed, or provisioned with no plots -- rather
    than showing an empty panel.

  - The band is rendered on work unit pages only. An experiment lists the
    artifacts of all its work units, and each band costs one GetChartData.

  - `ChartArtifactPayload.chart` is typed as `Chart` instead of
    `Record<string, unknown>`.

Verification: `ng test` passes (558 specs, 9 of them new), as do tsc, ESLint and
Prettier. The Go change is covered by new unit tests in
`dashboard_observer_test.go` but could not be compiled or run here -- this
checkout's Go import paths are Bazel-mapped and Bazel is not available -- so
only gofmt and golangci-lint were run against it.

TAG=agy
CONV=96ac94bd-c2b9-4753-b54f-b0b6b02d801f
Background chart provisioning has never been authenticated. The Dashboard
Service connection is dialed insecure with no per-RPC credentials, and
grpc-go does not carry incoming metadata onto outgoing calls, so the
CreateChart the observer issues arrives with no token. The service rejects
it with Unauthenticated, the observer stores that in the artifact's
error_message, and every ChartArtifact ends up FAILED with no chart.

An Experiment State Server identity would not fix it either: CreateChart
authorizes the *user's* WRITER role on the experiment, so the user's own
token is the one that has to make the trip. Copy the credential headers off
the incoming context onto the outgoing one, and warn when there are none to
copy rather than failing the artifact -- whether an anonymous call is
acceptable is the Dashboard Service's decision to make.

This was invisible until the full-width chart view began rendering
error_message; the narrow artifact card never showed it.

TAG=agy
CONV=96ac94bd-c2b9-4753-b54f-b0b6b02d801f
Six review findings on #710, four taken and two answered on the threads.

ESS:

  - uniquePlotID counted occurrences of a slug, so a metric name that
    already ends in a number could collide with a generated suffix:
    ["foo", "foo_2", "foo"] handed out foo_2 twice. Plot IDs are the key
    the UI looks plot data up by, so both plots would have drawn the same
    series. It now skips IDs already claimed.

  - The status write reused the context governing CreateChart. If
    CreateChart is what spent those two minutes, the write failed before
    reaching Spanner, so FAILED never persisted and the artifact sat in
    PROVISIONING for good -- the UI reporting a chart still being
    provisioned by a goroutine that had long exited. It now writes under
    context.WithoutCancel with its own short deadline.

UI:

  - notice() matched ChartArtifact.Status against its proto JSON names
    only. A serializer that emits the enum tag instead sent FAILED
    through as a healthy chart, swallowing the error message the payload
    carried. chartStatusName normalises both spellings, the way
    isSummaryBoxPlot already did for PlotSpec.type.

  - A chart declaring no plots no longer triggers GetChartData: nothing
    would display the response, and the data engine runs a query per plot
    behind it.

  - .chart-artifact-title had text-overflow: ellipsis with no
    white-space: nowrap, so it never ellipsised.

Not taken, with reasoning left on the threads: the suggested
initialValue for toSignal (it defaults to undefined without one --
only requireSync throws), and initialising isLoading from the payload
to avoid a first-render double mount (toObservable's effect flushes
within the same change-detection pass, so isLoading is already true on
the first painted frame; a probe found no frame where the two differ).

TAG=agy
CONV=96ac94bd-c2b9-4753-b54f-b0b6b02d801f
@AntonTyb
AntonTyb force-pushed the feat/chart-artifact-ui-view branch from 9ba7627 to a794a5b Compare September 7, 2026 11:47

@janzak-dev janzak-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this PR into multiple ones - it goes over the agreed upon limits.

Size. Over the 400-line threshold. Splitting the ESS fixes from the UI component was
considered, but the UI half alone renders nothing (unauthenticated call, no chart on the artifact, no plots on the chart) and the ESS half alone is unobservable, so neither half is independently reviewable or testable. Happy to split if you would rather.

If that's a concern - consider first returning mocked/fake data on the backend and building the UI based on that data and later properly generating the backend data.

@AntonTyb

AntonTyb commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

@janzak-dev — split done, closing this in favour of four stacked PRs.

main
└── #676  feat/chart-artifact-example              the example
    └── #809  fix/ess-chart-provisioning-lifecycle   authenticate CreateChart; persist the outcome
        └── #810  feat/ess-chart-artifact-plot-specs   derive plot specs; record the chart on the artifact
            └── #811  feat/ui-chart-artifact-view        full-width rendering, happy path
                └── #812  feat/ui-chart-artifact-view-states  notices, error recovery, refresh
PR Prod Test Total
#809 50 173 223
#810 83 195 278
#811 371 163 534
#812 148 112 260

Each is under the 400/1000 thresholds on its own base (tools/analyze_diff_size.py,
threshold_exceeded: false for all four).

Nothing under review changed. git diff between the top of the stack
(feat/ui-chart-artifact-view-states) and this PR's head is empty — the four slices reproduce
this branch byte-for-byte. Likewise git diff restricted to cmd/experiment_state_server/
between #810 and this branch is empty, so the two backend slices reproduce the backend exactly.
Everything already fixed in review round 2 is carried over.

The cut is by functional depth rather than by layer, but I want to flag the one place it is
not a clean vertical slice:

The three unresolved items from round 2 (deterministic ChartId, toSignal initialValue,
the isLoading double-mount) are answered on the threads here and unchanged by the split.

#713 has been re-parented onto #676, since its one-rule chart_card.scss change never
depended on any of this.

TAG=agy
CONV=96ac94bd-c2b9-4753-b54f-b0b6b02d801f

@AntonTyb AntonTyb closed this Sep 7, 2026
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.

3 participants