Skip to content

Embed backend in oclite binary (standalone mode) #128

@randomm

Description

@randomm

Problem

Current Ink TUI calls Instance.directory without first calling Instance.provide() to set up AsyncLocalStorage context. This causes 'No context found for instance' errors.

Root Cause (from research)

  • cli/ink/App.tsx line 26 calls Session.createNext({ directory: Instance.directory }) without bootstrapping
  • Backend depends on Instance.provide() establishing context before any Instance.directory access

Solution

Update cli/ink/entry.ts to bootstrap properly (following cli/cmd/tui/worker.ts pattern):

import { Global } from '@/global'
import { Log } from '@/util/log'
import { Instance, InstanceBootstrap } from '@/project/instance'
import { render } from 'ink'
import App from './App'

async function main() {
  await Global.init()
  await Log.init({ print: false, dev: false, level: 'INFO' })
  
  await Instance.provide({
    directory: process.cwd(),
    init: InstanceBootstrap,
    fn: async () => {
      render(<App />)
    }
  })
}

main()

What InstanceBootstrap Initializes

  • Plugin system
  • Share/ShareNext (collaboration)
  • Format (code formatting)
  • LSP (language servers)
  • FileWatcher
  • File operations
  • Vcs (version control)
  • Snapshot
  • Truncate

Acceptance Criteria

  • ~/bin/oclite works without separate server
  • Can send messages and receive streaming responses
  • No 'No context found' errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions