Skip to content

refactor(session-bridge): simplify view_bridge.py and watch.sh - #14568

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14346-42612672355-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14346-42612672355-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14346

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified two of the three listed session-bridge files without changing behavior. In view_bridge.py, a new load_log helper replaces three copies of load_json(path, {"seq": 0, "events": []}). page_input now builds its entries with two list comprehensions instead of append loops. cmd_ensure_running builds the serve argv in one list and sets the start-failure message inside the poll branch. In watch.sh, a value() helper replaces seven repeated sed|tr KEY= reads, and a case with an empty default arm becomes an if. wake.sh is 16 lines with nothing left to simplify that would make it shorter or clearer, so it is unchanged. The shared copies are regenerated with scripts/sync-shared-copies.sh.

Not verified

  • lib/session-bridge/test_view_bridge.py and test_session_bridge.py (they run watch.sh and view_bridge.py) were not run here because the lane's Bash runs only the named wrappers; left to the PR's CI
  • tidy skipped: the change spans 13 files (cutoff 10) and edits lib/, which is a listed shared path
  • verify step (build and tests) skipped: no test runner can run in this lane; behavior equivalence rests on the review and the CI suites
  • ci-status green: a PR CI check, left to the PR's CI

Fix

  • lib/session-bridge/view_bridge.py: added load_log() and used it in ViewHub.read_log, cmd_apply and cmd_status; page_input rewritten as two list comprehensions with the same entry order and key order; cmd_ensure_running builds the serve argv in one list and sets why inside the poll branch
  • lib/session-bridge/watch.sh: added value() for KEY=value reads (NAME, CONTROL, PORT, WATCH_TOKEN, TOKEN, WAIT_TIMEOUT, PLUGIN_VERSION) with the conf reads' 2>/dev/null kept at their call sites; replaced the .watch-replay case and its empty default arm with an if
  • plugins/planning/surface/watch.sh, plugins/planning/shared/watch.sh, plugins/planning/view-bridge/watch.sh, plugins/work-items/view-bridge/watch.sh, plugins/review/view-bridge/watch.sh: regenerated copies of lib/session-bridge/watch.sh
  • plugins/planning/view-bridge/view_bridge.py, plugins/work-items/view-bridge/view_bridge.py, plugins/review/view-bridge/view_bridge.py: regenerated copies of lib/session-bridge/view_bridge.py
  • .changes/planning/work-resolve-issue-issue-14346-42612672355-1-7c5e1a1c.md, .changes/work-items/work-resolve-issue-issue-14346-42612672355-1-23d24041.md, .changes/review/work-resolve-issue-issue-14346-42612672355-1-69a20413.md: patch fragments recording the internal simplification

Verification

The runner ran each check from the base copy against d4adb64:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • sync-shared-copies: exit 0; regenerated the 8 copies of view_bridge.py and watch.sh
  • check-changelog-fragments: all 9 fragments under .changes/ valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 14 passed, 5 skipped (typos not installed; validate-plugins sub-checks that run code from the checked tree; changed-skills had no skill file), 0 failed, over 13 changed files
  • review: a fresh-context subagent read the diff against the current files for behavior changes (output text, exit codes, written files, JSON key order, bash 3.2 and Git Bash semantics, stderr redirection scope, shared mutable defaults) and found none
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42612672355

Left out: the items under Not verified.

Related

#14346

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed d4adb64e88962b50c2f3c36af0d6001513bd783c: read 13 of 13 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings. This is a complete review of all 13 changed files. I read the two lib/session-bridge/ sources and the first file of each identical-copy group. The copies' changes are identical to their sources, and none of the copy paths changes what the content does.

