Conversation
The function was incorrectly defined inside renderSessionListFromCache() as a local function, but was called by _sidebarRowHasVisibleMessages() which is defined outside that scope. This caused a ReferenceError: '_sessionAttentionState is not defined'. JavaScript function hoisting only works within the same scope, so the comment 'available via function hoisting' was incorrect. Fix: Move _sessionAttentionState to module scope so all callers can access it.
|
| Filename | Overview |
|---|---|
| static/sessions.js | Hoists _sessionAttentionState to module scope so _sidebarRowHasVisibleMessages can resolve it; _renderOneSession continues to work via normal scope-chain lookup. Change is a straight lift-and-shift with no logic modification. |
| CHANGELOG.md | Adds a ### Fixed entry in [Unreleased] documenting the runtime crash and the fix, satisfying the AGENTS.md requirement to record user-visible behavior changes. |
Sequence Diagram
sequenceDiagram
participant SB as _sidebarRowHasVisibleMessages (module scope)
participant SA as _sessionAttentionState (module scope — after fix)
participant RL as renderSessionListFromCache
participant RO as _renderOneSession (nested in RL)
Note over SB,SA: Before fix: SA was only visible inside RL → ReferenceError
Note over SB,SA: After fix: SA is at module scope → reachable everywhere
SB->>SA: _sessionAttentionState(s)
SA-->>SB: "{ kind, count, severity, label, title } | null"
RL->>RO: calls _renderOneSession(s)
RO->>SA: _sessionAttentionState(s)
SA-->>RO: "{ kind, count, severity, label, title } | null"
Reviews (2): Last reviewed commit: "docs: add CHANGELOG entry for _sessionAt..." | Re-trigger Greptile
| function _sessionAttentionState(s){ | ||
| const attention=s&&s.attention&&typeof s.attention==='object'?s.attention:null; | ||
| if(!attention||!attention.kind||!Number.isFinite(Number(attention.count))||Number(attention.count)<=0)return null; | ||
| const kind=String(attention.kind)==='approval'?'approval':(String(attention.kind)==='clarify'?'clarify':'attention'); | ||
| const count=Math.max(1,Number(attention.count)||1); | ||
| const labelKey=kind==='approval'?'session_attention_approval':(kind==='clarify'?'session_attention_clarify':'session_attention_generic'); | ||
| const titleKey=kind==='approval'?'session_attention_approval_title':(kind==='clarify'?'session_attention_clarify_title':'session_attention_generic_title'); | ||
| const fallback=kind==='approval'?(count===1?'Approval':`${count} approvals`):(kind==='clarify'?(count===1?'Question':`${count} questions`):(count===1?'Attention':`${count} items`)); | ||
| const titleFallback=kind==='approval'?'Waiting for permission decision':(kind==='clarify'?'Waiting for your answer':'Waiting for user action'); | ||
| const label=(typeof t==='function')?t(labelKey,count):fallback; | ||
| const title=(typeof t==='function')?t(titleKey,count):titleFallback; | ||
| return {kind,count,severity:String(attention.severity||''),label,title}; | ||
| } |
There was a problem hiding this comment.
CHANGELOG.md not updated for user-visible bug fix
Per AGENTS.md, "Update CHANGELOG.md for user-visible behavior, setup, workflow, or documentation changes that should be release-note ready." This fix resolves a runtime error (_sessionAttentionState is not defined) that broke session list rendering — it's a user-visible change that should be recorded in CHANGELOG.md before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Closing as superseded — this is already fixed on master. |
Problem
_sessionAttentionStatewas incorrectly defined insiderenderSessionListFromCache()as a local function, but was called by_sidebarRowHasVisibleMessages()which is defined outside that scope.This caused a runtime error:
Root Cause
JavaScript function hoisting only works within the same function scope. The comment "available via function hoisting" was incorrect - the outer function cannot access inner function declarations.
Fix
Move
_sessionAttentionStateto module scope (top-level function) so all callers can access it.Testing
_sidebarRowHasVisibleMessagesandrenderSessionListFromCache