Repository navigation
Add built-in OpenCode sidebar status integration #4797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
austinywang
wants to merge
30
commits into
main
from
issue-1425-add-built-in-opencode-sidebar-status
Closed
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e8fb8fa
Add bundled OpenCode status wrapper
austinywang 971a35a
Merge remote-tracking branch 'origin/main' into issue-1425-add-built-…
austinywang 80e584f
Fix OpenCode prompt status notifications
austinywang 0087bf8
Handle OpenCode status edge cases
austinywang d55134d
Harden OpenCode event notifications
austinywang 25a221b
Track OpenCode idle transitions by state
austinywang 55126ff
Localize OpenCode runtime status hooks
austinywang 9559053
Fix OpenCode runtime hook session state
austinywang 667bb4b
merge: resolve conflicts with main
austinywang 0aa984f
fix: normalize project file after merge
austinywang f9c892d
fix: stabilize opencode runtime lifecycle hooks
austinywang a76c681
fix: bound opencode lifecycle state
austinywang 753054e
fix: protect opencode prompt lifecycle
austinywang b93f159
fix: handle opencode run lifecycle
austinywang 2e9d693
fix: resolve opencode prompt status
austinywang 1a8f60b
fix: harden opencode lifecycle followups
austinywang 61b6526
fix: respect opencode primary status fields
austinywang a8a2411
fix: protect opencode blocking lifecycle states
austinywang 57bf740
fix: keep opencode lifecycle cache bounded
austinywang ac9a1a5
fix: preserve blocking opencode session updates
austinywang ac28cf1
Merge remote-tracking branch 'origin/main' into issue-1425-add-built-…
austinywang 4968947
fix: regenerate Swift length budget
austinywang dda1d7d
Merge remote-tracking branch 'origin/main' into issue-1425-add-built-…
austinywang 048ca9c
fix: address opencode PR review findings
austinywang 1585506
fix: avoid checked-in opencode provider path
austinywang 5e95211
fix: preserve opencode prompt lifecycle on updates
austinywang 0965bdb
fix: keep opencode runtime status on shared guard paths
austinywang bce0a18
merge: sync with origin/main
austinywang c03082b
merge: resolve conflicts with main
austinywang e6fadb4
fix: address opencode hook review feedback
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| #!/usr/bin/env bash | ||
| # cmux opencode wrapper - installs cmux plugins and captures launch metadata. | ||
| # | ||
| # When running inside a cmux terminal with a live cmux socket, this wrapper | ||
| # installs the bundled OpenCode plugins before launching the real opencode | ||
| # binary. Outside cmux, it passes through unchanged. | ||
|
|
||
| find_real_opencode() { | ||
| local self_dir | ||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| local IFS=: | ||
| for d in $PATH; do | ||
| [[ "$d" == "$self_dir" ]] && continue | ||
| local candidate="$d/opencode" | ||
| [[ -x "$candidate" ]] || continue | ||
| if [[ "$candidate" -ef "$0" ]]; then | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| continue | ||
| fi | ||
| printf '%s' "$candidate" | ||
| return 0 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| resolve_cmux_bin() { | ||
| local bundled_cli self_dir | ||
| bundled_cli="${CMUX_BUNDLED_CLI_PATH:-}" | ||
| if [[ -n "$bundled_cli" && -x "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| bundled_cli="$self_dir/cmux" | ||
| if [[ -x "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| bundled_cli="$(command -v cmux || true)" | ||
| if [[ -n "$bundled_cli" ]]; then | ||
| printf '%s' "$bundled_cli" | ||
| return 0 | ||
| fi | ||
|
|
||
| return 1 | ||
| } | ||
|
|
||
| cmux_socket_available() { | ||
| local socket="${CMUX_SOCKET_PATH:-}" | ||
| [[ -n "$socket" && -S "$socket" ]] || return 1 | ||
|
|
||
| local cmux_bin | ||
| cmux_bin="$(resolve_cmux_bin)" || return 1 | ||
| CMUXTERM_CLI_RESPONSE_TIMEOUT_SEC=0.75 \ | ||
| "$cmux_bin" --socket "$socket" ping >/dev/null 2>&1 | ||
| } | ||
|
|
||
| encode_launch_argv() { | ||
| { | ||
| printf '%s\0' "$REAL_OPENCODE" | ||
| if (( $# > 0 )); then | ||
| printf '%s\0' "$@" | ||
| fi | ||
| } | base64 | tr -d '\n' | ||
| } | ||
|
|
||
| opencode_passthrough_option_flag() { | ||
| case "$1" in | ||
| --help|-h|--version|-v) | ||
| return 0 | ||
| ;; | ||
| esac | ||
| return 1 | ||
| } | ||
|
|
||
| opencode_builtin_command_name() { | ||
| case "$1" in | ||
| completion|acp|mcp|attach|run|debug|providers|auth|agent|upgrade|\ | ||
| uninstall|serve|web|models|stats|export|import|pr|github|session|\ | ||
| plugin|plug|db|help|version) | ||
| return 0 | ||
| ;; | ||
| esac | ||
| return 1 | ||
| } | ||
|
|
||
| opencode_command_like_invocation() { | ||
| local candidate="$1" | ||
| [[ -n "$candidate" ]] || return 1 | ||
| case "$candidate" in | ||
| *[![:alnum:]_-]*) | ||
| return 1 | ||
| ;; | ||
| esac | ||
| opencode_builtin_command_name "$candidate" | ||
| } | ||
|
|
||
| should_install_opencode_hooks() { | ||
| (( $# == 0 )) && return 0 | ||
|
|
||
| local arg | ||
| local skip_next=false | ||
| for arg in "$@"; do | ||
| if [[ "$skip_next" == true ]]; then | ||
| skip_next=false | ||
| continue | ||
| fi | ||
| case "$arg" in | ||
| --) | ||
| return 0 | ||
| ;; | ||
| --log-level|--port|--hostname|--mdns-domain|--cors|--file|-f|\ | ||
| --model|-m|--session|-s|--prompt|--agent) | ||
| skip_next=true | ||
| continue | ||
| ;; | ||
| -*) | ||
| if opencode_passthrough_option_flag "$arg"; then | ||
| return 1 | ||
| fi | ||
| continue | ||
| ;; | ||
| *) | ||
| if opencode_command_like_invocation "$arg"; then | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
| REAL_OPENCODE="$(find_real_opencode)" || { echo "Error: opencode not found in PATH" >&2; exit 127; } | ||
|
|
||
| IN_CMUX=0 | ||
| if [[ -n "${CMUX_SURFACE_ID:-}" ]]; then | ||
| IN_CMUX=1 | ||
| fi | ||
|
|
||
| if [[ "$IN_CMUX" == "1" && "${CMUX_OPENCODE_HOOKS_DISABLED:-}" != "1" ]] \ | ||
| && cmux_socket_available \ | ||
| && should_install_opencode_hooks "$@"; then | ||
| CMUX_BIN="$(resolve_cmux_bin || true)" | ||
| if [[ -n "$CMUX_BIN" ]]; then | ||
| CMUXTERM_CLI_RESPONSE_TIMEOUT_SEC=2 \ | ||
| "$CMUX_BIN" --socket "$CMUX_SOCKET_PATH" hooks opencode install --yes >/dev/null 2>&1 || true | ||
| export CMUX_OPENCODE_CMUX_BIN="$CMUX_BIN" | ||
| fi | ||
| export CMUX_OPENCODE_PID=$$ | ||
| export CMUX_AGENT_LAUNCH_KIND="opencode" | ||
| export CMUX_AGENT_LAUNCH_EXECUTABLE="$REAL_OPENCODE" | ||
| export CMUX_AGENT_LAUNCH_ARGV_B64="$(encode_launch_argv "$@")" | ||
| export CMUX_AGENT_LAUNCH_CWD="$PWD" | ||
| fi | ||
|
|
||
| exec "$REAL_OPENCODE" "$@" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.