Chat usage: a member refused usage still re-requests it after every chat turn

Aperta Adatta ai principianti
#2,085 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Leggi src/features/instance/applications/components/Chat/index.tsx e src/react-query/pollUnlessForbidden.ts per tracciare l’uso dell’invalidazione delle query e la gestione dei 403. Controlla lo stato di errore della query in cache prima di invalidarla in onFinish; verifica che un 403 non attivi un’altra richiesta dopo un turno di chat, mentre il ripristino del focus o un nuovo montaggio consentano comunque di recuperare. La pulizia facoltativa del predicato di retry non è necessaria per la correzione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

rum
Problem

Org members who aren't admins or chat-read staff get a 403 from GET /Chat/Usage/<org> (central manager's chat usage resource refuses them). The fix-chat-usage-403 branch stops the retries and the toast, but the query still re-asks:

  • src/features/instance/applications/components/Chat/index.tsx:45 invalidates ['getMyUsage'] in onFinish, so every assistant turn sends one more request that is refused.
  • The query stays in error state, so a window refocus or remount sends one more as well. src/react-query/pollUnlessForbidden.ts:79-82 treats refocus and remount as the way to recover from a 403, so that part is deliberate.
  • retryUnlessRejected() is called on every render, so a new closure is built each time. This is minor and not on a hot path.

Each case is one silent request, down from four requests and a toast.

Fix

Skip the onFinish invalidation while the cached usage query holds a 403. Or resolve a 403 to null with a long staleTime, which means a newly granted permission only shows up after a reload. Hoisting the retry predicate to module scope is optional.

Review-Deferral: 88c3da70d8bcb076 severity=nit category=performance
Review-Deferral: 5ee4dd3d93066134 severity=nit category=performance

🤖 Generated by Anthropic Claude (Claude Code); posted via @dawsontoth.

Lingua principale
TypeScript
Stelle
5
Fork
4
Merge medio
2g 13h
PR unite (30g)
60

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di HarperFast/studio

Tutte le issue di HarperFast/studio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.