opencode attach crashes with 'session().parentID' error in v1.1.1 (regression from #6319) #4187

Closed
opened 2026-02-16 17:42:57 -05:00 by yindo · 1 comment
Owner

Originally created by @rmk40 on GitHub (Jan 4, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

After upgrading from v1.0.223 to v1.1.1, the opencode attach command crashes immediately when trying to attach to a session.

Error

TypeError: undefined is not an object (evaluating 'session().parentID')
    at <anonymous> (src/cli/cmd/tui/routes/session/index.tsx:82:17)
    at runComputation (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:742:22)
    at updateComputation (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:724:3)
    at createMemo (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:273:10)
    at Session4 (src/cli/cmd/tui/routes/session/index.tsx:81:23)
    ...

Root Cause

Introduced in commit 351ddeed9 ("Permission rework #6319"). The permissions memo accesses session().parentID without optional chaining, but session() can be undefined when the session data hasn't loaded yet (e.g., during attach):

// packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
const permissions = createMemo(() => {
  if (session().parentID) return sync.data.permission[route.sessionID] ?? []
  //     ^^^^^^^^^ Missing optional chaining
  return children().flatMap((x) => sync.data.permission[x.id] ?? [])
})

The children memo on line ~108 correctly uses session()?.parentID, but the permissions memo on line ~119 doesn't.

Suggested Fix

- if (session().parentID) return sync.data.permission[route.sessionID] ?? []
+ if (session()?.parentID) return sync.data.permission[route.sessionID] ?? []

Steps to Reproduce

  1. Start an OpenCode server: opencode serve or opencode web
  2. Create a session
  3. From another terminal: opencode attach http://localhost:<port> --session <id>
  4. Error appears immediately

Versions

Version Status
1.0.223 Works
1.1.1 Crashes

Workaround

opencode upgrade 1.0.223
Originally created by @rmk40 on GitHub (Jan 4, 2026). Originally assigned to: @rekram1-node on GitHub. ## Description After upgrading from v1.0.223 to v1.1.1, the `opencode attach` command crashes immediately when trying to attach to a session. ## Error ``` TypeError: undefined is not an object (evaluating 'session().parentID') at <anonymous> (src/cli/cmd/tui/routes/session/index.tsx:82:17) at runComputation (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:742:22) at updateComputation (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:724:3) at createMemo (../../node_modules/.bun/solid-js@1.9.10/node_modules/solid-js/dist/dev.js:273:10) at Session4 (src/cli/cmd/tui/routes/session/index.tsx:81:23) ... ``` ## Root Cause Introduced in commit `351ddeed9` ("Permission rework #6319"). The `permissions` memo accesses `session().parentID` without optional chaining, but `session()` can be `undefined` when the session data hasn't loaded yet (e.g., during attach): ```typescript // packages/opencode/src/cli/cmd/tui/routes/session/index.tsx const permissions = createMemo(() => { if (session().parentID) return sync.data.permission[route.sessionID] ?? [] // ^^^^^^^^^ Missing optional chaining return children().flatMap((x) => sync.data.permission[x.id] ?? []) }) ``` The `children` memo on line ~108 correctly uses `session()?.parentID`, but the `permissions` memo on line ~119 doesn't. ## Suggested Fix ```diff - if (session().parentID) return sync.data.permission[route.sessionID] ?? [] + if (session()?.parentID) return sync.data.permission[route.sessionID] ?? [] ``` ## Steps to Reproduce 1. Start an OpenCode server: `opencode serve` or `opencode web` 2. Create a session 3. From another terminal: `opencode attach http://localhost:<port> --session <id>` 4. Error appears immediately ## Versions | Version | Status | |---------|--------| | 1.0.223 | ✅ Works | | 1.1.1 | ❌ Crashes | ## Workaround ```bash opencode upgrade 1.0.223 ```
yindo added the opentui label 2026-02-16 17:42:57 -05:00
yindo closed this issue 2026-02-16 17:42:57 -05:00
Author
Owner

@rmk40 commented on GitHub (Jan 4, 2026):

Closing as duplicate of #6867. The fix is already in dev branch (commit 226a5c200).

@rmk40 commented on GitHub (Jan 4, 2026): Closing as duplicate of #6867. The fix is already in dev branch (commit 226a5c200).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4187