feat: AeroSpace レイアウト自動復元スクリプトを追加 - #199
Conversation
ディスプレイ抜き差し時のワークスペースレイアウト崩れを自動修正するスクリプトを追加。 ## 機能 - AeroSpace設定を再読み込み - ワークスペースA (Slack + Spark Desktop) を vertical tiles レイアウトに修正 - ワークスペース11 (Cursor) を horizontal tiles レイアウトに修正 ## 使用方法 ```bash # フルパスで実行 /Users/keito4/develop/github.com/keito4/config/script/aerospace-fix-layout # または ~/.zshrc にエイリアスを追加して alias aerospace-fix='/Users/keito4/develop/github.com/keito4/config/script/aerospace-fix-layout' # 簡単に実行 aerospace-fix ``` ## 使用タイミング - 外部ディスプレイ接続/切断後 - ワークスペースレイアウトが乱れたとき - AeroSpace再起動後 ## 前提条件 - AeroSpace v0.20.0+ - ~/.aerospace.toml に workspace-to-monitor-force-assignment が設定済み 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughDocumentation expanded with a new "Local GitHub Actions Testing with act" section covering Quick Start, Configuration, and Common Use Cases. Additionally, a new Bash script introduces AeroSpace workspace layout restoration functionality, automating configuration reload and workspace tile rebuilding after display changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Review: AeroSpace レイアウト自動復元スクリプト総合評価このPRは、ディスプレイ接続時のワークスペースレイアウト崩れを修正するユーティリティスクリプトを追加しています。全体的によく設計されており、コード品質は高いです。 ✅ 良い点
🔍 改善提案1. エラーハンドリングの強化現在、エラーは 2>/dev/null で抑制されていますが、ユーザーが問題を把握できるようにすべきです。 推奨: aerospace コマンドの存在チェックと、reload-config の失敗時のエラー表示 2. ハードコードされたパスの問題README.md line 31とスクリプトのコメントに /Users/keito4/develop/github.com/keito4/config がハードコードされています。 問題点:
推奨: パスを汎用的な /path/to/your/config/script/aerospace-fix-layout に変更 3. テストカバレッジCLAUDE.md の品質基準では 70%+行カバレッジ が要求されていますが、このスクリプトには自動テストがありません。 推奨: test/aerospace-fix-layout.test.bash を作成し、既存のtest_helper.bashパターンを使用 📋 チェックリスト(CLAUDE.md準拠)Definition of Done
Git Workflow
🎯 推奨アクションアイテムCritical (マージ前対応推奨)
High (次回イテレーション推奨)
Medium (将来的改善)
📊 最終判定LGTM with minor suggestions 👍 このPRは以下の理由でマージ可能です:
ただし、上記のCritical項目(ハードコードパス)の対応を推奨します。High以降の項目は、後続のイテレーションで対応可能です。 レビュー実施: Claude Code |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
script/aerospace-fix-layout (2)
31-31: Consider using a generic path in the alias example.The hardcoded path
/Users/keito4/develop/github.com/keito4/config/script/aerospace-fix-layoutis user-specific. Consider using a generic placeholder or referencing the$REPO_PATHvariable used elsewhere in the repository.🔎 Suggested improvement
-# alias aerospace-fix='/Users/keito4/develop/github.com/keito4/config/script/aerospace-fix-layout' +# alias aerospace-fix='$REPO_PATH/script/aerospace-fix-layout' +# # Or use absolute path: alias aerospace-fix='/path/to/config/script/aerospace-fix-layout'
1-64: Consider adding prerequisite validation.The script documentation mentions AeroSpace v0.20.0+ is required, but the script doesn't verify:
- AeroSpace is installed
- AeroSpace version meets minimum requirements
- AeroSpace is currently running
🔎 Suggested prerequisite checks
Add this after the shebang and before the main logic:
# Verify AeroSpace is installed and running if ! command -v aerospace &>/dev/null; then echo "❌ AeroSpace is not installed" echo " Install from: https://github.com/nikitabobko/AeroSpace" exit 1 fi # Verify AeroSpace version (requires v0.20.0+) if ! aerospace --version &>/dev/null; then echo "❌ AeroSpace is not running" echo " Start AeroSpace and try again" exit 1 fi
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.mdscript/aerospace-fix-layout
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/docker-image.yml : Build DevContainer images automatically with semantic versioning and multi-platform support in .github/workflows/docker-image.yml
Applied to files:
README.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/ci.yml : Validate code quality in CI pipeline (.github/workflows/ci.yml) with linting, formatting, testing, and building
Applied to files:
README.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/**,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json
Applied to files:
README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
🔇 Additional comments (1)
README.md (1)
584-584: LGTM!The glossary entry for "act" is clear, concise, and properly positioned alphabetically.
| #### Local GitHub Actions Testing with act | ||
|
|
||
| This repository includes [act](https://nektosact.com/) for testing GitHub Actions workflows locally before pushing to GitHub. | ||
|
|
||
| **Quick Start:** | ||
|
|
||
| ```bash | ||
| # List all available workflows | ||
| act -l | ||
|
|
||
| # Run all workflows that would trigger on push | ||
| act push | ||
|
|
||
| # Run a specific workflow | ||
| act -j <job-name> | ||
|
|
||
| # Run with secrets from environment | ||
| GITHUB_TOKEN=your_token act | ||
|
|
||
| # Dry run to see what would be executed | ||
| act -n | ||
| ``` | ||
|
|
||
| **Configuration:** | ||
|
|
||
| The `.actrc` file provides default settings: | ||
|
|
||
| - Uses `catthehacker/ubuntu:full-*` images for better GitHub Actions compatibility | ||
| - Loads environment variables from `.env.local` (create this file for local secrets) | ||
| - Enables container reuse for faster subsequent runs | ||
| - Binds workspace for improved performance | ||
|
|
||
| **Common Use Cases:** | ||
|
|
||
| ```bash | ||
| # Test CI pipeline locally before pushing | ||
| act -j ci | ||
|
|
||
| # Test with specific event payload | ||
| act pull_request --eventpath event.json | ||
|
|
||
| # Test Docker builds | ||
| act -j docker-image | ||
|
|
||
| # Run with verbose logging for debugging | ||
| act -v | ||
| ``` | ||
|
|
||
| **Environment Variables:** | ||
|
|
||
| Create `.env.local` (git-ignored) for local testing: | ||
|
|
||
| ```bash | ||
| cat <<'EOF' > .env.local | ||
| GITHUB_TOKEN=your_github_token | ||
| OPENAI_API_KEY=your_openai_key | ||
| EOF | ||
| chmod 600 .env.local | ||
| ``` | ||
|
|
||
| **Important Notes:** | ||
|
|
||
| - Some actions may not work identically to GitHub's hosted runners | ||
| - Docker-in-Docker workflows require `--privileged` flag | ||
| - Network requests may behave differently in containerized environment | ||
|
|
||
| For more details, see the [act documentation](https://nektosact.com/). |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify .actrc file existence and workflow job names
echo "=== Checking for .actrc file ==="
if [ -f .actrc ]; then
echo "✓ .actrc exists"
echo "Content:"
cat .actrc
else
echo "✗ .actrc not found"
fi
echo ""
echo "=== Checking workflow files in .github/workflows ==="
if [ -d .github/workflows ]; then
ls -la .github/workflows
else
echo "✗ .github/workflows directory not found"
fi
echo ""
echo "=== Extracting job names from workflow files ==="
if [ -d .github/workflows ]; then
find .github/workflows -name "*.yml" -o -name "*.yaml" | while read file; do
echo "File: $file"
grep -E "^[a-z]" "$file" | head -20
done
fiRepository: keito4/config
Length of output: 1344
🏁 Script executed:
#!/bin/bash
# Extract job names from workflow files properly
echo "=== Job names in ci.yml ==="
grep -A 20 "^jobs:" .github/workflows/ci.yml | grep "^ " | grep -v "^ "
echo ""
echo "=== Job names in docker-image.yml ==="
grep -A 20 "^jobs:" .github/workflows/docker-image.yml | grep "^ " | grep -v "^ "
echo ""
echo "=== Full jobs section of ci.yml (first 30 lines) ==="
sed -n '/^jobs:/,/^[^ ]/p' .github/workflows/ci.yml | head -30
echo ""
echo "=== Full jobs section of docker-image.yml (first 30 lines) ==="
sed -n '/^jobs:/,/^[^ ]/p' .github/workflows/docker-image.yml | head -30Repository: keito4/config
Length of output: 1738
Update act examples to match actual workflow job names and remove reference to non-existent .actrc file.
The .actrc file is documented but doesn't exist in the repository. Additionally, the job name examples are incorrect: use quality instead of ci (from ci.yml) and build-and-release instead of docker-image (from docker-image.yml). Users following these examples will encounter job not found errors.
Remove the Configuration section referencing .actrc, and update the Common Use Cases section:
# Test CI pipeline locally before pushing
act -j quality
# Test Docker builds
act -j build-and-release🤖 Prompt for AI Agents
In README.md around lines 428 to 494, remove the "Configuration" subsection that
references a non-existent .actrc file and any bullets tied exclusively to it,
and update the "Common Use Cases" examples to use the actual workflow job names:
replace the `act -j ci` example with `act -j quality` and replace `act -j
docker-image` with `act -j build-and-release`; keep the rest of the act guidance
(quick start, env file notes) intact but ensure no mention of .actrc remains.
| # Reload configuration | ||
| echo " → Reloading config..." | ||
| aerospace reload-config | ||
|
|
||
| # Wait a moment for reload to complete | ||
| sleep 0.5 |
There was a problem hiding this comment.
Add error handling for configuration reload.
The script doesn't verify that aerospace reload-config succeeds before proceeding. If the reload fails (e.g., invalid config, AeroSpace not running), the subsequent commands will operate on stale configuration.
🔎 Proposed fix with error handling
# Reload configuration
echo " → Reloading config..."
-aerospace reload-config
+if ! aerospace reload-config 2>/dev/null; then
+ echo "❌ Failed to reload AeroSpace configuration"
+ echo " Check that AeroSpace is running: aerospace --version"
+ exit 1
+fi
# Wait a moment for reload to complete
sleep 0.5📝 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.
| # Reload configuration | |
| echo " → Reloading config..." | |
| aerospace reload-config | |
| # Wait a moment for reload to complete | |
| sleep 0.5 | |
| # Reload configuration | |
| echo " → Reloading config..." | |
| if ! aerospace reload-config 2>/dev/null; then | |
| echo "❌ Failed to reload AeroSpace configuration" | |
| echo " Check that AeroSpace is running: aerospace --version" | |
| exit 1 | |
| fi | |
| # Wait a moment for reload to complete | |
| sleep 0.5 |
🤖 Prompt for AI Agents
In script/aerospace-fix-layout around lines 44 to 49, the script runs "aerospace
reload-config" but does not check its result; update the script to capture the
command exit status and handle failures by checking "$?" (or use a conditional
directly), printing a clear error message to stderr if the reload fails, and
exiting with a non‑zero status (or retry/backoff if desired) so subsequent steps
do not run on stale configuration.
| # Fix workspace A (Slack + Spark Desktop) - vertical layout | ||
| echo " → Fixing workspace A (Slack + Spark)..." | ||
| aerospace flatten-workspace-tree --workspace A 2>/dev/null | ||
| aerospace layout v_tiles --workspace A 2>/dev/null | ||
|
|
||
| # Fix workspace 11 (Cursor) - horizontal layout | ||
| echo " → Fixing workspace 11 (Cursor)..." | ||
| aerospace flatten-workspace-tree --workspace 11 2>/dev/null | ||
| aerospace layout h_tiles --workspace 11 2>/dev/null |
There was a problem hiding this comment.
Reconsider suppressing all error output.
Redirecting errors to /dev/null hides important feedback when commands fail. If workspaces don't exist, have no windows, or encounter permission issues, users won't know why the script appears to succeed but doesn't fix the layout.
🔎 Proposed fix with selective error handling
# Fix workspace A (Slack + Spark Desktop) - vertical layout
echo " → Fixing workspace A (Slack + Spark)..."
-aerospace flatten-workspace-tree --workspace A 2>/dev/null
-aerospace layout v_tiles --workspace A 2>/dev/null
+if aerospace flatten-workspace-tree --workspace A 2>&1 | grep -v "No windows found" >/dev/null; then
+ aerospace layout v_tiles --workspace A || echo "⚠️ Warning: Could not apply vertical layout to workspace A"
+else
+ echo "⚠️ Workspace A is empty or not found"
+fi
# Fix workspace 11 (Cursor) - horizontal layout
echo " → Fixing workspace 11 (Cursor)..."
-aerospace flatten-workspace-tree --workspace 11 2>/dev/null
-aerospace layout h_tiles --workspace 11 2>/dev/null
+if aerospace flatten-workspace-tree --workspace 11 2>&1 | grep -v "No windows found" >/dev/null; then
+ aerospace layout h_tiles --workspace 11 || echo "⚠️ Warning: Could not apply horizontal layout to workspace 11"
+else
+ echo "⚠️ Workspace 11 is empty or not found"
+fi🤖 Prompt for AI Agents
In script/aerospace-fix-layout around lines 51 to 59, the commands currently
redirect all stderr to /dev/null which hides failures; update the script to stop
discarding errors, instead run each aerospace command capturing its exit status
and, on non-zero exit, print a clear warning that includes the command,
workspace name, and the stderr output; if you want to suppress only known benign
messages, filter stderr for those specific patterns and allow other errors to be
shown; ensure the script continues where appropriate but returns non-zero
overall if critical commands fail.
| echo "✅ Layout restoration complete!" | ||
| echo "" | ||
| echo "Workspace A: Slack + Spark Desktop (vertical)" | ||
| echo "Workspace 11: Cursor windows (horizontal)" |
There was a problem hiding this comment.
Success message is misleading without error tracking.
The script always reports "Layout restoration complete!" even when commands fail silently. This gives false confidence that layouts were fixed.
Consider tracking which operations succeeded and providing an accurate summary, or only print success after verifying commands completed without errors.
🤖 Prompt for AI Agents
In script/aerospace-fix-layout around lines 61-64, the script always prints "✅
Layout restoration complete!" even if preceding commands fail; modify the script
to track command success and only print the success message when all operations
complete successfully (or print a summary of failures). Implement this by
capturing each relevant command's exit status (or enable safe-fail behavior),
accumulate failures in a variable or array, and at the end check if any failures
occurred — if none, print the current success message, otherwise print a clear
error summary listing failed steps and return a non-zero exit code.
|
🎉 This PR is included in version 1.22.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
概要
ディスプレイ抜き差し時のワークスペースレイアウト崩れを自動修正するスクリプトを追加しました。
変更内容
script/aerospace-fix-layoutを新規作成使用方法
使用タイミング
前提条件
テストプラン
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
New Features
✏️ Tip: You can customize this high-level summary in your review settings.