fix(portal): show OAuth/Claude.ai assistants in the connected list#165
Merged
Conversation
A lista de assistentes do portal lia só account_api_tokens. Conexões via
OAuth do Claude.ai (e o operator bearer "Claude Code") nunca criam linha
nessa tabela, então o assistente MAIS usado ficava invisível — embora toda
busca dele seja gravada em ai_search_log com client='Claude.ai'.
Fix em listMcpTokens (src/portal/mcp-tokens.ts): UNION de duas fontes —
(a) os bearer tokens do portal (last_used_at derivado do log, como antes,
revocable=true) e (b) os clients DISTINCT vistos em ai_search_log que NÃO
têm token (created_at=MIN(ts), last_used_at=MAX(ts), revocable=false),
excluindo os que já batem com o label de um token (sem duplicar). Ordenado
por uso mais recente. Isolado por account_id (nunca cruza contas).
Front: McpTokenSummary ganha `revocable?`; AssistantsCard (/inicio) mostra
"via OAuth" em vez do botão revogar pros não-revogáveis; ContaTokensCard
("Tokens MCP") filtra pra revocable (segue só sobre tokens reais).
Teste: src/portal/__tests__/mcp-tokens.test.ts cobre Claude.ai OAuth
aparecendo, revocable por tipo, não-duplicação, escopo por conta, client
NULL ignorado e ordenação. Backend build + 1484 testes verdes; web
typecheck + lint + 255 vitest verdes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
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.
ENG-3
A lista de assistentes do portal lia so
account_api_tokens. Conexoes via OAuth do Claude.ai (e o operator bearer 'Claude Code') nunca criam linha la, entao o assistente MAIS usado ficava invisivel — embora toda busca dele seja gravada emai_search_logcomclient='Claude.ai'.Fix
listMcpTokens(src/portal/mcp-tokens.ts) faz UNION de:last_used_atderivado do log,revocable=true);ai_search_logsem token (created_at=MIN(ts),last_used_at=MAX(ts),revocable=false), excluindo os que ja batem com o label de um token. Ordenado por uso recente, isolado poraccount_id.Front:
McpTokenSummaryganharevocable?;AssistantsCard(/inicio) mostra 'via OAuth' em vez de revogar pros nao-revogaveis;ContaTokensCard('Tokens MCP') filtra pra revogaveis.Aceite
src/portal/__tests__/mcp-tokens.test.ts: Claude.ai OAuth aparece, revocable por tipo, nao-duplicacao, escopo por conta, client NULL ignorado, ordenacao.npm run buildlimpo +npm test= 1484 pass / 0 fail.Generated with Claude Code