#3721: fix(ui): webchat not displaying chat responses
channel: telegram
app: web-ui
gateway
## Summary
- Fix webchat Control UI not displaying assistant responses (messages were going to TUI but not appearing in webchat)
- Add final message from chat event payload directly to chatMessages instead of relying on loadChatHistory (which returns 0 messages when session transcript file doesn't exist)
- Add configurable debug logging controlled by settings/environment variables
## Changes
- **UI**: Add `debug()` utility controlled by `debugLogs` setting, localStorage, or `window.MOLTBOT_UI_DEBUG`
- **Server**: Add `debugChat()` utility controlled by `CLAWDBOT_DEBUG_CHAT` env var
- **Fix**: Handle final chat event by adding message directly to chatMessages array
## Test plan
- [ ] Send message in webchat, verify response appears
- [ ] Enable debug logging (`localStorage.setItem('moltbot-ui-debug', 'true')`) and verify logs appear in browser console
- [ ] Set `CLAWDBOT_DEBUG_CHAT=1` and verify server-side debug logs appear
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes webchat assistant responses not appearing by appending the final chat event payload directly into the UI `chatMessages` list and avoiding reliance on `chat.history` when no transcript exists. It also adds optional debug logging (UI + server) and a few related adjustments (e.g., applying URL settings earlier, better token mismatch hints, restart-sentinel wiring to register chat runs).
Main issue found: a debug log executes inside the chat render path, which can cause heavy console spam and degrade responsiveness when debug logging is enabled.
<h3>Confidence Score: 4/5</h3>
- This PR is generally safe to merge; the main risk is debug logging placement causing noisy/slow renders when enabled.
- Most changes are additive and scoped to chat event handling and debug instrumentation. I found one performance/UX footgun (debug logging executed during render) but no clear correctness regressions from the diff review.
- ui/src/ui/app-render.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
86.3%
#14966: fix(webchat): preserve user message visibility after chat.send
by BenediktSchackenberg · 2026-02-12
84.0%
#15110: fix: enable auto-scroll during assistant response streaming
by jwchmodx · 2026-02-13
82.6%
#5693: fix(chat): display error messages when LLM requests fail
by niemesrw · 2026-01-31
82.1%
#22808: test(ui): split baseline browser-test fixes from webchat feature
by opnsec · 2026-02-21
82.0%
#23073: fix(ui): strip reply directive tags from assistant messages in WebC...
by x4v13r1120 · 2026-02-22
81.8%
#7316: fix: /chat dashboard performance
by felipcsousa · 2026-02-02
81.4%
#22798: feat(webchat): ChatGPT-style multi-chat threads with generated titles
by opnsec · 2026-02-21
81.4%
#9122: fix(webchat): constrain .chat-new-messages to button size
by ridermw · 2026-02-04
81.1%
#8742: fix(webchat): hide internal system messages from UI (#7440)
by revenuestack · 2026-02-04
81.0%