Repository navigation
✨ Betty answers questions about the hive from its live state #18593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - **Betty answers questions about the hive from its live state.** "Betty, how many open issues are there?" or "what PRs are open in the hive repo?" is answered in seconds from the same in-memory status the Overview and the dashboard chat read (open, actionable, held and blocked counts, agents and what they are doing, recent completions, open PRs), and is no longer sent to the research agents. ([#18590](https://github.com/hivecommons/hive/issues/18590)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| package dashboard | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| // Hive status for the meeting attendee (hivecommons/hive#18590 finding 9). | ||
| // "Betty, how many open issues are there?" is answered from the same | ||
| // in-memory status the Overview tiles and the dashboard chat's grounded | ||
| // answers read (s.status via chatBuildSnapshot), in-process and in | ||
| // milliseconds, instead of going to the research agents. Nothing is | ||
| // fetched and nothing is written. | ||
|
|
||
| const ( | ||
| // hiveStatusMaxListed bounds each named list (working agents, recent | ||
| // completions, open PRs) in the brief. | ||
| hiveStatusMaxListed = 5 | ||
| // hiveStatusMaxChars bounds the whole brief. | ||
| hiveStatusMaxChars = 1500 | ||
| // hiveStatusTextCap truncates one listed item's free text. | ||
| hiveStatusTextCap = 80 | ||
| ) | ||
|
|
||
| // errHiveStatusUnavailable means the dashboard has no status snapshot yet. | ||
| var errHiveStatusUnavailable = errors.New("hive status is still initializing") | ||
|
|
||
| // HiveStatusBrief is the hive's live state as a few plain sentences for | ||
| // the meeting attendee: open and actionable issues and PRs, held and | ||
| // blocked counts, items awaiting a decision, agents (working, paused, | ||
| // blocked) and what they are doing or last finished, and the newest open | ||
| // PRs. | ||
| func (s *Server) HiveStatusBrief(ctx context.Context) (string, error) { | ||
| if err := ctx.Err(); err != nil { | ||
| return "", err | ||
| } | ||
| status := s.chatStatusSnapshot() | ||
| if status == nil { | ||
| return "", errHiveStatusUnavailable | ||
| } | ||
| now := time.Now() | ||
| snap := chatBuildSnapshot(status, "", now, nil) | ||
| return hiveStatusBrief(status, snap), nil | ||
| } | ||
|
|
||
| func hiveStatusBrief(status *StatusPayload, snap chatSnapshot) string { | ||
| var b strings.Builder | ||
| t := snap.Totals | ||
| if t == nil { | ||
| t = &chatSnapshotTotals{} | ||
| } | ||
| oi := status.OpenItems | ||
| fmt.Fprintf(&b, "Open now: %d issues and %d PRs", oi.Issues, oi.PRs) | ||
| if oi.IssuesSyncing { | ||
| b.WriteString(" (issue count still syncing, at least this many)") | ||
| } | ||
| fmt.Fprintf(&b, ". Actionable: %d issues, %d PRs. Held: %d issues, %d PRs. Blocked: %d issues, %d PRs. Awaiting a decision: %d.", | ||
| oi.Buckets.Actionable.Issues, oi.Buckets.Actionable.PRs, oi.Buckets.Held.Issues, oi.Buckets.Held.PRs, | ||
| oi.Buckets.Blocked.Issues, oi.Buckets.Blocked.PRs, t.AwaitingDecision) | ||
|
|
||
| var working, blocked, done []string | ||
| for _, a := range snap.Agents { | ||
| switch { | ||
| case a.BlockedReason != "": | ||
| blocked = append(blocked, a.Name) | ||
| case a.Busy == "working": | ||
| w := a.Name | ||
| if a.Doing != "" { | ||
| w += " (" + chatTruncate(a.Doing, hiveStatusTextCap) + ")" | ||
| } | ||
| working = append(working, w) | ||
| } | ||
| if a.LastCompleted != "" { | ||
| done = append(done, a.Name+": "+chatTruncate(a.LastCompleted, hiveStatusTextCap)) | ||
| } | ||
| } | ||
| fmt.Fprintf(&b, " Agents: %d, %d paused, %d blocked.", t.Agents, t.AgentsPaused, len(blocked)) | ||
| hiveStatusList(&b, " Working on", working) | ||
| hiveStatusList(&b, " Blocked", blocked) | ||
| hiveStatusList(&b, " Recently finished", done) | ||
| var prs []string | ||
| for _, pr := range snap.PRs { | ||
| line := pr.Ref + " " + chatTruncate(pr.Title, hiveStatusTextCap) | ||
| if pr.CI != "" { | ||
| line += " (CI " + pr.CI + ")" | ||
| } | ||
| prs = append(prs, line) | ||
| } | ||
| hiveStatusList(&b, " Open PRs", prs) | ||
| if status.StaleSince != "" { | ||
| b.WriteString(" Some counts are last-good figures from " + status.StaleSince + ".") | ||
| } | ||
| return chatTruncate(b.String(), hiveStatusMaxChars) | ||
| } | ||
|
|
||
| // hiveStatusList appends "<label>: a; b; c (and N more)." when list has items. | ||
| func hiveStatusList(b *strings.Builder, label string, list []string) { | ||
| if len(list) == 0 { | ||
| return | ||
| } | ||
| more := len(list) - hiveStatusMaxListed | ||
| if more > 0 { | ||
| list = list[:hiveStatusMaxListed] | ||
| } | ||
| b.WriteString(label + ": " + strings.Join(list, "; ")) | ||
| if more > 0 { | ||
| fmt.Fprintf(b, " (and %d more)", more) | ||
| } | ||
| b.WriteString(".") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package dashboard | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| // TestHiveStatusBrief pins hivecommons/hive#18590 finding 9: the meeting | ||
| // attendee answers hive-state questions from the dashboard's in-memory | ||
| // status, the same counts the Overview shows. | ||
| func TestHiveStatusBrief(t *testing.T) { | ||
| s := &Server{} | ||
| if _, err := s.HiveStatusBrief(context.Background()); !errors.Is(err, errHiveStatusUnavailable) { | ||
| t.Fatalf("no snapshot: err = %v", err) | ||
| } | ||
| st := chatEvalStatus(time.Now()) | ||
| st.OpenItems.Buckets.Actionable = FrontendOpenItemKinds{Issues: 7, PRs: 3} | ||
| st.OpenItems.Buckets.Held = FrontendOpenItemKinds{Issues: 4, PRs: 1} | ||
| st.OpenItems.Buckets.Blocked = FrontendOpenItemKinds{Issues: 2} | ||
| st.Agents = append(st.Agents, FrontendAgent{Name: "coder", State: "running", Busy: "working", Doing: "fixing #13990"}) | ||
| s.status = st | ||
| got, err := s.HiveStatusBrief(context.Background()) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| for _, want := range []string{ | ||
| "Open now: 40 issues and 12 PRs.", | ||
| "Actionable: 7 issues, 3 PRs. Held: 4 issues, 1 PRs. Blocked: 2 issues, 0 PRs.", | ||
| "Agents: 17, 1 paused, 1 blocked.", | ||
| "Working on: coder (fixing #13990).", | ||
| "Blocked: reviewer-2.", | ||
| "Recently finished: scanner: opened PR hivecommons/hive#14001", | ||
| "Open PRs: ", | ||
| "14002 fix: other (CI failure)", | ||
| } { | ||
| if !strings.Contains(got, want) { | ||
| t.Errorf("brief lacks %q:\n%s", want, got) | ||
| } | ||
| } | ||
| if len(got) > hiveStatusMaxChars { | ||
| t.Fatalf("brief is %d bytes", len(got)) | ||
| } | ||
|
|
||
| st.StaleSince = "2026-11-16T10:00:00Z" | ||
| st.OpenItems.IssuesSyncing = true | ||
| got, _ = s.HiveStatusBrief(context.Background()) | ||
| if !strings.Contains(got, "at least this many") || !strings.Contains(got, "last-good figures from 2026-11-16T10:00:00Z") { | ||
| t.Fatalf("stale and syncing are said: %s", got) | ||
| } | ||
|
|
||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| cancel() | ||
| if _, err := s.HiveStatusBrief(ctx); err == nil { | ||
| t.Fatal("a cancelled context returns its error") | ||
| } | ||
| } | ||
|
|
||
| func TestHiveStatusListCaps(t *testing.T) { | ||
| var b strings.Builder | ||
| hiveStatusList(&b, "L", []string{"1", "2", "3", "4", "5", "6", "7"}) | ||
| if got := b.String(); got != "L: 1; 2; 3; 4; 5 (and 2 more)." { | ||
| t.Fatalf("got %q", got) | ||
| } | ||
| b.Reset() | ||
| hiveStatusList(&b, "L", nil) | ||
| if b.Len() != 0 { | ||
| t.Fatal("an empty list writes nothing") | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Advisory (low): PR titles,
a.Doinganda.LastCompletedgo to every meeting participant, including guests in external meetings, with no check on who is asking. Consider limiting the answer to counts unless the meeting is internal.