fix: ホーム/ルートでセッションが無くてもshpoolを起動できるようにする#3
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughこのPRは、カレントディレクトリ由来のセッション名が空になる場合(ホームディレクトリやファイルシステムルートなど)にフォールバック名を導出する Changesセッション名フォールバック
Sequence DiagramsequenceDiagram
participant CLI as shp (main)
participant Session as internal/session
participant OS as os
participant TUI as tui.SelectWithDefault
participant Shpool as shpool.Attach
CLI->>Session: FromCwdOrFallback()
Session->>Session: FromCwd()
alt FromCwd returns empty
Session->>OS: os.Getwd()
OS-->>Session: cwd path
Session->>Session: FromPath(cwd, "")
alt FromPath empty
Session-->>Session: return "shell"
else FromPath non-empty
Session-->>Session: return fallback name
end
else FromCwd returns name
Session-->>CLI: return cwd-derived name
end
CLI->>TUI: SelectWithDefault(defaultName)
TUI->>Shpool: Attach(selectedName)
Shpool-->>CLI: attached / exit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 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 |
レビュー指摘(Codex)対応: - FromCwdOrFallback() を追加し、picker/-f/--print-name を共通化 - ホーム/ルートで -f がエラー・--print-name が空になる不一致を解消 - DEV.md を新挙動に合わせて更新 - ホームでの実トリガ(FromCwd()=="")を直接押さえるテストを追加
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
ホームディレクトリ
~(およびルート/)でセッションが1つも無いとき、shpが次のように起動できず行き止まりになっていた。プロジェクトディレクトリではセッションが無くても1件ピッカーから attach/create できるのに、ホーム/ルートだけ何もせず終了していた。
session.FromCwd()がホーム自身・ルートでは意図的に空文字を返すため、cwdName == "" && len(sessions) == 0の分岐に落ちていたのが原因。変更
internal/session/name.go:FallbackName()を追加。フルパス由来(home プレフィックスを剥がさない)で名前を生成するため~(/home/developer) はhome.developerになる。FromPathを再利用し命名ルール(ハッシュ付与等)も一貫。フルパスでも空になるルート/のみ"shell"に固定フォールバック。cmd/shp/main.go: 「No shpool sessions found.」で終了していたブロックを、FallbackName()でcwdNameを埋める処理に置き換え。既存セッションがある場合は従来どおりリスト表示。internal/session/name_test.go: フルパス由来になること・ルートでshellになることのテストを追加。挙動
~home.developerを作成/attach~/shellを作成/attach行き止まりを消すため、フォールバック名での1件ピッカー(Enterで起動)とした。これはプロジェクトディレクトリでセッションが無いときの既存挙動と一貫させたもの。
テスト
go build ./.../go test ./.../go vet ./...すべてパス。Summary by CodeRabbit
Bug Fixes
Documentation
Tests