Skip to content

Fix null reference error when sending custom welcome message#1161

Open
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/welcome-message-null-check
Open

Fix null reference error when sending custom welcome message#1161
PaoloC68 wants to merge 1 commit intoagent0ai:developmentfrom
PaoloC68:fix/welcome-message-null-check

Conversation

@PaoloC68
Copy link

@PaoloC68 PaoloC68 commented Mar 1, 2026

Fixes #1164

Summary

Fixes Cannot read properties of undefined (reading 'running') error that occurs when a custom welcome message is configured. The auto-send triggers before selectedContext is initialized in the Alpine.js store.

Change

webui/index.js line 60: Add optional chaining operator (?.) on selectedContext.running.

- if (chatsStore.selectedContext.running || messageQueueStore.hasQueue) {
+ if (chatsStore.selectedContext?.running || messageQueueStore.hasQueue) {

This matches the existing pattern already used in webui/js/input-store.js line 15:

const running = !!chatsStore.selectedContext?.running;

Testing

One-line defensive fix. The optional chaining safely returns undefined (falsy) when selectedContext is null, allowing the send to proceed normally once the context initializes.

Add optional chaining on selectedContext.running in webui/index.js.
When a custom welcome message is configured, auto-send triggers before
selectedContext is initialized, causing 'Cannot read properties of
undefined (reading running)'. This matches the existing pattern used
in input-store.js.
@PaoloC68 PaoloC68 force-pushed the fix/welcome-message-null-check branch from 878be5e to e81cbfb Compare March 12, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant