chore(scripts): task-clean repo resolution, drop mac symlink, surface PORT#912
Conversation
… 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.
📝 WalkthroughWalkthroughBoth ChangesTask Script Robustness and Symlink Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
scripts/task-clean.shscripts/task-use.sh
| 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 |
There was a problem hiding this comment.
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.
| 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.
…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.
Summary
Three small dev-script fixes for the per-task worktree workflow, scoped by a codex review of the multi-port story.
task-clean.shrepo resolution. Running from inside a worktree resolvedrepoto that worktree, so the worktree-dir + branch deletions targeted the wrong place. Switch togit rev-parse --git-common-dir --path-format=absolute, matching the fixtask-setup.sh(fix(cli): task-setup uses --path-format=absolute for git-common-dir #900) andtask-use.shalready use.task-clean.shwarn onlobu context rmfailure. Mirrorstask-setup.sh:188. Silent failures left stale context entries after a clean.task-use.shdrops the Mac symlink. The Mac menubar reads~/.config/lobu/config.jsonon every popover expand (AppState.swift:456 refreshContexts) and shows each context'sapiUrlindependently — per-worktree contexts already appear in its picker, no "active mac" indirection needed. Devs open Xcode at the worktree'spackages/owletto/apps/macdirectly. The Chrome symlink stays.task-use.shsurfaces PORT. Reads PORT from.env.localand 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
task-clean.shrepo-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 existingtask-setup.sh/task-use.shpattern).Notes
localhost:$PORThas its own better-auth session — expected, but worth knowing when switching worktrees. Not changing.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}.shbash scripts/task-use.sh <worktree>retargets chrome symlink + prints PORTtask-setup+task-cleanround-trip after merge (uses the new repo resolution from inside a worktree)Summary by CodeRabbit