Skip to content

Conversation

@ulivz
Copy link
Member

@ulivz ulivz commented Sep 24, 2025

Summary

Refactored the setupUI function in @tarko/agent-cli to improve code clarity and maintainability. This change extracts complex routing logic into smaller, focused functions and simplifies the request handling flow.

Key improvements:

  • Extract static file pattern as constant for better readability
  • Separate config injection logic into injectConfig function
  • Create dedicated serveIndexWithConfig function for serving SPA routes
  • Simplify route handling logic with clearer conditional flow
  • Use mergedWebUIConfig.base instead of webui.base for consistency

No breaking changes - this is a pure refactor that maintains identical functionality.

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.

@netlify
Copy link

netlify bot commented Sep 24, 2025

Deploy Preview for agent-tars-docs ready!

Name Link
🔨 Latest commit 75523a0
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/68d3869330f6fa0008c5859a
😎 Deploy Preview https://deploy-preview-1631--agent-tars-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Sep 24, 2025

Deploy Preview for tarko ready!

Name Link
🔨 Latest commit 75523a0
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/68d38693a8881b0009e64151
😎 Deploy Preview https://deploy-preview-1631--tarko.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

if (fs.existsSync(filePath)) {
return res.sendFile(filePath);
}
return fs.existsSync(filePath) ? res.sendFile(filePath) : next();

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
if (fs.existsSync(filePath)) {
return res.sendFile(filePath);
}
return fs.existsSync(filePath) ? res.sendFile(filePath) : next();

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
@ulivz ulivz changed the title refactor(tarko-agent-cli): simplify setupUI function logic refactor(tarko-agent-cli): simplify setup ui logic Sep 24, 2025
@ulivz ulivz merged commit 6cd5c08 into main Sep 24, 2025
9 of 10 checks passed
@ulivz ulivz deleted the refactor/simplify-setupui-function branch September 24, 2025 06:04
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.

2 participants