fix(cosh-ng): forward shell cwd to registry mode - #2686
Conversation
registry_query_short spawns a one-shot cosh-core --registry process without forwarding --workspace, causing workspace_root() to fall back to the cosh-shell process cwd. When the process cwd differs from the user's shell cwd (e.g. daemon-style startup or cd after launch), project-level skills under <workspace>/.copilot-shell/skills/ are not discovered. Add a shell_cwd field to CoshCoreAdapter, set by render_slash_command from the OSC 1337 shell cwd. registry_query_short forwards it as --workspace so the registry-mode cosh-core resolves the same project root as the headless runtime. Falls back to active_workspace_scope() when shell cwd is unavailable. Only affects the registry_query_short path; live_registry_query (IPC) and headless prepare_invocation are unaffected. Assisted-by: Qoder:1.22.0 Signed-off-by: Kailong Zhou <zhoukailong.zkl@alibaba-inc.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 72be99f977
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // resolves the same project root as the headless runtime. Falls | ||
| // back to the active session's workspace scope when the shell | ||
| // cwd is unavailable (e.g. programmatic callers without a PTY). | ||
| let workspace = self |
There was a problem hiding this comment.
Add the mandatory Fixes attribution
This standalone fix is based on a commit already contained in main, but its commit body has no Fixes: <hash> ("<subject>") entry. Add the commit that introduced the incorrect registry workspace behavior so the fix complies with the repository's required history attribution.
AGENTS.md reference: AGENTS.md:L378-L384
Useful? React with 👍 / 👎.
| /// Shell cwd tracked from the PTY host so that short-lived `--registry` | ||
| /// processes resolve the same project root as the headless runtime. | ||
| pub(crate) shell_cwd: Arc<Mutex<Option<String>>>, |
There was a problem hiding this comment.
Include the cosh-shell crate scope in the subject
The subject fix(cosh-ng): forward shell cwd to registry mode omits the mandatory crate scope for a change confined to cosh-shell. Rewrite it with [shell] while keeping the complete subject under 50 characters so it follows the component's commit format.
AGENTS.md reference: src/cosh-ng/AGENTS.md:L132-L139
Useful? React with 👍 / 👎.
|
PR number: #2686 评审结论Findings未发现 blocking package/module/public API 组织问题。
结构合规检查(对照 code organization 规则)
Open Questions
Validation
剩余风险: |
Why
When cosh-core is not yet running in headless mode, slash commands such as
/skills listfall back toregistry_query_short, which spawns a one-shotcosh-core --registryprocess. Previously this path did not pass--workspace, so cosh-core fell back to the cosh-shell process cwd. When the process cwd differs from the user's shell cwd (e.g. daemon-style startup orcdafter launch), project-level skills under<workspace>/.copilot-shell/skills/were not discovered.What changed
shell_cwdfield toCoshCoreAdapterto track the latest shell working directory reported by OSC 1337.render_slash_commandto synchronizeshell_cwdbefore dispatching any slash command.registry_query_shortto forwardshell_cwdas--workspaceto the registry-mode cosh-core process, falling back to the active session's workspace scope when unavailable.Related issue
no-issue: internal bug report
User / Agent impact
/skills list,/hooks,/extensionsand other slash registry queries now correctly discover project-level resources even when no Agent turn has been run yet.Risk and compatibility
Low risk. The change only affects the
registry_query_shortfallback path. The live IPC registry path and the headlessprepare_invocationpath are unchanged.Validation
cargo check --workspacecargo fmt --all -- --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace(888 passed, 1 pre-existing macOS-specific failure unrelated)cargo test -p cosh-shell(5 pre-existing macOS hook environment failures unrelated)Documentation and rollback
No documentation changes. Rollback: revert commit
72be99f97or checkout the previous main state.