@d86e/hive-panel 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/panel.js +101 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d86e/hive-panel",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "A read-only board for a Hive swarm: agents, task lanes and the event tail, served from the refs and files you already have.",
5
5
  "type": "module",
6
6
  "bin": {
package/public/panel.js CHANGED
@@ -10,6 +10,7 @@ const MAX_EVENTS = 80;
10
10
  const DEFAULT_SNAPSHOT_URL = "/api/snapshot";
11
11
  const DEFAULT_ACTIONS_URL = "/api/actions";
12
12
  const DEFAULT_SUPERVISOR_URL = "/api/hive-runner";
13
+ const QUEEN_DISMISS_KEY = "hive.queenNoticeDismissed";
13
14
  const DEFAULT_INTERVAL_MS = 3000;
14
15
 
15
16
  const CARD_ACTIONS = Object.freeze({
@@ -692,8 +693,9 @@ const PANEL_STYLES = `.hive { position: relative; }
692
693
  .hive-queen-hint {
693
694
  display: none;
694
695
  flex: 0 0 auto;
695
- flex-direction: column;
696
- gap: 4px;
696
+ align-items: flex-start;
697
+ flex-direction: row;
698
+ gap: 8px;
697
699
  padding: 10px 16px;
698
700
  border-bottom: 1px solid color-mix(in srgb, var(--hive-accent, #58c4dc) 32%, var(--hive-line, #232b38));
699
701
  background: var(--hive-accent-soft);
@@ -735,6 +737,14 @@ const PANEL_STYLES = `.hive { position: relative; }
735
737
  color: var(--hive-fg-soft);
736
738
  }
737
739
 
740
+ .hive-queen-body {
741
+ display: flex;
742
+ flex: 1 1 auto;
743
+ flex-direction: column;
744
+ gap: 4px;
745
+ min-width: 0;
746
+ }
747
+
738
748
  .hive-queen-offer {
739
749
  display: flex;
740
750
  flex-wrap: wrap;
@@ -743,8 +753,18 @@ const PANEL_STYLES = `.hive { position: relative; }
743
753
  max-width: 76ch;
744
754
  }
745
755
 
746
- .hive-queen-offer.is-hidden,
747
- .hive-queen-exit.is-hidden { display: none; }
756
+ .hive-queen-offer.is-hidden { display: none; }
757
+
758
+ .hive-queen-dismiss {
759
+ flex: 0 0 auto;
760
+ min-width: 24px;
761
+ padding: 0 6px;
762
+ color: var(--hive-fg-soft);
763
+ font-size: 16px;
764
+ line-height: 1.4;
765
+ }
766
+
767
+ .hive-queen-dismiss.is-hidden { display: none; }
748
768
 
749
769
  .hive-queen-takeover {
750
770
  border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 45%, var(--hive-line, #232b38));
@@ -764,28 +784,6 @@ const PANEL_STYLES = `.hive { position: relative; }
764
784
  overflow-wrap: anywhere;
765
785
  }
766
786
 
767
- .hive-queen-exit {
768
- display: flex;
769
- flex-wrap: wrap;
770
- align-items: baseline;
771
- gap: 5px;
772
- max-width: 76ch;
773
- color: color-mix(in srgb, var(--hive-accent, #58c4dc) 80%, var(--hive-fg, #e6edf3));
774
- }
775
-
776
- .hive-queen-command {
777
- padding: 1px 6px;
778
- border: 1px solid color-mix(in srgb, var(--hive-accent, #58c4dc) 30%, var(--hive-line, #232b38));
779
- border-radius: 4px;
780
- background: color-mix(in srgb, var(--hive-fg, #e6edf3) 10%, transparent);
781
- color: var(--hive-fg, #e6edf3);
782
- font-family: var(--hive-mono);
783
- font-size: 10px;
784
- line-height: 1.5;
785
- cursor: text;
786
- user-select: text;
787
- }
788
-
789
787
  .hive-queen-output {
790
788
  margin-top: 6px;
791
789
  border-color: color-mix(in srgb, var(--hive-accent, #58c4dc) 32%, var(--hive-line, #232b38));
@@ -1045,8 +1043,7 @@ const PANEL_STYLES = `.hive { position: relative; }
1045
1043
  .hive-plan-hint,
1046
1044
  .hive-limits-description,
1047
1045
  .hive-limits-hint,
1048
- .hive-queen-text,
1049
- .hive-queen-exit { max-width: 76ch; line-height: 1.55; }
1046
+ .hive-queen-text { max-width: 76ch; line-height: 1.55; }
1050
1047
 
1051
1048
  .hive-empty,
1052
1049
  .hive-filter-empty,
@@ -1252,9 +1249,11 @@ export const messages = Object.freeze({
1252
1249
  "init.output": "stdout",
1253
1250
  "init.noOutput": "(no output)",
1254
1251
  "init.queen": "This session's input now routes to the Queen (it splits tasks, it does not do the work).",
1255
- "init.queenExit": "Exit from the chat window:",
1256
- "init.queenCommand": "/queen off",
1257
1252
  "init.queenOutput": "Initialisation output",
1253
+ "queen.dismiss": "Dismiss",
1254
+ "queen.dismissAria": "Dismiss the Queen notice for this repository",
1255
+ "help.queen": "Queen mode",
1256
+ "help.queenDesc": "Type /queen off to exit. After exiting, this session returns to normal coding mode. Hiding the notice does not change Queen mode.",
1258
1257
  "queen.status.active": "Queen active",
1259
1258
  "queen.status.inactive": "Queen not active",
1260
1259
  "queen.source.auto": "auto",
@@ -1447,9 +1446,11 @@ export const messages = Object.freeze({
1447
1446
  "init.output": "标准输出",
1448
1447
  "init.noOutput": "(无输出)",
1449
1448
  "init.queen": "本会话输入框已接入女王模式(女王只拆解任务,不亲自干活)。",
1450
- "init.queenExit": "退出请在聊天窗口输入:",
1451
- "init.queenCommand": "/queen off",
1452
1449
  "init.queenOutput": "初始化输出",
1450
+ "queen.dismiss": "关闭提示",
1451
+ "queen.dismissAria": "关闭这个仓库的女王提示",
1452
+ "help.queen": "女王模式",
1453
+ "help.queenDesc": "输入 /queen off 退出,退出后本会话恢复普通编码模式;关闭提示不影响女王状态。",
1453
1454
  "queen.status.active": "女王已接管",
1454
1455
  "queen.status.inactive": "女王未接管",
1455
1456
  "queen.source.auto": "自动",
@@ -2261,6 +2262,7 @@ export function mount(root, options = {}) {
2261
2262
  let initRequestSeq = 0;
2262
2263
  let queenNotice = false;
2263
2264
  let queenBusy = false;
2265
+ const queenDismissedFallback = new Set();
2264
2266
  let supervisorData = [];
2265
2267
  let supervisorRequest = null;
2266
2268
  let limitsOverlay = null;
@@ -2325,15 +2327,11 @@ export function mount(root, options = {}) {
2325
2327
 
2326
2328
  const freezeSlot = element(doc, "div", "hive-freeze-slot");
2327
2329
 
2328
- // Queen-mode notice, shown only after a successful init in this mount.
2330
+ // Queen-mode notice, driven by snapshot.queen.
2329
2331
  const queenHint = element(doc, "section", "hive-queen-hint");
2330
2332
  setAttr(queenHint, "role", "status");
2333
+ const queenBody = element(doc, "div", "hive-queen-body");
2331
2334
  const queenHintText = element(doc, "div", "hive-queen-text", "");
2332
- const queenExit = element(doc, "div", "hive-queen-exit");
2333
- const queenExitText = element(doc, "span", "hive-queen-exit-text", "");
2334
- const queenCommand = element(doc, "code", "hive-queen-command", "");
2335
- queenExit.appendChild(queenExitText);
2336
- queenExit.appendChild(queenCommand);
2337
2335
  const queenOffer = element(doc, "div", "hive-queen-offer is-hidden");
2338
2336
  const queenTakeoverButton = element(doc, "button", "hive-btn hive-queen-takeover", translate("queen.takeover"));
2339
2337
  setAttr(queenTakeoverButton, "type", "button");
@@ -2348,10 +2346,18 @@ export function mount(root, options = {}) {
2348
2346
  const queenOutputPre = element(doc, "pre", "hive-output-pre", "");
2349
2347
  queenOutputDetails.appendChild(queenOutputSummary);
2350
2348
  queenOutputDetails.appendChild(queenOutputPre);
2351
- queenHint.appendChild(queenHintText);
2352
- queenHint.appendChild(queenOffer);
2353
- queenHint.appendChild(queenExit);
2354
- queenHint.appendChild(queenOutputDetails);
2349
+ queenBody.appendChild(queenHintText);
2350
+ queenBody.appendChild(queenOffer);
2351
+ queenBody.appendChild(queenOutputDetails);
2352
+ const queenDismissButton = element(doc, "button", "hive-btn hive-btn-ghost hive-queen-dismiss is-hidden", "×");
2353
+ setAttr(queenDismissButton, "type", "button");
2354
+ setAttr(queenDismissButton, "title", translate("queen.dismissAria"));
2355
+ setAttr(queenDismissButton, "aria-label", translate("queen.dismissAria"));
2356
+ queenDismissButton.addEventListener("click", () => {
2357
+ dismissQueenNotice();
2358
+ });
2359
+ queenHint.appendChild(queenBody);
2360
+ queenHint.appendChild(queenDismissButton);
2355
2361
 
2356
2362
  const main = element(doc, "main", "hive-main");
2357
2363
 
@@ -2597,6 +2603,8 @@ export function mount(root, options = {}) {
2597
2603
  body.appendChild(item);
2598
2604
  }
2599
2605
  }
2606
+ body.appendChild(element(doc, "div", "hive-help-section", translate("help.queen")));
2607
+ body.appendChild(element(doc, "div", "hive-help-desc hive-help-queen", translate("help.queenDesc")));
2600
2608
  body.appendChild(element(doc, "div", "hive-help-hint", translate("help.hint")));
2601
2609
  }
2602
2610
 
@@ -3665,11 +3673,57 @@ export function mount(root, options = {}) {
3665
3673
  initOutputPre.textContent = initOutput && initOutput.stdout ? initOutput.stdout : translate("init.noOutput");
3666
3674
  }
3667
3675
 
3676
+ function queenStorage() {
3677
+ try {
3678
+ const storage = view && view.localStorage;
3679
+ if (storage && typeof storage.getItem === "function" && typeof storage.setItem === "function") {
3680
+ return storage;
3681
+ }
3682
+ } catch {
3683
+ // A blocked localStorage must not break the panel.
3684
+ }
3685
+ return null;
3686
+ }
3687
+
3688
+ function queenDismissStorageKey(repo) {
3689
+ return QUEEN_DISMISS_KEY + "=" + repo;
3690
+ }
3691
+
3692
+ function isQueenNoticeDismissed(repo) {
3693
+ if (!repo) return false;
3694
+ if (queenDismissedFallback.has(repo)) return true;
3695
+ const storage = queenStorage();
3696
+ if (!storage) return false;
3697
+ try {
3698
+ if (storage.getItem(queenDismissStorageKey(repo)) !== null) return true;
3699
+ return storage.getItem(QUEEN_DISMISS_KEY) === repo;
3700
+ } catch {
3701
+ return false;
3702
+ }
3703
+ }
3704
+
3705
+ function dismissQueenNotice() {
3706
+ const repo = lastModel ? lastModel.repo : "";
3707
+ if (!repo) return;
3708
+ queenDismissedFallback.add(repo);
3709
+ const storage = queenStorage();
3710
+ if (storage) {
3711
+ try {
3712
+ storage.setItem(queenDismissStorageKey(repo), "1");
3713
+ storage.setItem(QUEEN_DISMISS_KEY, repo);
3714
+ } catch {
3715
+ // The in-memory fallback above still hides it for this mount.
3716
+ }
3717
+ }
3718
+ if (!destroyed && lastModel) renderQueenHint(lastModel);
3719
+ }
3720
+
3668
3721
  function renderQueenHint(model) {
3669
3722
  const initialised = Boolean(model && model.initialised !== false);
3670
3723
  const state = model && isRecord(model.queen) ? model.queen : null;
3671
3724
  const active = state ? state.active === true : Boolean(queenNotice);
3672
- const show = initialised && Boolean(state || queenNotice);
3725
+ const dismissed = active && isQueenNoticeDismissed(model ? model.repo : "");
3726
+ const show = initialised && Boolean(state || queenNotice) && !dismissed;
3673
3727
  const offer = show && !active;
3674
3728
 
3675
3729
  if (initialised && state) {
@@ -3698,15 +3752,16 @@ export function mount(root, options = {}) {
3698
3752
  queenHint.className = "hive-queen-hint" + (show ? " is-visible" : "") + (offer ? " is-offer" : "");
3699
3753
  queenHintText.textContent = active ? translate("init.queen") : translate("queen.offer");
3700
3754
  queenOffer.className = "hive-queen-offer" + (offer ? "" : " is-hidden");
3755
+ queenDismissButton.className =
3756
+ "hive-btn hive-btn-ghost hive-queen-dismiss" + (active && show ? "" : " is-hidden");
3757
+ setAttr(queenDismissButton, "title", translate("queen.dismissAria"));
3758
+ setAttr(queenDismissButton, "aria-label", translate("queen.dismissAria"));
3701
3759
  queenTakeoverButton.disabled = queenBusy;
3702
3760
  queenTakeoverButton.textContent = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeover");
3703
3761
  const takeoverAria = queenBusy ? translate("queen.takeoverBusy") : translate("queen.takeoverAria");
3704
3762
  setAttr(queenTakeoverButton, "title", takeoverAria);
3705
3763
  setAttr(queenTakeoverButton, "aria-label", takeoverAria);
3706
3764
 
3707
- queenExit.className = "hive-queen-exit" + (active ? "" : " is-hidden");
3708
- queenExitText.textContent = translate("init.queenExit");
3709
- queenCommand.textContent = translate("init.queenCommand");
3710
3765
  queenOutputSummary.textContent = translate("init.queenOutput");
3711
3766
  setAttr(queenOutputSummary, "title", translate("init.queenOutput"));
3712
3767
  const output = initOutput && initOutput.stdout ? initOutput.stdout : translate("init.noOutput");