Skip to content

SessionStart: surface pending item queue automatically instead of requiring /handoff inbox - #194

Merged
getappz merged 3 commits into
masterfrom
task/47
Jul 15, 2026
Merged

SessionStart: surface pending item queue automatically instead of requiring /handoff inbox#194
getappz merged 3 commits into
masterfrom
task/47

Conversation

@getappz

@getappz getappz commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Auto-opened on item done for 019f5fa8-3c1f-7432-b8e7-edc6a41e0fa3.

Summary by CodeRabbit

  • New Features

    • Session start messages now show a “Pending items assigned to you” section when backend data is available.
    • The section includes up to 10 pending items for the current agent (ordered by sort order), formatted with sequence ID and name, plus an ellipsis if more items exist.
    • Items that are completed, cancelled, or deleted (and items assigned to other agents) are excluded.
  • Tests

    • Added a unit test confirming the session-start output includes only items assigned to the current agent and the pending-items section header.

SessionStart hook now queries backend DB for items assigned to the
current agent that are still open (excludes completed/cancelled via
state group check). Pending items listed as:

  Pending items assigned to you (claude-code, 3 open):
    #42 Review PR #193
    #47 MCP prompt argument completion

Adds agentflare-backend::item::list_by_assignee_agent(conn, project_id, agent)
with a JOIN on states to filter out completed/cancelled state groups.
Graceful no-op when backend.db doesn't exist yet (first run).
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b48544aa-8216-458e-ad33-d5fded2202a6

📥 Commits

Reviewing files that changed from the base of the PR and between 267529b and a422429.

📒 Files selected for processing (3)
  • crates/agentflare-backend/src/item.rs
  • src/hook.rs
  • src/mcp_server.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/mcp_server.rs
  • crates/agentflare-backend/src/item.rs
  • src/hook.rs

📝 Walkthrough

Walkthrough

Changes

Pending assigned items

Layer / File(s) Summary
Backend assignee query
crates/agentflare-backend/src/item.rs
Adds an exported query for ordered, non-deleted items assigned to an agent while excluding completed and cancelled states.
Session-start integration and validation
src/hook.rs, src/mcp_server.rs
Reads the backend database during session start, resolves the project, displays matching pending items, and tests exclusion of items assigned to another agent.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SessionStart
  participant BackendDB
  participant ProjectResolver
  participant ItemQuery
  SessionStart->>BackendDB: Open backend.db
  SessionStart->>ProjectResolver: Resolve project
  SessionStart->>ItemQuery: Query items for current agent
  ItemQuery-->>SessionStart: Return pending items
  SessionStart-->>SessionStart: Append pending items section
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too brief and does not follow the required template sections for Summary, Test plan, or Notes for reviewers. Expand the PR description to fill in the template sections: Summary, Test plan, and Notes for reviewers, including risk areas and backward compatibility.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: automatically surfacing pending items at SessionStart.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/47

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

@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)
src/hook.rs (1)

88-97: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider capping the pending-item list.

Unbounded iteration over items could produce a very long session-start message for agents with many open items.

♻️ Example cap
                         for item in &items {
-                            lines.push(format!("  #{} {}", item.sequence_id, item.name));
+                            for item in items.iter().take(10) {
+                                lines.push(format!("  #{} {}", item.sequence_id, item.name));
+                            }
+                            if items.len() > 10 {
+                                lines.push(format!("  ... and {} more", items.len() - 10));
+                            }
                         }
🤖 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 `@src/hook.rs` around lines 88 - 97, Cap the pending-item output in the hook’s
items iteration so session-start messages remain bounded for agents with many
open items. Update the loop over items to emit only the configured maximum
number, while preserving the existing header and formatting for the displayed
entries.
🤖 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 `@src/hook.rs`:
- Around line 73-102: Replace the arbitrary project query in the pending-item
lookup with resolution of the active project from the current workspace/cwd. Use
that resolved project ID when calling list_by_assignee_agent, preserving the
existing filtering and display behavior for pending items.

