@jmanuelcorral/bond-app 0.1.5 → 0.2.0

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 (80) hide show
  1. package/README.md +280 -23
  2. package/app/brand/TOKENS.md +5 -5
  3. package/app/layouts/bond.json +10 -14
  4. package/app/mods/bond-agents/api.js +35 -0
  5. package/app/mods/bond-agents/branch.svg +1 -0
  6. package/app/mods/bond-agents/brand.js +53 -2
  7. package/app/mods/bond-agents/config.js +4 -0
  8. package/app/mods/bond-agents/eye-off.svg +1 -0
  9. package/app/mods/bond-agents/eye.svg +1 -0
  10. package/app/mods/bond-agents/main.js +308 -327
  11. package/app/mods/bond-agents/model.js +376 -5
  12. package/app/mods/bond-board/api.js +35 -0
  13. package/app/mods/bond-board/branch.svg +1 -0
  14. package/app/mods/bond-board/brand.js +53 -2
  15. package/app/mods/bond-board/config.js +4 -0
  16. package/app/mods/bond-board/main.js +1000 -449
  17. package/app/mods/bond-board/model.js +170 -28
  18. package/app/mods/bond-pane/close.svg +1 -0
  19. package/app/mods/bond-pane/hide.svg +1 -0
  20. package/app/mods/bond-pane/main.js +103 -0
  21. package/app/mods/bond-pane/mod.json +1 -0
  22. package/app/mods/bond-pane/model.js +18 -0
  23. package/app/mods/bond-pane/split-down.svg +1 -0
  24. package/app/mods/bond-pane/split-right.svg +1 -0
  25. package/app/mods/bond-pane/unzoom.svg +1 -0
  26. package/app/mods/bond-pane/zoom.svg +1 -0
  27. package/app/mods/bond-settings/api.js +35 -0
  28. package/app/mods/bond-settings/brand.js +53 -2
  29. package/app/mods/bond-settings/config.js +4 -0
  30. package/app/mods/bond-settings/main.js +1216 -272
  31. package/app/mods/bond-settings/mod.json +1 -1
  32. package/app/mods/bond-status/api.js +35 -0
  33. package/app/mods/bond-status/brand.js +53 -2
  34. package/app/mods/bond-status/config.js +4 -0
  35. package/app/mods/bond-status/main.js +37 -15
  36. package/app/mods/bond-status/model.js +19 -1
  37. package/app/mods/bond-tabs/brand.js +53 -2
  38. package/app/mods/bond-tabs/main.js +45 -3
  39. package/app/mods/bond-titlebar/brand.js +53 -2
  40. package/app/mods/bond-titlebar/main.js +85 -29
  41. package/app/mods/bond-titlebar/version.js +3 -0
  42. package/app/themes/bond-dark.json +5 -5
  43. package/app/themes/bond-light.json +5 -5
  44. package/package.json +1 -1
  45. package/runner/Dockerfile +16 -2
  46. package/runner/SPIKE-BOND.md +6 -2
  47. package/runner/entrypoint.sh +16 -0
  48. package/runner/setup.sh +439 -8
  49. package/runner/versions.env +32 -1
  50. package/scripts/app-install.ts +322 -27
  51. package/src/cli.ts +562 -21
  52. package/src/config.ts +15 -3
  53. package/src/core/agy-login.ts +683 -0
  54. package/src/core/delivery.ts +125 -6
  55. package/src/core/doctor.ts +748 -0
  56. package/src/core/hub-session.ts +108 -91
  57. package/src/core/hub.ts +40 -8
  58. package/src/core/orchestrator.ts +1481 -187
  59. package/src/core/paths.ts +107 -0
  60. package/src/core/permissions.ts +143 -0
  61. package/src/core/pr-source.ts +147 -0
  62. package/src/core/repo-host.ts +60 -0
  63. package/src/core/service-windows.ts +180 -0
  64. package/src/core/service.ts +861 -0
  65. package/src/core/setup-install.ts +1380 -0
  66. package/src/core/setup.ts +62 -1
  67. package/src/core/watchdog.ts +6 -6
  68. package/src/db/database.ts +54 -7
  69. package/src/db/settings-repo.ts +332 -7
  70. package/src/db/ticket-repo.ts +73 -25
  71. package/src/index.ts +4 -4
  72. package/src/runner/azure-devops-client.ts +273 -0
  73. package/src/runner/docker-client.ts +93 -9
  74. package/src/runner/github-client.ts +148 -3
  75. package/src/runner/hc-client.ts +33 -5
  76. package/src/runner/image-builder.ts +123 -5
  77. package/src/runner/jira-client.ts +368 -0
  78. package/src/runner/tool-catalog.ts +84 -0
  79. package/src/server/app.ts +467 -8
  80. package/src/types.ts +140 -2
@@ -12,12 +12,12 @@
12
12
  //
13
13
  // P6: bond's look. A header with a counter per state, filters (repo, agent, text) and
14
14
  // «Nuevo ticket» (a dialog with validation; the ticket lands in Ready, D4); each column
15
- // in its state's color; empty columns folded to a narrow strip. Colors come from the
15
+ // in its state's color; empty columns keep their width with a short line. Colors come from the
16
16
  // theme through brand.js (stateColor), never as literals here.
17
17
  //
18
18
  // Props: none (the board), or { view: "launch" | "cancel" | "deliver" | "nudge" | "approve"
19
19
  // | "create" | "pick", ... } when this mod is opened as a dialog or popup by the board.
20
- import { View, div } from "gpui-kit";
20
+ import { View, div, svg, image } from "gpui-kit";
21
21
  import { v_flex, h_flex, TextareaState, Textarea, InputState, Input } from "gpui-base";
22
22
  import { run, spaces, props, theme, openOverlay, closeOverlay, notify, shared, setShared, exec } from "herdr";
23
23
  import { api, hcGet, apiUrl } from "./api.js";
@@ -25,10 +25,14 @@ import { CONFIG } from "./config.js";
25
25
  import {
26
26
  COLUMNS, POLL_MS, buildCards, groupByColumn, loadBoard, launchTicket, cancelRun, launchSummary,
27
27
  deliverRun, nudgeRun, finishRun, approveHubFixes, deleteTicket, getDeletePreview,
28
- columnCounts, filterOptions, filterCards, validateNewTicket, createTicket, AGENTS, TICKET_MODES, TEAM_ENGINES,
29
- cleanRepoChips, listAssignedIssues, issueTicketId, searchRepos, listRepoIssues, needsWizard,
28
+ columnCounts, filterOptions, filterCards, issueChip, validateNewTicket, createTicket, AGENTS, TICKET_MODES, TEAM_ENGINES,
29
+ cleanRepoChips, listAssignedIssues, issueTicketId, searchRepos, listRepoIssues, searchJiraIssues, resetIssueProviderState, needsWizard, timeoutLabel,
30
+ searchPullRequests, resolvePullRequest, parsePrSearchInput, formatSourceError,
30
31
  } from "./model.js";
31
- import { stateColor, UI } from "./brand.js";
32
+ import { stateColor, UI, settingsOverlay, createOverlay, markColor } from "./brand.js";
33
+
34
+ /** The Shell button's program: zsh when the run's container has it, else bash (login shells). */
35
+ const SHELL_ARGV = ["sh", "-c", "if command -v zsh >/dev/null 2>&1; then exec zsh -l; else exec bash -l; fi"];
32
36
 
33
37
  const REFRESH_KEY = "bond.board.refresh";
34
38
  // The board's repo/agent filter: a picker popup of this mod sets it, the board reads it.
@@ -50,6 +54,12 @@ function spanishStateLabel(col, status) {
50
54
  return `● ${s.toUpperCase()}`;
51
55
  }
52
56
 
57
+ /** Height of an empty column's placeholder: one for all five, subtitle or not. */
58
+ const EMPTY_COLUMN_H = 132;
59
+
60
+ /** The line an empty column shows under its header. */
61
+ const EMPTY_LINE = { ready: "Nada pendiente", running: "Nada en curso", waiting: "Nada en espera", finished: "Nada terminado", error: "Sin errores" };
62
+
53
63
  export default class BondBoard extends View {
54
64
  init(_props, cx) {
55
65
  const p = props() ?? {};
@@ -122,32 +132,89 @@ export default class BondBoard extends View {
122
132
  title: InputState.new({ placeholder: "título del ticket" }),
123
133
  model: InputState.new({ placeholder: "por defecto" }),
124
134
  issue: InputState.new({ placeholder: "https://github.com/org/repo/issues/123 (o pulsa Buscar)" }),
125
- repo: InputState.new({ placeholder: "https://github.com/org/repo" }),
135
+ repo: InputState.new({ placeholder: "https://github.com/org/repo o https://dev.azure.com/org/proyecto/_git/repo" }),
126
136
  repos: TextareaState.new({ placeholder: "un repo por línea: https://github.com/org/repo [agente]" }),
127
137
  hub: InputState.new({ placeholder: "https://github.com/org/hub" }),
128
138
  base: InputState.new({ placeholder: "rama base (opcional: main)" }),
129
139
  budget: InputState.new({ value: "2" }),
130
- timeout: InputState.new({ value: "30" }),
140
+ timeout: InputState.new({ value: "0", placeholder: "0 = sin timeout" }),
131
141
  };
132
142
  // Plan bond-app-nuevo-ticket (P2): la issue se busca, no se pega (D2/D4). Jira hasta P3.
133
143
  this.issueProvider = "github";
134
144
  this.pickedIssue = null;
135
145
  this.carryBody = true; // lleva el cuerpo de la issue a la historia salvo que se desmarque
136
146
  this.bondify = true; // bondifica el repo si no lo está salvo que se desmarque (P4, D-U)
147
+ // «Docker en el run»: marcado por defecto (decisión 2026-11-25: se trabaja casi siempre
148
+ // con devcontainers); la persona lo desmarca para un ticket concreto.
149
+ this.docker = true;
150
+ this.dockerTouched = false;
151
+ this.devcontainerRepo = null; // "owner/repo" con devcontainer detectado
152
+ this.devcontainerChecked = null; // último "owner/repo@base" consultado
153
+ // Dónde: el repo elegido es un hub (hub.toml) → el ticket va en modo hub, salvo que
154
+ // la persona pida tratarlo como un repo normal.
155
+ this.hubDetected = null; // URL del repo elegido cuando trae hub.toml
156
+ this.hubAsRepo = false;
137
157
  this.issuePanel = null;
138
158
  this.issues = null;
139
159
  this.issuesLoading = false;
140
160
  this.issuesError = null;
141
- this.issueQuery = InputState.new({ placeholder: "filtrar por título…" });
161
+ this.issueQuery = InputState.new({ placeholder: "filtra tus issues, escribe owner/repo para ver las de un repo, o pega la URL de una issue" });
142
162
  this.issueQuery.on("change", (_e, cx) => cx.notify());
163
+ this.jiraQuery = InputState.new({ placeholder: "buscar por texto o clave en Jira (KEY-123)…" });
164
+ this.jiraQuery.on("change", (_e, cx) => cx.notify());
165
+ this.jiraResults = null;
166
+ this.jiraSearching = false;
167
+ // «Asignadas a mí»: on, the list is your open issues and «Buscar» stays within them;
168
+ // off, it searches the whole site (and with no text lists its open issues).
169
+ this.jiraMine = true;
143
170
  this.issueRepo = null;
144
- this.repoQuery = InputState.new({ placeholder: "buscar repo…" });
171
+ this.repoQuery = InputState.new({ placeholder: "buscar repo en favoritos, recientes, GitHub y Azure Repos (o pega su URL)" });
145
172
  this.repoQuery.on("change", (_e, cx) => cx.notify());
173
+ // P4: con un repo de GitHub completo (escrito o elegido con su issue) se mira si trae
174
+ // devcontainer; checkDevcontainer no repite la misma consulta.
175
+ for (const f of [this.fields.repo, this.fields.base]) {
176
+ f.on("change", (_e, cx) => this.checkDevcontainer(cx));
177
+ f.on("blur", (_e, cx) => this.checkDevcontainer(cx));
178
+ }
146
179
  this.assignedPool = null;
147
180
  this.poolLoading = false;
148
181
  this.repoResults = [];
149
182
  this.reposLoading = false;
150
183
  this.reposError = null;
184
+ // Alta en tres bloques (Qué · Dónde · Quién; decisión 2026-11-24): la historia se ve y
185
+ // se edita; el repo se elige aparte de la issue, con favoritos, recientes, GitHub y Azure.
186
+ this.source = "github"; // github | jira | manual
187
+ this.createKind = "scratch"; // scratch | pr
188
+ this.prQuery = InputState.new({ placeholder: "buscar PR abierta (texto o owner/repo) o pegar URL de PR o rama" });
189
+ this.prQuery.on("change", (_e, cx) => this.searchPrsSoon(cx));
190
+ this.prResults = null;
191
+ this.prSearching = false;
192
+ this.prSearchErrors = {};
193
+ this.prSearchFor = null;
194
+ // Filtros de la búsqueda de PRs: host (todas | github | azure) y de quién (todas | assigned | author).
195
+ this.prHost = "todas";
196
+ this.prMine = "todas";
197
+ this.prResolving = false;
198
+ this.prResolvingUrl = null;
199
+ this.prResolveError = null;
200
+ this.prDisabled = {};
201
+ this.pickedPr = null;
202
+ this.prChoosing = true;
203
+ this.choosing = true; // la lista de issues abierta (al elegir una se pliega)
204
+ this.story = TextareaState.new({ placeholder: "qué tiene que hacer el agente: lo lee como primer mensaje" });
205
+ this.story.set_rows(4);
206
+ this.repoSel = null; // { url, label, host, base? } del bloque Dónde
207
+ this.repoChoosing = true;
208
+ this.repoFilter = "todos"; // todos | recientes | github | azure
209
+ this.repoSuggest = null;
210
+ this.repoSuggestLoading = false;
211
+ this.repoSuggestErrors = {};
212
+ this.repoSuggestFor = null;
213
+ this.listRepos = []; // «Varios (hub)»: { url, label }
214
+ this.optionsOpen = false;
215
+ this.repoQuery.on("change", (_e, cx) => this.suggestReposSoon(cx));
216
+ this.loadPool(cx);
217
+ this.suggestRepos(cx, "");
151
218
  this.fields.title.focus();
152
219
  return;
153
220
  }
@@ -199,10 +266,7 @@ export default class BondBoard extends View {
199
266
  const state = await api("/setup");
200
267
  if (!needsWizard(state)) return;
201
268
  wizardOffered = true;
202
- openOverlay({
203
- mod: "bond-settings", kind: "dialog", modal: true, width: 560, height: 0.92,
204
- props: { view: "wizard", step: 1 },
205
- });
269
+ openOverlay(settingsOverlay({ view: "wizard", step: 1 }));
206
270
  } catch {
207
271
  // no API: the board already shows its own «sin conexión» card.
208
272
  }
@@ -246,6 +310,9 @@ export default class BondBoard extends View {
246
310
  closeOverlay(p.overlay);
247
311
  } catch (e) {
248
312
  this.error = String(e?.message ?? e);
313
+ // Also as a toast: the dialog may be gone by the time the start fails.
314
+ notify({ title: "No se pudo lanzar el run", body: this.error, level: "error" });
315
+ setShared(REFRESH_KEY, Date.now());
249
316
  this.busy = false;
250
317
  cx.notify();
251
318
  }
@@ -373,12 +440,33 @@ export default class BondBoard extends View {
373
440
  modelVal = v("model") || null;
374
441
  }
375
442
  }
