Skip to content

feat(ponytail): per-session mode + status report - #87

Merged
getappz merged 3 commits into
masterfrom
feat/session-mode
Jul 7, 2026
Merged

feat(ponytail): per-session mode + status report#87
getappz merged 3 commits into
masterfrom
feat/session-mode

Conversation

@getappz

@getappz getappz commented Jul 7, 2026

Copy link
Copy Markdown
Owner
  • Add session-scoped mode via /ponytail session
  • 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 [ponytail#229] Per-session mode: /ponytail-session vs global default #74

Summary by CodeRabbit

  • New Features
    • Added session-aware mode handling with session vs global precedence.
    • Added commands to report current state and to set a mode for the current session.
  • Bug Fixes
    • The bare command now reports status instead of defaulting to a mode change.
    • Clearing active state now also clears any session-specific value, restoring fallback behavior.
  • Tests
    • Updated coverage for session precedence, scope reporting, and new command parsing behaviors.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@getappz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 22ac9f78-8b96-42ec-8f14-b5bda242058c

📥 Commits

Reviewing files that changed from the base of the PR and between 866dd16 and e99fea0.

📒 Files selected for processing (2)
  • crates/ponytail/src/state.rs
  • src/cli/ponytail.rs
📝 Walkthrough

Walkthrough

This PR introduces session-scoped mode handling in the ponytail crate. state.rs adds session file read/write/clear functions and a scope reporter, switcher.rs adds SetSession and Report action variants with new subcommand parsing, and lib.rs re-exports the new state functions.

Changes

Session mode and status support

Layer / File(s) Summary
Session state storage and scope reporting
crates/ponytail/src/state.rs, crates/ponytail/src/lib.rs
Adds session_path(), set_session(), clear_session(); updates active_mode() to prefer session value over global, clear_active() to clear both, adds active_scope(); expands tests; re-exports new functions from lib.rs.
Switcher command parsing for session/status/report
crates/ponytail/src/switcher.rs
Adds SetSession(String) and Report variants to SwitchAction; detect() now returns Report for bare command and status, and SetSession for session <mode>; adds corresponding tests.

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
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lists key changes, but it omits the required Summary, Test plan, and Notes for reviewers sections from the template. Add the missing template sections with a short summary, test commands or results, and reviewer notes on risks and backward compatibility.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the new per-session mode and status reporting changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/session-mode

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

@getappz

getappz commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

🧹 Nitpick comments (1)
crates/ponytail/src/state.rs (1)

20-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate session-read logic in active_mode() and active_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

📥 Commits

Reviewing files that changed from the base of the PR and between 05263fa and 866dd16.

📒 Files selected for processing (3)
  • crates/ponytail/src/lib.rs
  • crates/ponytail/src/state.rs
  • crates/ponytail/src/switcher.rs

Comment thread crates/ponytail/src/state.rs Outdated
@getappz

getappz commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

getappz added 3 commits July 8, 2026 00:12
- 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
@getappz
getappz force-pushed the feat/session-mode branch from e99fea0 to e0ebc7d Compare July 7, 2026 18:43
@getappz
getappz merged commit a5b5107 into master Jul 7, 2026
6 of 7 checks passed
@getappz
getappz deleted the feat/session-mode branch July 7, 2026 18:43
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant