Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-15813-tracker-toast-soak-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The Activity Monitor's ⚙ settings gain a "Toasts & timing" section: info and error toast durations (`dashboard.stage_tracker.toast_info_s` / `toast_error_s`, 3–120 s, saved per hive through `PUT /api/config/dashboard` and served in the `/api/stage-tracker` payload, with a localStorage fallback only when the write is refused) and the contributor lane's pre-merge soak (`auto_merge.contributor_lane.soak_minutes`), live without a restart ([#15813](https://github.com/hivecommons/hive/issues/15813)).
13 changes: 12 additions & 1 deletion dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -32160,7 +32160,7 @@
"System"
],
"summary": "Update dashboard settings",
"description": "Owner-only update for dashboard.port, dashboard.agent_poll_interval_s, dashboard.strategy_lab, dashboard.auth_token, dashboard.authorized_users, dashboard.authorized_user_names, dashboard.hub_proxied, and dashboard.issue_bands.",
"description": "Owner-only update for dashboard.port, dashboard.agent_poll_interval_s, dashboard.strategy_lab, dashboard.auth_token, dashboard.authorized_users, dashboard.authorized_user_names, dashboard.hub_proxied, dashboard.issue_bands, and dashboard.stage_tracker (toast_info_s / toast_error_s, 3-120 seconds, 0 resets the default).",
"requestBody": {
"required": true,
"content": {
Expand Down Expand Up @@ -32197,6 +32197,17 @@
},
"issue_bands": {
"type": "object"
},
"stage_tracker": {
"type": "object",
"properties": {
"toast_info_s": {
"type": "integer"
},
"toast_error_s": {
"type": "integer"
}
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,10 @@ A PR merges through this tier only when all of the following hold:
the soak. The skip reason is the stable `contributor-lane:soaking`; the
soak head, start and window are recorded once on the stage record, so the
stage tracker computes "N left" from that deadline at request time instead
of the hive re-stamping its note every pass.
of the hive re-stamping its note every pass. The window is also editable
from the Activity Monitor's ⚙ → Toasts & timing ("Pre-merge soak"), which
writes `soak_minutes` through `PUT /api/config/auto-merge`; the lane reads
the knob on every pass, so a running soak follows the new window.

Merges squash through the same effect-claimed `MergePR` path as the other tiers,
log `automerge merged tier=contributor-lane admitted_by=<path>`, record the
Expand Down
4 changes: 3 additions & 1 deletion src/docs/operator-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ advanced into the merge path.
| `auto_merge.trusted_authors.require_github_permission` | `true` | Also require GitHub to report author write access; API errors fail closed. Fork PRs still need this check even if the setting is false. |
| `auto_merge.trusted_authors.exclude_labels` | `hold`, `do-not-merge`, `needs-human` | Labels that keep a PR out of trusted-author auto-merge. |
| `auto_merge.contributor_lane.enabled` | `true` | Enables the contributor-lane tier: Hive merges a green, soaked, reviewer-approved PR whose author holds a `require_tiers` tier in the contributor registry (`registry_tiers_sufficient`), or whose linked issue carries this hive's App-authored `hive:claim kind=contributor` marker naming the PR author with a `tier=` in `require_tiers` and `verified=true`. Grants unattended merge only to contributors an operator granted such a tier and whose GitHub login was proven; set `false` to make every contributor PR wait for a human `/lgtm` + `/approve`. See [hive-merge.md](hive-merge.md#contributor-lane-auto-merge). |
| `auto_merge.contributor_lane.soak_minutes` | `30` | How long the current head must stay green before the tier merges it; a new push restarts the soak. `0`/unset means the default (30); the shortest real soak is `1`. |
| `auto_merge.contributor_lane.soak_minutes` | `30` | How long the current head must stay green before the tier merges it; a new push restarts the soak. `0`/unset means the default (30); the shortest real soak is `1`. Also editable from the Activity Monitor's ⚙ → Toasts & timing ("Pre-merge soak"), which writes through `PUT /api/config/auto-merge`; the lane re-reads it on every pass, so a running soak follows the new window. |
| `auto_merge.contributor_lane.require_reviewer_verdict` | `true` | Require an approving aggregate reviewer verdict for the current head. Independently of this key, a hive with no reviewer agent never merges through the tier (`contributor-lane:no-reviewer`). |
| `auto_merge.contributor_lane.require_tiers` | `trusted`, `merger` | Contributor trust tiers whose verified claims the tier may merge. Only operator-granted tiers (`trusted`, `merger`, `advisor`) are accepted; `newcomer` and `contributor` are rejected at validation. |
| `auto_merge.contributor_lane.registry_tiers_sufficient` | `true` | Admit a PR whose author's contributor-registry profile carries a `require_tiers` tier without a linked issue or `hive:claim` marker (logged as `contributor-lane:registry-trusted`). All other gates still apply. `false` requires the claim marker for every contributor. |
Expand Down Expand Up @@ -2016,6 +2016,8 @@ dashboard:
webhook_refresh_replay_window_s: 1800 # re-apply re-reads to snapshots published meanwhile
closed_sweep_interval_s: 300 # list items closed since the last look and evict rows still shown; -1 disables
waiting_push_stale_h: 4 # hours without a push on a CI / Review row before the pill's age turns muted-amber
toast_info_s: 15 # how long the tracker's result / waiting-on-you toasts stay (3-120 s); the merge banner stays twice as long
toast_error_s: 30 # how long a failed row action's toast stays (3-120 s); editable from the Activity Monitor's ⚙ → Toasts & timing
```

## `HIVE_GITHUB_TOKEN` permissions
Expand Down
45 changes: 45 additions & 0 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4966,6 +4966,51 @@ type DashboardStageTrackerConfig struct {
// age takes the muted-stale tone (hivecommons/hive#15784). 0 means the
// default (4); a negative value never marks the wait stale.
WaitingPushStaleH int `yaml:"waiting_push_stale_h,omitempty" json:"waiting_push_stale_h,omitempty"`
// ToastInfoS is how many seconds the activity monitor's informational
// toasts (action results, waiting-on-human nudges, the merge banner)
// stay up before dismissing themselves (hivecommons/hive#15813).
// 0 means the default (15); values are clamped to 3..120.
ToastInfoS int `yaml:"toast_info_s,omitempty" json:"toast_info_s,omitempty"`
// ToastErrorS is the same for error toasts. 0 means the default (30);
// values are clamped to 3..120.
ToastErrorS int `yaml:"toast_error_s,omitempty" json:"toast_error_s,omitempty"`
}

// Defaults and bounds for dashboard.stage_tracker.toast_info_s and
// toast_error_s. The bounds are shared with the settings modal's number
// fields and the PUT validation so every path agrees on what is legal.
const (
DefaultStageTrackerToastInfoS = 15
DefaultStageTrackerToastErrorS = 30
MinStageTrackerToastS = 3
MaxStageTrackerToastS = 120
)

// stageTrackerToastSeconds applies the shared default/clamp rule for a
// toast duration knob.
func stageTrackerToastSeconds(configured, def int) int {
if configured == 0 {
return def
}
return min(max(configured, MinStageTrackerToastS), MaxStageTrackerToastS)
}

// StageTrackerToastInfo is the effective dashboard.stage_tracker.toast_info_s
// as a duration.
func (c *Config) StageTrackerToastInfo() time.Duration {
if c == nil {
return DefaultStageTrackerToastInfoS * time.Second
}
return time.Duration(stageTrackerToastSeconds(c.Dashboard.StageTracker.ToastInfoS, DefaultStageTrackerToastInfoS)) * time.Second
}

// StageTrackerToastError is the effective
// dashboard.stage_tracker.toast_error_s as a duration.
func (c *Config) StageTrackerToastError() time.Duration {
if c == nil {
return DefaultStageTrackerToastErrorS * time.Second
}
return time.Duration(stageTrackerToastSeconds(c.Dashboard.StageTracker.ToastErrorS, DefaultStageTrackerToastErrorS)) * time.Second
}

// defaultStageTrackerWaitingPushStale is the default
Expand Down
55 changes: 55 additions & 0 deletions src/pkg/config/stage_tracker_toast_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package config

import (
"testing"
"time"

"gopkg.in/yaml.v3"
)

// Toast duration knobs (hivecommons/hive#15813): defaults when unset or nil,
// clamped to [MinStageTrackerToastS, MaxStageTrackerToastS] otherwise.
func TestStageTrackerToastAccessors(t *testing.T) {
var nilCfg *Config
if got := nilCfg.StageTrackerToastInfo(); got != DefaultStageTrackerToastInfoS*time.Second {
t.Fatalf("nil info = %v", got)
}
if got := nilCfg.StageTrackerToastError(); got != DefaultStageTrackerToastErrorS*time.Second {
t.Fatalf("nil error = %v", got)
}

cases := []struct {
name string
info, errS int
wantInfo, wantE time.Duration
}{
{"unset", 0, 0, 15 * time.Second, 30 * time.Second},
{"configured", 20, 45, 20 * time.Second, 45 * time.Second},
{"clamped low", 1, -7, 3 * time.Second, 3 * time.Second},
{"clamped high", 500, 121, 120 * time.Second, 120 * time.Second},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var c Config
c.Dashboard.StageTracker.ToastInfoS = tc.info
c.Dashboard.StageTracker.ToastErrorS = tc.errS
if got := c.StageTrackerToastInfo(); got != tc.wantInfo {
t.Errorf("info = %v, want %v", got, tc.wantInfo)
}
if got := c.StageTrackerToastError(); got != tc.wantE {
t.Errorf("error = %v, want %v", got, tc.wantE)
}
})
}
}

func TestStageTrackerToastYAMLKeys(t *testing.T) {
var c Config
src := "dashboard:\n stage_tracker:\n toast_info_s: 9\n toast_error_s: 60\n"
if err := yaml.Unmarshal([]byte(src), &c); err != nil {
t.Fatal(err)
}
if c.StageTrackerToastInfo() != 9*time.Second || c.StageTrackerToastError() != 60*time.Second {
t.Fatalf("yaml keys not wired: info=%v error=%v", c.StageTrackerToastInfo(), c.StageTrackerToastError())
}
}
51 changes: 33 additions & 18 deletions src/pkg/dashboard/api_dashboard_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ package dashboard
import (
"net/http"
"strings"
"time"

"github.com/hivecommons/hive/pkg/config"
)

type dashboardSettingsPayload struct {
Port int `json:"port"`
AgentPollIntervalS int `json:"agent_poll_interval_s"`
ExperimentLab bool `json:"experiment_lab"`
StrategyLab bool `json:"strategy_lab"`
AuthTokenConfigured bool `json:"auth_token_configured"`
AuthorizedUsers []string `json:"authorized_users"`
AuthorizedUserNames map[string]string `json:"authorized_user_names"`
HubProxied bool `json:"hub_proxied"`
IssueBands dashboardIssueBandsPayload `json:"issue_bands"`
Port int `json:"port"`
AgentPollIntervalS int `json:"agent_poll_interval_s"`
ExperimentLab bool `json:"experiment_lab"`
StrategyLab bool `json:"strategy_lab"`
AuthTokenConfigured bool `json:"auth_token_configured"`
AuthorizedUsers []string `json:"authorized_users"`
AuthorizedUserNames map[string]string `json:"authorized_user_names"`
HubProxied bool `json:"hub_proxied"`
IssueBands dashboardIssueBandsPayload `json:"issue_bands"`
StageTracker dashboardStageTrackerPayload `json:"stage_tracker"`
}

type dashboardIssueBandsPayload struct {
Expand All @@ -34,6 +36,8 @@ func dashboardSettingsResponse(cfg *config.Config) dashboardSettingsPayload {
for k, v := range d.AuthorizedUserNames {
names[k] = v
}
toastInfo := int(cfg.StageTrackerToastInfo() / time.Second)
toastError := int(cfg.StageTrackerToastError() / time.Second)
return dashboardSettingsPayload{
Port: d.Port,
AgentPollIntervalS: d.AgentPollIntervalS,
Expand All @@ -48,6 +52,7 @@ func dashboardSettingsResponse(cfg *config.Config) dashboardSettingsPayload {
DoneLabels: append([]string{}, d.IssueBands.DoneLabels...),
StaleDays: d.IssueBands.StaleDays,
},
StageTracker: dashboardStageTrackerPayload{ToastInfoS: &toastInfo, ToastErrorS: &toastError},
}
}

Expand All @@ -63,15 +68,16 @@ func (s *Server) handleDashboardSettingsPut(w http.ResponseWriter, r *http.Reque
return
}
var body struct {
Port *int `json:"port"`
AgentPollIntervalS *int `json:"agent_poll_interval_s"`
ExperimentLab *bool `json:"experiment_lab"`
StrategyLab *bool `json:"strategy_lab"`
AuthToken *string `json:"auth_token"`
AuthorizedUsers []string `json:"authorized_users"`
AuthorizedUserNames map[string]string `json:"authorized_user_names"`
HubProxied *bool `json:"hub_proxied"`
IssueBands *dashboardIssueBandsPayload `json:"issue_bands"`
Port *int `json:"port"`
AgentPollIntervalS *int `json:"agent_poll_interval_s"`
ExperimentLab *bool `json:"experiment_lab"`
StrategyLab *bool `json:"strategy_lab"`
AuthToken *string `json:"auth_token"`
AuthorizedUsers []string `json:"authorized_users"`
AuthorizedUserNames map[string]string `json:"authorized_user_names"`
HubProxied *bool `json:"hub_proxied"`
IssueBands *dashboardIssueBandsPayload `json:"issue_bands"`
StageTracker *dashboardStageTrackerPayload `json:"stage_tracker"`
}
if err := decodeBody(r, &body); err != nil {
jsonError(w, "invalid body", http.StatusBadRequest)
Expand Down Expand Up @@ -132,12 +138,21 @@ func (s *Server) handleDashboardSettingsPut(w http.ResponseWriter, r *http.Reque
}
next.IssueBands.StaleDays = body.IssueBands.StaleDays
}
if err := applyStageTrackerSettings(&next, body.StageTracker); err != nil {
jsonError(w, err.Error(), http.StatusBadRequest)
return
}
cfg.Dashboard = next
if err := s.saveConfig(); err != nil {
s.logger.Error("failed to persist config after dashboard settings update", "error", err)
jsonError(w, "failed to save config", http.StatusInternalServerError)
return
}
s.auditFromRequest(r, "config_dashboard_settings", auditDetail("section", "dashboard"), "")
if body.StageTracker != nil {
// The tracker payload carries the toast knobs; drop the memoised
// body so the next poll sees the new durations.
s.invalidateStageTrackerCache()
}
jsonResponse(w, dashboardSettingsResponse(cfg))
}
14 changes: 14 additions & 0 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ type StageTrackerResponse struct {
// the last few merges. Unlike RecentlyMerged it survives a roll, so it
// is what the "Merged" chip shows.
Merged StageTrackerMergedSummary `json:"merged"`
// Settings carries the operator-tunable timings the tracker's settings
// modal edits (hivecommons/hive#15813), so every viewer — not only the
// owner who may read /api/config/dashboard — sees the live values.
Settings StageTrackerSettings `json:"settings"`
}

// StageTrackerSettings is the live value of the timing knobs the Activity
// Monitor settings modal edits: dashboard.stage_tracker.toast_info_s,
// dashboard.stage_tracker.toast_error_s and
// auto_merge.contributor_lane.soak_minutes.
type StageTrackerSettings struct {
ToastInfoS int `json:"toast_info_s"`
ToastErrorS int `json:"toast_error_s"`
SoakMinutes int `json:"soak_minutes"`
}

// StageTrackerMerged is one recently merged pull request.
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ func (s *Server) encodeStageTracker(status *StatusPayload, now time.Time, ttl ti
resp := build(status, s.stageStoreOrShared(), now)
s.stageTrackerEnrichSoftLinks(resp.Items, stageTrackerRepoQualifier(status), now)
resp.CacheTTLSeconds = int64(ttl / time.Second)
resp.Settings = s.stageTrackerSettings()
// The encoded body carries source=cache: that is what every later hit
// serves verbatim, and what the ETag validates. The building request
// alone rewrites the marker to fresh on its way out (handleStageTracker).
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_cues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func stageTrackerCelebrateJS(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_CELEBRATE_MAX_FLIGHTS"),
jsConstLine(t, html, "STAGE_TRACKER_CELEBRATE_EXIT_PAD"),
jsConstLine(t, html, "STAGE_TRACKER_MERGE_BANNER_MS"),
"function stageTrackerMergeBannerMs() { return STAGE_TRACKER_MERGE_BANNER_MS; }",
jsConstLine(t, html, "STAGE_TRACKER_MERGE_BANNER_MAX"),
jsConstLine(t, html, "STAGE_TRACKER_SOUND_MAX_PLAYS"),
jsFunc(t, html, "stageTrackerCelebrateSetting"),
Expand Down
Loading
Loading