376
- const check = validateNewTicket({
377
- title: v("title"), issue: v("issue"), mode: this.mode, repo: v("repo"), repos: v("repos"), hub: v("hub"),
378
- base: v("base"), model: modelVal, agent: this.agent, team_engine: this.team_engine, budget: v("budget"), timeout: v("timeout"),
379
- story: this.carryBody && this.pickedIssue ? String(this.pickedIssue.body ?? "") : "",
380
- bondify: this.bondify,
381
- });
443
+ // Dónde: the chosen repo (or the typed URL) and the chips of «Varios (hub)».
444
+ const repoUrl = this.repoSel?.url ?? v("repo");
445
+ const reposText = this.listRepos.map((r) => r.url).join("\n");
446
+ const storyText = String(this.story.value() ?? "");
447
+ const check = this.createKind === "pr"
448
+ ? validateNewTicket({
449
+ kind: "pr",
450
+ source_pr_url: this.pickedPr?.url ?? "",
451
+ is_hub: Boolean(this.pickedPr?.is_hub),
452
+ hub_url: !this.pickedPr?.is_hub && this.pickedPrHub ? this.pickedPrHub : undefined,
453
+ title: v("title"), model: modelVal, agent: this.agent, team_engine: this.team_engine,
454
+ budget: v("budget"), timeout: v("timeout"),
455
+ story: storyText.trim() ? storyText : this.pickedPr ? "" : undefined,
456
+ bondify: this.bondify,
457
+ docker: this.docker,
458
+ })
459
+ : validateNewTicket({
460
+ title: v("title"), issue: v("issue"), mode: this.mode, repo: repoUrl, repos: reposText, hub: v("hub"),
461
+ base: v("base"), model: modelVal, agent: this.agent, team_engine: this.team_engine, budget: v("budget"), timeout: v("timeout"),
462
+ // Desmarcado con issue que trae cuerpo = story "" explícita (el agente arranca sin
463
+ // historia); sin issue o sin cuerpo = undefined (comportamiento heredado).
464
+ // The story is what the box holds: emptied on purpose with an issue = "" (the agent
465
+ // starts without it); nothing typed and no issue = undefined (legacy behaviour).
466
+ story: storyText.trim() ? storyText : this.pickedIssue ? "" : undefined,
467
+ bondify: this.bondify,
468
+ docker: this.docker,
469
+ });
382
470
  this.errors = check.errors;
383
471
  this.error = null;
384
472
  if (!check.ok) {
@@ -394,8 +482,8 @@ export default class BondBoard extends View {
394
482
  setShared(REFRESH_KEY, Date.now());
395
483
  closeOverlay(p.overlay);
396
484
  } catch (e) {
397
- // The API's own validation (e.g. an agent the runner image doesn't carry).
398
- this.error = String(e?.message ?? e);
485
+ // The API's own validation (e.g. an agent the runner image doesn't carry, or source_*).
486
+ this.error = formatSourceError(e);
399
487
  this.busy = false;
400
488
  cx.notify();
401
489
  }
@@ -418,6 +506,13 @@ export default class BondBoard extends View {
418
506
  this.searchReposOn(cx);
419
507
  cx.stop_propagation();
420
508
  }
509
+ if (e.key === "enter" && this.view === "create" && this.createKind === "pr") {
510
+ const q = String(this.prQuery.value() ?? "").trim();
511
+ if (/^https?:\/\//.test(q)) {
512
+ this.resolvePr(q, cx);
513
+ cx.stop_propagation();
514
+ }
515
+ }
421
516
  }
422
517
 
423
518
  // ---- board actions ----
@@ -493,7 +588,7 @@ export default class BondBoard extends View {
493
588
  }
494
589
 
495
590
  openCreate() {
496
- openOverlay({ mod: "bond-board", kind: "dialog", modal: true, width: 560, props: { view: "create" } });
591
+ openOverlay(createOverlay());
497
592
  }
498
593
 
499
594
  openPick(field, options) {
@@ -623,6 +718,13 @@ export default class BondBoard extends View {
623
718
  try {
624
719
  run("space.select", { id: sp.id });
625
720
  } catch {}
721
+ } else if (card.run?.hc_machine && ["running", "waiting", "verifying", "blocked", "analyzing"].includes(String(card.run.state))) {
722
+ // E1 (plan bond-app-pestanas-paneles): the run gets its own space on its machine,
723
+ // never a terminal.show over whatever tab was open. space.new brings a shell in the
724
+ // "bond-init" tab; bond-agents gives the orchestrator its own tab and closes that one.
725
+ try {
726
+ run("space.new", { machine: card.run.hc_machine, name: card.title || card.id, tab: "bond-init" });
727
+ } catch {}
626
728
  } else if (card.terminal) {
627
729
  try {
628
730
  run("terminal.show", { terminal: card.terminal });
@@ -669,6 +771,9 @@ export default class BondBoard extends View {
669
771
 
670
772
  const folder = card.hub ? "/workspace/hub" : "/workspace";
671
773
  const tabName = "shell";
774
+ // Plan bond-app-ajustes-imagen P3: zsh (oh-my-zsh, grupo «shell» de la imagen) when the
775
+ // container has it, bash otherwise. Only this human shell: the agents keep bash.
776
+ const argv = SHELL_ARGV;
672
777
 
673
778
  try {
674
779
  const sp = this.spaceForCard(card);
@@ -677,6 +782,7 @@ export default class BondBoard extends View {
677
782
  space: sp.id,
678
783
  name: tabName,
679
784
  folder,
785
+ argv,
680
786
  });
681
787
  } else {
682
788
  run("space.new", {
@@ -684,6 +790,7 @@ export default class BondBoard extends View {
684
790
  name: card.title || card.id,
685
791
  tab: tabName,
686
792
  folder,
793
+ argv,
687
794
  });
688
795
  }
689
796
  } catch {
@@ -715,168 +822,114 @@ export default class BondBoard extends View {
715
822
 
716
823
  card(card) {
717
824
  const t = theme();
718
- const dim = (text) => div().text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.dim).truncate().child(String(text ?? ""));
719
- const money = card.run ? `$${(card.costUsd || 0).toFixed(2)}` : "$0.00";
720
- const budget = `/$${(card.budgetUsd || 0).toFixed(2)}`;
721
- const time = card.elapsed ? `⏱ ${card.elapsed}` : "";
825
+ const mono = (el) => el.font_family("JetBrains Mono");
722
826
  const color = stateColor(t, card.column);
723
827
  const isSelected = this.selectedCardId === card.id;
724
- const isWaiting = card.column === "waiting" || card.status === "waiting";
725
- const cardBorder = isSelected ? t.ring : (isWaiting ? (t.bond_waiting ?? t.blocked) : (card.canOpen ? t.accent : t.border));
726
-
727
- const hubLabel = card.hub ? String(card.hub.label || card.hub.url || (typeof card.hub === "string" ? card.hub : "hub")) : "";
728
- const rawRepos = (card.hub && Array.isArray(card.hub.repos)) ? card.hub.repos : [];
729
- const hubRepos = cleanRepoChips(rawRepos, hubLabel);
828
+ // The state's color goes on the card's border for the columns that ask for attention
829
+ // (running, waiting, error); ready and finished stay neutral.
830
+ const attention = ["running", "waiting", "error"].includes(card.column) || card.status === "waiting";
831
+ const cardBorder = isSelected ? t.ring : (attention ? color : t.border);
832
+ const hovered = this.hoveredCard === card.id;
833
+ const action = this.primaryAction(card);
834
+ const chip = issueChip(card.issueUrl, card.repoKeys?.[0]);
835
+ const azure = /dev\.azure\.com|visualstudio\.com/.test(String(card.repoUrl ?? ""));
836
+ const hubLabel = card.hub ? String(card.hub.label || card.hub.url || "hub").replace(/^hub\s+/i, "") : "";
837
+ const hubRepos = card.hub ? cleanRepoChips(Array.isArray(card.hub.repos) ? card.hub.repos : [], hubLabel) : [];
838
+ const money = card.run ? `$${(card.costUsd || 0).toFixed(2)}` : "$0.00";
730
839
 
731
- const body = v_flex().flex_1().min_w(0).p(8).gap(4)
732
- // Top row: status chip + branch + open session link
733
- .child(
734
- h_flex().items_center().justify_between().gap(4)
735
- .child(
736
- h_flex().items_center().gap(4).flex_wrap()
737
- .child(
738
- div().px(6).py(1).rounded(UI.radius).bg(t.raised).border_1().border_color(color)
739
- .text_size(UI.text.tiny).font_family("JetBrains Mono").font_semibold().text_color(color)
740
- .child(spanishStateLabel(card.column, card.status))
741
- )
742
- .when(Boolean(card.branch), (el) =>
743
- el.child(
744
- div().px(5).py(1).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
745
- .text_size(UI.text.tiny).font_family("JetBrains Mono").text_color(t.muted).truncate().child(String(card.branch))
746
- )
747
- )
748
- )
749
- .child(
750
- h_flex().items_center().gap(4)
751
- .when(Boolean(card.canOpen), (el) =>
752
- el.child(
753
- div().text_size(UI.text.tiny).font_family("JetBrains Mono").text_color(t.accent).child("Abrir sesión →")
754
- )
755
- )
756
- .child(
757
- div().id(`card-menu-btn-${card.id}`).px(4).py(0.5).rounded(UI.radius)
758
- .text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.muted).cursor_pointer()
759
- .hover((s) => s.bg(t.hover).text_color(t.foreground))
760
- .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
761
- .on_click((_e, cx) => {
762
- cx.stop_propagation();
763
- this.openCardMenu(card);
764
- })
765
- .child("⋯")
766
- )
767
- )
768
- )
769
- // Ticket title in sans UI font
770
- .child(div().text_size(UI.text.title).font_semibold().font_family(UI.fontSans).text_color(t.foreground).child(String(card.title || card.id || "")))
771
- // Hub and Repositories
772
- .when(Boolean(card.hub), (el) =>
773
- el.child(
774
- v_flex().gap(2).font_family("JetBrains Mono").text_size(UI.text.small)
775
- .child(
776
- h_flex().gap(4).items_center().truncate()
777
- .child(div().text_color(t.dim).child("hub:"))
778
- .child(div().text_color(t.accent).truncate().child(hubLabel.replace(/^hub\s+/i, "")))
779
- )
780
- .when(hubRepos.length > 0, (sub) =>
781
- sub.child(
782
- h_flex().gap(3).items_center().truncate()
783
- .child(div().text_color(t.dim).child("repos:"))
784
- .children(hubRepos.map((r) =>
785
- div().px(4).py(0.5).rounded(4).bg(t.raised).border_1().border_color(t.border).text_color(t.muted).text_size(UI.text.tiny).child(r)
786
- ))
787
- )
788
- )
789
- )
790
- )
791
- .when(!card.hub && Boolean(card.repo), (el) =>
792
- el.child(
793
- h_flex().gap(4).items_center().font_family("JetBrains Mono").text_size(UI.text.small).truncate()
794
- .child(div().text_color(t.dim).child("repo:"))
795
- .child(div().text_color(t.muted).truncate().child(String(card.repo)))
796
- )
797
- )
798
- // Agent & state
799
- .child(dim(`${card.agent || "agente"} · ${card.agentState || "listo"}`))
800
- // Metrics bar: Cost + Time. Los costes están desactivados por defecto
801
- // (CONFIG.costs); el tiempo se sigue mostrando si hay run.
802
- .when(CONFIG.costs || Boolean(time), (bar) => bar.child(
803
- h_flex().items_center().justify_between().p(5).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border).font_family("JetBrains Mono").text_size(UI.text.small)
804
- .when(CONFIG.costs, (el) => el.child(
805
- h_flex().gap(3).items_center()
806
- .child(div().text_color(t.dim).child("Gasto:"))
807
- .child(div().font_semibold().text_color(t.working).child(money))
808
- .child(div().text_color(t.dim).text_size(UI.text.tiny).child(budget))
809
- ))
810
- .when(Boolean(time), (el) =>
811
- el.child(
812
- div().text_color(t.bond_waiting ?? t.blocked).font_medium().child(String(time))
813
- )
814
- )
815
- ))
816
- // Diagnostic box with motivo: and bond hub check:
840
+ const body = v_flex().flex_1().min_w(0).p(8).gap(5)
841
+ // 1. State, issue and, on hover, the state's main action; «⋯» always.
842
+ .child(h_flex().items_center().gap(4).min_w(0)
843
+ .child(mono(div().flex_none().px(6).py(1).rounded(UI.radius).bg(t.raised).border_1().border_color(color)
844
+ .text_size(UI.text.tiny).font_semibold().text_color(color)).child(spanishStateLabel(card.column, card.status)))
845
+ .when(Boolean(chip), (el) => el.child(mono(div().id(`card-issue-${card.id}`).flex_none().px(5).py(1).rounded(UI.radius)
846
+ .bg(t.raised).border_1().border_color(t.border).text_size(UI.text.tiny).text_color(markColor(t, chip.host)).cursor_pointer()
847
+ .hover((s) => s.bg(t.hover)).tooltip(`Abrir ${chip.url}`)
848
+ .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
849
+ .on_click((_e, cx) => { cx.stop_propagation(); exec("xdg-open", [chip.url]).catch(() => {}); }))
850
+ .child(chip.label)))
851
+ .child(div().flex_1())
852
+ .when(hovered && Boolean(action), (el) => el.child(this.button(`card-act-${card.id}`, action[1], "primary", () => action[2](), true)))
853
+ .child(mono(div().id(`card-menu-btn-${card.id}`).flex_none().px(4).rounded(UI.radius)
854
+ .text_size(UI.text.small).text_color(t.muted).cursor_pointer()
855
+ .hover((s) => s.bg(t.hover).text_color(t.foreground))
856
+ .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
857
+ .on_click((_e, cx) => { cx.stop_propagation(); this.openCardMenu(card); }))
858
+ .child("⋯")))
859
+ // 2. Title, two lines at most (the full one in its tooltip).
860
+ .child(div().id(`card-title-${card.id}`).max_h(36).overflow_hidden().tooltip(String(card.title || card.id || ""))
861
+ .text_size(UI.text.title).font_semibold().font_family(UI.fontSans).text_color(t.foreground)
862
+ .child(String(card.title || card.id || "")))
863
+ // 3. Where: host, repo (or hub and its repos) and branch.
864
+ .child(mono(h_flex().gap(5).items_center().min_w(0).text_size(UI.text.small))
865
+ .when(Boolean(card.hub), (el) => el
866
+ .child(div().flex_none().text_color(t.accent).child("⬡"))
867
+ .child(div().flex_none().max_w(140).truncate().text_color(t.muted).child(hubLabel))
868
+ .when(hubRepos.length > 0, (sub) => sub.child(div().flex_none().text_color(t.dim).child(`${hubRepos.length} repos`))))
869
+ .when(!card.hub && Boolean(card.repo), (el) => el
870
+ .child(div().flex_none().text_size(UI.text.tiny).text_color(markColor(t, azure ? "azure" : "github")).child(azure ? "AZ" : "GH"))
871
+ .child(div().flex_none().max_w(160).truncate().text_color(t.muted).child(String(card.repo))))
872
+ .when(Boolean(card.branch), (el) => el
873
+ .child(div().flex_none().text_color(t.dim).child("·"))
874
+ .child(div().flex_1().min_w(0).truncate().text_color(t.dim).child(String(card.branch)))))
875
+ // 4. Who and how long.
876
+ .child(mono(h_flex().gap(6).items_center().text_size(UI.text.small).text_color(t.dim))
877
+ .child(div().flex_1().min_w(0).truncate().child(`${card.agent || "agente"} · ${card.agentState || "listo"}`))
878
+ .when(CONFIG.costs, (el) => el.child(div().flex_none().text_color(t.working).child(money)))
879
+ .when(Boolean(card.elapsed), (el) => el.child(div().flex_none().text_color(t.muted).child(`⏱ ${card.elapsed}`))))
880
+ // Why it stopped, and a hub's check.
817
881
  .when(Boolean(card.failureReason) || Boolean(card.hub && card.analysis), (el) =>
818
- el.child(
819
- v_flex().p(6).rounded(UI.radius).bg(t.popover).border_1().border_color(t.border).gap(3).font_family("JetBrains Mono").text_size(UI.text.tiny)
820
- .when(Boolean(card.failureReason), (sub) =>
821
- sub.child(
822
- h_flex().items_center().justify_between().gap(4)
823
- .child(div().font_semibold().text_color(t.bond_waiting ?? t.blocked).flex_none().child("motivo:"))
824
- .child(div().text_color(t.foreground).truncate().child(String(card.failureReason)))
825
- )
826
- )
827
- .when(Boolean(card.hub), (sub) => {
828
- const analysisReady = !card.analysis || card.analysis.status === "ready" || card.analysis.status === "ok" || (card.analysis.fixable === 0 && !card.hubBlocked);
829
- const analysisLabel = analysisReady ? "análisis: listo" : (card.analysis?.fixable ? `${card.analysis.fixable} arreglos pendientes` : "análisis: revisión");
830
- const analysisColor = analysisReady ? t.working : (t.bond_waiting ?? t.blocked);
831
- return sub.child(
832
- h_flex().items_center().justify_between().gap(4)
833
- .child(div().text_color(t.dim).child("bond hub check:"))
834
- .child(div().font_medium().text_color(analysisColor).child(analysisLabel))
835
- );
836
- })
837
- )
838
- )
839
- .when(Boolean(card.story), (el) => el.child(div().text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.muted).truncate().child(`historia: ${String(card.story)}`)))
840
- .when(Boolean(card.issueUrl) && !card.story, (el) => el.child(dim(`issue: ${String(card.issueUrl).split("/").slice(-3).join("/")}`)))
841
- .children((card.deliveries || []).filter((d) => d.prUrl).map((d) => div().text_size(UI.text.small).font_family("JetBrains Mono").truncate()
842
- .text_color(d.status === "failed" ? t.blocked : t.accent)
843
- .child(String(`${d.name}: PR #${d.prNumber} · ${d.prUrl}`))))
882
+ el.child(mono(v_flex().p(6).rounded(UI.radius).bg(t.popover).border_1().border_color(t.border).gap(3).text_size(UI.text.tiny))
883
+ .when(Boolean(card.failureReason), (sub) => sub.child(h_flex().items_center().gap(4)
884
+ .child(div().font_semibold().text_color(color).flex_none().child("motivo:"))
885
+ .child(div().text_color(t.foreground).truncate().child(String(card.failureReason)))))
886
+ .when(Boolean(card.hub), (sub) => {
887
+ const ready = !card.analysis || card.analysis.status === "ready" || card.analysis.status === "ok" || (card.analysis.fixable === 0 && !card.hubBlocked);
888
+ return sub.child(h_flex().items_center().justify_between().gap(4)
889
+ .child(div().text_color(t.dim).child("bond hub check:"))
890
+ .child(div().font_medium().text_color(ready ? t.working : stateColor(t, "waiting"))
891
+ .child(ready ? "análisis: listo" : (card.analysis?.fixable ? `${card.analysis.fixable} arreglos pendientes` : "análisis: revisión"))));
892
+ })))
893
+ .children((card.deliveries || []).filter((d) => d.prUrl).map((d) => mono(div().text_size(UI.text.small).truncate()
894
+ .text_color(d.status === "failed" ? t.blocked : t.accent)).child(String(`${d.name}: PR #${d.prNumber}`))))
895
+ .when(Boolean(card.prUrl) && (card.deliveries || []).length === 0, (el) => el.child(mono(div().text_size(UI.text.small).text_color(t.accent).truncate()).child(`PR #${card.prNumber}`)))
844
896
  .when(card.verifyFailures > 0 && card.status !== "pr_ready" && card.status !== "finished",
845
- (el) => el.child(dim(`verificación fallida ${card.verifyFailures} ${card.verifyFailures === 1 ? "vez" : "veces"}`)))
846
- .when(Boolean(card.prUrl) && (card.deliveries || []).length === 0, (el) => el.child(div().text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.accent).truncate().child(String(`PR #${card.prNumber} · ${card.prUrl}`))))
847
- // Footer
848
- .child(
849
- div().pt(2).text_size(UI.text.tiny).font_family(UI.fontSans).text_color(t.dim).text_right()
850
- .child(card.run ? "Haz clic para abrir sesión y consola" : "Haz clic para lanzar")
851
- );
897
+ (el) => el.child(mono(div().text_size(UI.text.small).text_color(t.dim)).child(`verificación fallida ${card.verifyFailures} ${card.verifyFailures === 1 ? "vez" : "veces"}`)));
852
898
 
