-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(tarko): add webui.base support for flexible routing
#1623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- Add basePath property to BaseAgentWebUIImplementation interface - Support both static paths and regex patterns for deployment flexibility - Update agent-ui to use basePath from config for React Router - Update agent-cli setupUI function to handle basePath matching - Auto-detect regex patterns vs static paths - Maintain backward compatibility with existing deployments Examples: - Static: basePath: '/agent-ui' - Regex: basePath: '/tenant-.+' for multi-tenant deployments (close: #1622)
✅ Deploy Preview for agent-tars-docs canceled.
|
✅ Deploy Preview for tarko canceled.
|
basePath support for flexible routing
… functions - Add tests for isRegexPattern function covering various regex patterns - Add tests for createPathMatcher function covering static and regex patterns - Test edge cases including malformed regex, unicode chars, and performance - Test setupUI integration scenarios with different basePath configurations - Extract webui routing functions to separate module for better testability - Improve regex extraction logic to properly handle .+ patterns Tests cover: - Static paths: /agent-ui, /foo/bar - Regex patterns: /tenant-.+, /(dev|staging|prod)/app - Edge cases: malformed regex, unicode, performance - Integration with setupUI function
- Add extractActualBasename function to compute basename from current URL
- Support regex patterns like /tenant-.+, /[a-zA-Z0-9]{33} for dynamic routing
- Replace .+ with [^/]+ for non-greedy matching up to first slash
- Handle malformed regex patterns gracefully with fallback
- Add comprehensive unit tests covering static and regex patterns
- Enable multi-tenant and dynamic ID routing scenarios
Fixes issue where React Router basename only accepts static strings.
Now supports URL patterns like https://example.com/p9fgsSryzeO5JtefS1bMfsa7G11S6pGKY/chat
- Move isRegexPattern, createPathMatcher, extractActualBasename to shared-utils - Update agent-cli to re-export from shared-utils for backward compatibility - Update agent-ui to import from shared-utils instead of local implementation - Add comprehensive tests for shared webui routing utilities - Build shared-utils to ensure proper exports Benefits: - Eliminates code duplication between server and client - Centralizes webui routing logic in one place - Maintains backward compatibility for existing imports - Enables consistent behavior across server and frontend
- Remove duplicated tests from agent-ui since shared-utils already has comprehensive coverage - shared-utils has 17 test cases covering all routing logic scenarios - Eliminates test duplication and maintenance overhead - Core routing logic is tested in shared-utils, no need to duplicate in consumer packages
- Remove duplicated tests from agent-cli since shared-utils already has comprehensive coverage - agent-cli/src/utils/webui-routing.ts now only re-exports from shared-utils - No need to test simple re-exports, core logic is tested in shared-utils - Eliminates test duplication across packages
- Remove multimodal/tarko/agent-cli/src/utils/webui-routing.ts - Update start.ts to import directly from @tarko/shared-utils - Eliminates unnecessary indirection layer - Simplifies import paths and reduces maintenance overhead The re-export file was only used in one place and added no value.
- Update createPathMatcher to accept string | undefined - Update extractActualBasename to accept string | undefined - Add comprehensive tests for undefined basePath scenarios - Fixes TypeScript compilation error in agent-cli This aligns with the AgentWebUIImplementation interface where basePath is optional.
- Return original path when basePath doesn't match in extract() method - Applies to both static and regex basePath patterns - Ensures consistent behavior across all path matching scenarios - All tests pass with improved error handling
Keep only the essential quick-test.js for basePath verification
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1623 +/- ##
=======================================
Coverage 14.26% 14.26%
=======================================
Files 250 250
Lines 8562 8562
Branches 1672 1672
=======================================
Hits 1221 1221
Misses 7166 7166
Partials 175 175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
basePath support for flexible routingwebui.base support for flexible routing
- Update AgentWebUIImplementation interface: basePath -> base - Update shared-utils routing functions parameter names - Update agent-cli and agent-ui to use new base property - Update all tests and documentation - Maintain backward compatibility through consistent naming BREAKING CHANGE: WebUI config now uses 'base' instead of 'basePath'
c0bc140 to
f8873da
Compare
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.
Summary
Add support for
baserouting configuration in WebUI deployment, enabling flexible path-based routing for various deployment scenarios.Close: #1622
Checklist