Repository navigation
perf: reduce repeated and serialized UI/flow-chat work - #3962
Open
Raing5Days wants to merge 5 commits into
Open
Raing5Days wants to merge 5 commits into
Raing5Days wants to merge 5 commits into
Conversation
…y node key The trajectory panel is keyed by session, so switching sessions remounts it and its mount pass runs over the whole loaded node page: the saved endpoint keys were resolved with one built JSON key per node per endpoint, and the range summary walked the selection five times through filter passes and a reduce closure. - resolveTrajectoryRange reads the two endpoint identities once and matches node fields in a single pass. An endpoint from an unexpected source still falls back to the former per-node key comparison. - summarizeTrajectoryRange counts kinds, tallies errors and sums both durations in one pass, keeping "no duration recorded" distinct from a measured zero. Measured with the local OpCase benchmark (400 nodes, panel mount pass, 72000 measured calls): 85.83 us/call -> 7.30 us/call against a 60.08 us/call budget. The number is module cost, not a frame time. Testing: node scripts/run-vitest.mjs run src/flow_chat/trajectory (49 passed); pnpm run check:web (pre-existing failures only: stale MiniApp chrome theme artifact and appearance-contract warnings).
…tation trajectoryRange.ts now resolves endpoints by comparing node fields and summarizes a range in one pass. Both replacements are checked against the previous slice/filter/key-scan implementations copied into the test file, so a difference in counts, duration sums, empty selections, endpoint identity, or first-match behaviour fails here instead of in the panel. Covered on purpose: - every interesting bound shape: reversed, equal, negative, past the end; - an empty selection, where the previous code reported no endpoints; - "no duration recorded" vs a measured zero; - identities that need JSON escaping (quotes, backslashes, newlines, NUL, non-ASCII), so the parsed endpoint path cannot drift from the key format; - a prepended page, a repeated identity, a malformed or missing endpoint.
Hoist reusable regular expressions and replace per-item `.map/.filter` work with a single loop while preserving path normalization and casing semantics.
Return early when no selectable route exists and use a Set plus one pass to compute the narrowest native-image ceiling, preserving the previous model selection semantics.
Starting the workspace activation and the search-hit metadata read together removes one host round trip from the critical path of opening a session found through global search, which is most noticeable when the target lives in another workspace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This branch reduces repeated or serialized work in several flow-chat and UI paths:
trajectoryRange.tspreviously built a JSON key for every node twice when resolving two endpoints, and walked the selected range five times to build one summary. Both paths now use single passes, with a fallback that preserves the old comparison for unfamiliar endpoint shapes.fileTreeReveal.tsrebuilt regular expressions and intermediate arrays on each reveal. Reusable patterns are hoisted, and path expansion uses one loop while preserving Windows, POSIX, UNC and remote-path semantics.modelImageBudget.tsscanned the entire model list even when no selectable primary/pool route existed. It now returns immediately in that case and otherwise uses a Set plus one pass to find the narrowest native-image ceiling.globalSearchActivator.tsopened a session hit by first awaiting the workspace switch and only then loading the search hit's persisted session metadata. These two operations are independent (the metadata read addresses the target workspace directly), so they now start together. This removes one host round trip from search-all-to-session navigation, most visible when the target is in another workspace.Evidence
Local OpCase microbenchmarks (jsdom module cost, not frame time):
Global-search session navigation: a deterministic regression test (globalSearchActivator.test.ts) holds the workspace switch pending and asserts the metadata read has already started, so the old serialized order fails and the new overlapped order passes. This is a control-flow guarantee, not a frame-time claim; the saved time is one host round trip on cross-workspace session opens.
Testing
node scripts/run-vitest.mjs run src/app/global-search- passed, 93 tests.node scripts/run-vitest.mjs run src/tools/file-system/utils/fileTreeReveal.test.ts src/flow_chat/utils/modelImageBudget.test.ts- passed, 9 tests.pnpm run lint:web- passed.pnpm run type-check:web- passed.pnpm run check:repo-hygiene- passed.node scripts/check-git-object-sizes.mjs --base origin/main --head HEAD- passed.pnpm run check:webstops atStale MiniApp chrome theme: src/shared/miniapp-chrome/generated/theme.cssbefore type-check runs. This failure is present on the clean base tree and is unrelated to these files; type-check was run separately and passes.Remote scenarios: none exercised. These changes touch no IPC, persistence, protocol, remote-surface behavior, or permission path.
AI-assisted: yes, written with an agent. Testing level: fully tested at module level (focused unit tests, benchmark budgets, and equivalence/control-flow tests where applicable); lightly tested at component level.
Generated with OpenBitFun