Behavior equivalence (the issue's main acceptance criterion), checked by reading the code:

  • view_bridge.py load_log: returns a fresh {"seq": 0, "events": []} on every call, so no mutable default is shared. It is the same as the three inline load_json calls it replaces.
  • page_input:
    • event["action"] was only reached when the action was lock or unlock, so event.get("action") gives the same result there.
    • For other actions, locks is {}, which matches the old guarded loop.
    • Lock entries still come before comment entries, and the dict key order is unchanged.
  • cmd_ensure_running:
    • The argv is built in the same order (--dir d serve --port P --nonce N --idle-seconds S). Nothing else in the function reads cmd or idle.
    • The why branches line up with the old conditional expression: no exit code means kill the process plus the "did not start" message; an exit code gives the "exited with status" message.
  • watch.sh value():
    • 2>/dev/null on the function call still hides sed's stderr when the conf file is missing.
    • The keys are literal, so $1 inside the sed pattern adds no regex risk.
    • Running tr -d '\r' before tr -dc '0-9' for WAIT_TIMEOUT gives the same output.
    • Nothing else in the script uses the name value.
  • watch.sh: the old case and the new [[ $out == '…'*'…'* ]] use the same glob, with literal quoted parts.

Closing issue #14346:

  • Behavior unchanged: met, by the reading above. test_view_bridge.py and test_session_bridge.py exercise status, ensure-running and the watcher. I did not run them.
  • Only listed files, plus their regenerated copies and changelog fragments, are edited: met. wake.sh is left unchanged, with the reason given.
  • Size: met. The change is well under 400 lines and touches 2 hand-edited files.
  • Shared copies regenerated: met. The copies match the lib/ changes.
  • ci-status green: not verified here. The PR CI checks this.

The PR body's verification commands and the subagent's equivalence review are the author's claims; I did not verify them.

Changelog fragments: bump: patch fits an internal refactor that changes no behavior.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d4adb64e88962b50c2f3c36af0d6001513bd783c: read 13 of 13 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14568 (refactor(session-bridge): simplify view_bridge.py and watch.sh)

I found no security issues.

I read the whole change for the first path of each identical group and for both lib/session-bridge/ sources: the .changes/* fragments, lib/session-bridge/view_bridge.py, lib/session-bridge/watch.sh, plugins/planning/shared/watch.sh and plugins/planning/view-bridge/view_bridge.py. The other copies under plugins/{planning,review,work-items}/ have the same content as these. None of them sits at a hook, workflow, settings or manifest path, so being a copy doesn't change what any of them does. No changed file matches a trusted-path glob. No manifest or userConfig is touched.

What I checked:

  • watch.sh value() helper (lib/session-bridge/watch.sh:157): the key passed into the sed expression ("s/^$1=//p") is always a hard-coded literal (NAME, CONTROL, PORT, WATCH_TOKEN, TOKEN, WAIT_TIMEOUT, PLUGIN_VERSION). No outside input reaches the sed program, so there is no injection path. The checks that run after each read are unchanged: the NAME/CONTROL regex gate, the PORT numeric check, the tr -dc '0-9' on WAIT_TIMEOUT, and the WATCH_TOKEN → TOKEN fallback. The 2>/dev/null on the conf reads now covers the whole function rather than just sed. That only hides more of the function's stderr and changes nothing about trust.
  • case → [[ == ]] (lib/session-bridge/watch.sh:170): the quoted parts are still matched literally and the unquoted * still works as a glob, so the match is the same. The .watch-replay write still goes through the same digits-only sed capture.
  • view_bridge.py:
    • load_log returns a fresh dict on every call, the same as the old inline literal, so no shared mutable default is introduced.
    • In page_input, kind is set from event["action"] only on the lock/unlock branch, as before.
    • cmd_ensure_running still passes a list argv to bridge.spawn with no shell, and the nonce, port and idle arguments are unchanged.

Nothing in the PR context reads as an instruction to the review lane. The closing issue's body was left out upstream.

The prior-findings file lists no earlier posts from this lane, so this was a full review, not a blocking-only one.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit ab68630 Nov 9, 2026
57 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14346-42612672355-1 branch November 9, 2026 13:17
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.

Simplify the session-bridge shared lib source (2 of 2)

1 participant