853
899
  return h_flex().id(`card-${card.id}`).flex_none().items_stretch().rounded(UI.radiusLg).overflow_hidden()
854
900
  .bg(isSelected ? t.selected : t.surface)
855
901
  .border_1().border_color(cardBorder)
856
902
  .cursor_pointer().hover((s) => s.bg(t.hover))
903
+ .tooltip(card.run ? "Abrir la sesión" : "Lanzar el ticket")
904
+ .on_hover((h, cx) => {
905
+ const next = h ? card.id : (this.hoveredCard === card.id ? null : this.hoveredCard);
906
+ if (next !== this.hoveredCard) { this.hoveredCard = next; cx.notify(); }
907
+ })
857
908
  .on_click((_e, cx) => this.selectCard(card, cx))
858
909
  .on_mouse_down("right", (_e, cx) => {
859
910
  cx.stop_propagation();
860
911
  this.openCardMenu(card);
861
912
  })
862
- .child(div().w(3).flex_none().bg(color))
863
913
  .child(body);
864
914
  }
865
915
 
866
- // An empty column placeholder matching design
916
+ // An empty column placeholder matching design (only «Listos» on a board with no ticket)
867
917
  emptyColumnPlaceholder(colId) {
868
918
  const t = theme();
869
919
  const conf = {
870
- ready: { icon: "📋", title: "Sin tareas pendientes", subtitle: "Crea un ticket o arrastra aquí" },
920
+ ready: { icon: "📋", title: "Sin tareas pendientes", subtitle: "Crea uno con «+ Nuevo ticket»" },
871
921
  running: { icon: "⚡", title: "Ningún run en proceso", subtitle: null },
872
922
  waiting: { icon: "⏳", title: "Sin tareas en espera", subtitle: null },
873
923
  finished: { icon: "✓", title: "Ninguna tarea finalizada hoy", subtitle: null },
874
924
  error: { icon: "⚠️", title: "Sin errores reportados", subtitle: null },
875
925
  };
876
926
  const c = conf[colId] ?? { icon: "▫", title: "Columna vacía", subtitle: null };
927
+ // Same height in every column, with or without a subtitle (content centered).
877
928
  return v_flex()
878
929
  .w_full()
879
- .p(16)
930
+ .h(EMPTY_COLUMN_H)
931
+ .flex_none()
932
+ .px(12)
880
933
  .gap(4)
881
934
  .items_center()
882
935
  .justify_center()
@@ -893,196 +946,99 @@ export default class BondBoard extends View {
893
946
  );
894
947
  }
895
948
 
