The AI Was Right, but the UI Made It Look Wrong
What building a real-time Angular dashboard taught me about snapshots, asynchronous responses, and making correctness visible. The explanation was correct. So why did it look wrong? Imagine a dashboard that c
What building a real-time Angular dashboard taught me about snapshots, asynchronous responses, and making correctness visible.
The explanation was correct. So why did it look wrong?
Imagine a dashboard that continuously receives vehicle telemetry. You click Analyze when the coolant temperature reads 100.6Β°C.
The application captures the data and starts an asynchronous explanation request. You resume the telemetry stream, and the live reading eventually reaches 105.4Β°C.
Meanwhile, the explanation still says:
Coolant temperature was 100.6Β°C in the analyzed snapshot.
The screen now seems to contradict itself: 105.4Β°C on one side, 100.6Β°C on the other.
Did the model hallucinate? Did the analysis use the wrong measurement?
Neither. The explanation describes the reading captured when the request started. The dashboard displays a newer reading. Both values are correct, but the UI makes them look as though they describe the same moment.
In the first article of this series, I explored how an LLM can return perfectly valid JSON containing unsupported claims. This time, I wanted to investigate the opposite problem: the answer is grounded in the right data, but the interface undermines our confidence in it.
To isolate that failure, I built a small standalone Angular 22 application with two views of the same situation: Broken UX and Fixed UX.
One scenario, two interfaces
The tutorial uses a deterministic synthetic coolant-temperature stream. At tick 7, the reading is 100.6Β°C; at tick 23, it is 105.4Β°C.
The generator is deliberately uncomplicated:
export function temperatureAtTick(tick: number): number {
const safeTick = Math.max(0, tick);
return roundTemp(98.5 + safeTick * 0.3);
}
This isn't a real vehicle data feed, and the explainer is a deterministic mock rather than an actual LLM. That's intentional: I wanted the mismatch to be reproducible without API keys, unpredictable generation, or network variability.
Broken UX: a correct explanation looks suspicious
In Broken UX, the live reading is visually prominent. The snapshot context exists but is easy to overlook. The explanation appears beside newer telemetry, and the application highlights the clash:
100.6Β°C β 105.4Β°C
Broken UX: the live dashboard has moved to 105.4Β°C, while the explanation correctly describes the 100.6Β°C snapshot.
Crucially, I didn't make the explainer return fabricated data to create the problem. It always receives the right snapshot. The presentation is deliberately weak.
Fixed UX: show what the answer belongs to
In Fixed UX, the same explanation is explicitly attached to its evidence. The interface emphasizes Analyzed temperature, RECORDED AT, the snapshot ID, the request ID, and the explanation source.
It also pauses an actively playing stream when analysis begins, making the tutorial easier to follow. If the reader used Jump to 100.6Β°C, the replay was already paused by that control.
Fixed UX: the explanation is clearly associated with its captured snapshot and request.
There is no difference in the explanation's accuracy. What changes is the meaning the UI communicates.
Live state is not request state
In Broken UX, the sequence looks like this:
T0 Click Analyze snapshot = 100.6Β°C
T1 Async analysis explanation uses T0 snapshot
T2 Replay continues live reading advances
T3 Compare on screen live = 105.4Β°C, explanation = 100.6Β°C
A live metric answers What is the latest reading?
An analysis result answers What did we conclude about a particular collection of readings?
These questions are different, even if they happen to appear on the same screen.
I found it helpful to model that distinction explicitly instead of assuming every component should derive its content from whatever happens to be the newest Signal value.
Capture evidence before the async boundary
The first important part is a snapshot that belongs to a specific request.
In the demo, the type includes the reading, recent history, a timestamp, and an identifier:
export interface TelemetrySnapshot {
snapshotId: string;
capturedAt: string;
reading: TelemetryReading;
history: readonly TelemetryReading[];
}
The Telemetry service captures it before the analysis starts:
captureSnapshot(): TelemetrySnapshot {
const reading = this.current();
const historyCopy = this.historyInternal().map((item) => ({ ...item }));
return {
snapshotId: createId('snap'),
capturedAt: reading.recordedAt,
reading: { ...reading },
history: historyCopy,
};
}
Notice that the reading and every history entry are copied. The next telemetry tick can update the service's history without changing the values already captured for the request.
One technical distinction matters: these are detached copies, not deeply frozen JavaScript objects. The tutorial does not call Object.freeze(). With the flat reading objects used here, copying them is sufficient to stop later stream updates from mutating the captured evidence. A more complex application may need deeper immutability guarantees.
A snapshot is more than a backup of one number. It is the context against which a response must be interpreted.
Angular Signals make the separation explicit
The live stream is owned by the Telemetry service:
private readonly historyInternal =
signal<TelemetryReading[]>([this.buildReading(0)]);
readonly current = computed(() => {
const history = this.historyInternal();
return history[history.length - 1]!;
});
readonly history = this.historyInternal.asReadonly();
The Analysis service owns a different lifecycle:
readonly analysisStatus = signal<AnalysisStatus>('idle');
readonly activeRequestId = signal<string | null>(null);
readonly capturedSnapshot = signal<TelemetrySnapshot | null>(null);
readonly explanation = signal<ExplanationResult | null>(null);
This is not about putting everything into Signals. It's about defining which state can change with each telemetry tick and which state represents a completed or pending request.
The UI can read both. It just shouldn't silently treat them as equivalent.
The explainer receives a snapshot, not a live service
The mock explainer accepts the captured evidence as an argument:
async explain(
snapshot: TelemetrySnapshot,
requestId: string,
latencyMs: number,
): Promise<ExplanationResult> {
await this.delayFn(latencyMs);
const temp = snapshot.reading.coolantTempC;
const unit = snapshot.reading.unit;
return {
requestId,
snapshotId: snapshot.snapshotId,
groundedTempC: temp,
summary: `Coolant temperature was ${temp}${unit} in the analyzed snapshot.`,
details:
`Based on snapshot ${snapshot.snapshotId} recorded at ${snapshot.capturedAt}, ` +
`coolant_temp measured ${temp}${unit}. This explanation is grounded only on that ` +
`frozen evidence package. It is a deterministic mock β not a real LLM response, ` +
`not an OEM diagnosis, and not genuine vehicle telemetry.`,
source: 'deterministic_mock',
producedAt: new Date().toISOString(),
};
}
The important line is not the text generation. It's this one:
const temp = snapshot.reading.coolantTempC;
There is no late lookup of telemetry.current() after the artificial delay. The explainer uses the data that initiated the operation.
That prevents one category of inconsistency. But it doesn't solve the entire asynchronous-state problem.
What if responses arrive out of order?
Suppose a user starts two analyses:
Request A β snapshot 100.6Β°C β slow response
Request B β snapshot 102.1Β°C β fast response
B finishes first and appears in the UI.
A finishes later and overwrites it.
Every response could be correct for its own snapshot, and the final UI would still show the wrong request.
The demo uses an active request ID. When a response arrives, it may update the interface only if it still belongs to the currently active request:
const result = await this.mockExplanation.explain(
snapshot,
requestId,
this.latencyMs(),
);
// Stale-response protection: only the latest request may publish.
if (this.activeRequestId() !== requestId) {
return;
}
this.explanation.set(result);
this.analysisStatus.set('success');
The error path performs the same check. Reset also clears activeRequestId, so a late response from an earlier request cannot reappear after the interface has been reset.
The Analyze button is disabled during loading, but this guard belongs in the service anyway. State correctness shouldn't depend entirely on one button's disabled state.
In a larger application you might also cancel in-flight requests or use RxJS operators appropriate to the desired semantics. For this tutorial, the request-ID guard makes the rule clear and testable.
Derive mismatch state; don't manually synchronize it
Angular's computed() is useful for showing the discrepancy without introducing another manually maintained flag:
readonly liveVsSnapshotDelta = computed(() => {
const snapshot = this.capturedSnapshot();
if (!snapshot) {
return null;
}
const live = this.telemetry.current().coolantTempC;
const snap = snapshot.reading.coolantTempC;
return {
liveTempC: live,
snapshotTempC: snap,
deltaC: Math.round((live - snap) * 10) / 10,
mismatched: Math.abs(live - snap) >= 0.15,
};
});
The Broken UX annotation is derived from the mode, analysis status, and that calculated difference:
readonly showMismatchAnnotation = computed(() => {
if (this.uxMode() !== 'broken') {
return false;
}
if (this.analysisStatus() !== 'success') {
return false;
}
return this.liveVsSnapshotDelta()?.mismatched === true;
});
The 0.15Β°C cutoff is just a display rule for the tutorial. It is not a mechanical diagnostic threshold.
There is no need to run an effect on every telemetry change just to keep a second copy of this information in sync.
The fix isn't actually βpause the streamβ
In Fixed UX, starting an analysis calls telemetry.pause() and records that the app has chosen a stable presentation:
if (this.uxMode() === 'fixed') {
this.telemetry.pause();
this.autoPausedForAnalysis.set(true);
} else {
this.autoPausedForAnalysis.set(false);
}
That makes the example easy to understand. It is not the guarantee that makes the explanation correct.
A production telemetry system might need to stream continuously. It could show the latest measurement in one panel and the historical analysis in another, without pausing anything.
The important rules are:
- Capture the evidence associated with the operation.
- Correlate each response to the correct request and snapshot.
- Make that relationship visible when presenting the result.
The first two preserve the relationship in code. The third preserves it in the user's mental model.
Test behavior across time, not just at one instant
The repository includes tests for snapshot stability, Broken/Fixed framing, request correlation, stale responses, reset, and error states.
One test deliberately resolves two requests in reverse order:
// Resolve newer request first.
resolvers[1]!();
await second;
expect(analysis.explanation()?.requestId).toBe(secondRequestId);
// Resolve older request afterward β must be ignored.
resolvers[0]!();
await first;
expect(analysis.explanation()?.requestId).toBe(secondRequestId);
That is the test I would care about even if I replaced the mock with an actual LLM API tomorrow.
The question isn't only βIs the response correct?β It is also βDoes this response still belong to the request the UI claims to be showing?β
Try the Angular example
The companion application uses Angular 22, TypeScript 6, Signals, Vitest, a minimal SVG chart, and a deterministic mock explainer. Its local .nvmrc selects Node 24, while the first article's example remains separate.
cd 02-ai-ux-and-snapshots
nvm use
npm install
npm start
To reproduce Broken UX:
- Select Broken UX.
- Click Jump to 100.6Β°C.
- Click Analyze.
- Click Resume, let live telemetry climb toward 105.4Β°C, and compare it with the explanation.
To reproduce Fixed UX:
- Reset and select Fixed UX.
- Jump to 100.6Β°C, then click Analyze.
- Inspect Analyzed temperature, RECORDED AT, the request and snapshot IDs, and the evidence trace.
The service also pauses a genuinely playing stream when analysis begins in Fixed UX; the Jump control itself already leaves playback paused.
Run the checks with:
npm test
npm run typecheck
npm run build
npm audit
Source code: Explore the Angular example on GitHub
What this solves, and what it doesn't
This example does not validate whether a language model is telling the truth. It doesn't even call a language model.
It demonstrates how to preserve and display the context of an asynchronous explanation when the surrounding data changes.
That is deliberately separate from the first article's evidence-validation problem. A perfectly correlated response might still contain fabricated information. A perfectly validated response might still look inconsistent if the UI puts it next to unrelated live state.
Those safeguards solve different problems, and we need to think about both.
I originally approached this as a small frontend detail in an automotive telemetry demo. But the same issue can appear in monitoring dashboards, financial interfaces, analytics tools, and AI assistants that summarize changing information.
The lesson I took away is simple:
A correct answer isn't enough. The interface must make clear what that answer is correct about.
This is part 2 of Engineering Trustworthy Applications, a series inspired by building a real-time automotive telemetry application.
Previously: Your LLM Returned Valid JSON. That Doesn't Mean It's Telling the Truth.
Next: Predicting Threshold Crossings with TypeScript: Regression, Confidence, and Uncertainty.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.
