fix: favorite list route should respect type query parameter

The /global/favorite/skills GET route was hardcoded to list only
skill-type favorites, causing cloud hub to show Cloud status for
non-skill favorites (agent, command, mcp) even after they were
loaded locally.

Now it reads the optional type query parameter and passes it to
listFavoriteItems, matching the opencode server behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
林凯90331 2026-05-19 17:57:38 +08:00
parent 321be8a128
commit 9093d20fcf

View File

@ -3,6 +3,7 @@ import {
listFavoriteItems, listFavoriteItems,
loadFavoriteItem, loadFavoriteItem,
unloadFavoriteItem, unloadFavoriteItem,
type FavoriteItemType,
} from '../../costrict/favorite/favorite.js' } from '../../costrict/favorite/favorite.js'
import { notFound } from '../errors.js' import { notFound } from '../errors.js'
@ -10,7 +11,8 @@ export function createFavoriteRoutes(): Hono {
return new Hono() return new Hono()
.get('/global/favorite/skills', async c => { .get('/global/favorite/skills', async c => {
try { try {
const items = await listFavoriteItems('skill') const type = c.req.query('type') as FavoriteItemType | undefined
const items = await listFavoriteItems(type)
return c.json({ success: true, items }) return c.json({ success: true, items })
} catch (error) { } catch (error) {
const message = error instanceof Error ? error.message : String(error) const message = error instanceof Error ? error.message : String(error)