896
- column(col) {
949
+ /** One column. All of them share the board's width evenly; an empty one shows a short line
950
+ * under its header (the full hint only in «Listos» while the board has no ticket). With a
951
+ * column chosen in the title bar's counters it is the only one, its cards in a grid, and its
952
+ * header offers going back to every column. */
953
+ column(col, only = null) {
897
954
  const t = theme();
898
955
  const color = stateColor(t, col.id);
899
956
  const count = col.cards.length;
900
- const isWaiting = col.id === "waiting";
901
- const colBorder = (isWaiting && count > 0) ? (t.bond_waiting ?? t.blocked) : t.border;
902
- return v_flex().id(`col-${col.id}`).flex_none().w(UI.columnWidth || 270).h_full().gap(6).p(8).bg(t.chrome).rounded(UI.radiusLg)
957
+ const alone = only === col.id;
958
+ const colBorder = t.border;
959
+ const header = h_flex().items_center().justify_between().gap(6).p(4).border_b(1).border_color(colBorder)
960
+ .child(h_flex().items_center().gap(6).min_w(0)
961
+ .child(div().size(8).rounded(4).flex_none().bg(count > 0 ? color : t.dim))
962
+ .child(div().truncate().text_size(UI.text.small).font_bold().font_family(UI.fontSans).text_color(count > 0 ? color : t.muted).child(col.label.toUpperCase())))
963
+ .child(h_flex().items_center().gap(6).flex_none()
964
+ .when(alone, (el) => el.child(div().id("col-show-all").px(6).py(1).rounded(UI.radius).cursor_pointer()
965
+ .text_size(UI.text.tiny).text_color(t.muted).hover((st) => st.bg(t.hover).text_color(t.foreground))
966
+ .on_click((_e, cx) => { setShared(FILTER_KEY, { ...(shared(FILTER_KEY) ?? {}), column: null }); cx.notify(); })
967
+ .child("Ver todas las columnas")))
968
+ .child(div().px(7).py(1).rounded(12).bg(t.raised).border_1().border_color(count > 0 ? color : t.border)
969
+ .text_size(UI.text.tiny).font_family("JetBrains Mono").font_semibold().text_color(count > 0 ? color : t.dim).child(String(count))));
970
+ const empty = count === 0 && (col.id !== "ready" || this.boardHasCards)
971
+ ? div().w_full().py(14).text_center().text_size(UI.text.small).font_family(UI.fontSans).text_color(t.dim).child(EMPTY_LINE[col.id] ?? "Vacía")
972
+ : this.emptyColumnPlaceholder(col.id);
973
+ return v_flex().id(`col-${col.id}`).flex_1().min_w(0).h_full().gap(6).p(8).bg(t.chrome).rounded(UI.radiusLg)
903
974
  .border_1().border_color(colBorder)
904
975
  .overflow_y_scrollbar()
905
- .child(
906
- h_flex().items_center().justify_between().p(4).border_b(1).border_color(colBorder)
907
- .child(
908
- h_flex().items_center().gap(6)
909
- .child(div().size(8).rounded(4).flex_none().bg(color))
910
- .child(div().text_size(UI.text.small).font_bold().font_family(UI.fontSans).text_color(color).child(col.label.toUpperCase()))
911
- )
912
- .child(
913
- div().px(7).py(1).rounded(12).bg(t.raised).border_1().border_color(count > 0 ? color : t.border)
914
- .text_size(UI.text.tiny).font_family("JetBrains Mono").font_semibold().text_color(count > 0 ? color : t.dim).child(String(count))
915
- )
916
- )
917
- .when(count === 0, (el) => el.child(this.emptyColumnPlaceholder(col.id)))
918
- .children(col.cards.map((c) => this.card(c)));
976
+ .child(header)
977
+ .when(count === 0, (el) => el.child(empty))
978
+ .when(alone && count > 0, (el) => el.child(h_flex().w_full().flex_wrap().gap(8).items_start()
979
+ .children(col.cards.map((c) => div().w(UI.columnWidth + 70).flex_none().child(this.card(c))))))
980
+ .when(!alone, (el) => el.children(col.cards.map((c) => this.card(c))));
919
981
  }
920
982
 
983
+ /** The main action of a card's state, shown as the one primary button of the session
984
+ * header (the rest goes to its «⋯» menu): [id, label, action] or null. */
985
+ primaryAction(card) {
986
+ if (card.canNudge) return ["nudge", "Desbloquear…", () => this.openNudge(card)];
987
+ if (card.canApprove) return ["approve", "Aprobar…", () => this.openApprove(card)];
988
+ if (card.canDeliver) return ["deliver", "Entregar…", () => this.openDeliver(card)];
989
+ if (card.canLaunch) return ["launch", "Lanzar…", () => this.openLaunch(card)];
990
+ return null;
991
+ }
992
+
993
+ /** Session header (one line, 2026-11-23): back · state + title + short branch · Shell, the
994
+ * state's main action and «⋯» (Terminado, PR, copy docker exec, Cancelar, Borrar). The
995
+ * title's tooltip carries the full title, repo and branch. */
921
996
  renderSessionBar(card) {
922
997
  const t = theme();
923
998
  const colColor = stateColor(t, card.column);
999
+ const primary = this.primaryAction(card);
1000
+ const repo = card.hub
1001
+ ? String(card.hub.label || card.hub.url || "hub").replace(/^hub\s+/i, "")
1002
+ : String(card.repo || "");
1003
+ const tip = [String(card.title || card.id), repo && `repo: ${repo}`, card.branch && `rama: ${card.branch}`].filter(Boolean).join("\n");
1004
+ const iconBtn = (id, label, tooltip, action) => div().id(id).flex_none().size(26).rounded(UI.radius)
1005
+ .flex().items_center().justify_center().text_size(UI.text.body).text_color(t.muted).cursor_pointer()
1006
+ .hover((st) => st.bg(t.hover).text_color(t.foreground)).tooltip(tooltip)
1007
+ .on_mouse_down("left", (_e, cx) => cx.stop_propagation())
1008
+ .on_click((_e, cx) => { cx.stop_propagation(); action(cx); })
1009
+ .child(label);
924
1010
  return h_flex()
925
1011
  .id("bond-session-bar")
926
1012
  .size_full()
927
- .px(10)
1013
+ .min_w(0)
1014
+ .px(8)
928
1015
  .gap(8)
929
1016
  .items_center()
930
1017
  .bg(t.chrome)
931
1018
  .border_b(1)
932
1019
  .border_color(t.border)
933
1020
  .text_color(t.foreground)
934
- .font_family("JetBrains Mono")
935
- .child(
936
- h_flex()
937
- .id("btn-back-to-kanban")
938
- .h(26)
939
- .px(8)
940
- .gap(4)
941
- .items_center()
942
- .rounded(UI.radius)
943
- .bg(t.raised)
944
- .border_1()
945
- .border_color(t.border)
946
- .text_size(UI.text.small)
947
- .font_family(UI.fontSans)
948
- .font_semibold()
949
- .text_color(t.accent)
950
- .cursor_pointer()
951
- .hover((s) => s.bg(t.hover).text_color(t.foreground))
952
- .on_click((_e, cx) => this.backToKanban(cx))
953
- .child("← Volver al kanban")
954
- )
955
- .child(div().w(1).h(16).bg(t.border))
956
- .child(
957
- h_flex()
958
- .gap(6)
959
- .items_center()
960
- .child(div().size(7).rounded(4).bg(colColor))
961
- .child(
962
- div()
963
- .font_semibold()
964
- .text_size(UI.text.body)
965
- .font_family(UI.fontSans)
966
- .text_color(t.foreground)
967
- .truncate()
968
- .child(String(card.title || card.id))
969
- )
970
- )
971
- .when(Boolean(card.branch), (el) =>
972
- el.child(
973
- div()
974
- .px(5)
975
- .py(1)
976
- .rounded(UI.radius)
977
- .bg(t.raised)
978
- .border_1()
979
- .border_color(t.border)
980
- .text_size(UI.text.tiny)
981
- .font_family("JetBrains Mono")
982
- .text_color(t.muted)
983
- .truncate()
984
- .child(String(card.branch))
985
- )
986
- )
987
- .when(Boolean(card.repo), (el) => {
988
- let repoText = "";
989
- if (card.hub) {
990
- const raw = (card.hub && Array.isArray(card.hub.repos)) ? card.hub.repos : [];
991
- const rawLabel = String(card.hub.label || card.hub.url || (typeof card.hub === "string" ? card.hub : "hub"));
992
- const chips = cleanRepoChips(raw, rawLabel);
993
- repoText = chips.length > 0 ? `· repos: ${chips.join(", ")}` : `· hub: ${rawLabel.replace(/^hub\s+/i, "")}`;
994
- } else {
995
- repoText = `· repo: ${String(card.repo)}`;
996
- }
997
- return el.child(
998
- div()
999
- .text_size(UI.text.small)
1000
- .font_family("JetBrains Mono")
1001
- .text_color(t.dim)
1002
- .truncate()
1003
- .child(repoText)
1004
- );
1005
- })
1006
- // Copyable docker exec command pill (D23)
1007
- .when(Boolean(card.containerCommand), (el) =>
1008
- el.child(
1009
- h_flex()
1010
- .id(`session-docker-cmd-${card.id}`)
1011
- .items_center()
1012
- .gap(5)
1013
- .px(6)
1014
- .h(24)
1015
- .rounded(UI.radius)
1016
- .bg(t.raised)
1017
- .border_1()
1018
- .border_color(t.border)
1019
- .cursor_pointer()
1020
- .hover((s) => s.bg(t.hover))
1021
- .on_click((_e, cx) => {
1022
- cx.stop_propagation();
1023
- this.copyToClipboard(String(card.containerCommand), cx);
1024
- })
1025
- .child(
1026
- div()
1027
- .font_family("JetBrains Mono")
1028
- .text_size(UI.text.tiny)
1029
- .text_color(t.muted)
1030
- .truncate()
1031
- .child(String(card.containerCommand))
1032
- )
1033
- .child(
1034
- div()
1035
- .text_size(UI.text.tiny)
1036
- .text_color(t.dim)
1037
- .flex_none()
1038
- .child("📋")
1039
- )
1040
- )
1041
- )
1042
- .child(div().flex_1())
1043
- // Action buttons in session bar
1044
- .when(Boolean(card.canShell), (el) =>
1045
- el.child(this.button(`session-shell-${card.id}`, "Shell del contenedor", "plain", (cx) => this.openContainerShell(card, cx), true))
1046
- )
1047
- .when(Boolean(card.canLaunch), (el) =>
1048
- el.child(this.button(`session-launch-${card.id}`, "Lanzar…", "primary", () => this.openLaunch(card), true))
1049
- )
1050
- .when(Boolean(card.canDeliver), (el) =>
1051
- el.child(this.button(`session-deliver-${card.id}`, "Entregar…", "primary", () => this.openDeliver(card), true))
1021
+ .child(iconBtn("btn-back-to-kanban", "←", "Volver al kanban", (cx) => this.backToKanban(cx)))
1022
+ .child(div().w(1).h(16).flex_none().bg(t.border))
1023
+ // State, title and short branch: the only part that shrinks
1024
+ .child(h_flex().flex_1().min_w(0).items_center().gap(8)
1025
+ .child(div().flex_none().font_family("JetBrains Mono").text_size(UI.text.tiny).font_semibold().text_color(colColor)
1026
+ .child(spanishStateLabel(card.column, card.status)))
1027
+ .child(div().id(`session-title-${card.id}`).flex_1().min_w(0).truncate().tooltip(tip)
1028
+ .font_semibold().text_size(UI.text.body).font_family(UI.fontSans).text_color(t.foreground)
1029
+ .child(String(card.title || card.id)))
1030
+ .when(Boolean(card.branch), (el) => el.child(h_flex().flex_none().max_w(180).items_center().gap(4).text_color(t.dim)
1031
+ .child(svg("mods/bond-board/branch.svg").size(12).flex_none())
1032
+ .child(div().min_w(0).truncate().font_family("JetBrains Mono").text_size(UI.text.tiny).child(String(card.branch).replace(/^feat\//, "")))))
1052
1033
  )
1053
- .when(Boolean(card.canNudge), (el) =>
1054
- el.child(this.button(`session-nudge-${card.id}`, "Desbloquear…", "primary", () => this.openNudge(card), true))
1055
- )
1056
- .when(Boolean(card.canFinish), (el) =>
1057
- el.child(this.button(`session-finish-${card.id}`, "Terminado…", "plain", () => this.openFinish(card), true))
1058
- )
1059
- .when(Boolean(card.canApprove), (el) =>
1060
- el.child(this.button(`session-approve-${card.id}`, "Aprobar…", "primary", () => this.openApprove(card), true))
1061
- )
1062
- .when(Boolean(card.prUrl) && (card.deliveries || []).length === 0, (el) =>
1063
- el.child(this.button(`session-pr-${card.id}`, "Abrir PR", "plain", () => this.openPr(card), true))
1064
- )
1065
- .children((card.deliveries || []).filter((d) => d.prUrl).map((d) =>
1066
- this.button(`session-pr-${card.id}-${d.name}`, `PR ${d.name}`, "plain", () => this.openPr({ ...card, prUrl: d.prUrl, prNumber: d.prNumber }), true)))
1067
- .when(Boolean(card.canCancel), (el) =>
1068
- el.child(this.button(`session-cancel-${card.id}`, "Cancelar…", "danger", () => this.openCancel(card), true))
1069
- )
1070
- .child(this.button(`session-delete-${card.id}`, "Borrar…", "danger", () => this.openDelete(card), true))
1071
- // State chip
1072
- .child(
1073
- div()
1074
- .px(6)
1075
- .py(2)
1076
- .rounded(UI.radius)
1077
- .bg(t.raised)
1078
- .border_1()
1079
- .border_color(colColor)
1080
- .text_size(UI.text.tiny)
1081
- .font_family("JetBrains Mono")
1082
- .font_semibold()
1083
- .text_color(colColor)
1084
- .child(spanishStateLabel(card.column, card.status))
1085
- );
1034
+ // Actions: Shell, the state's main action, «⋯»
1035
+ .child(h_flex().flex_none().items_center().gap(6)
1036
+ .when(Boolean(card.canShell), (el) => el.child(this.button(`session-shell-${card.id}`, "Shell", "plain", (cx) => this.openContainerShell(card, cx), true)))
1037
+ .when(Boolean(primary), (el) => el.child(this.button(`session-${primary[0]}-${card.id}`, primary[1], "primary", () => primary[2](), true)))
1038
+ .child(iconBtn(`session-more-${card.id}`, "⋯", "Más acciones", () => openOverlay({
1039
+ mod: "bond-board", kind: "popup", width: 220,
1040
+ props: { view: "card-menu", cardId: card.id, card, session: true },
1041
+ }))));
1086
1042
  }
1087
1043
 
1088
1044
  // El orquestador nunca respondió: tarjeta centrada que explica cómo arreglarlo y permite
@@ -1173,15 +1129,20 @@ export default class BondBoard extends View {
1173
1129
  }
1174
1130
 
1175
1131
  const shown = filterCards(cards, { repo: filter.repo, agent: filter.agent, text: searchVal });
1176
- const columns = groupByColumn(shown);
1132
+ // A column chosen in the title bar's counters is shown alone; «Con error» goes away
1133
+ // while it has nothing.
1134
+ const only = COLUMNS.some((c) => c.id === filter.column) ? filter.column : null;
1135
+ this.boardHasCards = shown.length > 0;
1136
+ const columns = groupByColumn(shown)
1137
+ .filter((col) => (only ? col.id === only : (col.id !== "error" || col.cards.length > 0)));
1177
1138
 
1178
1139
  return v_flex().id("bond-board").size_full().p(10).gap(8).bg(t.canvas).text_color(t.foreground)
1179
1140
  // La API cae tras haber cargado: se conserva el último kanban; el aviso no lleva el crudo.
1180
1141
  .when(Boolean(this.apiError), (el) => el.child(div().px(10).py(6).rounded(UI.radius).bg(t.raised).border_1().border_color(t.blocked)
1181
1142
  .text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.blocked)
1182
1143
  .child(`Sin respuesta del orquestador (${apiUrl()}); se reintenta cada 3 s`)))
1183
- .child(h_flex().id("bond-columns").flex_1().min_h(0).gap(8).items_stretch().overflow_x_scrollbar()
1184
- .children(columns.map((col) => this.column(col))));
1144
+ .child(h_flex().id("bond-columns").w_full().min_w(0).flex_1().min_h(0).gap(8).items_stretch()
1145
+ .children(columns.map((col) => this.column(col, only))));
1185
1146
  }
1186
1147
 
1187
1148
  renderDialog(title, body, actions) {
@@ -1210,7 +1171,7 @@ export default class BondBoard extends View {
1210
1171
  return h_flex().id(id).flex_none().h(24).px(9).items_center().rounded(UI.radius).border_1()
1211
1172
  .border_color(on ? t.accent : t.input).bg(on ? t.selected : t.surface)
1212
1173
  .text_size(12).text_color(on ? t.foreground : t.muted).cursor_pointer()
1213
- .hover((s) => s.bg(t.hover)).on_click((_e, cx) => { action(); cx.notify(); })
1174
+ .hover((s) => s.bg(t.hover)).on_click((_e, cx) => { action(cx); cx.notify(); })
1214
1175
  .child(label);
1215
1176
  }
1216
1177
 
@@ -1219,6 +1180,15 @@ export default class BondBoard extends View {
1219
1180
  // Paso 2: issues abiertas del repo elegido (ready primero, luego las tuyas).
1220
1181
  ghErrorText(e) {
1221
1182
  const msg = String(e?.message ?? e);
1183
+ if (this.issueProvider === "jira") {
1184
+ return msg === "jira_not_configured"
1185
+ ? "No hay credencial de Jira: conéctala en Ajustes (sección Jira) y reintenta."
1186
+ : msg === "jira_authentication_failed"
1187
+ ? "Credencial de Jira inválida: revísala en Ajustes (sección Jira)."
1188
+ : msg === "jira_api_error" || msg.startsWith("HTTP")
1189
+ ? "Jira Cloud no responde ahora mismo; reintenta."
1190
+ : msg;
1191
+ }
1222
1192
  return msg === "github_not_configured"
1223
1193
  ? "No hay sesión de GitHub: conéctala en Ajustes («Usar mi sesión de gh») y reintenta."
1224
1194
  : msg === "github_api_error" || msg.startsWith("HTTP")
@@ -1227,6 +1197,15 @@ export default class BondBoard extends View {
1227
1197
  }
1228
1198
 
1229
1199
  searchIssues(cx) {
1200
+ if (this.issueProvider === "jira") {
1201
+ this.issuePanel = "jira";
1202
+ this.loadPool(cx);
1203
+ // Sin consulta se muestran las asignadas: los resultados de una búsqueda anterior
1204
+ // taparían el refresco de assignedPool (la panel prioriza jiraResults).
1205
+ if (String(this.jiraQuery.value() ?? "").trim() || !this.jiraMine) this.searchJiraOn(cx);
1206
+ else { this.jiraResults = null; cx.notify(); }
1207
+ return;
1208
+ }
1230
1209
  this.issuePanel = "repos";
1231
1210
  this.loadPool(cx);
1232
1211
  if (String(this.repoQuery.value() ?? "").trim()) this.searchReposOn(cx);
@@ -1236,6 +1215,7 @@ export default class BondBoard extends View {
1236
1215
  loadPool(cx) {
1237
1216
  if (this.assignedPool || this.poolLoading) { cx.notify(); return; }
1238
1217
  this.poolLoading = true;
1218
+ this.reposError = null;
1239
1219
  cx.notify();
1240
1220
  cx.spawn(async (cx) => {
1241
1221
  try {
@@ -1250,6 +1230,34 @@ export default class BondBoard extends View {
1250
1230
  });
1251
1231
  }
1252
1232
 
1233
+ /** «Asignadas a mí» on/off: back to your list, or the site's search with the same text. */
1234
+ toggleJiraMine(cx) {
1235
+ this.jiraMine = !this.jiraMine;
1236
+ this.jiraResults = null;
1237
+ const term = String(this.jiraQuery.value() ?? "").trim();
1238
+ if (term || !this.jiraMine) this.searchJiraOn(cx);
1239
+ else { this.loadPool(cx); cx.notify(); }
1240
+ }
1241
+
1242
+ searchJiraOn(cx) {
1243
+ const term = String(this.jiraQuery.value() ?? "").trim();
1244
+ if ((!term && this.jiraMine) || this.jiraSearching) return;
1245
+ this.jiraSearching = true;
1246
+ this.reposError = null;
1247
+ cx.notify();
1248
+ cx.spawn(async (cx) => {
1249
+ try {
1250
+ const data = await searchJiraIssues(api, { q: term, mine: this.jiraMine });
1251
+ this.jiraResults = Array.isArray(data?.issues) ? data.issues : [];
1252
+ } catch (e) {
1253
+ this.reposError = this.ghErrorText(e);
1254
+ } finally {
1255
+ this.jiraSearching = false;
1256
+ cx.notify();
1257
+ }
1258
+ });
1259
+ }
1260
+
1253
1261
  searchReposOn(cx) {
1254
1262
  const term = String(this.repoQuery.value() ?? "").trim();
1255
1263
  if (!term || this.reposLoading) return;
@@ -1347,17 +1355,151 @@ export default class BondBoard extends View {
1347
1355
  .child("Bondificar el repo si no lo está (bond init + commit propio)");
1348
1356
  }
1349
1357
 
1350
- pickIssue(it) {
1358
+ // P4: «Docker en el run». Avisa del riesgo (contenedor privilegiado) en la propia casilla.
1359
+ dockerRow() {
1360
+ const t = theme();
1361
+ return v_flex().gap(2)
1362
+ .child(h_flex()
1363
+ .id("ticket-docker")
1364
+ .gap(7).items_center().px(2).py(3).cursor_pointer()
1365
+ .text_color(t.foreground).font_family(UI.fontSans).text_size(UI.text.small)
1366
+ .on_click((_e, cx) => {
1367
+ this.docker = !this.docker;
1368
+ this.dockerTouched = true;
1369
+ cx.notify();
1370
+ })
1371
+ .child(div().w(13).h(13).rounded(3).border_1()
1372
+ .border_color(this.docker ? t.accent : t.border)
1373
+ .bg(this.docker ? t.accent : t.input)
1374
+ .child(div().text_size(10).text_center().text_color(t.chrome).child(this.docker ? "✓" : "")))
1375
+ .child("Docker en el run (devcontainers, compose…)")
1376
+ .when(Boolean(this.devcontainerRepo), (el) => el.child(div().id("ticket-docker-devcontainer").text_size(UI.text.tiny).text_color(t.accent).child("el repo trae devcontainer"))))
1377
+ .when(this.docker, (el) => el.child(div().pl(22).text_size(UI.text.tiny).font_family(UI.fontSans).text_color(t.dim)
1378
+ .child("El contenedor del run va privilegiado: un agente podría tomar este equipo (en Windows y Mac, la VM de Docker Desktop). La imagen necesita el grupo «Docker en el run».")));
1379
+ }
1380
+
1381
+ /** P4: asks the orchestrator whether the repo carries a devcontainer; pre-ticks Docker. */
1382
+ checkDevcontainer(cx) {
1383
+ const m = /github\.com[/:]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(String(this.fields.repo.value() ?? "").trim());
1384
+ if (!m || this.mode === "list") return;
1385
+ const base = String(this.fields.base?.value?.() ?? "").trim();
1386
+ const key = `${m[1]}/${m[2]}@${base}`;
1387
+ if (key === this.devcontainerChecked) return;
1388
+ this.devcontainerChecked = key;
1389
+ cx.spawn(async (cx) => {
1390
+ try {
1391
+ const q = `owner=${encodeURIComponent(m[1])}&repo=${encodeURIComponent(m[2])}${base ? `&ref=${encodeURIComponent(base)}` : ""}`;
1392
+ const res = await api(`/repos/devcontainer?${q}`);
1393
+ if (key !== this.devcontainerChecked) return;
1394
+ this.devcontainerRepo = res?.devcontainer ? `${m[1]}/${m[2]}` : null;
1395
+ if (res?.devcontainer && !this.dockerTouched) this.docker = true;
1396
+ this.hubDetected = res?.hub ? (this.repoSel?.url ?? String(this.fields.repo.value() ?? "").trim()) : null;
1397
+ this.applyHubMode();
1398
+ cx.notify();
1399
+ } catch {}
1400
+ });
1401
+ }
1402
+
1403
+ /** Hub detectado (y no tratado como repo): modo hub con ese repo; si no, un repo. */
1404
+ applyHubMode() {
1405
+ if (this.mode === "list") return;
1406
+ const url = this.repoSel?.url ?? String(this.fields.repo.value() ?? "").trim();
1407
+ const hub = Boolean(this.hubDetected) && this.hubDetected === url && !this.hubAsRepo;
1408
+ this.mode = hub ? "hub" : "repo";
1409
+ this.fields.hub.set_value(hub ? url : "");
1410
+ }
1411
+
1412
+ pickIssue(it, cx) {
1351
1413
  this.pickedIssue = it;
1352
1414
  this.issuePanel = null;
1353
1415
  this.fields.issue.set_value(it.url ?? "");
1354
- if (it.title) this.fields.title.set_value(it.title); // D4: automático y editable
1355
- if (this.mode === "repo" && it.owner && it.repo) {
1356
- this.fields.repo.set_value(`https://github.com/${it.owner}/${it.repo}`);
1416
+ const title = it.title || it.summary || "";
1417
+ if (title) this.fields.title.set_value(title); // D4: automático y editable
1418
+ const desc = it.description || it.body || "";
1419
+ if (it.key) {
1420
+ this.pickedIssue.body = title + (desc ? `\n\n${desc}` : "");
1421
+ }
1422
+ // Qué: the story box gets the issue's text (editable); the list folds to this issue.
1423
+ this.story.set_value(String(this.pickedIssue.body ?? desc ?? ""));
1424
+ this.choosing = false;
1425
+ // Dónde: a GitHub issue only preloads its repo, and only when none is chosen yet.
1426
+ if (it.owner && it.repo && !this.repoSel) {
1427
+ this.selectRepo({ url: `https://github.com/${it.owner}/${it.repo}`, label: `${it.owner}/${it.repo}`, host: "github" });
1428
+ if (cx) this.checkDevcontainer(cx);
1357
1429
  }
1358
1430
  this.errors = {};
1359
1431
  }
1360
1432
 
1433
+ // ---- Alta en tres bloques: Dónde (repos) ---------------------------------------------
1434
+
1435
+ /** Asks the orchestrator for repos (favorites, recent, Azure, GitHub) for the query. */
1436
+ suggestRepos(cx, q) {
1437
+ this.repoSuggestFor = q;
1438
+ this.repoSuggestLoading = true;
1439
+ cx.notify();
1440
+ cx.spawn(async (cx) => {
1441
+ try {
1442
+ const res = await api(`/repos/suggest?q=${encodeURIComponent(q)}`);
1443
+ if (this.repoSuggestFor !== q) return;
1444
+ this.repoSuggest = Array.isArray(res?.repos) ? res.repos : [];
1445
+ this.repoSuggestErrors = res?.errors ?? {};
1446
+ } catch (e) {
1447
+ this.repoSuggestErrors = { api: String(e?.message ?? e) };
1448
+ }
1449
+ this.repoSuggestLoading = false;
1450
+ cx.notify();
1451
+ });
1452
+ }
1453
+
1454
+ /** On typing: the shown list filters at once; the search (GitHub) waits a little. */
1455
+ suggestReposSoon(cx) {
1456
+ const asked = String(this.repoQuery.value() ?? "").trim();
1457
+ cx.notify();
1458
+ if (asked === this.repoSuggestFor) return;
1459
+ cx.spawn(async (cx) => {
1460
+ await cx.sleep(350);
1461
+ if (String(this.repoQuery.value() ?? "").trim() !== asked) return;
1462
+ this.suggestRepos(cx, asked);
1463
+ });
1464
+ }
1465
+
1466
+ selectRepo(r) {
1467
+ if (this.mode === "list") {
1468
+ if (r.host !== "github") {
1469
+ this.errors = { ...this.errors, repos: "Un hub solo admite repos de GitHub" };
1470
+ return;
1471
+ }
1472
+ if (!this.listRepos.some((x) => x.url === r.url)) this.listRepos = [...this.listRepos, { url: r.url, label: r.label }];
1473
+ return;
1474
+ }
1475
+ this.repoSel = r;
1476
+ this.repoChoosing = false;
1477
+ // Otro repo: su detección empieza de cero (checkDevcontainer la repite).
1478
+ this.hubDetected = null;
1479
+ this.hubAsRepo = false;
1480
+ this.devcontainerChecked = null;
1481
+ this.devcontainerRepo = null;
1482
+ this.applyHubMode();
1483
+ this.fields.repo.set_value(r.url);
1484
+ if (r.base) this.fields.base.set_value(r.base);
1485
+ this.errors = { ...this.errors, repo: undefined };
1486
+ }
1487
+
1488
+ /** ★: adds or removes the repo from the favorites (Ajustes keeps the list too). */
1489
+ toggleFavorite(cx, r) {
1490
+ const current = (this.repoSuggest ?? []).filter((x) => x.favorite).map((x) => x.url);
1491
+ const next = r.favorite ? current.filter((u) => u !== r.url) : [...current, r.url];
1492
+ cx.spawn(async (cx) => {
1493
+ try {
1494
+ await api("/repos/favorites", { method: "PUT", body: { favorites: next } });
1495
+ this.suggestRepos(cx, String(this.repoQuery.value() ?? "").trim());
1496
+ } catch (e) {
1497
+ this.error = String(e?.message ?? e);
1498
+ cx.notify();
1499
+ }
1500
+ });
1501
+ }
1502
+
1361
1503
  useIssueUrl() {
1362
1504
  const url = String(this.fields.issue.value() ?? "").trim();
1363
1505
  if (!url) {
@@ -1411,13 +1553,15 @@ export default class BondBoard extends View {
1411
1553
 
1412
1554
  issueRow(it) {
1413
1555
  const t = theme();
1414
- return h_flex().id(`iss-row-${it.owner}-${it.repo}-${it.number}`).h(26).px(8).gap(6).items_center()
1556
+ const id = it.key ? `iss-row-${it.key}` : `iss-row-${it.owner}-${it.repo}-${it.number}`;
1557
+ const label = it.key ?? `#${it.number}`;
1558
+ return h_flex().id(id).h(26).px(8).gap(6).items_center()
1415
1559
  .rounded(UI.radius).text_size(12).font_family("JetBrains Mono").cursor_pointer()
1416
1560
  .text_color(t.foreground).hover((s) => s.bg(t.hover))
1417
- .on_click((_e, cx) => { this.pickIssue(it); cx.notify(); })
1418
- .child(div().w(12).text_center().text_color(it.ready ? t.accent : t.dim).child(it.ready ? "✓" : "#"))
1419
- .child(div().w(46).text_color(t.dim).child(`#${it.number}`))
1420
- .child(div().flex_1().truncate().child(String(it.title ?? "")))
1561
+ .on_click((_e, cx) => { this.pickIssue(it, cx); cx.notify(); })
1562
+ .child(div().w(12).text_center().text_color(it.ready ? t.accent : t.dim).child(it.ready ? "✓" : (it.key ? "●" : "#")))
1563
+ .child(div().w(it.key ? 75 : 46).text_color(t.dim).child(label))
1564
+ .child(div().flex_1().truncate().child(String(it.title ?? it.summary ?? "")))
1421
1565
  .when(Boolean(it.ready), (el) => el.child(div().text_size(UI.text.tiny).text_color(t.accent).child("ready")));
1422
1566
  }
1423
1567
 
@@ -1438,120 +1582,524 @@ export default class BondBoard extends View {
1438
1582
  }));
1439
1583
  }
1440
1584
 
1441
- renderCreate(p) {
1585
+ // ---- Alta en tres bloques (Qué · Dónde · Quién; decisión 2026-11-24) -----------------
1586
+
1587
+ createBlock(n, title, hint, children, error) {
1588
+ const t = theme();
1589
+ return v_flex().id(`create-block-${n}`).gap(8).px(14).py(11).rounded(UI.radiusLg).border_1()
1590
+ .border_color(error ? t.blocked : t.border).bg(t.background)
1591
+ .child(h_flex().gap(10).items_center()
1592
+ .child(div().w(22).h(22).rounded(11).bg(t.accent).flex().items_center().justify_center()
1593
+ .text_size(11).font_semibold().text_color(t.accent_foreground ?? t.background).child(String(n)))
1594
+ .child(div().text_size(UI.text.title + 1).font_family(UI.fontSans).font_semibold().child(title))
1595
+ .child(div().flex_1())
1596
+ .when(Boolean(hint), (el) => el.child(div().text_size(UI.text.small).font_family(UI.fontSans).text_color(t.dim).child(hint))))
1597
+ .children(children)
1598
+ .when(Boolean(error), (el) => el.child(div().text_size(UI.text.small).text_color(t.blocked).child(error)));
1599
+ }
1600
+
1601
+ /** P3: search open PRs in GitHub and Azure DevOps. */
1602
+ searchPrs(cx, q, repo = "") {
1603
+ const host = this.prHost === "todas" ? "" : this.prHost;
1604
+ const mine = this.prMine === "todas" ? "" : this.prMine;
1605
+ const key = `${repo}\0${q}\0${host}\0${mine}`;
1606
+ this.prSearchFor = key;
1607
+ this.prSearching = true;
1608
+ this.prResolveError = null;
1609
+ cx.notify();
1610
+ cx.spawn(async (cx) => {
1611
+ try {
1612
+ const res = await searchPullRequests(api, { q, repo, host, mine });
1613
+ if (this.prSearchFor !== key) return;
1614
+ this.prResults = Array.isArray(res?.items) ? res.items : [];
1615
+ this.prSearchErrors = res?.errors ?? {};
1616
+ } catch (e) {
1617
+ if (this.prSearchFor !== key) return;
1618
+ this.prSearchErrors = { api: String(e?.message ?? e) };
1619
+ }
1620
+ this.prSearching = false;
1621
+ cx.notify();
1622
+ });
1623
+ }
1624
+
1625
+ /** P3: debounced PR search on typing; pasted URLs wait for «Usar URL» or Enter. */
1626
+ searchPrsSoon(cx) {
1627
+ const raw = String(this.prQuery.value() ?? "").trim();
1628
+ cx.notify();
1629
+ if (/^https?:\/\//.test(raw)) return;
1630
+ const { q, repo } = parsePrSearchInput(raw);
1631
+ const key = `${repo}\0${q}\0${this.prHost === "todas" ? "" : this.prHost}\0${this.prMine === "todas" ? "" : this.prMine}`;
1632
+ if (key === this.prSearchFor) return;
1633
+ cx.spawn(async (cx) => {
1634
+ await cx.sleep(350);
1635
+ const now = String(this.prQuery.value() ?? "").trim();
1636
+ if (now !== raw || /^https?:\/\//.test(now)) return;
1637
+ this.searchPrs(cx, q, repo);
1638
+ });
1639
+ }
1640
+
1641
+ /** P3/P5: resolve a PR or branch URL, validate it (no forks/closed) and fill Qué/Dónde. */
1642
+ resolvePr(url, cx) {
1643
+ const target = String(url ?? "").trim();
1644
+ if (!target) return;
1645
+ this.prResolving = true;
1646
+ this.prResolvingUrl = target;
1647
+ this.prResolveError = null;
1648
+ cx.notify();
1649
+ cx.spawn(async (cx) => {
1650
+ try {
1651
+ const info = await resolvePullRequest(api, target);
1652
+ if (info?.is_fork || (info?.state && info.state !== "open")) {
1653
+ const reason = info.is_fork
1654
+ ? "fork, solo lectura"
1655
+ : info.state === "merged" ? "mergeada" : "cerrada";
1656
+ this.prDisabled = { ...this.prDisabled, [target]: reason, ...(info.url ? { [info.url]: reason } : {}) };
1657
+ this.prResolveError = formatSourceError(info.is_fork ? "source_fork" : "source_closed");
1658
+ } else {
1659
+ this.pickedPr = info;
1660
+ this.pickedPrHub = info.is_hub
1661
+ ? (info.hub?.url ?? info.repo_url ?? "")
1662
+ : (Array.isArray(info.hubs) && info.hubs.length > 0 ? (info.hub?.url ?? info.hubs[0].url) : "");
1663
+ this.prChoosing = false;
1664
+ this.prResolveError = null;
1665
+ this.fields.title.set_value(info.title || info.head || "");
1666
+ this.story.set_value(String(info.body ?? ""));
1667
+ this.errors = {};
1668
+ }
1669
+ } catch (e) {
1670
+ this.prResolveError = formatSourceError(e);
1671
+ }
1672
+ this.prResolving = false;
1673
+ this.prResolvingUrl = null;
1674
+ cx.notify();
1675
+ });
1676
+ }
1677
+
1678
+ /** P5: pick one of the hubs proposed for a repo PR (or none for single-repo). */
1679
+ selectPrHub(hubUrl, cx) {
1680
+ const pr = this.pickedPr;
1681
+ if (!pr || pr.is_hub) return;
1682
+ this.pickedPrHub = hubUrl || "";
1683
+ if (!hubUrl || pr.hub?.url === hubUrl) {
1684
+ cx.notify();
1685
+ return;
1686
+ }
1687
+ this.prHubLoading = true;
1688
+ cx.notify();
1689
+ cx.spawn(async (cx) => {
1690
+ try {
1691
+ const updated = await resolvePullRequest(api, pr.url, hubUrl);
1692
+ if (this.pickedPr?.url === pr.url && this.pickedPrHub === hubUrl && updated?.hub) {
1693
+ this.pickedPr = { ...this.pickedPr, hub: updated.hub };
1694
+ }
1695
+ } catch {}
1696
+ this.prHubLoading = false;
1697
+ cx.notify();
1698
+ });
1699
+ }
1700
+
1701
+ createPrRow(pr, picked = false) {
1702
+ const t = theme();
1703
+ const disabledReason = this.prDisabled?.[pr.url]
1704
+ || (pr.is_fork ? "fork, solo lectura" : pr.state && pr.state !== "open" ? (pr.state === "merged" ? "mergeada" : "cerrada") : null);
1705
+ const disabled = Boolean(disabledReason);
1706
+ const resolvingThis = this.prResolving && this.prResolvingUrl === pr.url;
1707
+ const label = pr.number ? `#${pr.number}` : (pr.head ? "rama" : "PR");
1708
+ let row = h_flex().id(`pr-row-${slug(pr.url || `${pr.repo_label}-${pr.number}`)}`)
1709
+ .h(30).px(8).gap(8).items_center().rounded(UI.radius).min_w(0)
1710
+ .bg(picked ? t.selected : t.background).border_1().border_color(picked ? t.accent : t.background);
1711
+ if (!disabled && !picked) {
1712
+ row = row.cursor_pointer().hover((s) => s.bg(t.hover)).on_click((_e, cx) => this.resolvePr(pr.url, cx));
1713
+ }
1714
+ return row
1715
+ .child(this.hostBadge(pr.host))
1716
+ .child(div().w(48).flex_none().text_size(12).font_semibold().text_color(disabled ? t.dim : t.accent).child(label))
1717
+ .child(div().flex_1().min_w(0).truncate().text_size(12.5).font_family(UI.fontSans)
1718
+ .text_color(disabled ? t.dim : t.foreground).child(String(pr.title || pr.head || pr.url || "")))
1719
+ .when(Boolean(pr.repo_label), (el) => el.child(div().flex_none().text_size(UI.text.small).text_color(t.dim).child(String(pr.repo_label))))
1720
+ .when(Boolean(pr.is_hub), (el) => el.child(div().flex_none().px(6).h(18).rounded(4).flex().items_center().border_1().border_color(t.accent)
1721
+ .text_size(10).text_color(t.accent).child("hub")))
1722
+ .when(Boolean(pr.draft) && !disabled, (el) => el.child(div().flex_none().px(6).h(18).rounded(4).flex().items_center().border_1().border_color(t.border)
1723
+ .text_size(10).text_color(t.muted).child("borrador")))
1724
+ .when(resolvingThis, (el) => el.child(div().flex_none().text_size(UI.text.small).text_color(t.dim).child("resolviendo…")))
1725
+ .when(disabled, (el) => el.child(div().flex_none().px(6).h(18).rounded(4).flex().items_center().border_1().border_color(t.blocked)
1726
+ .text_size(10).text_color(t.blocked).child(disabledReason)));
1727
+ }
1728
+
1729
+ hostBadge(host) {
1730
+ const t = theme();
1731
+ const azure = host === "azure";
1732
+ return div().flex_none().px(6).h(18).rounded(4).flex().items_center()
1733
+ .bg(azure ? "#0078d422" : "#8b5cf622").text_size(10).font_semibold()
1734
+ .text_color(markColor(t, azure ? "azure" : "github")).child(azure ? "Azure" : "GitHub");
1735
+ }
1736
+
1737
+ /** One issue of the «Qué» list (GitHub #n or Jira KEY), clickable. */
1738
+ createIssueRow(it, picked = false) {
1739
+ const t = theme();
1740
+ const label = it.key ?? (it.number ? `#${it.number}` : "URL");
1741
+ const where = it.key ? (it.project ?? "") : (it.owner && it.repo ? `${it.owner}/${it.repo}` : "");
1742
+ return h_flex().id(it.key ? `iss-row-${it.key}` : `iss-row-${it.owner}-${it.repo}-${it.number}`)
1743
+ .h(30).px(8).gap(10).items_center().rounded(UI.radius).cursor_pointer().min_w(0)
1744
+ .bg(picked ? t.selected : t.background).border_1().border_color(picked ? t.accent : t.background)
1745
+ .hover((s) => s.bg(t.hover)).on_click((_e, cx) => { this.pickIssue(it, cx); cx.notify(); })
1746
+ .child(div().w(it.key ? 72 : 50).flex_none().text_size(12).font_semibold().text_color(t.accent).child(label))
1747
+ .child(div().flex_1().min_w(0).truncate().text_size(12.5).font_family(UI.fontSans).child(String(it.title ?? it.summary ?? it.url ?? "")))
1748
+ .when(Boolean(where), (el) => el.child(div().flex_none().text_size(UI.text.small).text_color(t.dim).child(where)))
1749
+ .when(Boolean(it.status), (el) => el.child(div().flex_none().px(6).h(18).rounded(4).flex().items_center().border_1().border_color(t.border)
1750
+ .text_size(10).text_color(t.muted).child(String(it.status))))
1751
+ .when(Boolean(it.ready), (el) => el.child(div().flex_none().text_size(UI.text.tiny).text_color(t.accent).child("ready")));
1752
+ }
1753
+
1754
+ /** One repo of the «Dónde» list: ★ toggles the favorite, the row picks it. */
1755
+ createRepoRow(r, picked = false) {
1756
+ const t = theme();
1757
+ return h_flex().id(`repo-row-${slug(r.url)}`).h(30).px(8).gap(10).items_center().rounded(UI.radius).cursor_pointer().min_w(0)
1758
+ .bg(picked ? t.selected : t.background).border_1().border_color(picked ? t.accent : t.background)
1759
+ .hover((s) => s.bg(t.hover)).on_click((_e, cx) => { this.selectRepo(r); this.checkDevcontainer(cx); cx.notify(); })
1760
+ .child(div().id(`repo-fav-${slug(r.url)}`).w(16).flex_none().text_size(13).cursor_pointer()
1761
+ .text_color(r.favorite ? markColor(t, "star") : t.dim).tooltip(r.favorite ? "Quitar de favoritos" : "Añadir a favoritos")
1762
+ .on_click((_e, cx) => { cx.stop_propagation(); this.toggleFavorite(cx, r); })
1763
+ .child(r.favorite ? "★" : r.recent ? "↺" : "☆"))
1764
+ .child(this.hostBadge(r.host))
1765
+ .child(div().flex_1().min_w(0).truncate().text_size(12.5).child(String(r.label ?? r.url)))
1766
+ .when(Boolean(r.base), (el) => el.child(div().flex_none().text_size(UI.text.small).text_color(t.dim).child(r.base)));
1767
+ }
1768
+
1769
+ createWhat() {
1442
1770
  const t = theme();
1443
1771
  const e = this.errors ?? {};
1444
- const input = (k) => Input.new(this.fields[k]).h(30).px(9).rounded(UI.radius).border_1()
1445
- .border_color(e[k] ? t.blocked : t.input).bg(t.background).text_size(12.5);
1446
- const area = (k, h) => Textarea.new(this.fields[k]).h(h).p(8).rounded(UI.radius).border_1()
1447
- .border_color(e[k] ? t.blocked : t.input).bg(t.background).text_size(12);
1448
- const where = this.mode === "repo"
1449
- ? this.field("Repo de GitHub", input("repo"), e.repo)
1450
- : this.mode === "list"
1451
- ? this.field("Repos (se crea un hub con ellos)", area("repos", 70), e.repos)
1452
- : this.field("Hub existente", input("hub"), e.hub);
1453
-
1454
- // Panel de búsqueda combinada: primero repos, luego las issues del repo elegido.
1455
- // Filtro «contiene»: cada palabra escrita debe aparecer (en cualquier orden); los
1456
- // separadores no importan — «bond app» encuentra «bond-app».
1457
- const lq = (s) => String(s ?? "").trim().toLowerCase();
1772
+ if (this.createKind === "pr") {
1773
+ const rows = [];
1774
+ if (this.pickedPr && !this.prChoosing) {
1775
+ rows.push(h_flex().gap(8).items_center()
1776
+ .child(div().flex_1().min_w(0).child(this.createPrRow(this.pickedPr, true)))
1777
+ .child(this.button("pr-change", "Cambiar", "plain", () => { this.prChoosing = true; })));
1778
+ } else {
1779
+ const q = String(this.prQuery.value() ?? "").trim();
1780
+ const looksUrl = /^https?:\/\//.test(q);
1781
+ const list = this.prResults ?? [];
1782
+ const loading = this.prSearching || this.prResolving;
1783
+ const errList = Object.entries(this.prSearchErrors ?? {}).map(([k, v]) => ({
1784
+ host: k,
1785
+ text: `${k === "azure" ? "Azure" : k === "github" ? "GitHub" : "API"}: ${formatSourceError(v)}`,
1786
+ notConfigured: String(v).endsWith("_not_configured"),
1787
+ }));
1788
+ rows.push(h_flex().gap(6).items_center()
1789
+ .child(div().flex_1().child(Input.new(this.prQuery).h(28).px(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)))
1790
+ .when(looksUrl, (el) => el.child(this.button("pr-use-url", this.prResolving ? "Resolviendo…" : "Usar URL", "plain", (cx) => this.resolvePr(q, cx)))));
1791
+ // Filtros: dónde (GitHub / Azure) y de quién (asignadas a mí / mías). Cambiarlos repite la búsqueda.
1792
+ const refilter = (cx) => {
1793
+ if (looksUrl) return;
1794
+ const { q: words, repo } = parsePrSearchInput(q);
1795
+ this.searchPrs(cx, words, repo);
1796
+ };
1797
+ const hostChip = (id, label) => this.choice(`prh-${id}`, label, this.prHost === id, (cx) => { if (this.prHost === id) return; this.prHost = id; refilter(cx); });
1798
+ const mineChip = (id, label) => this.choice(`prm-${id}`, label, this.prMine === id, (cx) => { if (this.prMine === id) return; this.prMine = id; refilter(cx); });
1799
+ rows.push(h_flex().gap(12).items_center().flex_wrap()
1800
+ .child(h_flex().gap(4).child(hostChip("todas", "Todas")).child(hostChip("github", "GitHub")).child(hostChip("azure", "Azure")))
1801
+ .child(div().w(1).h(16).bg(t.border))
1802
+ .child(h_flex().gap(4).child(mineChip("todas", "Todas")).child(mineChip("assigned", "Asignadas a mí")).child(mineChip("author", "Mías"))));
1803
+ rows.push(v_flex().id("pr-list").max_h(150).overflow_y_scrollbar().gap(1)
1804
+ .when(loading, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim).child(this.prResolving ? "Resolviendo URL…" : "Buscando PRs…")))
1805
+ .when(Boolean(this.prResolveError), (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.blocked).child(this.prResolveError)))
1806
+ .children(errList.map((err) => h_flex().gap(8).items_center().px(6).py(2)
1807
+ .child(div().flex_1().text_size(UI.text.small).text_color(t.blocked).child(err.text))
1808
+ .when(err.notConfigured && (err.host === "github" || err.host === "azure"), (el) =>
1809
+ el.child(this.button(`pr-open-settings-${err.host}`, "Abrir Ajustes", "plain", () => openOverlay(settingsOverlay({ section: err.host })))))))
1810
+ .when(!loading && !this.prResolveError && errList.length === 0 && list.length === 0, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim)
1811
+ .child("No hay PRs abiertas que coincidan: busca por texto, owner/repo o pega la URL de una PR o rama")))
1812
+ .children(list.slice(0, 40).map((pr) => this.createPrRow(pr))));
1813
+ }
1814
+ rows.push(h_flex().gap(10).items_start()
1815
+ .child(v_flex().flex_1().gap(3).child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child("Título"))
1816
+ .child(Input.new(this.fields.title).h(30).px(9).rounded(UI.radius).border_1().border_color(e.title ? t.blocked : t.input).bg(t.background).text_size(12.5))
1817
+ .when(Boolean(e.title), (el) => el.child(div().text_size(UI.text.small).text_color(t.blocked).child(e.title)))));
1818
+ const storyHint = this.pickedPr
1819
+ ? (this.pickedPr.kind === "pr" && this.pickedPr.number ? `desde PR #${this.pickedPr.number}` : `desde rama ${this.pickedPr.head}`)
1820
+ : "elige una PR o rama";
1821
+ rows.push(v_flex().gap(3)
1822
+ .child(h_flex().items_center()
1823
+ .child(div().flex_1().text_size(UI.text.small).font_medium().text_color(t.muted).child("Historia (lo que lee el agente; editable)"))
1824
+ .child(div().text_size(UI.text.small).text_color(t.dim).child(storyHint)))
1825
+ .child(Textarea.new(this.story).h(80).p(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)));
1826
+ return this.createBlock(1, "Qué", "de qué PR o rama parte el ticket", rows, e.source_pr_url);
1827
+ }
1828
+
1829
+ const lq = (s) => String(s ?? "").trim().toLowerCase().split(/\s+/).filter(Boolean);
1458
1830
  const has = (text, words) => words.every((w) => String(text).toLowerCase().includes(w));
1459
- const rq = lq(this.repoQuery.value()).split(/\s+/).filter(Boolean);
1460
- const iq = lq(this.issueQuery.value()).split(/\s+/).filter(Boolean);
1461
- const repos = this.issueRepoChoices().filter((g) => has(g.key, rq));
1462
- const shown = (this.issues ?? [])
1463
- .filter((it) => `${it.owner}/${it.repo}` === this.issueRepo)
1464
- .filter((it) => has(`${it.title} #${it.number}`, iq));
1465
- const withStatus = (el, loading, error, loadingText, tag) => el
1466
- .when(Boolean(loading), (x) => x.child(div().px(6).py(2).text_size(UI.text.small).text_color(t.dim).child(String(loadingText))))
1467
- .when(Boolean(error), (x) => x.child(h_flex().gap(8).items_center()
1468
- .child(div().flex_1().text_size(UI.text.small).text_color(t.blocked).child(String(error)))
1469
- .when(String(error).includes("Ajustes"), (y) => y.child(this.button(`iss-open-settings-${tag}`, "Abrir Ajustes", "plain", () => run("layout.toggle", { id: "settings" }))))));
1470
- const urlRow = h_flex().gap(6).items_center()
1471
- .child(div().flex_1().child(Input.new(this.fields.issue).h(26).px(8).rounded(UI.radius).border_1()
1472
- .border_color(e.issue ? t.blocked : t.input).bg(t.background).text_size(11)))
1473
- .child(this.button("iss-use-url", "Usar URL", "plain", () => this.useIssueUrl()));
1474
- let panel = null;
1475
- if (this.issuePanel === "repos") {
1476
- panel = withStatus(v_flex().id("iss-repos-panel").gap(6).p(8).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
1477
- .child(h_flex().gap(6).items_center()
1478
- .child(div().flex_1().child(Input.new(this.repoQuery).h(26).px(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)))
1479
- .child(this.button("iss-repo-go", this.reposLoading ? "Buscando…" : "Buscar", "plain", (cx) => this.searchReposOn(cx))))
1480
- .child(v_flex().max_h(170).overflow_y_scrollbar().gap(1)
1481
- .when(!this.reposLoading && !this.poolLoading && !this.reposError && repos.length === 0, (el) => el.child(
1482
- div().px(6).py(3).text_size(UI.text.small).text_color(t.dim).child(rq.length ? "Ningún repo coincide; pulsa Buscar para mirar en GitHub" : "No tienes issues asignadas abiertas")))
1483
- .children(repos.map((g) => this.repoRow(g))))
1484
- .child(urlRow),
1485
- this.reposLoading || this.poolLoading, this.reposError,
1486
- this.reposLoading ? "Buscando repositorios en GitHub…" : "Buscando tus issues asignadas…", "repos");
1487
- } else if (this.issuePanel === "issues") {
1488
- panel = withStatus(v_flex().id("iss-issues-panel").gap(6).p(8).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
1489
- .child(h_flex().gap(6).items_center()
1490
- .child(this.button("iss-back-repos", "←", "plain", () => { this.issuePanel = "repos"; }))
1491
- .child(div().text_size(12).font_medium().child(String(this.issueRepo ?? "")))
1492
- .child(div().flex_1())
1493
- .child(div().w(220).child(Input.new(this.issueQuery).h(26).px(8).rounded(UI.radius).border_1()
1494
- .border_color(t.input).bg(t.background).text_size(12))))
1495
- .child(v_flex().max_h(170).overflow_y_scrollbar().gap(1)
1496
- .when(!this.issuesLoading && !this.issuesError && shown.length === 0, (el) => el.child(
1497
- div().px(6).py(3).text_size(UI.text.small).text_color(t.dim).child(iq.length ? "Ninguna issue coincide" : "Sin issues abiertas en este repo")))
1498
- .children(shown.map((it) => this.issueRow(it))))
1499
- .child(urlRow),
1500
- this.issuesLoading, this.issuesError, "Buscando issues del repo…", "issues");
1831
+ const src = (id, label) => this.choice(`src-${id}`, label, this.source === id, () => {
1832
+ if (this.source === id) return;
1833
+ this.source = id;
1834
+ this.issueProvider = id === "jira" ? "jira" : "github";
1835
+ resetIssueProviderState(this);
1836
+ this.choosing = true;
1837
+ this.pickedIssue = null;
1838
+ this.fields.issue.set_value("");
1839
+ });
1840
+ const rows = [h_flex().gap(6).child(src("github", "GitHub")).child(src("jira", "Jira")).child(src("manual", "Escribirla yo"))];
1841
+ if (this.source !== "manual") {
1842
+ if (this.pickedIssue && !this.choosing) {
1843
+ rows.push(h_flex().gap(8).items_center()
1844
+ .child(div().flex_1().min_w(0).child(this.createIssueRow(this.pickedIssue, true)))
1845
+ .child(this.button("iss-change", "Cambiar", "plain", () => { this.choosing = true; })));
1846
+ } else {
1847
+ const jira = this.source === "jira";
1848
+ const q = String((jira ? this.jiraQuery : this.issueQuery).value() ?? "").trim();
1849
+ const words = lq(q);
1850
+ const repoKey = !jira && /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(q) ? q : null;
1851
+ const looksUrl = /^https:\/\//.test(q);
1852
+ let list = jira ? (this.jiraResults ?? this.assignedPool ?? []) : (this.issuePanel === "issues" ? (this.issues ?? []) : (this.assignedPool ?? []));
1853
+ if (!(jira && this.jiraResults) && !repoKey && !looksUrl) list = list.filter((it) => has(`${it.key ?? `#${it.number}`} ${it.title ?? it.summary ?? ""} ${it.owner ?? ""}/${it.repo ?? ""}`, words));
1854
+ const loading = this.poolLoading || this.jiraSearching || this.issuesLoading;
1855
+ rows.push(h_flex().gap(6).items_center()
1856
+ .child(div().flex_1().child(Input.new(jira ? this.jiraQuery : this.issueQuery).h(28).px(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)))
1857
+ .when(jira, (el) => el
1858
+ .child(this.choice("iss-jira-mine", this.jiraMine ? "✓ Asignadas a mí" : "Asignadas a mí", this.jiraMine, (cx) => this.toggleJiraMine(cx)))
1859
+ .child(this.button("iss-jira-go", this.jiraSearching ? "Buscando…" : "Buscar", "plain", (cx) => this.searchJiraOn(cx))))
1860
+ .when(Boolean(repoKey), (el) => el.child(this.button("iss-repo-go", `Issues de ${repoKey}`, "plain", (cx) => this.pickRepo(repoKey, cx))))
1861
+ .when(looksUrl, (el) => el.child(this.button("iss-use-url", "Usar URL", "plain", () => { this.fields.issue.set_value(q); this.useIssueUrl(); this.choosing = false; }))));
1862
+ rows.push(v_flex().id("iss-list").max_h(150).overflow_y_scrollbar().gap(1)
1863
+ .when(loading, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim).child(jira ? "Buscando en Jira…" : "Buscando en GitHub…")))
1864
+ .when(Boolean(this.reposError || this.issuesError), (el) => el.child(h_flex().gap(8).items_center()
1865
+ .child(div().flex_1().text_size(UI.text.small).text_color(t.blocked).child(String(this.reposError || this.issuesError)))
1866
+ .child(this.button("iss-open-settings", "Abrir Ajustes", "plain", () => openOverlay(settingsOverlay({ section: jira ? "jira" : "github" }))))))
1867
+ .when(!loading && !this.reposError && list.length === 0, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim)
1868
+ .child(jira ? (this.jiraMine ? "Sin issues asignadas a ti: busca por texto o clave (VEL-123), o quita «Asignadas a mí»" : "Sin issues: busca por texto o clave (VEL-123)") : "Sin issues asignadas: escribe owner/repo o pega la URL de una issue")))
1869
+ .children(list.slice(0, 40).map((it) => this.createIssueRow(it))));
1870
+ }
1871
+ }
1872
+ rows.push(h_flex().gap(10).items_start()
1873
+ .child(v_flex().flex_1().gap(3).child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child("Título"))
1874
+ .child(Input.new(this.fields.title).h(30).px(9).rounded(UI.radius).border_1().border_color(e.title ? t.blocked : t.input).bg(t.background).text_size(12.5))
1875
+ .when(Boolean(e.title), (el) => el.child(div().text_size(UI.text.small).text_color(t.blocked).child(e.title)))));
1876
+ rows.push(v_flex().gap(3)
1877
+ .child(h_flex().items_center()
1878
+ .child(div().flex_1().text_size(UI.text.small).font_medium().text_color(t.muted).child("Historia (lo que lee el agente; editable)"))
1879
+ .child(div().text_size(UI.text.small).text_color(t.dim).child(this.pickedIssue ? `desde ${this.pickedIssue.key ?? (this.pickedIssue.number ? `#${this.pickedIssue.number}` : "la issue")}` : "escrita a mano")))
1880
+ .child(Textarea.new(this.story).h(80).p(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)));
1881
+ return this.createBlock(1, "Qué", "de dónde sale la historia", rows, e.issue);
1882
+ }
1883
+
1884
+ createWhere() {
1885
+ const t = theme();
1886
+ const e = this.errors ?? {};
1887
+ if (this.createKind === "pr") {
1888
+ const pr = this.pickedPr;
1889
+ if (!pr) {
1890
+ return this.createBlock(2, "Dónde", "repo, rama y base fijados por la PR", [
1891
+ div().text_size(UI.text.small).text_color(t.dim).child("Elige primero una PR o pega su URL arriba: el repo, la rama y la base salen de ella."),
1892
+ ], null);
1893
+ }
1894
+ const hubs = Array.isArray(pr.hubs) ? pr.hubs : [];
1895
+ const activeHub = pr.is_hub || Boolean(this.pickedPrHub);
1896
+ const hubInfo = activeHub && pr.hub && (!this.pickedPrHub || pr.hub.url === this.pickedPrHub || pr.is_hub) ? pr.hub : null;
1897
+ const rows = [
1898
+ h_flex().id("pr-where-repo").h(30).px(8).gap(8).items_center().rounded(UI.radius).bg(t.selected).border_1().border_color(t.accent).min_w(0)
1899
+ .child(this.hostBadge(pr.host))
1900
+ .child(div().flex_1().min_w(0).truncate().text_size(12.5).child(String(pr.repo_label || pr.repo_url || "")))
1901
+ .when(Boolean(pr.is_hub), (el) => el.child(div().id("pr-where-hub").flex_none().px(6).h(18).rounded(4).flex().items_center()
1902
+ .border_1().border_color(t.accent).text_size(10).font_semibold().text_color(t.accent).child("hub"))),
1903
+ h_flex().id("pr-where-branch").gap(8).items_center().px(2)
1904
+ .child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child("Rama fija:"))
1905
+ .child(div().flex_1().min_w(0).truncate().text_size(12).text_color(t.foreground).child(`${pr.head} → ${pr.base}`)),
1906
+ ];
1907
+ if (!pr.is_hub && hubs.length > 0) {
1908
+ rows.push(v_flex().id("pr-hub-selector").gap(4).pt(2)
1909
+ .child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child("Hub"))
1910
+ .child(h_flex().gap(6).flex_wrap()
1911
+ .children(hubs.map((h) => this.choice(`pr-hub-${slug(h.url)}`, h.name || h.url, this.pickedPrHub === h.url, (cx) => this.selectPrHub(h.url, cx))))
1912
+ .child(this.choice("pr-hub-none", "Ninguno (solo este repo)", !this.pickedPrHub, (cx) => this.selectPrHub("", cx)))));
1913
+ }
1914
+ if (this.prHubLoading) {
1915
+ rows.push(div().px(2).text_size(UI.text.small).text_color(t.dim).child("Consultando repos del hub…"));
1916
+ } else if (hubInfo && Array.isArray(hubInfo.repos) && hubInfo.repos.length > 0) {
1917
+ rows.push(v_flex().id("pr-hub-repos").gap(3).px(8).py(6).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
1918
+ .child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child(`Repos del hub (${hubInfo.repos.length})`))
1919
+ .children(hubInfo.repos.map((r) => {
1920
+ const prNum = r.pr_url ? /\/(?:pull|pullrequest)\/([0-9]+)/.exec(r.pr_url)?.[1] : null;
1921
+ const statusText = r.pr_url
1922
+ ? `${prNum ? `PR #${prNum}` : "PR abierta"} · rama ${pr.head}`
1923
+ : r.branch_exists
1924
+ ? `rama ${pr.head}`
1925
+ : `sin rama: base ${r.base}`;
1926
+ const statusColor = r.pr_url ? t.accent : r.branch_exists ? t.foreground : t.dim;
1927
+ return h_flex().id(`pr-hub-repo-${slug(r.name)}`).gap(8).items_center().min_w(0)
1928
+ .child(div().flex_1().min_w(0).truncate().text_size(12).text_color(t.foreground).child(r.name))
1929
+ .child(div().flex_none().text_size(UI.text.small).text_color(statusColor).child(statusText));
1930
+ })));
1931
+ }
1932
+ return this.createBlock(2, "Dónde", "repo, rama y base fijados por la PR", rows, null);
1501
1933
  }
1502
- const badge = this.pickedIssue ? (() => {
1503
- const id = issueTicketId(this.pickedIssue);
1504
- const text = this.pickedIssue.manual
1505
- ? `issue enlazada → ${this.pickedIssue.url}`
1506
- : `issue enlazada → ${id ?? this.pickedIssue.url}${id ? ` · rama feat/${id}` : ""} · ${String(this.pickedIssue.title ?? "")}`;
1507
- return div().id("iss-picked").px(8).py(5).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
1508
- .text_size(UI.text.tiny).text_color(t.muted).child(text);
1509
- })() : null;
1510
-
1511
- // El panel va justo debajo de la fila de Buscar, no al pie del diálogo.
1512
- const body = [
1513
- this.field("Título", input("title"), e.title),
1514
- this.field("Historia de usuario (issue)", h_flex().gap(6).flex_wrap().items_center()
1515
- .child(this.choice("iss-provider-github", "GitHub", this.issueProvider === "github", () => { this.issueProvider = "github"; }))
1516
- .child(this.choice("iss-provider-jira", "Jira (después)", false, () => { this.errors = { ...this.errors, issue: "Jira llega en su fase del plan" }; }))
1517
- .child(this.button("iss-search", this.issuesLoading ? "Buscando…" : "Buscar", "plain", (cx) => this.searchIssues(cx)))
1518
- .when(Boolean(this.pickedIssue), (el) => el.child(this.button("iss-clear", "quitar", "plain", () => this.clearIssue()))), e.issue),
1519
- ];
1520
- if (badge) body.push(badge);
1521
- if (panel) body.push(panel);
1522
- if (this.pickedIssue && String(this.pickedIssue.body ?? "").trim()) {
1523
- const row = this.issueBodyRow();
1524
- if (row) body.push(row);
1934
+ // Un repo o un hub: se elige igual; si trae hub.toml, el alta lo detecta y pasa a modo hub.
1935
+ const rows = [];
1936
+ {
1937
+ if (this.mode === "list" && this.listRepos.length) {
1938
+ rows.push(h_flex().gap(6).flex_wrap().children(this.listRepos.map((r) => h_flex().id(`list-chip-${slug(r.url)}`).h(24).pl(8).pr(4).gap(6).items_center()
1939
+ .rounded(UI.radius).bg(t.selected).border_1().border_color(t.accent).text_size(12)
1940
+ .child(r.label)
1941
+ .child(div().id(`list-chip-x-${slug(r.url)}`).px(3).cursor_pointer().text_color(t.dim).on_click((_e, cx) => { this.listRepos = this.listRepos.filter((x) => x.url !== r.url); cx.notify(); }).child("✕")))));
1942
+ }
1943
+ if (this.mode !== "list" && this.repoSel && !this.repoChoosing) {
1944
+ const fav = (this.repoSuggest ?? []).find((x) => x.url === this.repoSel.url);
1945
+ rows.push(h_flex().gap(8).items_center()
1946
+ .child(div().flex_1().min_w(0).child(this.createRepoRow({ ...this.repoSel, favorite: Boolean(fav?.favorite), recent: Boolean(fav?.recent) }, true)))
1947
+ .child(this.button("repo-change", "Cambiar", "plain", () => { this.repoChoosing = true; })));
1948
+ if (this.hubDetected && this.hubDetected === this.repoSel.url) {
1949
+ const asHub = this.mode === "hub";
1950
+ rows.push(h_flex().id("repo-hub-detected").gap(10).items_center().px(10).py(7).rounded(UI.radius)
1951
+ .bg(asHub ? t.selected : t.raised).border_1().border_color(asHub ? t.accent : t.border)
1952
+ .child(v_flex().flex_1().min_w(0).gap(2)
1953
+ .child(div().text_size(12).font_semibold().text_color(asHub ? t.accent : t.foreground).child(asHub ? "⬡ Tipo hub detectado" : "⬡ Hub detectado, tratado como repo normal"))
1954
+ .child(div().text_size(UI.text.small).text_color(t.dim).child(asHub
1955
+ ? "Trae hub.toml: el ticket trabaja en los repos del hub, un agente por repo (motor en «Opciones»)."
1956
+ : "Trae hub.toml, pero el ticket trabaja solo en este repo.")))
1957
+ .child(this.choice("repo-hub-toggle", asHub ? "Tratarlo como repo normal" : "Usarlo como hub", false, () => {
1958
+ this.hubAsRepo = asHub;
1959
+ this.applyHubMode();
1960
+ })));
1961
+ }
1962
+ } else {
1963
+ const q = String(this.repoQuery.value() ?? "").trim();
1964
+ const words = q.toLowerCase().split(/\s+/).filter(Boolean);
1965
+ const filters = [["todos", "Todos"], ["recientes", "★ Recientes"], ["github", "GitHub"], ["azure", "Azure"]];
1966
+ let list = (this.repoSuggest ?? []).filter((r) => this.repoFilter === "todos"
1967
+ || (this.repoFilter === "recientes" ? r.favorite || r.recent : r.host === this.repoFilter));
1968
+ if (!/^https:\/\//.test(q)) list = list.filter((r) => words.every((w) => `${r.label} ${r.url}`.toLowerCase().includes(w)));
1969
+ if (this.mode === "list") list = list.filter((r) => r.host === "github");
1970
+ const pasted = /^https:\/\/(github\.com|dev\.azure\.com|[A-Za-z0-9_.-]+\.visualstudio\.com)\//.test(q) && !list.some((r) => r.url === q);
1971
+ rows.push(h_flex().gap(6).items_center()
1972
+ .child(div().flex_1().child(Input.new(this.repoQuery).h(28).px(8).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12)))
1973
+ .child(h_flex().gap(4).children(filters.map(([id, label]) => this.choice(`rf-${id}`, label, this.repoFilter === id, () => { this.repoFilter = id; })))));
1974
+ const errs = Object.entries(this.repoSuggestErrors ?? {}).map(([k, v]) => `${k === "azure" ? "Azure" : k === "github" ? "GitHub" : "API"}: ${v}`);
1975
+ rows.push(v_flex().id("repo-list").max_h(160).overflow_y_scrollbar().gap(1)
1976
+ .when(pasted, (el) => el.child(this.createRepoRow({ url: q, label: q, host: /github\.com/.test(q) ? "github" : "azure" })))
1977
+ .when(this.repoSuggestLoading && !(this.repoSuggest ?? []).length, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim).child("Buscando repos…")))
1978
+ .when(errs.length > 0, (el) => el.child(div().px(6).py(2).text_size(UI.text.small).text_color(t.blocked).child(errs.join(" · "))))
1979
+ .when(!this.repoSuggestLoading && list.length === 0 && !pasted, (el) => el.child(div().px(6).py(3).text_size(UI.text.small).text_color(t.dim)
1980
+ .child(q ? "Ningún repo coincide: prueba otro nombre o pega su URL" : "Sin favoritos ni recientes todavía: busca un repo o pega su URL")))
1981
+ .children(list.slice(0, 40).map((r) => this.createRepoRow(r))));
1982
+ if (this.mode === "list") rows.push(div().text_size(UI.text.small).text_color(t.dim).child("Un hub solo admite repos de GitHub; elige dos o más."));
1983
+ }
1525
1984
  }
1526
- body.push(this.bondifyRow());
1527
- body.push(
1528
- this.field("Dónde trabaja", h_flex().gap(6).flex_wrap()
1529
- .children(TICKET_MODES.map((m) => this.choice(`mode-${m.id}`, m.label, this.mode === m.id, () => { this.mode = m.id; }))), null),
1530
- where,
1531
- h_flex().gap(10)
1532
- .child(div().flex_1().child(this.field(this.mode === "hub" ? "Rama base del hub" : "Rama base", input("base"), e.base)))
1533
- .when(CONFIG.costs, (el) => el.child(div().w(90).child(this.field("Tope USD", input("budget"), e.budget))))
1534
- .child(div().w(90).child(this.field("Timeout min", input("timeout"), e.timeout))),
1535
- this.field("Agente", h_flex().gap(6).flex_wrap()
1536
- .children(AGENTS.map((a) => this.choice(`agent-${a}`, a, this.agent === a, () => { this.agent = a; }))), e.agent),
1537
- );
1985
+ rows.push(h_flex().gap(10).items_center()
1986
+ .child(v_flex().w(220).gap(3).child(div().text_size(UI.text.small).font_medium().text_color(t.muted).child(this.mode === "hub" ? "Rama base del hub" : "Rama base"))
1987
+ .child(Input.new(this.fields.base).h(30).px(9).rounded(UI.radius).border_1().border_color(e.base ? t.blocked : t.input).bg(t.background).text_size(12.5)))
1988
+ .when(Boolean(this.devcontainerRepo), (el) => el.child(div().flex_1().pt(16).text_size(UI.text.small).font_family(UI.fontSans).text_color(t.accent)
1989
+ .child("Este repo trae devcontainer: «Docker en el run» queda marcado."))));
1990
+ return this.createBlock(2, "Dónde", "el repo no tiene por qué ser el de la issue", rows, e.repo || e.repos || e.hub || e.base);
1991
+ }
1992
+
1993
+ createWho() {
1994
+ const t = theme();
1995
+ const e = this.errors ?? {};
1996
+ const icons = { pi: ["icons/pi.svg", true], claude: ["icons/claude.svg", false], codex: ["icons/codex.svg", false], copilot: ["icons/copilot.svg", true], agy: ["icons/antigravity.svg", false] };
1997
+ const agentChip = (a) => {
1998
+ const on = this.agent === a;
1999
+ const ic = icons[a];
2000
+ return h_flex().id(`agent-${a}`).flex_none().h(26).px(10).gap(6).items_center().rounded(UI.radius).border_1()
2001
+ .border_color(on ? t.accent : t.input).bg(on ? t.selected : t.surface).text_size(12).text_color(on ? t.foreground : t.muted)
2002
+ .cursor_pointer().hover((s) => s.bg(t.hover)).on_click((_e, cx) => { this.agent = a; cx.notify(); })
2003
+ .when(Boolean(ic), (el) => el.child(ic[1] ? svg(ic[0]).size(13).text_color(t.foreground) : image(ic[0]).w(13).h(13)))
2004
+ .child(a);
2005
+ };
2006
+ const rows = [h_flex().gap(6).flex_wrap().children(AGENTS.map(agentChip))];
1538
2007
  if (this.agent === "pi") {
1539
2008
  const models = Array.isArray(this.setup?.models) ? this.setup.models : [];
1540
- if (models.length > 0) {
1541
- body.push(this.field("Modelo", this.renderModelSelector(models), e.model));
1542
- } else {
1543
- body.push(this.field("Modelo", input("model"), e.model));
1544
- }
2009
+ rows.push(this.field("Modelo", models.length > 0 ? this.renderModelSelector(models)
2010
+ : Input.new(this.fields.model).h(30).px(9).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12.5), e.model));
1545
2011
  }
1546
- if (this.mode !== "repo") {
1547
- body.push(this.field("Motor de equipo", h_flex().gap(6).flex_wrap()
1548
- .children(TEAM_ENGINES.map((en) => this.choice(`engine-${en.id}`, en.label, this.team_engine === en.id, () => { this.team_engine = en.id; }))), null));
2012
+ const summary = [`bondificar ${this.bondify ? "sí" : "no"}`, `Docker ${this.docker ? "sí" : "no"}`, timeoutLabel(String(this.fields.timeout.value() ?? "").trim() || 0)];
2013
+ rows.push(h_flex().id("opts-toggle").gap(6).items_center().cursor_pointer().on_click((_e, cx) => { this.optionsOpen = !this.optionsOpen; cx.notify(); })
2014
+ .child(div().text_size(12).text_color(t.muted).child(this.optionsOpen ? "▾ Opciones" : "▸ Opciones"))
2015
+ .when(!this.optionsOpen, (el) => el.child(div().text_size(UI.text.small).text_color(t.dim).child(summary.join(" · ")))));
2016
+ if (this.optionsOpen) {
2017
+ const box = v_flex().gap(6).pl(14).child(this.bondifyRow()).child(this.dockerRow())
2018
+ .child(h_flex().gap(10)
2019
+ .child(div().w(110).child(this.field("Timeout min (0 = sin)", Input.new(this.fields.timeout).h(30).px(9).rounded(UI.radius).border_1().border_color(e.timeout ? t.blocked : t.input).bg(t.background).text_size(12.5), e.timeout)))
2020
+ .when(CONFIG.costs, (el) => el.child(div().w(110).child(this.field("Tope USD", Input.new(this.fields.budget).h(30).px(9).rounded(UI.radius).border_1().border_color(e.budget ? t.blocked : t.input).bg(t.background).text_size(12.5), e.budget)))))
2021
+ .when(this.mode !== "repo" || Boolean(this.createKind === "pr" && (this.pickedPr?.is_hub || this.pickedPrHub)), (el) => el.child(this.field("Motor de equipo", h_flex().gap(6).flex_wrap()
2022
+ .children(TEAM_ENGINES.map((en) => this.choice(`engine-${en.id}`, en.label, this.team_engine === en.id, () => { this.team_engine = en.id; }))), null)));
2023
+ rows.push(box);
2024
+ }
2025
+ return this.createBlock(3, "Quién", null, rows, e.agent || (!this.optionsOpen ? e.timeout || e.budget : null));
2026
+ }
2027
+
2028
+ createSummary() {
2029
+ const t = theme();
2030
+ if (this.createKind === "pr") {
2031
+ const pr = this.pickedPr;
2032
+ if (!pr) {
2033
+ return h_flex().id("create-summary").gap(8).items_center().px(14).py(9).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border).text_size(12).min_w(0)
2034
+ .child(div().flex_none().text_color(t.dim).child("elige una PR o rama"))
2035
+ .child(div().flex_none().text_color(t.dim).child("·"))
2036
+ .child(div().flex_none().child(this.agent));
2037
+ }
2038
+ const prLabel = pr.kind === "pr" && pr.number ? `PR #${pr.number} · rama ${pr.head} → ${pr.base}` : `rama ${pr.head} → ${pr.base}`;
2039
+ const isHub = Boolean(pr.is_hub || this.pickedPrHub);
2040
+ const hubName = pr.is_hub
2041
+ ? (pr.hub?.name || pr.repo_label || pr.repo_url)
2042
+ : (pr.hubs?.find((h) => h.url === this.pickedPrHub)?.name || pr.hub?.name || this.pickedPrHub);
2043
+ const where = pr.is_hub
2044
+ ? `${pr.repo_label || pr.repo_url} (hub)`
2045
+ : this.pickedPrHub
2046
+ ? `${pr.repo_label || pr.repo_url} · hub ${hubName}`
2047
+ : (pr.repo_label || pr.repo_url);
2048
+ return h_flex().id("create-summary").gap(8).items_center().px(14).py(9).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border).text_size(12).min_w(0)
2049
+ .child(div().flex_none().text_color(t.accent).font_semibold().child(prLabel))
2050
+ .child(div().flex_none().text_color(t.dim).child("·"))
2051
+ .child(this.hostBadge(pr.host))
2052
+ .child(div().flex_1().min_w(0).truncate().child(where))
2053
+ .when(isHub, (el) => el.child(div().flex_none().text_color(t.accent).child("hub")))
2054
+ .child(div().flex_none().text_color(t.dim).child("·"))
2055
+ .child(div().flex_none().child(this.agent));
1549
2056
  }
1550
- body.push(div().text_size(UI.text.small).text_color(t.dim).child("El ticket queda en Ready: no arranca hasta que lo lances (D4)."));
1551
- return this.renderDialog("Nuevo ticket", body, [
1552
- this.button("dlg-back", "Volver", "plain", () => closeOverlay(p.overlay)),
1553
- this.button("dlg-create", this.busy ? "Creando…" : "Crear ticket", "primary", (cx) => this.create(cx)),
1554
- ]);
2057
+ const it = this.pickedIssue;
2058
+ const what = it ? (it.key ?? (it.number ? `#${it.number}` : "issue")) : this.source === "manual" ? "historia a mano" : "sin issue";
2059
+ const where = this.mode === "hub" ? (this.repoSel?.label ? `${this.repoSel.label} (hub)` : String(this.fields.hub.value() ?? "") || "hub sin elegir")
2060
+ : this.mode === "list" ? (this.listRepos.length ? `${this.listRepos.length} repos (hub)` : "repos sin elegir")
2061
+ : this.repoSel?.label ?? (String(this.fields.repo.value() ?? "") || "repo sin elegir");
2062
+ const id = it ? issueTicketId(it) : null;
2063
+ return h_flex().id("create-summary").gap(8).items_center().px(14).py(9).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border).text_size(12).min_w(0)
2064
+ .child(div().flex_none().text_color(t.accent).font_semibold().child(what))
2065
+ .child(div().flex_none().text_color(t.dim).child("→"))
2066
+ .when(this.mode !== "list" && Boolean(this.repoSel), (el) => el.child(this.hostBadge(this.repoSel.host)))
2067
+ .child(div().flex_none().child(where))
2068
+ .child(div().flex_none().text_color(t.dim).child("·"))
2069
+ .child(div().flex_none().child(this.agent))
2070
+ .when(Boolean(id), (el) => el.child(div().flex_none().text_color(t.dim).child("·")).child(div().flex_1().min_w(0).truncate().text_color(t.muted).child(`rama feat/${id}`)));
2071
+ }
2072
+
2073
+ renderCreate(p) {
2074
+ const t = theme();
2075
+ return v_flex().id("bond-dialog").track_focus(this.handle).on_key_down((ev, cx) => this.key(ev, cx))
2076
+ .size_full().bg(t.popover).rounded(UI.radiusLg).border_1().border_color(t.border).text_color(t.foreground).font_family("JetBrains Mono")
2077
+ .child(h_flex().h(46).flex_none().px(16).items_center().border_b_1().border_color(t.border)
2078
+ .child(div().flex_1().text_size(UI.text.title + 2).font_family(UI.fontSans).font_semibold().child("Nuevo ticket"))
2079
+ .child(div().text_size(UI.text.small).text_color(t.dim).child("Esc")))
2080
+ .child(v_flex().id("create-body").flex_1().min_h(0).px(16).py(12).gap(10).overflow_y_scrollbar()
2081
+ .child(h_flex().id("create-kind").gap(6).items_center()
2082
+ .child(this.choice("kind-scratch", "De cero", this.createKind === "scratch", () => {
2083
+ this.createKind = "scratch";
2084
+ this.errors = {};
2085
+ this.error = null;
2086
+ }))
2087
+ .child(this.choice("kind-pr", "Desde una PR", this.createKind === "pr", (cx) => {
2088
+ this.createKind = "pr";
2089
+ this.errors = {};
2090
+ this.error = null;
2091
+ if (this.prResults === null && !this.prSearching) {
2092
+ this.searchPrs(cx, "", "");
2093
+ }
2094
+ })))
2095
+ .child(this.createWhat()).child(this.createWhere()).child(this.createWho()))
2096
+ .child(v_flex().flex_none().gap(8).px(16).py(12).border_t_1().border_color(t.border)
2097
+ .child(this.createSummary())
2098
+ .when(Boolean(this.error), (el) => el.child(div().text_size(UI.text.small).text_color(t.blocked).child(this.error)))
2099
+ .child(h_flex().gap(8).items_center()
2100
+ .child(div().flex_1().text_size(UI.text.small).text_color(t.dim).child("El ticket queda en Ready: no arranca hasta que lo lances."))
2101
+ .child(this.button("dlg-back", "Volver", "plain", () => closeOverlay(p.overlay)))
2102
+ .child(this.button("dlg-create", this.busy ? "Creando…" : "Crear ticket", "primary", (cx) => this.create(cx)))));
1555
2103
  }
1556
2104
 
1557
2105
  renderPick(p) {
@@ -1574,6 +2122,9 @@ export default class BondBoard extends View {
1574
2122
  renderCardMenu(p) {
1575
2123
  const t = theme();
1576
2124
  const card = p.card ?? (this.tickets && this.runs ? buildCards(this.tickets, this.runs, this.agentStatus).find((c) => c.id === p.cardId) : null) ?? {};
2125
+ // From the session header: no «Abrir sesión», Shell nor the main action (already shown there).
2126
+ const inSession = Boolean(p.session);
2127
+ const shown = inSession ? this.primaryAction(card)?.[0] ?? null : null;
1577
2128
  const item = (id, label, icon, danger, action, keep = false) =>
1578
2129
  h_flex()
1579
2130
  .id(id)
@@ -1607,25 +2158,25 @@ export default class BondBoard extends View {
1607
2158
  .border_1()
1608
2159
  .border_color(t.border)
1609
2160
  .text_color(t.foreground)
1610
- .when(Boolean(card.canOpen), (el) =>
2161
+ .when(Boolean(card.canOpen) && !inSession, (el) =>
1611
2162
  el.child(item(`menu-open-${card.id}`, "Abrir sesión", "→", false, (cx) => this.selectCard(card, cx)))
1612
2163
  )
1613
- .when(Boolean(card.canShell), (el) =>
2164
+ .when(Boolean(card.canShell) && !inSession, (el) =>
1614
2165
  el.child(item(`menu-shell-${card.id}`, "Shell del contenedor", "", false, (cx) => this.openContainerShell(card, cx)))
1615
2166
  )
1616
- .when(Boolean(card.canLaunch), (el) =>
2167
+ .when(Boolean(card.canLaunch) && shown !== "launch", (el) =>
1617
2168
  el.child(item(`menu-launch-${card.id}`, "Lanzar run", "▶", false, () => this.openLaunch(card), true))
1618
2169
  )
1619
- .when(Boolean(card.canDeliver), (el) =>
2170
+ .when(Boolean(card.canDeliver) && shown !== "deliver", (el) =>
1620
2171
  el.child(item(`menu-deliver-${card.id}`, "Entregar…", "↑", false, () => this.openDeliver(card), true))
1621
2172
  )
1622
- .when(Boolean(card.canNudge), (el) =>
2173
+ .when(Boolean(card.canNudge) && shown !== "nudge", (el) =>
1623
2174
  el.child(item(`menu-nudge-${card.id}`, "Desbloquear…", "💬", false, () => this.openNudge(card), true))
1624
2175
  )
1625
2176
  .when(Boolean(card.canFinish), (el) =>
1626
2177
  el.child(item(`menu-finish-${card.id}`, "Terminado…", "✓", false, () => this.openFinish(card), true))
1627
2178
  )
1628
- .when(Boolean(card.canApprove), (el) =>
2179
+ .when(Boolean(card.canApprove) && shown !== "approve", (el) =>
1629
2180
  el.child(item(`menu-approve-${card.id}`, "Aprobar arreglos…", "✓", false, () => this.openApprove(card), true))
1630
2181
  )
1631
2182
  .when(Boolean(card.prUrl) && (card.deliveries || []).length === 0, (el) =>