Skip to content

chore(scripts): task-clean repo resolution, drop mac symlink, surface PORT#912

Merged
buremba merged 1 commit into
mainfrom
feat/task-script-fixes
May 19, 2026
Merged

chore(scripts): task-clean repo resolution, drop mac symlink, surface PORT#912
buremba merged 1 commit into
mainfrom
feat/task-script-fixes

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 19, 2026

Summary

Three small dev-script fixes for the per-task worktree workflow, scoped by a codex review of the multi-port story.

  • task-clean.sh repo resolution. Running from inside a worktree resolved repo to that worktree, so the worktree-dir + branch deletions targeted the wrong place. Switch to git rev-parse --git-common-dir --path-format=absolute, matching the fix task-setup.sh (fix(cli): task-setup uses --path-format=absolute for git-common-dir #900) and task-use.sh already use.
  • task-clean.sh warn on lobu context rm failure. Mirrors task-setup.sh:188. Silent failures left stale context entries after a clean.
  • task-use.sh drops the Mac symlink. The Mac menubar reads ~/.config/lobu/config.json on every popover expand (AppState.swift:456 refreshContexts) and shows each context's apiUrl independently — per-worktree contexts already appear in its picker, no "active mac" indirection needed. Devs open Xcode at the worktree's packages/owletto/apps/mac directly. The Chrome symlink stays.
  • task-use.sh surfaces PORT. Reads PORT from .env.local and prints it in the success message. The Chrome extension's gateway URL (sidepanel "Server URL" → chrome.storage.local) and the source symlink are independent switches; surfacing PORT each invocation makes the "still pointed at the previous worktree" footgun visible.

Reproducer

$ cd /Users/burakemre/Code/lobu/.claude/worktrees/task-script-fixes
$ bash scripts/task-use.sh task-script-fixes
→ chrome: /Users/burakemre/.config/lobu-dev/active/chrome → …/task-script-fixes/packages/owletto/apps/chrome
✓ active worktree: task-script-fixes
  ↳ Chrome ext: set Server URL to http://localhost:8789
    (open the owletto sidepanel; or reset via chrome://extensions → Reload)
    MV3 service workers re-register on extension reload, not on symlink change.

task-clean.sh repo-resolution path was syntax-checked (bash -n); not run end-to-end because doing so would remove this worktree mid-PR. The change is mechanical (one variable, identical to existing task-setup.sh / task-use.sh pattern).

Notes

  • Per-port auth cookies. Each localhost:$PORT has its own better-auth session — expected, but worth knowing when switching worktrees. Not changing.
  • Menubar refresh cadence. refreshContexts() is on-popover, not a filesystem watcher; new contexts appear on the next menu open. Acceptable.

Test plan

  • bash -n scripts/task-{clean,use}.sh
  • bash scripts/task-use.sh <worktree> retargets chrome symlink + prints PORT
  • Verify next task-setup + task-clean round-trip after merge (uses the new repo resolution from inside a worktree)

Summary by CodeRabbit

  • Improvements
    • Enhanced error handling in cleanup operations with explicit warnings for missing dependencies.
    • Streamlined extension development setup process.
    • Improved setup guidance for configuring extension server connection and MV3 reload behavior.

Review Change Stack

… PORT

Three small dev-script fixes shaped by codex review of the worktree workflow.

- task-clean.sh repo resolution: invoking from inside a worktree resolved
  $repo to that worktree (not the main checkout), so the worktree_dir +
  branch deletion paths targeted the wrong place. Switch to
  `git rev-parse --git-common-dir --path-format=absolute`, matching the
  fix task-setup.sh (#900) and task-use.sh already use.
- task-clean.sh: warn when `lobu context rm` fails or when the CLI isn't
  on PATH, mirroring task-setup.sh:188's symmetry. Silent failure left
  stale context entries after a clean.
- task-use.sh: drop the active/mac symlink. The Mac menubar reads
  ~/.config/lobu/config.json on every popover expand and shows each
  context's apiUrl independently (AppState.swift:456 refreshContexts) —
  per-worktree contexts already appear in the picker. Devs open Xcode at
  the worktree's packages/owletto/apps/mac directly. The remaining Chrome
  symlink is the only one task-use manages now.
- task-use.sh: read PORT from the worktree's .env.local and print it in
  the success message. The Chrome ext's gateway URL (sidepanel "Server
  URL" → chrome.storage.local) and the source symlink are independent
  switches; surfacing PORT every invocation makes the "still talking to
  the old worktree's gateway" footgun visible.

Tested locally: ran `bash scripts/task-use.sh task-script-fixes` end-to-end
inside this worktree; chrome symlink retargets, PORT (8789) appears in
the reminder.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

Both scripts/task-clean.sh and scripts/task-use.sh are updated to use Git-based directory resolution. task-clean.sh adds explicit error handling for Lobu context cleanup. task-use.sh removes Mac symlink setup, retargets Chrome only, and reads active worktree PORT from .env.local to guide users in setting the Chrome extension "Server URL".

Changes

Task Script Robustness and Symlink Updates

Layer / File(s) Summary
task-clean.sh: repo path resolution and error handling
scripts/task-clean.sh
repo is resolved from the script's location via git rev-parse --path-format=absolute --git-common-dir instead of cd "$script_dir/..". Lobu context removal explicitly warns to stderr if the command fails or if lobu is not on PATH.
task-use.sh: Chrome symlink retargeting and port-aware user guidance
scripts/task-use.sh
Mac symlink setup is removed; only the Chrome ~/.config/lobu-dev/active/chrome symlink is updated. Header docs clarify that the extension "Server URL" must be set manually. When using a worktree, PORT is parsed from $source_root/.env.local and printed in instructions to set the Chrome sidepanel to http://localhost:<PORT>. Repo resolution comment reframes the Git shared .git path requirement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • lobu-ai/lobu#909: Modifies scripts/task-use.sh around repo/worktree path resolution, switching to git rev-parse ... --git-common-dir for symlink retargeting.
  • lobu-ai/lobu#900: Updates scripts' repo path resolution to use git rev-parse --path-format=absolute --git-common-dir to avoid cwd-dependent worktree path bugs.
  • lobu-ai/lobu#899: Updates task scripts' repo-root resolution to use git rev-parse --git-common-dir instead of cd "$script_dir/..", aligning shared-worktree path logic.

Poem

🐰 Our task scripts now resolve their paths with Git's sure hand,
No more fumbling through symlinks in this scattered land;
Chrome gets its retarget, and warnings are clear,
PORT reads from .env, bringing guidance near!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the three main changes: task-clean repo resolution fix, removal of mac symlink, and surfacing of PORT in task-use.sh.
Description check ✅ Passed The PR description is comprehensive with detailed summaries of changes, a reproducer example, and test plan; it deviates from the template structure but provides all essential information in an organized manner.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/task-script-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/task-use.sh`:
- Around line 91-94: The PORT parsing currently assigned to active_port from
env_local can return quoted or commented values (e.g. PORT="5173" or PORT=5173 #
dev); update the parsing logic around active_port to robustly extract a numeric
port: read the PORT line (grep or awk matching ^PORT=), strip surrounding
quotes, remove any trailing inline comments or whitespace, and validate/retain
only the digits (fall back to empty or a default if not numeric). Target the
code that sets env_local and active_port so the updated command normalizes
values like "5173" and ignores comments before assigning active_port.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dd8c5e5-e3da-4f90-84a7-2c989fa9d142

📥 Commits

Reviewing files that changed from the base of the PR and between f8f087b and 0f827e9.

📒 Files selected for processing (2)
  • scripts/task-clean.sh
  • scripts/task-use.sh

Comment thread scripts/task-use.sh
Comment on lines +91 to +94
env_local="$source_root/.env.local"
if [[ -f "$env_local" ]]; then
active_port="$(awk -F= '/^PORT=/{print $2; exit}' "$env_local" | tr -d '[:space:]')"
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Harden PORT parsing from .env.local to handle common formats.

Line 93 only matches PORT=... and can emit bad output for quoted/commented values (for example PORT="5173" or PORT=5173 # dev).

Suggested fix
-    active_port="$(awk -F= '/^PORT=/{print $2; exit}' "$env_local" | tr -d '[:space:]')"
+    active_port="$(sed -nE 's/^[[:space:]]*PORT[[:space:]]*=[[:space:]]*"?([^"#[:space:]]+)"?.*$/\1/p' "$env_local" | head -n1)"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
env_local="$source_root/.env.local"
if [[ -f "$env_local" ]]; then
active_port="$(awk -F= '/^PORT=/{print $2; exit}' "$env_local" | tr -d '[:space:]')"
fi
env_local="$source_root/.env.local"
if [[ -f "$env_local" ]]; then
active_port="$(sed -nE 's/^[[:space:]]*PORT[[:space:]]*=[[:space:]]*"?([^"#[:space:]]+)"?.*$/\1/p' "$env_local" | head -n1)"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/task-use.sh` around lines 91 - 94, The PORT parsing currently
assigned to active_port from env_local can return quoted or commented values
(e.g. PORT="5173" or PORT=5173 # dev); update the parsing logic around
active_port to robustly extract a numeric port: read the PORT line (grep or awk
matching ^PORT=), strip surrounding quotes, remove any trailing inline comments
or whitespace, and validate/retain only the digits (fall back to empty or a
default if not numeric). Target the code that sets env_local and active_port so
the updated command normalizes values like "5173" and ignores comments before
assigning active_port.

@buremba buremba merged commit 30edc10 into main May 19, 2026
26 checks passed
@buremba buremba deleted the feat/task-script-fixes branch May 19, 2026 16:56
buremba added a commit that referenced this pull request May 19, 2026
…lock image builds (#927)

PR #911 added `examples/personal-finance` to root `package.json`'s
`workspaces` field but didn't update the Dockerfiles, which only COPY
`packages/*/package.json` for the install layer. `bun install` inside
the Docker build then errored:

    error: Workspace not found "examples/personal-finance"
        at /app/package.json:8:5

Every image build on `main` since #911 merged (13:25 UTC today) has
been red: #911#913 (+revert) → #914#915#919#923#924#912#925 — all sitting on `main` un-deployable, including the
`principal_kind` migration from #923 and my own loading-skeletons
shipping artifacts.

Two ways to fix it:

1. **Add stubs to all three Dockerfiles** for the example. Treats the
   symptom; couples prod build pipeline to whatever's under `examples/`,
   wrong direction.
2. **Take the example out of root workspaces.** Examples are
   documentation/demos for users to clone + run; they don't belong in
   the prod build graph. Cleaner separation.

Going with (2). Side effects:

- Example's dependency on `@lobu/promptfoo-provider` switched from
  `workspace:*` (workspace-protocol-only) to
  `file:../../packages/promptfoo-provider`. Resolves locally without
  requiring the example to be in a workspace; consumers run
  `cd examples/personal-finance && bun install` standalone (after
  building the provider once: `cd packages/promptfoo-provider && bun
  run build`).
- `bun.lock` regenerated. Most of the diff is bun's "linked
  workspaces" table shrinking — no upstream version churn.

Verified: simulated Docker build context (root files + stubbed
packages/* manifests + provider stub, no examples/) runs `bun install`
cleanly. No "Workspace not found" error.
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