Skip to content

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

Closed

Description

@rmk40

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 4, 2026
  2. rmk40 commented on Jan 4, 2026

    @rmk40
    ContributorAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions