Skip to content

Conversation

@ulivz
Copy link
Member

@ulivz ulivz commented Sep 23, 2025

Summary

Add support for base routing configuration in WebUI deployment, enabling flexible path-based routing for various deployment scenarios.

Close: #1622

Checklist

  • Added or updated necessary tests (Optional).
  • Updated documentation to align with changes (Optional).
  • Verified no breaking changes, or prepared solutions for any occurring breaking changes (Optional).
  • My change does not involve the above items.

- 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)
@netlify
Copy link

netlify bot commented Sep 23, 2025

Deploy Preview for agent-tars-docs canceled.

Name Link
🔨 Latest commit 86f0f04
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/68d35f4d3668610008fbb826

@netlify
Copy link

netlify bot commented Sep 23, 2025

Deploy Preview for tarko canceled.

Name Link
🔨 Latest commit 86f0f04
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/68d35f4d17802a0008350845

@ulivz ulivz changed the title feat(tarko-interface): add basePath support for flexible WebUI routing feat(tarko): add basePath support for flexible routing Sep 23, 2025
… 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
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 14.26%. Comparing base (f380287) to head (f8873da).
⚠️ Report is 38 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ulivz ulivz requested a review from cjraft September 23, 2025 17:49
@ulivz ulivz changed the title feat(tarko): add basePath support for flexible routing feat(tarko): add webui.base support for flexible routing Sep 23, 2025
- 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'
@ulivz ulivz force-pushed the feat/webui-routing-basepath branch from c0bc140 to f8873da Compare September 24, 2025 02:58
@ulivz ulivz merged commit dce0e7e into main Sep 24, 2025
8 of 10 checks passed
@ulivz ulivz deleted the feat/webui-routing-basepath branch September 24, 2025 05:03
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.

[Feature] Enhance webui routing for flexible deployment paths

2 participants