Repository navigation
Connect stdiod to multiple backend profiles - #151
Miyamura80 wants to merge 4 commits into
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
3 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/stdiod/crates/sealgate-stdiod/src/daemon_auth.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/daemon_auth.rs:29">
P2: `has_overrides` counts env-sourced values as explicit overrides. With `SEALGATE_BACKEND_URL` exported, a fatal error in the default profile makes `run()` break out and shut down every named profile, which conflicts with the per-profile isolation this PR adds. Limit the fatal-exit path to values given on the command line, or have named sessions keep running.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/paths.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/paths.rs:99">
P3: `config_dir()` creates the directory on every lookup, so read-only commands such as `status --profile <typo>` leave an empty `profiles/<typo>/` directory behind. Create the directory only in the write paths (login, keep-awake, logout save) instead.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/power/controller.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/power/controller.rs:137">
P3: This arm is now reachable whenever the last `KeepAwake` handle drops, which can happen while the daemon keeps running (a profile's `run_backend` returns and is restarted). It releases the block but does not update the status or `state.json`, so keep-awake can stay reported as active until the restart. Publish the off/released status before returning, and update the "process is ending" comment.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| } | ||
|
|
||
| impl RunArgs { | ||
| pub(crate) fn has_overrides(&self) -> bool { |
There was a problem hiding this comment.
P2: has_overrides counts env-sourced values as explicit overrides. With SEALGATE_BACKEND_URL exported, a fatal error in the default profile makes run() break out and shut down every named profile, which conflicts with the per-profile isolation this PR adds. Limit the fatal-exit path to values given on the command line, or have named sessions keep running.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/daemon_auth.rs, line 29:
<comment>`has_overrides` counts env-sourced values as explicit overrides. With `SEALGATE_BACKEND_URL` exported, a fatal error in the default profile makes `run()` break out and shut down every named profile, which conflicts with the per-profile isolation this PR adds. Limit the fatal-exit path to values given on the command line, or have named sessions keep running.</comment>
<file context>
@@ -25,6 +25,15 @@ pub struct RunArgs {
}
+impl RunArgs {
+ pub(crate) fn has_overrides(&self) -> bool {
+ self.backend.is_some()
+ || self.api_key.is_some()
</file context>
| dirs::home_dir().ok_or_else(|| anyhow!("could not resolve home dir; HOME not set?"))?; | ||
| let dir = home.join(".config").join("sealgate-stdiod"); | ||
| let mut dir = root_config_dir()?; | ||
| if let Ok(profile) = PROFILE.try_with(Clone::clone) { |
There was a problem hiding this comment.
P3: config_dir() creates the directory on every lookup, so read-only commands such as status --profile <typo> leave an empty profiles/<typo>/ directory behind. Create the directory only in the write paths (login, keep-awake, logout save) instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/paths.rs, line 99:
<comment>`config_dir()` creates the directory on every lookup, so read-only commands such as `status --profile <typo>` leave an empty `profiles/<typo>/` directory behind. Create the directory only in the write paths (login, keep-awake, logout save) instead.</comment>
<file context>
@@ -28,9 +95,10 @@ use anyhow::{anyhow, Result};
- dirs::home_dir().ok_or_else(|| anyhow!("could not resolve home dir; HOME not set?"))?;
- let dir = home.join(".config").join("sealgate-stdiod");
+ let mut dir = root_config_dir()?;
+ if let Ok(profile) = PROFILE.try_with(Clone::clone) {
+ dir = dir.join(PROFILES_DIRECTORY).join(profile);
+ }
</file context>
| read_local: Box::new(read_local), | ||
| rx, | ||
| events: handle.events.clone(), | ||
| events: Arc::downgrade(&handle.events), |
There was a problem hiding this comment.
P3: This arm is now reachable whenever the last KeepAwake handle drops, which can happen while the daemon keeps running (a profile's run_backend returns and is restarted). It releases the block but does not update the status or state.json, so keep-awake can stay reported as active until the restart. Publish the off/released status before returning, and update the "process is ending" comment.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/power/controller.rs, line 137:
<comment>This arm is now reachable whenever the last `KeepAwake` handle drops, which can happen while the daemon keeps running (a profile's `run_backend` returns and is restarted). It releases the block but does not update the status or `state.json`, so keep-awake can stay reported as active until the restart. Publish the off/released status before returning, and update the "process is ending" comment.</comment>
<file context>
@@ -120,17 +124,17 @@ impl KeepAwake {
+ read_local: Box::new(read_local),
rx,
- events: handle.events.clone(),
+ events: Arc::downgrade(&handle.events),
status,
resume: handle.resume.clone(),
</file context>
There was a problem hiding this comment.
4 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/stdiod/crates/sealgate-stdiod/src/cli/login.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/cli/login.rs:246">
P2: This message assumes a daemon is running whenever `--profile` is set. If the service is installed but stopped, the user is told it will pick up the profile automatically and is never told to start it. Consider wording that does not promise a running daemon, for example: "Profile saved. A running daemon picks it up within a few seconds; otherwise start the service with `sealgate-stdiod install` or your service manager."</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/platform/macos.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/platform/macos.rs:354">
P2: Install now accepts a broken default config when a named profile is valid. The daemon then retries the default session about once per second with a warning each time, because a parse error is returned immediately and not treated as AwaitingLogin. Either skip the default session when its config fails to load, or keep the install refusal when the default config is present but unreadable.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs:124">
P3: The new test covers only `purge_config`. Add coverage for the profile state.json removal in `uninstall` and for the `--keep-profiles` argument wiring, since neither is exercised here.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs:57">
P2: A panic in one profile's session tears down the daemon and every other backend session. Keep the other sessions running by tracking task IDs to profiles, then retire only the panicked profile.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| println!("Saved {}", path.display()); | ||
| println!("Next: `sealgate-stdiod install` to register the supervisor service."); | ||
| if paths::profile_selected() { | ||
| println!("The running daemon picks up this profile automatically. If the service is not installed, run `sealgate-stdiod install`."); |
There was a problem hiding this comment.
P2: This message assumes a daemon is running whenever --profile is set. If the service is installed but stopped, the user is told it will pick up the profile automatically and is never told to start it. Consider wording that does not promise a running daemon, for example: "Profile saved. A running daemon picks it up within a few seconds; otherwise start the service with sealgate-stdiod install or your service manager."
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/cli/login.rs, line 246:
<comment>This message assumes a daemon is running whenever `--profile` is set. If the service is installed but stopped, the user is told it will pick up the profile automatically and is never told to start it. Consider wording that does not promise a running daemon, for example: "Profile saved. A running daemon picks it up within a few seconds; otherwise start the service with `sealgate-stdiod install` or your service manager."</comment>
<file context>
@@ -242,7 +242,11 @@ fn save_login(cfg: &PersistedConfig) -> Result<()> {
println!("Saved {}", path.display());
- println!("Next: `sealgate-stdiod install` to register the supervisor service.");
+ if paths::profile_selected() {
+ println!("The running daemon picks up this profile automatically. If the service is not installed, run `sealgate-stdiod install`.");
+ } else {
+ println!("Next: `sealgate-stdiod install` to register the supervisor service.");
</file context>
| println!("The running daemon picks up this profile automatically. If the service is not installed, run `sealgate-stdiod install`."); | |
| println!("Profile saved. A running daemon picks it up within a few seconds; otherwise start the service with `sealgate-stdiod install` or your service manager."); |
| // immediately rather than discovering it in the logs later. | ||
| let cfg = crate::config::PersistedConfig::load()?; | ||
| cfg.ensure_installable()?; | ||
| crate::daemon_profiles::ensure_daemon_installable()?; |
There was a problem hiding this comment.
P2: Install now accepts a broken default config when a named profile is valid. The daemon then retries the default session about once per second with a warning each time, because a parse error is returned immediately and not treated as AwaitingLogin. Either skip the default session when its config fails to load, or keep the install refusal when the default config is present but unreadable.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/platform/macos.rs, line 354:
<comment>Install now accepts a broken default config when a named profile is valid. The daemon then retries the default session about once per second with a warning each time, because a parse error is returned immediately and not treated as AwaitingLogin. Either skip the default session when its config fails to load, or keep the install refusal when the default config is present but unreadable.</comment>
<file context>
@@ -351,8 +351,7 @@ pub fn install() -> Result<()> {
// immediately rather than discovering it in the logs later.
- let cfg = crate::config::PersistedConfig::load()?;
- cfg.ensure_installable()?;
+ crate::daemon_profiles::ensure_daemon_installable()?;
let binary = std::env::current_exe().context("could not resolve current exe path")?;
</file context>
| } | ||
| active_profiles.remove(&profile); | ||
| } | ||
| Err(error) => break Err(error.into()), |
There was a problem hiding this comment.
P2: A panic in one profile's session tears down the daemon and every other backend session. Keep the other sessions running by tracking task IDs to profiles, then retire only the panicked profile.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs, line 57:
<comment>A panic in one profile's session tears down the daemon and every other backend session. Keep the other sessions running by tracking task IDs to profiles, then retire only the panicked profile.</comment>
<file context>
@@ -0,0 +1,107 @@
+ }
+ active_profiles.remove(&profile);
+ }
+ Err(error) => break Err(error.into()),
+ },
+ }
</file context>
| use super::*; | ||
|
|
||
| #[test] | ||
| fn default_reset_preserves_named_profile_credentials() { |
There was a problem hiding this comment.
P3: The new test covers only purge_config. Add coverage for the profile state.json removal in uninstall and for the --keep-profiles argument wiring, since neither is exercised here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs, line 124:
<comment>The new test covers only `purge_config`. Add coverage for the profile state.json removal in `uninstall` and for the `--keep-profiles` argument wiring, since neither is exercised here.</comment>
<file context>
@@ -85,3 +115,27 @@ fn purge_user_data() -> Result<()> {
+ use super::*;
+
+ #[test]
+ fn default_reset_preserves_named_profile_credentials() {
+ let root =
+ std::env::temp_dir().join(format!("stdiod-profile-purge-{}", std::process::id()));
</file context>
There was a problem hiding this comment.
3 existing issues remain and 4 new issues found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/stdiod/crates/sealgate-stdiod/tests/multiple_backends.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/tests/multiple_backends.rs:102">
P2: This fixed temporary path makes the integration test fail on a stale directory after an interrupted run or PID reuse. Add a per-invocation unique suffix (or use the repository's temporary-directory helper) before creating the home.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/platform/linux.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/platform/linux.rs:136">
P3: The comment above this call still describes a default-only check. `ensure_daemon_installable` now passes when any named profile has credentials, and a daemon without default credentials waits for login rather than reconnect-looping. Update the comment to say the install requires at least one usable backend profile.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs:64">
P2: A panicking session during shutdown returns early via `result?`, so the remaining sessions are not awaited. Log the `JoinError` and keep draining the set.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs:66">
P2: This profile-state deletion races daemon shutdown on macOS. `platform::uninstall()` returns before `bootout` has finished, so a profile session can rewrite `state.json` after this call; wait for all sessions to stop before deleting state, or perform the cleanup after teardown has settled.</violation>
</file>
Requires human review: Auto-approval blocked because this review re-detected 9 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
| async fn discovers_a_second_backend_without_replacing_the_first_session() { | ||
| timeout(Duration::from_secs(15), async { | ||
| let home = | ||
| TestHome(std::env::temp_dir().join(format!("stdiod-profiles-{}", std::process::id()))); |
There was a problem hiding this comment.
P2: This fixed temporary path makes the integration test fail on a stale directory after an interrupted run or PID reuse. Add a per-invocation unique suffix (or use the repository's temporary-directory helper) before creating the home.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/tests/multiple_backends.rs, line 102:
<comment>This fixed temporary path makes the integration test fail on a stale directory after an interrupted run or PID reuse. Add a per-invocation unique suffix (or use the repository's temporary-directory helper) before creating the home.</comment>
<file context>
@@ -0,0 +1,160 @@
+async fn discovers_a_second_backend_without_replacing_the_first_session() {
+ timeout(Duration::from_secs(15), async {
+ let home =
+ TestHome(std::env::temp_dir().join(format!("stdiod-profiles-{}", std::process::id())));
+ std::fs::create_dir(&home.0).unwrap();
+ let default = TcpListener::bind("127.0.0.1:0").await.unwrap();
</file context>
| TestHome(std::env::temp_dir().join(format!("stdiod-profiles-{}", std::process::id()))); | |
| TestHome(std::env::temp_dir().join(format!( | |
| "stdiod-profiles-{}-{}", | |
| std::process::id(), | |
| std::time::SystemTime::now() | |
| .duration_since(std::time::UNIX_EPOCH) | |
| .unwrap() | |
| .as_nanos(), | |
| ))); |
|
|
||
| shutdown.send_replace(true); | ||
| while let Some(result) = sessions.join_next().await { | ||
| let (profile, result) = result?; |
There was a problem hiding this comment.
P2: A panicking session during shutdown returns early via result?, so the remaining sessions are not awaited. Log the JoinError and keep draining the set.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs, line 64:
<comment>A panicking session during shutdown returns early via `result?`, so the remaining sessions are not awaited. Log the `JoinError` and keep draining the set.</comment>
<file context>
@@ -0,0 +1,107 @@
+
+ shutdown.send_replace(true);
+ while let Some(result) = sessions.join_next().await {
+ let (profile, result) = result?;
+ if let Err(error) = result {
+ warn!(profile = profile.as_deref().unwrap_or("default"), %error, "backend session failed during shutdown");
</file context>
| let (profile, result) = result?; | |
| let Ok((profile, result)) = result else { | |
| warn!("backend session panicked during shutdown"); | |
| continue; | |
| }; |
| match paths::profile_names() { | ||
| Ok(names) => { | ||
| for name in names { | ||
| remove_state(&paths::profile_dir(&name)?.join("state.json")); |
There was a problem hiding this comment.
P2: This profile-state deletion races daemon shutdown on macOS. platform::uninstall() returns before bootout has finished, so a profile session can rewrite state.json after this call; wait for all sessions to stop before deleting state, or perform the cleanup after teardown has settled.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/cli/install.rs, line 66:
<comment>This profile-state deletion races daemon shutdown on macOS. `platform::uninstall()` returns before `bootout` has finished, so a profile session can rewrite `state.json` after this call; wait for all sessions to stop before deleting state, or perform the cleanup after teardown has settled.</comment>
<file context>
@@ -55,27 +58,54 @@ pub fn uninstall(args: UninstallArgs) -> Result<()> {
+ match paths::profile_names() {
+ Ok(names) => {
+ for name in names {
+ remove_state(&paths::profile_dir(&name)?.join("state.json"));
}
}
</file context>
| // macOS path.) | ||
| let cfg = crate::config::PersistedConfig::load()?; | ||
| cfg.ensure_installable()?; | ||
| crate::daemon_profiles::ensure_daemon_installable()?; |
There was a problem hiding this comment.
P3: The comment above this call still describes a default-only check. ensure_daemon_installable now passes when any named profile has credentials, and a daemon without default credentials waits for login rather than reconnect-looping. Update the comment to say the install requires at least one usable backend profile.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/platform/linux.rs, line 136:
<comment>The comment above this call still describes a default-only check. `ensure_daemon_installable` now passes when any named profile has credentials, and a daemon without default credentials waits for login rather than reconnect-looping. Update the comment to say the install requires at least one usable backend profile.</comment>
<file context>
@@ -133,8 +133,7 @@ pub fn install() -> Result<()> {
// macOS path.)
- let cfg = crate::config::PersistedConfig::load()?;
- cfg.ensure_installable()?;
+ crate::daemon_profiles::ensure_daemon_installable()?;
if !systemd_user_available() {
</file context>
There was a problem hiding this comment.
3 issues found across 13 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/stdiod/crates/sealgate-stdiod/src/cli/server.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/cli/server.rs:145">
P3: The new `--profile` suffix in the auto-approved hint has no test. Add a case that runs `format_create_result` inside `paths::with_profile(Some("work".into()), ...)` and asserts the output contains `status --profile work`.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/main.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/main.rs:134">
P3: This new early `bail!` returns from `main` before the exit-code file is written. The `--exit-code-file` contract says it is written on every way out, so a wizard waiting on that file would hang if it ever combined it with `--profile`. Consider routing this error through `result` so the exit-code block still runs.</violation>
</file>
<file name="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs">
<violation number="1" location="crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs:75">
P2: `run_profile` now treats every `run_backend` error as transient and retries after 10 seconds. An invalid explicit `run` override therefore leaves the foreground command hanging instead of returning its setup error; propagate setup errors for the default override session while retaining retries for discovered profiles.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| ); | ||
| paths::with_profile(profile, async { | ||
| loop { | ||
| match daemon::run_backend(args.clone(), signal.clone()).await { |
There was a problem hiding this comment.
P2: run_profile now treats every run_backend error as transient and retries after 10 seconds. An invalid explicit run override therefore leaves the foreground command hanging instead of returning its setup error; propagate setup errors for the default override session while retaining retries for discovered profiles.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/daemon_profiles.rs, line 75:
<comment>`run_profile` now treats every `run_backend` error as transient and retries after 10 seconds. An invalid explicit `run` override therefore leaves the foreground command hanging instead of returning its setup error; propagate setup errors for the default override session while retaining retries for discovered profiles.</comment>
<file context>
@@ -46,42 +48,42 @@ pub async fn run(args: RunArgs) -> Result<()> {
- (profile, result)
+ paths::with_profile(profile, async {
+ loop {
+ match daemon::run_backend(args.clone(), signal.clone()).await {
+ Ok(()) => return,
+ Err(error) => warn!(%error, "backend session stopped; will retry"),
</file context>
|
|
||
| fn format_create_result(name: &str, response: ClientCreateRequestResponse) -> String { | ||
| if response.auto_approved { | ||
| let profile_option = crate::paths::profile_name() |
There was a problem hiding this comment.
P3: The new --profile suffix in the auto-approved hint has no test. Add a case that runs format_create_result inside paths::with_profile(Some("work".into()), ...) and asserts the output contains status --profile work.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/cli/server.rs, line 145:
<comment>The new `--profile` suffix in the auto-approved hint has no test. Add a case that runs `format_create_result` inside `paths::with_profile(Some("work".into()), ...)` and asserts the output contains `status --profile work`.</comment>
<file context>
@@ -142,8 +142,11 @@ pub(crate) async fn submit(
fn format_create_result(name: &str, response: ClientCreateRequestResponse) -> String {
if response.auto_approved {
+ let profile_option = crate::paths::profile_name()
+ .map(|profile| format!(" --profile {profile}"))
+ .unwrap_or_default();
</file context>
| | Command::Server(_) => { | ||
| let config = paths::profile_dir(profile)?.join("config.toml"); | ||
| if !config.try_exists()? { | ||
| anyhow::bail!("profile '{profile}' does not exist. Run `sealgate-stdiod login --profile {profile} --backend <url>`."); |
There was a problem hiding this comment.
P3: This new early bail! returns from main before the exit-code file is written. The --exit-code-file contract says it is written on every way out, so a wizard waiting on that file would hang if it ever combined it with --profile. Consider routing this error through result so the exit-code block still runs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/stdiod/crates/sealgate-stdiod/src/main.rs, line 134:
<comment>This new early `bail!` returns from `main` before the exit-code file is written. The `--exit-code-file` contract says it is written on every way out, so a wizard waiting on that file would hang if it ever combined it with `--profile`. Consider routing this error through `result` so the exit-code block still runs.</comment>
<file context>
@@ -122,17 +122,22 @@ fn open_daemon_log() -> Option<std::fs::File> {
+ | Command::Server(_) => {
+ let config = paths::profile_dir(profile)?.join("config.toml");
+ if !config.try_exists()? {
+ anyhow::bail!("profile '{profile}' does not exist. Run `sealgate-stdiod login --profile {profile} --backend <url>`.");
+ }
+ }
</file context>
Summary
--profileto login, logout, status, server, and keep-awake commands. The running daemon discovers new profiles automatically.uninstall --purgestill removes all profiles.Verification
Summary by cubic
Connects stdiod to multiple backends from a single daemon process, with one WebSocket session per named profile.
--profiletologin,logout,status,keep-awake, andserver; commands without it still use the default sign-in.daemon_profiles) that discovers and respawns backend sessions; tunnel handling stays indaemon::run_backend, and session tasks are aborted cleanly on shutdown.resetStdiodpreserves named profiles (previously--purgewiped them); explicituninstall --purgestill removes everything, with--keep-profilesopting into preservation.Written for commit 0232af3. Summary will update on new commits.