---

Nitpick comments:
In `@src/hook.rs`:
- Around line 88-97: Cap the pending-item output in the hook’s items iteration
so session-start messages remain bounded for agents with many open items. Update
the loop over items to emit only the configured maximum number, while preserving
the existing header and formatting for the displayed entries.
🪄 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: 0689b111-22ed-47fd-9024-053a983bdc28

📥 Commits

Reviewing files that changed from the base of the PR and between 2690262 and 1c47656.

📒 Files selected for processing (2)
  • crates/agentflare-backend/src/item.rs
  • src/hook.rs

Comment thread src/hook.rs
getappz added 2 commits July 15, 2026 15:47
- SessionStart's pending-item lookup used
  "SELECT id FROM projects WHERE deleted_at IS NULL ORDER BY created_at
  LIMIT 1" -- backend.db is a single shared database across every repo
  agentflare has ever touched on this machine, so with more than one
  project this picked an arbitrary (oldest) one instead of the current
  repo's, surfacing the wrong agent's pending items. Now reuses
  AgentflareMcp::resolve_project (made pub(crate)), the same repo-linked
  resolution every other item/artifact/comment call already goes
  through.
- Cap the displayed pending-item list at 10 with a "+N more" note so an
  agent with a large open queue doesn't blow up the session-start
  message.
- Fix clippy (collapsible_if via let-chains) and fmt.
- Update the regression test to route project setup through the same
  resolve_project() call session_start_message uses internally, so it
  proves the actual fix instead of a lookup path that no longer matches
  production.
@getappz
getappz merged commit be22ffc into master Jul 15, 2026
14 checks passed
@getappz
getappz deleted the task/47 branch July 15, 2026 10:46
getappz pushed a commit that referenced this pull request Aug 27, 2026
…ntic warnings in an unrelated crate. Both crates compile, clippy is clean on the changed files, and all tests pass.

Implemented the dependency-cascade auto-dispatch mechanism per the spec:

1. **`crates/agentflare-backend/src/item/relations.rs`**: added `dependents_of(conn, item_id)` (reverse of `list_dependencies`) and `all_dependencies_completed(conn, item_id)` (true only when the item has ≥1 dependency and every one is in the `completed` state group; a soft-deleted dependency target counts as unsatisfied, fail-closed).
2. **`src/supervisor.rs`**: added `cascade_unblock_dependents(conn, item_id)` — for each dependent of `item_id` whose dependencies are now all completed, applies `READY_LABEL` via the existing `item::add_label` (idempotent `INSERT OR IGNORE`). Dependents with no `assignee_agent` are skipped with a loud `eprintln!` rather than silently no-op'd, per option (a) in the spec.
3. **`src/mcp_server/item.rs`**: `item_check_merge` now calls `cascade_unblock_dependents` right after `promoted` becomes true — this is the single hook point that catches both the automatic tick (`promote_merged_item`) and manual/reconciliation calls.

