feat(ponytail): per-session mode + status report - #87
Conversation
|
Warning Review limit reached
Next review available in: 17 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces session-scoped mode handling in the ponytail crate. ChangesSession mode and status support
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Switcher as switcher.rs
participant State as state.rs
User->>Switcher: "/ponytail session ultra"
Switcher->>State: set_session("ultra")
State-->>Switcher: Ok
User->>Switcher: "/ponytail status"
Switcher-->>User: Report
User->>State: active_scope() / active_mode()
State-->>User: "session" / "ultra"
User->>Switcher: "/ponytail"
Switcher-->>User: Report
Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/ponytail/src/state.rs (1)
20-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate session-read logic in
active_mode()andactive_scope().Both functions independently perform
std::fs::read_to_string(session_path()).ok().map(trim).filter(!empty). Extracting a shared helper would avoid drift if the read logic changes later.♻️ Suggested refactor
+fn read_session() -> Option<String> { + std::fs::read_to_string(session_path()) + .ok() + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()) +} + pub fn active_mode() -> Option<String> { - std::fs::read_to_string(session_path()) - .ok() - .map(|s| s.trim().to_string()) - .filter(|s| !s.is_empty()) - .or_else(|| { + read_session().or_else(|| { std::fs::read_to_string(flag_path()) .ok() .map(|s| s.trim().to_string()) .filter(|s| !s.is_empty()) }) } ... pub fn active_scope() -> &'static str { - if std::fs::read_to_string(session_path()).ok().map_or(false, |s| !s.trim().is_empty()) { + if read_session().is_some() { "session" } else { "global" } }Also applies to: 58-63
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ponytail/src/state.rs` around lines 20 - 30, The session-file read/trim/filter logic is duplicated between active_mode() and active_scope(), so extract the shared read helper used by both functions and have each caller reuse it instead of repeating std::fs::read_to_string(session_path()).ok().map(...).filter(...). Keep the existing behavior identical, but centralize the helper so any future change to session loading only needs to be made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/ponytail/src/state.rs`:
- Around line 12-30: The session-mode storage in session_path() is still a
single global file, so concurrent ponytail runs can overwrite each other and
clear_active() can affect unrelated sessions. Update the state helpers in
state.rs to include a session/conversation-specific identifier in the path (or
switch to a process-local store) and make active_mode()/clear_active() operate
on that scoped location instead of the shared global file.
---
Nitpick comments:
In `@crates/ponytail/src/state.rs`:
- Around line 20-30: The session-file read/trim/filter logic is duplicated
between active_mode() and active_scope(), so extract the shared read helper used
by both functions and have each caller reuse it instead of repeating
std::fs::read_to_string(session_path()).ok().map(...).filter(...). Keep the
existing behavior identical, but centralize the helper so any future change to
session loading only needs to be made in one place.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c2867a08-b8b7-47ab-9de6-2d3e0282c643
📒 Files selected for processing (3)
crates/ponytail/src/lib.rscrates/ponytail/src/state.rscrates/ponytail/src/switcher.rs
|
@coderabbitai review |
✅ Action performedReview finished.
|
- Add session-scoped mode via /ponytail session <mode> - Session mode overrides global default, resets per conversation - /ponytail status reports mode + scope (session|global) - Bare /ponytail now reports instead of defaulting to full - SwitchAction::SetSession and SwitchAction::Report variants - session_path(), set_session(), clear_session(), active_scope() - Closes ponytail PR audit ticket #74
…n-read logic - Extract read_session() shared helper for active_mode() and active_scope() - Addresses CodeRabbit nitpick on duplicated session-file read/trim/filter
- Add SetSession and Report arms to prompt_submit hook handler - Fixes non-exhaustive match compilation error
e99fea0 to
e0ebc7d
Compare
Summary by CodeRabbit