Skip to content

POC for triage integration with ui#5644

Merged
anandbraman merged 1 commit intomainfrom
anandraman/fde-15-integrate-support-triage-package-with-web-ui
Mar 9, 2026
Merged

POC for triage integration with ui#5644
anandbraman merged 1 commit intomainfrom
anandraman/fde-15-integrate-support-triage-package-with-web-ui

Conversation

@anandbraman
Copy link
Contributor

@anandbraman anandbraman commented Feb 17, 2026

Describe Manual Test Plan

Test with and without plugin from cloud package

Checklist

  • Unit tests added/updated
  • Integration tests added/updated
  • Documentation updated
  • Changelog updated

Breaking Changes?

Mark if you think the answer is yes for any of these components:

Describe Incompatible Changes

Copy link
Collaborator

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

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

POC looks like a reasonable plugin architecture — virtual module resolution via env var is a clean extensibility approach, and the type definitions in triage.ts are solid. Three code-level things to fix before this ships, and the usual missing-tests note.

Commit messages: both need work before merge. "poc for triage integratino with ui" has a typo, is lowercase, and has no body. "remove dependency as it is resolved via plugin instead" is lowercase and doesn't explain why the approach changed. Please git rebase -i and rewrite them with imperative-mood subjects and a brief body explaining the motivation.

Tests: all checklist boxes are unchecked. The web-console has zero running tests — every PR should be nudging this in the right direction. For this PR, the most testable thing is the triage plugin invocation logic. The recommended stack is Vitest + @testing-library/svelte — runs in Node, no browser, no flake. Setup: npm install -D vitest @testing-library/svelte jsdom. A good first test: pure unit tests for any triage utility functions you extract from the component.

@Karakatiza666
Copy link
Contributor

If you are adding the tests, please use vitest-browser-svelte for unit UI tests and @playwright/experimental-ct-svelte for e2e tests - don't use @testing-library/svelte and jsdom

@anandbraman anandbraman force-pushed the anandraman/fde-15-integrate-support-triage-package-with-web-ui branch from 2084877 to 47b1feb Compare February 26, 2026 19:29
@mythical-fred
Copy link
Collaborator

Thanks @Karakatiza666 — duly noted. vitest-browser-svelte for unit UI tests and @playwright/experimental-ct-svelte for e2e is the right stack here, not jsdom-based testing. I'll use the correct framework in future suggestions.

Copy link
Collaborator

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

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

Good progress — all the blockers from my last pass are resolved. The new triage-types package is well-structured with solid JSDoc, error handling now surfaces via toast, the unused import and console.log are gone. One last minor nit inline.

@@ -92,6 +97,19 @@
;(async () => {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

.map() is being used for its side effects — each .triage() call mutates triageResults but the mapped array is discarded. Use .forEach() instead:

triagePlugins.forEach((p) => p.triage(bundle, triageResults))

Copy link
Contributor

@Karakatiza666 Karakatiza666 left a comment

Choose a reason for hiding this comment

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

Nice integration. Please run bun run format to revert formatting changes in TabProfileVisualizer.svelte‎, and refactor to one of the two API suggestions. They have different tradeoffs, but both are better than the current approach.

Other than that - LGTM

}

/** Accumulator for triage findings produced across one or more plugins. */
export class TriageResults {
Copy link
Contributor

Choose a reason for hiding this comment

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

Right now class TriageResults introduces indirection for no benefit. Let's refactor the API to either of the two approaches:

  1. Simplify the interface
    Drop TriageResults, refactor interface TriagePlugin to triage: (bundle: DecodedBundle) => TriageResult[].

This will let us replace

const results = new TriageResults()
triagePlugins.map((p) => p.triage(bundle, results))
triageResults = results.results

with

triageResults = triagePlugins.flatMap((p) => p.triage(bundle))
  1. Keep TriageResults class to future-proof against more complicated functionality, but make it more ergonomic
    Refactor interface TriagePlugin to triage: (bundle: DecodedBundle) => TriageResults, instead of public readonly results - get results: () => TriageRuleResult[], drop TriageResults::push;
    Add to class TriageResults static concat: (a: TriageResults, b: TriageResults) => TriageResults, which makes the code that executes the triage:
triageResults = triagePlugins.map((p) => p.triage(bundle)).reduce(TriageResults.concat, new TriageResults()).results

or

concat: (...rs: TriageResults[]) => TriageResults

triageResults = TriageResults.concat(...triagePlugins.map((p) => p.triage(bundle))).results

Option 1 is cleaner, but option 2 is better if you already know of possible future triage features beyound a simple list of results

Copy link
Contributor Author

@anandbraman anandbraman Mar 6, 2026

Choose a reason for hiding this comment

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

I had a discussion with @mihaibudiu on the TriageResults class. His suggestion was that the triage rules should not return the TriageResults object because the object can just function as an accumulator directly. The current implementation no longer includes triageResults = results.results. I replaced each instance of TriageResult[] with an instance of the TriageResults class. Take a look and let me know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing is mutating the object passed as an argument (as an explicit feature, not an optimization) is less obvious behavior than an explicit function output. I can open a separate PR for this, but we might as well decide on it now.

I'm not against merging the PR as-is, but it is a simple change and p.triage() mutating the passed TriageResults is both less obvious behavior and increases coupling between TriageResults and .triage function. Instead of constructing a clean TriageResults instance, .triage() needs to know how to mutate it properly.

You may think this difference is inconsequential, but when the codebase becomes overgrown with implicit behavior it becomes difficult to reason about.

@mihaibudiu please approve if you are fine with the current API

Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't see how appending to a list is different from calling a method on an object that holds the list. They both mutate the object.

The object approach is more general if you plan to do more than just add diagnostic messages. For example, you could have errors and warnings as a separate class of objects. (But for now I suggested keeping them as diagnostic messages too).

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the object as a response is more future proof.

If we look at option 2 i suggested, the idea is to separate concerns: plugin.triage() just wraps its own conclusions as a TriageResults. It does not need to concern itself with any pre-existing TriageResults state. Then, aggregating all TriageResults is a separate concern

Copy link
Contributor

Choose a reason for hiding this comment

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

That works as long as the results are always a TriageResult.

Copy link
Contributor

Choose a reason for hiding this comment

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

I assumed TriageResults is there to encapsulate the set of any triage output - list of suggestions, some overview performance graph, etc.

@Karakatiza666 Karakatiza666 self-requested a review March 6, 2026 19:01
@anandbraman anandbraman force-pushed the anandraman/fde-15-integrate-support-triage-package-with-web-ui branch from 2d9415f to a1e9659 Compare March 6, 2026 20:43
@gz
Copy link
Contributor

gz commented Mar 6, 2026

Please run bun run format

now that you are at least three people working on the typescript code-base please add a formatting rule you all can agree on to pre-commit

Copy link
Contributor

@Karakatiza666 Karakatiza666 left a comment

Choose a reason for hiding this comment

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

Approving as the approach is functional. My suggestions for improvement are not blockers to deliver the feature

@anandbraman anandbraman added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 2287c91 Mar 9, 2026
1 check passed
@anandbraman anandbraman deleted the anandraman/fde-15-integrate-support-triage-package-with-web-ui branch March 9, 2026 15:56
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.

5 participants