-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add built-in OpenCode status integration #1426
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
Open
coygeek
wants to merge
16
commits into
manaflow-ai:main
Choose a base branch
from
coygeek:feat/opencode-status-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b9ebd9a
feat: add built-in OpenCode status integration
coygeek ece7e89
fix: address review feedback on OpenCode status integration
coygeek c80abe6
fix: constrain --pid to Int32 to match server-side parsing
coygeek 802dd84
feat: add completion notification when OpenCode session finishes
ericmjl 66d0586
fix: add cooldown to completion notifications to prevent flashing
ericmjl 9638189
feat: make completion notifications persist until acknowledged
ericmjl fe9b110
fix: correct indentation in session.status handler
ericmjl 634467b
fix: reset completed flag when starting new work
ericmjl 5f54ce2
fix: remove duplicate completion detection code
ericmjl 5bd122c
fix: clear waiting text when leaving idle state
ericmjl cb51513
fix: suppress stdout from cmux CLI commands to prevent phantom OK text
ericmjl 811cf13
Fix #1972: resync terminal portal after restore-time bind (#1973)
austinywang 71b0cf0
Stabilize UI test launch foreground activation
austinywang 37b5e54
Retry flaky display UI launch in CI
austinywang 29d6277
Merge pull request #1 from ericmjl/feat/opencode-completion-notification
coygeek f007166
merge: resolve CLI/cmux.swift conflict with upstream main
coygeek 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #!/usr/bin/env bash | ||
| # cmux opencode wrapper - injects sidebar status + notifications | ||
|
|
||
| find_real_opencode() { | ||
| local self_dir | ||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| local IFS=: | ||
| local dir | ||
| for dir in $PATH; do | ||
| [[ "$dir" == "$self_dir" ]] && continue | ||
| [[ -x "$dir/opencode" ]] && printf '%s' "$dir/opencode" && return 0 | ||
| done | ||
| return 1 | ||
| } | ||
|
|
||
| CMUX_BIN="" | ||
|
|
||
| cmux_socket_available() { | ||
| local socket="${CMUX_SOCKET_PATH:-${CMUX_SOCKET:-}}" | ||
| [[ -n "$socket" && -S "$socket" ]] || return 1 | ||
|
|
||
| local self_dir | ||
| self_dir="$(cd "$(dirname "$0")" && pwd)" | ||
| CMUX_BIN="$self_dir/cmux" | ||
| [[ -x "$CMUX_BIN" ]] || CMUX_BIN="$(command -v cmux || true)" | ||
| [[ -n "$CMUX_BIN" ]] || return 1 | ||
|
|
||
| CMUXTERM_CLI_RESPONSE_TIMEOUT_SEC=0.75 \ | ||
| "$CMUX_BIN" --socket "$socket" ping >/dev/null 2>&1 | ||
| } | ||
|
|
||
| run_cmux() { | ||
| [[ -n "$CMUX_BIN" ]] || return 1 | ||
| "$CMUX_BIN" "$@" >/dev/null 2>&1 | ||
| } | ||
|
|
||
| link_children() { | ||
| local source_dir="$1" | ||
| local destination_dir="$2" | ||
| [[ -d "$source_dir" ]] || return 0 | ||
|
|
||
| mkdir -p "$destination_dir" | ||
| local item | ||
| local name | ||
| shopt -s dotglob nullglob | ||
| for item in "$source_dir"/*; do | ||
| name="$(basename "$item")" | ||
| [[ "$name" == "." || "$name" == ".." ]] && continue | ||
| [[ -e "$destination_dir/$name" ]] && continue | ||
| ln -s "$item" "$destination_dir/$name" | ||
| done | ||
| shopt -u dotglob nullglob | ||
| } | ||
|
|
||
| IN_CMUX=0 | ||
| if [[ -n "${CMUX_SURFACE_ID:-}" ]]; then | ||
| IN_CMUX=1 | ||
| fi | ||
|
|
||
| if [[ "$IN_CMUX" == "0" || "${CMUX_OPENCODE_INTEGRATION_DISABLED:-}" == "1" ]] || ! cmux_socket_available; then | ||
| REAL_OPENCODE="$(find_real_opencode)" || { echo "Error: opencode not found in PATH" >&2; exit 127; } | ||
| exec "$REAL_OPENCODE" "$@" | ||
| fi | ||
|
|
||
| REAL_OPENCODE="$(find_real_opencode)" || { echo "Error: opencode not found in PATH" >&2; exit 127; } | ||
|
|
||
| SELF_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| PLUGIN_SOURCE="$SELF_DIR/opencode-cmux-plugin.js" | ||
| if [[ ! -r "$PLUGIN_SOURCE" ]]; then | ||
| exec "$REAL_OPENCODE" "$@" | ||
| fi | ||
|
|
||
| CMUX_OPENCODE_CONFIG_DIR="$(mktemp -d "${TMPDIR:-/tmp}/cmux-opencode-config.XXXXXX")" | ||
| cleanup() { | ||
| rm -rf "$CMUX_OPENCODE_CONFIG_DIR" | ||
| } | ||
| trap cleanup EXIT HUP INT TERM | ||
|
|
||
| EXISTING_CONFIG_DIR="${OPENCODE_CONFIG_DIR:-}" | ||
| if [[ -n "$EXISTING_CONFIG_DIR" && -d "$EXISTING_CONFIG_DIR" ]]; then | ||
| local_item="" | ||
| local_name="" | ||
| shopt -s dotglob nullglob | ||
| for local_item in "$EXISTING_CONFIG_DIR"/*; do | ||
| local_name="$(basename "$local_item")" | ||
| [[ "$local_name" == "." || "$local_name" == ".." ]] && continue | ||
| [[ "$local_name" == "plugin" || "$local_name" == "plugins" ]] && continue | ||
| [[ -e "$CMUX_OPENCODE_CONFIG_DIR/$local_name" ]] && continue | ||
| ln -s "$local_item" "$CMUX_OPENCODE_CONFIG_DIR/$local_name" | ||
| done | ||
| shopt -u dotglob nullglob | ||
|
|
||
| link_children "$EXISTING_CONFIG_DIR/plugin" "$CMUX_OPENCODE_CONFIG_DIR/plugin" | ||
| link_children "$EXISTING_CONFIG_DIR/plugins" "$CMUX_OPENCODE_CONFIG_DIR/plugins" | ||
| fi | ||
|
|
||
| mkdir -p "$CMUX_OPENCODE_CONFIG_DIR/plugins" | ||
| cp "$PLUGIN_SOURCE" "$CMUX_OPENCODE_CONFIG_DIR/plugins/cmux-integration.js" | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| export OPENCODE_CONFIG_DIR="$CMUX_OPENCODE_CONFIG_DIR" | ||
|
|
||
| run_cmux clear-status opencode || true | ||
|
|
||
| "$REAL_OPENCODE" "$@" | ||
| STATUS=$? | ||
|
|
||
| run_cmux clear-status opencode || true | ||
| run_cmux clear-notifications || true | ||
|
|
||
| exit "$STATUS" | ||
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.