**Tests** (8 new, all passing):
- Backend: `dependents_of_finds_reverse_edges`, `all_dependencies_completed_requires_every_dependency_done`, `all_dependencies_completed_false_for_item_with_no_dependencies`.
- Supervisor: labels a dependent once its only dependency completes; leaves a dependent alone with a still-open sibling dependency; skips (doesn't label) an unassigned dependent; idempotent across repeated calls.

Ran `cargo test -p agentflare-backend` and `cargo test --bin agentflare -- supervisor:: item_check_merge` — all pass, no regressions in the 37 pre-existing supervisor tests. Clippy clean on both touched crates.

**Concerns / judgment calls:**
- Went with option (a) (require pre-existing `assignee_agent`, loud log) as recommended — unassigned dependents like #193/#194 won't auto-dispatch from this alone.
- Followed the spec literally on "completed" only (not "completed or cancelled") for the all-deps-done check, even though `groom`'s existing `blocked_by_map` treats cancelled dependencies as non-blocking too. This means a dependent stuck behind a *cancelled* dependency won't be auto-unblocked by this cascade — flagging this divergence in case it's not what's wanted.
- Didn't add a full `item_check_merge` end-to-end integration test (would require mocking a merged PR via git/worktree state) — coverage is at the `cascade_unblock_dependents` unit level instead, which matches the spec's test list.

Agentflare-Agent: claude-code_2-1-245_agent
Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking
Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking
getappz added a commit that referenced this pull request Aug 27, 2026
…cy-graph-driven dynamic workflows) (#621)

* Clean — no warnings from `agentflare-backend`, only pre-existing pedantic warnings in an unrelated crate. Both crates compile, clippy is clean on the changed files, and all tests pass.

Implemented the dependency-cascade auto-dispatch mechanism per the spec:

1. **`crates/agentflare-backend/src/item/relations.rs`**: added `dependents_of(conn, item_id)` (reverse of `list_dependencies`) and `all_dependencies_completed(conn, item_id)` (true only when the item has ≥1 dependency and every one is in the `completed` state group; a soft-deleted dependency target counts as unsatisfied, fail-closed).
2. **`src/supervisor.rs`**: added `cascade_unblock_dependents(conn, item_id)` — for each dependent of `item_id` whose dependencies are now all completed, applies `READY_LABEL` via the existing `item::add_label` (idempotent `INSERT OR IGNORE`). Dependents with no `assignee_agent` are skipped with a loud `eprintln!` rather than silently no-op'd, per option (a) in the spec.
3. **`src/mcp_server/item.rs`**: `item_check_merge` now calls `cascade_unblock_dependents` right after `promoted` becomes true — this is the single hook point that catches both the automatic tick (`promote_merged_item`) and manual/reconciliation calls.

**Tests** (8 new, all passing):
- Backend: `dependents_of_finds_reverse_edges`, `all_dependencies_completed_requires_every_dependency_done`, `all_dependencies_completed_false_for_item_with_no_dependencies`.
- Supervisor: labels a dependent once its only dependency completes; leaves a dependent alone with a still-open sibling dependency; skips (doesn't label) an unassigned dependent; idempotent across repeated calls.

Ran `cargo test -p agentflare-backend` and `cargo test --bin agentflare -- supervisor:: item_check_merge` — all pass, no regressions in the 37 pre-existing supervisor tests. Clippy clean on both touched crates.

**Concerns / judgment calls:**
- Went with option (a) (require pre-existing `assignee_agent`, loud log) as recommended — unassigned dependents like #193/#194 won't auto-dispatch from this alone.
- Followed the spec literally on "completed" only (not "completed or cancelled") for the all-deps-done check, even though `groom`'s existing `blocked_by_map` treats cancelled dependencies as non-blocking too. This means a dependent stuck behind a *cancelled* dependency won't be auto-unblocked by this cascade — flagging this divergence in case it's not what's wanted.
- Didn't add a full `item_check_merge` end-to-end integration test (would require mocking a merged PR via git/worktree state) — coverage is at the `cascade_unblock_dependents` unit level instead, which matches the spec's test list.

Agentflare-Agent: claude-code_2-1-245_agent
Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking
Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking

* cascade_unblock_dependents now inherits completed item's assignee (bare agent id) for unassigned dependents; added regression test; pre-existing unrelated test failure confirmed via baseline stash and flagged, not touched.

Agentflare-Agent: claude-code_2-1-245_agent
Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking
Agentflare-Item: 195-auto-dispatch-dependents-when-a-blocking

* style: cargo fmt cascade_unblock_dependents, allowlist supervisor_tests.rs LOC gate

Agentflare-Agent: claude-code
Agentflare-Branch: task/195-auto-dispatch-dependents-when-a-blocking
Agentflare-Item: 195
Agentflare-Session: 3eedea22-3a44-4342-963d-d211427f1fea

---------

Co-authored-by: shiva <shiva@gosysinfo.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant