Skip to content

fix(app): handle null session in ChatList ListFooter (#494)#562

Open
xoverride wants to merge 2 commits intoslopus:mainfrom
xoverride:fix/494-session-null-crash
Open

fix(app): handle null session in ChatList ListFooter (#494)#562
xoverride wants to merge 2 commits intoslopus:mainfrom
xoverride:fix/494-session-null-crash

Conversation

@xoverride
Copy link

Summary

Fixes #494 - App crashes with "undefined is not a function" when accessing a session.

Root Cause

The ListFooter component in ChatList.tsx used a non-null assertion (!) on useSession():

const session = useSession(props.sessionId)!;  // BUG: can be null!

useSession() returns Session | null. During initial render or timing issues, it can return null. Accessing session.agentState on null causes the crash.

Fix

Added proper null handling:

const session = useSession(props.sessionId);
if (!session) {
    return null;  // Don't render footer if session not loaded
}

Test plan

  • TypeScript compilation passes
  • Verified no other instances of useSession()! pattern in the codebase

The ListFooter component used a non-null assertion on useSession() which
can return null during initial render or timing issues. This caused
"undefined is not a function" crash when accessing session.agentState.

Fix: Add null check and return null if session not loaded yet.

Closes slopus#494
Fixes slopus#494 - "undefined is not a function" crash on iOS

The ToolHeader component was calling knownTool.icon() after only
checking if the property was truthy, without verifying it was
actually a function. This could cause a crash if the icon property
existed but was not callable.

Changed from:
  knownTool?.icon ? knownTool.icon(...) : fallback

To:
  knownTool && typeof knownTool.icon === 'function' ? knownTool.icon(...) : fallback

This matches the defensive pattern already used in ToolView.tsx
(lines 110-112) for the same purpose.
leeroybrun added a commit to happier-dev/happier that referenced this pull request Feb 14, 2026
@happier-bot

This comment was marked as abuse.

Comment on lines +31 to +33
if (!session) {
return null;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding the null checks, there is a lack of general null safety that breaks constantly. hope maintainers expedite the reviews on these critical ones

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.

Something went wrong in IOS26.6

3 participants