Skip to content

feat: add tui.json route to serve Kilo-branded TUI keybind schema#3205

Open
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
feat/tui-json-route
Open

feat: add tui.json route to serve Kilo-branded TUI keybind schema#3205
kilo-code-bot[bot] wants to merge 1 commit into
mainfrom
feat/tui-json-route

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented May 12, 2026

Summary

  • Adds apps/web/src/app/tui.json/route.ts, a Next.js route that proxies https://opencode.ai/tui.json and exposes it at https://app.kilo.ai/tui.json.
  • Follows the identical pattern established by apps/web/src/app/config.json/route.ts: fetch upstream at request time, cache at the CDN edge for 1 hour (s-maxage=3600, stale-while-revalidate), and allow CORS (access-control-allow-origin: *).
  • No Kilo-specific overlay is applied yet (no TUI keybind extras exist), but the structure is in place for future additions.

Verification

  • Visit https://app.kilo.ai/tui.json after deploy — should return the upstream JSON Schema with a 200.
  • Previously the path returned 404; this resolves it.

Visual Changes

N/A

Reviewer Notes

  • The route is referenced as TUI_SCHEMA_URL in packages/opencode/src/cli/cmd/tui/config/tui-migrate.ts (kilocode repo) and in the keybinds docs at https://app.kilo.ai/docs/customize/keybinds. No code changes are needed in those places once this route is deployed.
  • If a Kilo-specific TUI overlay is needed in the future, a merge() function and extras.ts can be added here following the same pattern as config.json/.

{ status: 502 },
);
}
const upstream: unknown = await res.json();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

WARNING: Unhandled JSON.parse failure — if the upstream returns a 200 with a non-JSON body (e.g. a CloudFlare HTML error page), res.json() will throw and the route will return an unhandled 500 instead of a graceful 502.

Consider wrapping:

let upstream: unknown;
try {
  upstream = await res.json();
} catch {
  return NextResponse.json(
    { error: `upstream ${UPSTREAM} returned invalid JSON` },
    { status: 502 },
  );
}

Note: config.json/route.ts has the same gap, so this pattern could be addressed in both places.

@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented May 12, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/app/tui.json/route.ts 26 res.json() can throw if the upstream returns a non-JSON body (e.g. an HTML error page on a CDN edge), resulting in an unhandled 500. The res.ok check only validates the HTTP status, not the body content-type. Wrap the parse in a try/catch and return a 502.
Other Observations (not in diff)
  • The same res.json() gap exists in apps/web/src/app/config.json/route.ts (line 51). If this is fixed here, consider fixing the sibling route in the same pass.
  • No fetch timeout is set on either proxy route. If opencode.ai becomes unresponsive, the serverless function will hang until the platform kills it. Adding AbortSignal.timeout(5000) to the fetch call would be a low-cost defensive improvement.
Files Reviewed (1 file)
  • apps/web/src/app/tui.json/route.ts — 1 issue

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-4.6 · 140,218 tokens

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.

0 participants