Skip to content

feat: AeroSpace レイアウト自動復元スクリプトを追加 - #199

Merged
keito4 merged 1 commit into
mainfrom
feat/aerospace-layout-fix-script
Dec 30, 2025
Merged

feat: AeroSpace レイアウト自動復元スクリプトを追加#199
keito4 merged 1 commit into
mainfrom
feat/aerospace-layout-fix-script

Conversation

@keito4

@keito4 keito4 commented Dec 30, 2025

Copy link
Copy Markdown
Owner

概要

ディスプレイ抜き差し時のワークスペースレイアウト崩れを自動修正するスクリプトを追加しました。

変更内容

  • script/aerospace-fix-layout を新規作成
    • AeroSpace設定の再読み込み
    • ワークスペースA (Slack + Spark Desktop) を vertical tiles レイアウトに修正
    • ワークスペース11 (Cursor) を horizontal tiles レイアウトに修正
  • 詳細な使用方法をスクリプトのヘッダーコメントに記載

使用方法

# フルパスで実行
/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 が設定済み

テストプラン

  • スクリプトが実行可能であることを確認
  • ディスプレイ接続/切断後にレイアウトが正しく復元されることを確認
  • エイリアスが正しく動作することを確認
  • pre-commit フックがすべてパス

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added comprehensive guidance for local GitHub Actions testing with act, including Quick Start, configuration options, common use cases, and environment variables setup.
  • New Features

    • Added a utility script to restore AeroSpace workspace layouts after display changes, with automatic configuration and layout rebuilding.

✏️ Tip: You can customize this high-level summary in your review settings.

ディスプレイ抜き差し時のワークスペースレイアウト崩れを自動修正するスクリプトを追加。

## 機能

- 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>
@coderabbitai

coderabbitai Bot commented Dec 30, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Documentation 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

Cohort / File(s) Summary
Documentation
README.md
Added comprehensive "Local GitHub Actions Testing with act" section with Quick Start, Configuration, Common Use Cases, Environment Variables, Notes, and act reference for local GitHub Actions testing guidance
Workspace Automation
script/aerospace-fix-layout
New Bash script to restore AeroSpace workspace layouts after display changes; reloads config, rebuilds Workspace A with vertical tiles (Slack + Spark Desktop) and Workspace 11 with horizontal tiles (Cursor)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A script hops through workspaces with care,
Layouts restored with each tiled repair,
Act documentation springs to life,
Smoothing the developer's workflow strife!

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding an AeroSpace layout auto-restoration script, which aligns with the primary file addition (script/aerospace-fix-layout) and the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

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

@claude

claude Bot commented Dec 30, 2025

Copy link
Copy Markdown
Contributor

PR Review: AeroSpace レイアウト自動復元スクリプト

総合評価

このPRは、ディスプレイ接続時のワークスペースレイアウト崩れを修正するユーティリティスクリプトを追加しています。全体的によく設計されており、コード品質は高いです。


✅ 良い点

  1. 優れたドキュメント

    • スクリプト内のヘッダーコメントが非常に詳細で、使用方法、前提条件、トラブルシューティングまで含まれている
    • README.mdへのactツールの追加により、ローカルGitHub Actions実行が可能になり、開発者体験が向上
    • Glossaryに適切にエントリが追加されている
  2. シェルスクリプトのベストプラクティス

    • shebangが正しく設定されている
    • 実行権限が適切に付与されている(755)
    • エラー出力のリダイレクトで冗長なエラーメッセージを抑制
  3. ユーザー体験への配慮

    • 視覚的なフィードバックでユーザーフレンドリー
    • sleep 0.5で設定リロード完了を待機
    • エイリアス設定例の提供

🔍 改善提案

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

  • ✅ Conventional Commits形式
  • ✅ PR説明文が詳細(Why/What/How)
  • ✅ ドキュメント更新(README)
  • ⚠️ テストカバレッジ70%+未達成 - 手動テストのみ
  • ⚠️ CI Quality Gates - 自動テスト未実装

Git Workflow

  • ✅ Linked Issue
  • ✅ Diff < 400行
  • ✅ ファイル数 < 25

🎯 推奨アクションアイテム

Critical (マージ前対応推奨)

  1. ハードコードされたパスを削除または汎用化

High (次回イテレーション推奨)

  1. エラーハンドリングの追加
  2. 基本的な自動テストの追加

Medium (将来的改善)

  1. 設定リロード完了の確実な待機ロジック
  2. より詳細なエラーメッセージ

📊 最終判定

LGTM with minor suggestions 👍

このPRは以下の理由でマージ可能です:

  • 明確な価値提供(ディスプレイ切替時の生産性向上)
  • 優れたドキュメント
  • 適切なコード品質

ただし、上記のCritical項目(ハードコードパス)の対応を推奨します。High以降の項目は、後続のイテレーションで対応可能です。


レビュー実施: Claude Code
基準: CLAUDE.md + Development Quality Standards

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-layout is user-specific. Consider using a generic placeholder or referencing the $REPO_PATH variable 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9b56de8 and 51408de.

📒 Files selected for processing (2)
  • README.md
  • script/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.

Comment thread README.md
Comment on lines +428 to +494
#### 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/).

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

🧩 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
fi

Repository: 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 -30

Repository: 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.

Comment on lines +44 to +49
# Reload configuration
echo " → Reloading config..."
aerospace reload-config

# Wait a moment for reload to complete
sleep 0.5

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 | 🟠 Major

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.

Suggested change
# 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.

Comment on lines +51 to +59
# 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

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 | 🟠 Major

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.

Comment on lines +61 to +64
echo "✅ Layout restoration complete!"
echo ""
echo "Workspace A: Slack + Spark Desktop (vertical)"
echo "Workspace 11: Cursor windows (horizontal)"

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

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.

@keito4
keito4 merged commit b6f677c into main Dec 30, 2025
9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.22.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Dec 30, 2025
@keito4
keito4 deleted the feat/aerospace-layout-fix-script branch January 29, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant