Brackets in chat messages are read as markup: text disappears and [/…] crashes the app

Aperta Adatta ai principianti
#1 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
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
frontend, security

Direzione di ricerca

Inizia da MessageWidget._update_display in src/chatty/ui/widgets.py e verifica come Textual gestisce la stringa passata a Static.update(). L’issue indica anche il percorso di errore in src/chatty/ui/workers.py:335; verifica che il testo del messaggio malformato non possa causare un errore neanche in quel percorso. Il lavoro è concluso quando il testo tra parentesi quadre e quello simile a un’azione vengono visualizzati letteralmente senza causare arresti anomali, anche durante lo streaming; l’evidenziazione della ricerca è tracciata separatamente in #2.

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

Descrizione

area: ui bug crash markup

MessageWidget._update_display (src/chatty/ui/widgets.py:128) builds f"**{prefix}:** {display_content}" and passes it to Static.update(). Textual parses a plain string as markup, so square brackets in a message are read as tags. This affects every user, system and error message, and every assistant message while it is streaming or while search is active.

Effect:

  • Text in brackets disappears. Submitting def f(x: list[str]) shows **You:** def f(x: list).
  • A stray closing tag crashes the app. Submitting pasted [/i] text raises MarkupError: closing tag '[/i]' does not match any open tag from action_submit, and chatty exits. Common sources are regexes (re.split(r'[/\]', p)), BBCode and log output, whether the user pastes them or the model streams them.
  • If the bad text arrives while streaming, the except in send_message (src/chatty/ui/workers.py:335) shows f"Unexpected error: {e}". That message contains the same tag, so it raises again and the worker exits the app (Textual workers default to exit_on_error=True).
  • Message text can trigger app actions. A message containing [@click=app.quit]here[/] renders as a link, and clicking it quits chatty. Any action_* on the app can be reached this way (new_session, save, export, and others), including from model output.

Fix: render messages as literal text: pass a textual.content.Content built from the plain string, or escape it with textual.markup.escape, and add the bold prefix as a style instead of ** inside the string. Search highlighting has its own bugs and should be fixed together (#2).

Lingua principale
Python
Stelle
0
Fork
2
Merge medio
1g 4h
PR unite (30g)
13

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 lanl/chatty

Tutte le issue di lanl/chatty

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.