Skip to content

feat: OpenCode support, performance improvements, WebSocket fix#68

Open
dgokeeffe wants to merge 5 commits intodatasciencemonkey:mainfrom
dgokeeffe:pr/perf-opencode-websocket
Open

feat: OpenCode support, performance improvements, WebSocket fix#68
dgokeeffe wants to merge 5 commits intodatasciencemonkey:mainfrom
dgokeeffe:pr/perf-opencode-websocket

Conversation

@dgokeeffe
Copy link
Copy Markdown
Contributor

Summary

  • OpenCode fork install: Adds OpenCode CLI setup with GitHub CLI integration and reduces keystroke latency in terminal I/O
  • Lock contention fix: Replaces global lock with per-session locks for batch polling, reducing contention under concurrent sessions
  • WebSocket detection: Fixes Socket.IO long-polling fallback detection to correctly identify real WebSocket connections

Test plan

  • Verify OpenCode CLI installs correctly on app startup
  • Confirm terminal keystroke latency is improved
  • Test WebSocket connections work correctly (not falling back to polling)
  • Load test with multiple concurrent sessions to verify lock contention fix

This pull request was AI-assisted by Isaac.

dgokeeffe and others added 3 commits March 17, 2026 22:46
- Install OpenCode from dgokeeffe/opencode fork with native Databricks
  provider (auto-discovers models, shares Claude Code skills)
- Add GitHub CLI (gh) setup with xterm.js-safe auth wrapper
- Reduce select() timeout 500ms→50ms and poll interval 100ms→50ms
- Add Makefile for deployment automation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace single global sessions_lock block in get_output_batch() with
3-step resolve/swap/join pattern matching get_output(). Snapshot session
dict in cleanup_stale_sessions() to iterate with per-session locks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Socket.IO sets connected=true even when falling back to its own
long-polling (Databricks Apps proxy blocks WS upgrade). This stopped
the fast poll-worker, routing all output through slow long-polling.

Now checks socket.io.engine.transport.name and only stops poll-worker
when transport is true 'websocket'. Also listens for late upgrades.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread app.py Outdated
Comment thread app.py Outdated
Comment thread app.py
Comment thread Makefile Outdated
Comment thread Makefile
Comment thread app.py Outdated
Comment thread Makefile
Move inline gh CLI installation from app.py into install_gh.sh,
following the same pattern as install_micro.sh. The script now
fetches the latest 2.x release from the GitHub API instead of
pinning a specific version. Also fixes a bug in the gh wrapper
where the auth login handler fell through to exec gh.real with
shifted args instead of exiting after handling the command.

Co-authored-by: Isaac
Add `make clean` to remove both the app and secret scope, helping
with manual testing teardown. Add `make create-pat` to auto-generate
a 90-day PAT via Databricks CLI and store it directly. Remove PAT
from the usage example header to discourage passing secrets on the
command line.

Co-authored-by: Isaac
Comment thread app.py
# Sanitizes requests/responses between OpenCode and Databricks
# (see OpenCode #5028, docs/plans/2026-03-11-litellm-empty-content-blocks-design.md)
_run_step("proxy", ["python", "setup_proxy.py"])
_run_step("proxy", ["uv", "run", "python", "setup_proxy.py"])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For using UV run, we'll need to update dependabot to ensure it's using uv instead of pip for package management

Copy link
Copy Markdown
Collaborator

@mpkrass7 mpkrass7 left a comment

Choose a reason for hiding this comment

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

Ok two pieces of feedback before we merge:

Code: Remove UV change for now, we need to add dependabot changes and that should be in another PR
PR:

  1. Change the name to reflect what you are actually doing in this PR (e.g. add Makefile and remove OpenCode support)
  2. Change the tests to reflect what you are actually doing in this PR
  3. Do the tests. Deploy onto dogfood to test it

@mpkrass7
Copy link
Copy Markdown
Collaborator

@dgokeeffe Let me know when you've deployed / tested your changes on dogfood. Once you confirm I'll test on my end and we can get this merged.
We spun up a Contributing guide, let me know if it's helpful!
https://github.com/datasciencemonkey/coding-agents-databricks-apps/blob/main/CONTRIBUTING.md

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.

2 participants