openclacky 1.5.25 → 1.5.26

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -0
  3. data/lib/clacky/agent/chunk_index.rb +2 -1
  4. data/lib/clacky/agent/message_compressor_helper.rb +20 -2
  5. data/lib/clacky/agent/session_serializer.rb +28 -1
  6. data/lib/clacky/agent/skill_manager.rb +2 -8
  7. data/lib/clacky/agent/time_machine.rb +108 -127
  8. data/lib/clacky/agent/tool_executor.rb +2 -11
  9. data/lib/clacky/agent.rb +15 -19
  10. data/lib/clacky/agent_config.rb +14 -4
  11. data/lib/clacky/billing/media_usage.rb +69 -0
  12. data/lib/clacky/billing/platform_billing.rb +5 -0
  13. data/lib/clacky/brand_config.rb +16 -215
  14. data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +2 -80
  15. data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +1 -1
  16. data/lib/clacky/default_extensions/ext-studio/skills/ext-develop/SKILL.md +10 -96
  17. data/lib/clacky/default_extensions/git/panels/git/view.js +208 -69
  18. data/lib/clacky/default_extensions/knowledge/README.md +1 -1
  19. data/lib/clacky/default_extensions/knowledge/README.zh.md +1 -1
  20. data/lib/clacky/default_extensions/knowledge/lib/importer.rb +1 -1
  21. data/lib/clacky/default_extensions/knowledge/panels/kb/view.js +3 -3
  22. data/lib/clacky/default_extensions/meeting/api/handler.rb +23 -2
  23. data/lib/clacky/default_extensions/meeting/panels/meeting/view.js +194 -36
  24. data/lib/clacky/default_extensions/preview/icon.svg +3 -2
  25. data/lib/clacky/default_extensions/secretary/panels/work/view.js +108 -33
  26. data/lib/clacky/default_extensions/side-chat/README.md +40 -0
  27. data/lib/clacky/default_extensions/side-chat/README.zh.md +40 -0
  28. data/lib/clacky/default_extensions/side-chat/api/handler.rb +90 -0
  29. data/lib/clacky/default_extensions/side-chat/api/runtime.rb +411 -0
  30. data/lib/clacky/default_extensions/side-chat/ext.yml +16 -0
  31. data/lib/clacky/default_extensions/side-chat/icon.svg +14 -0
  32. data/lib/clacky/default_extensions/side-chat/panels/side-chat/view.js +779 -0
  33. data/lib/clacky/default_extensions/terminal/README.md +36 -0
  34. data/lib/clacky/default_extensions/terminal/README.zh.md +36 -0
  35. data/lib/clacky/default_extensions/terminal/api/handler.rb +121 -0
  36. data/lib/clacky/default_extensions/terminal/api/runtime.rb +397 -0
  37. data/lib/clacky/default_extensions/terminal/ext.yml +16 -0
  38. data/lib/clacky/default_extensions/terminal/icon.svg +13 -0
  39. data/lib/clacky/default_extensions/terminal/panels/terminal/view.js +351 -0
  40. data/lib/clacky/default_extensions/terminal/vendor/LICENSE +21 -0
  41. data/lib/clacky/default_extensions/terminal/vendor/addon-fit.js +2 -0
  42. data/lib/clacky/default_extensions/terminal/vendor/xterm.css +218 -0
  43. data/lib/clacky/default_extensions/terminal/vendor/xterm.js +2 -0
  44. data/lib/clacky/default_skills/media-gen/SKILL.md +30 -9
  45. data/lib/clacky/extension/api_extension.rb +12 -0
  46. data/lib/clacky/locales/en.rb +14 -11
  47. data/lib/clacky/locales/i18n.rb +25 -0
  48. data/lib/clacky/locales/zh.rb +14 -11
  49. data/lib/clacky/media/base.rb +11 -1
  50. data/lib/clacky/media/openai_compat.rb +271 -3
  51. data/lib/clacky/message_format/open_ai.rb +17 -0
  52. data/lib/clacky/prompts/base.md +3 -0
  53. data/lib/clacky/providers.rb +33 -20
  54. data/lib/clacky/reasoning_levels.rb +75 -0
  55. data/lib/clacky/server/channel/channel_ui_controller.rb +12 -5
  56. data/lib/clacky/server/git_panel.rb +40 -18
  57. data/lib/clacky/server/http_server.rb +62 -71
  58. data/lib/clacky/server/session_registry.rb +3 -0
  59. data/lib/clacky/ui2/markdown_renderer.rb +153 -0
  60. data/lib/clacky/ui2/strings_cjk_patch.rb +134 -124
  61. data/lib/clacky/utils/file_link_normalizer.rb +30 -3
  62. data/lib/clacky/utils/frontmatter.rb +63 -0
  63. data/lib/clacky/utils/model_pricing.rb +67 -9
  64. data/lib/clacky/version.rb +1 -1
  65. data/lib/clacky/web/app.css +722 -274
  66. data/lib/clacky/web/app.js +2 -0
  67. data/lib/clacky/web/components/chat-composer.js +504 -0
  68. data/lib/clacky/web/components/chat-navigator.js +1 -1
  69. data/lib/clacky/web/components/model-picker.js +319 -20
  70. data/lib/clacky/web/components/quote-select.js +97 -39
  71. data/lib/clacky/web/core/aside.js +137 -27
  72. data/lib/clacky/web/core/ext.js +658 -81
  73. data/lib/clacky/web/features/brand/store.js +0 -4
  74. data/lib/clacky/web/features/brand/view.js +2 -99
  75. data/lib/clacky/web/features/extensions/store.js +3 -1
  76. data/lib/clacky/web/features/extensions/view.js +14 -15
  77. data/lib/clacky/web/features/new-session/store.js +4 -0
  78. data/lib/clacky/web/features/new-session/view.js +27 -4
  79. data/lib/clacky/web/features/skills/store.js +7 -5
  80. data/lib/clacky/web/features/skills/view.js +65 -16
  81. data/lib/clacky/web/features/version/view.js +1 -1
  82. data/lib/clacky/web/features/workspace/store.js +7 -3
  83. data/lib/clacky/web/features/workspace/view.js +46 -5
  84. data/lib/clacky/web/i18n.js +104 -58
  85. data/lib/clacky/web/index.html +21 -22
  86. data/lib/clacky/web/lib/box-diagram.js +239 -0
  87. data/lib/clacky/web/sessions.js +117 -151
  88. data/lib/clacky/web/settings.js +23 -16
  89. data/lib/clacky/web/ws-dispatcher.js +4 -1
  90. data/lib/clacky.rb +2 -0
  91. metadata +24 -1
@@ -92,10 +92,6 @@ const BrandStore = (() => {
92
92
  }
93
93
  },
94
94
 
95
- fetchSkillsBanner() {
96
- return fetch("/api/brand/skills").then(r => r.json());
97
- },
98
-
99
95
  async activate(key) {
100
96
  const res = await fetch("/api/brand/activate", {
101
97
  method: "POST",
@@ -1,6 +1,6 @@
1
- // ── Brand · view — banners, logo/favicon, owner badge, activation panel ───
1
+ // ── Brand · view — logo/favicon, owner badge, activation panel
2
2
  //
3
- // Owns all white-label DOM: activation banner, warning bar, header logo +
3
+ // Owns all white-label DOM: header logo +
4
4
  // favicon + theme color, OWNER badge, the "get serial" link, and the activation
5
5
  // panel flow. Reads brand info through BrandStore; status/activation network
6
6
  // calls go through store actions.
@@ -24,8 +24,6 @@ const BrandView = (() => {
24
24
  _applyBrandName("OpenClacky");
25
25
  Brand.clearBrandCache();
26
26
  _applyHeaderLogo();
27
- const banner = document.getElementById("brand-activation-banner");
28
- if (banner) banner.remove();
29
27
  if (typeof Settings !== "undefined" && Settings.loadBrand) Settings.loadBrand();
30
28
  return;
31
29
  }
@@ -34,80 +32,15 @@ const BrandView = (() => {
34
32
 
35
33
  if (data.needs_activation) {
36
34
  if (data.theme_color) Settings.applyAccentColor(data.theme_color, { persist: true });
37
- _showActivationBanner(data.product_name);
38
35
  _applyHeaderLogo();
39
36
  if (data.distribution_refresh_pending) _scheduleDistributionRefreshPoll();
40
37
  return;
41
38
  }
42
39
 
43
- if (data.warning) _showWarning(data.warning);
44
40
  _applyHeaderLogo();
45
41
  _applyOwnerBadge();
46
42
  }
47
43
 
48
- function _showActivationBanner(brandName) {
49
- if (document.getElementById("brand-activation-banner")) return;
50
-
51
- const name = brandName || I18n.t("brand.banner.defaultName");
52
-
53
- let settled = false;
54
- const settle = data => {
55
- if (settled) return;
56
- settled = true;
57
- if (document.getElementById("brand-activation-banner")) return;
58
- _renderActivationBanner(name, data);
59
- };
60
-
61
- Brand.fetchSkillsBanner().then(settle).catch(() => settle(null));
62
- setTimeout(() => settle(null), 5000);
63
- }
64
-
65
- function _renderActivationBanner(name, countsData) {
66
- const bar = document.createElement("div");
67
- bar.id = "brand-activation-banner";
68
- bar.className = "brand-activation-banner";
69
-
70
- const span = document.createElement("span");
71
- const link = document.createElement("button");
72
- link.className = "brand-activation-banner-link";
73
- link.addEventListener("click", () => _goToLicenseInput());
74
-
75
- let i18nKey = "brand.banner.prompt";
76
- let vars = { name };
77
- let hideLink = false;
78
-
79
- if (countsData && countsData.ok && countsData.free_mode) {
80
- const free = (countsData.skills || []).length;
81
- const paid = Number(countsData.paid_skills_count) || 0;
82
- vars = { name, free, paid, freePlural: free === 1 ? "" : "s", paidPlural: paid === 1 ? "" : "s" };
83
-
84
- if (free > 0 && paid > 0) i18nKey = "brand.banner.freePromptBoth";
85
- else if (free > 0 && paid === 0) { i18nKey = "brand.banner.freePromptOnlyFree"; hideLink = true; }
86
- else if (free === 0 && paid > 0) i18nKey = "brand.banner.freePromptOnlyPaid";
87
- }
88
-
89
- span.textContent = I18n.t(i18nKey, vars);
90
- span.setAttribute("data-i18n", i18nKey);
91
- span.setAttribute(
92
- "data-i18n-vars",
93
- Object.entries(vars).map(([k, v]) => `${k}=${v}`).join(";")
94
- );
95
-
96
- link.textContent = I18n.t("brand.banner.action");
97
- link.setAttribute("data-i18n", "brand.banner.action");
98
- if (hideLink) link.style.display = "none";
99
-
100
- const closeBtn = document.createElement("button");
101
- closeBtn.className = "brand-activation-banner-close";
102
- closeBtn.innerHTML = "✕";
103
- closeBtn.onclick = () => bar.remove();
104
-
105
- bar.appendChild(span);
106
- bar.appendChild(link);
107
- bar.appendChild(closeBtn);
108
- document.getElementById("main").prepend(bar);
109
- }
110
-
111
44
  function _goToLicenseInput() {
112
45
  window.Clacky.Router.navigate("settings");
113
46
  if (typeof Settings !== "undefined") Settings.open();
@@ -186,7 +119,6 @@ const BrandView = (() => {
186
119
  }
187
120
 
188
121
  function _skipActivation() {
189
- _showWarning(I18n.t("brand.skip.warning"), "brand.skip.warning");
190
122
  _bootUI();
191
123
  }
192
124
 
@@ -305,35 +237,6 @@ const BrandView = (() => {
305
237
  link.href = url;
306
238
  }
307
239
 
308
- function _showWarning(message, i18nKey) {
309
- const existing = document.getElementById("brand-warning-bar");
310
- if (existing) return;
311
-
312
- const bar = document.createElement("div");
313
- bar.id = "brand-warning-bar";
314
- bar.className = "brand-warning-bar";
315
-
316
- const span = document.createElement("span");
317
- span.textContent = message;
318
- if (i18nKey) span.setAttribute("data-i18n", i18nKey);
319
-
320
- const renewBtn = document.createElement("button");
321
- renewBtn.className = "brand-warning-renew-btn";
322
- renewBtn.textContent = I18n.t("brand.warning.renewBtn");
323
- renewBtn.setAttribute("data-i18n", "brand.warning.renewBtn");
324
- renewBtn.onclick = () => { bar.remove(); _goToLicenseInput(); };
325
-
326
- const closeBtn = document.createElement("button");
327
- closeBtn.className = "brand-warning-close-btn";
328
- closeBtn.innerHTML = "✕";
329
- closeBtn.onclick = () => bar.remove();
330
-
331
- bar.appendChild(span);
332
- bar.appendChild(renewBtn);
333
- bar.appendChild(closeBtn);
334
- document.getElementById("main").prepend(bar);
335
- }
336
-
337
240
  function _bootUI() {
338
241
  if (typeof window.bootAfterBrand === "function") {
339
242
  window.bootAfterBrand();
@@ -209,7 +209,9 @@ const ExtensionsStore = (() => {
209
209
  _official = official;
210
210
  _catalog = brand.extensions || [];
211
211
  _hasMore = false;
212
- _error = brand.warning || null;
212
+ // The brand catalog reports license state (expired / revoked …) through
213
+ // `warning`. That status belongs in Settings → Brand & License; showing
214
+ // it here only repeats a condition the user cannot act on from this page.
213
215
  } catch (e) {
214
216
  console.error("[Extensions] loadBrand failed", e);
215
217
  _official = [];
@@ -53,23 +53,20 @@ const ExtensionsView = (() => {
53
53
  // Group the active tab's data into sections. The all tab shows the two
54
54
  // publishers side by side, the brand tab swaps the public catalog for the
55
55
  // brand-private one, and the installed tab uses the same two headings, split
56
- // by the layer each extension actually lives in. A disabled extension is not
57
- // "installed" as far as the user is concerned: it leaves this tab and is
58
- // switched back on from the all tab's official group, which lists every
59
- // builtin extension.
56
+ // by the layer each extension actually lives in.
60
57
  //
61
- // The local tab is a workbench rather than a catalog: it is a single list and
62
- // it keeps switched-off extensions visible, since re-enabling one is exactly
63
- // what the owner comes here to do.
58
+ // Both the installed and the local tab keep switched-off extensions in the
59
+ // list, each with a badge and the same "+" affordance to switch it back on.
60
+ // Hiding a disabled one strands it: a marketplace install can drop out of the
61
+ // catalog (unlisted), and then no list on this page would lead back to it.
64
62
  function _groups(st) {
65
63
  if (st.tab === "local") {
66
64
  return [{ title: null, items: st.local }];
67
65
  }
68
66
  if (st.tab === "installed") {
69
- const live = st.installed.filter((e) => e.disabled !== true);
70
67
  return [
71
- { title: I18n.t("extensions.group.official"), items: live.filter((e) => e.layer === "builtin") },
72
- { title: I18n.t("extensions.group.user"), items: live.filter((e) => e.layer !== "builtin") },
68
+ { title: I18n.t("extensions.group.official"), items: st.installed.filter((e) => e.layer === "builtin") },
69
+ { title: I18n.t("extensions.group.user"), items: st.installed.filter((e) => e.layer !== "builtin") },
73
70
  ];
74
71
  }
75
72
  if (st.tab === "brand") {
@@ -199,11 +196,13 @@ const ExtensionsView = (() => {
199
196
  const failedHtml = (job && job.stage === "error")
200
197
  ? `<span class="ext-row-error">${escapeHtml(I18n.t("extensions.action.installFailed"))}</span>` : "";
201
198
 
202
- if (ext.installed) {
203
- // A builtin or local extension that is switched off reads as "not on
204
- // yet", so it keeps the same "+" (enable) affordance as anything waiting
205
- // to be installed rather than the "…" menu.
206
- if (ext.disabled === true && (ext.layer === "builtin" || ext.layer === "local")) {
199
+ if (ext.installed || ext.disabled === true) {
200
+ // Anything switched off reads as "not on yet", so it keeps the same "+"
201
+ // (enable) affordance as something waiting to be installed rather than the
202
+ // "…" menu. This holds for every layer: an installed extension from the
203
+ // marketplace is only reachable from the all tab once its catalog entry
204
+ // survives, and a disabled one is what the user is looking for there.
205
+ if (ext.disabled === true) {
207
206
  return `${failedHtml}<button type="button" class="ext-row-add" data-ext-row-enable="${escapeHtml(id)}" data-tooltip="${escapeHtml(I18n.t("extensions.action.enable"))}">${_plusSvg()}</button>`;
208
207
  }
209
208
  return `${failedHtml}${_rowMore(id)}`;
@@ -32,6 +32,9 @@ const NewSessionStore = (() => {
32
32
  workingDir: "",
33
33
  initProject: false,
34
34
  projectId: null,
35
+ // Reasoning stop for the session about to be created. Empty = leave the
36
+ // agent default ("off") alone.
37
+ reasoningEffort: "",
35
38
  },
36
39
  advancedOpen: false,
37
40
  creating: false,
@@ -247,6 +250,7 @@ const NewSessionStore = (() => {
247
250
  if (adv.workingDir.trim()) payload.working_dir = adv.workingDir.trim();
248
251
  if (adv.modelId) payload.model_id = adv.modelId;
249
252
  if (adv.projectId) payload.project_id = adv.projectId;
253
+ if (adv.reasoningEffort) payload.reasoning_effort = adv.reasoningEffort;
250
254
  }
251
255
 
252
256
  const res = await fetch("/api/sessions", {
@@ -585,11 +585,11 @@ const NewSessionView = (() => {
585
585
  return chip;
586
586
  }
587
587
 
588
- function _showCtxPopover(anchor, buildFn) {
588
+ function _showCtxPopover(anchor, buildFn, extraClass) {
589
589
  _dismissCtxPopover();
590
590
 
591
591
  const pop = document.createElement("div");
592
- pop.className = "ns-ctx-popover";
592
+ pop.className = "ns-ctx-popover" + (extraClass ? " " + extraClass : "");
593
593
  buildFn(pop);
594
594
 
595
595
  const rect = anchor.getBoundingClientRect();
@@ -767,6 +767,21 @@ const NewSessionView = (() => {
767
767
  }
768
768
 
769
769
  // ── Model chip popover ──
770
+ // The reasoning card tunes the session this page is about to create, so its
771
+ // stops come from the selected row and the choice rides on the create
772
+ // request. Nothing is stored server-side yet — there is no session.
773
+ function _newReasoningOpts(models, currentId) {
774
+ const row = models.find((m) => m.id === currentId) || models[0];
775
+ return {
776
+ levels: (row && row.reasoning_levels) || [],
777
+ current: NewSessionStore.state.advanced.reasoningEffort || "off",
778
+ onChange: (level) => {
779
+ NewSessionStore.updateAdvanced({ reasoningEffort: level });
780
+ return level;
781
+ },
782
+ };
783
+ }
784
+
770
785
  function _openModelPopover(anchor) {
771
786
  _showCtxPopover(anchor, (pop) => {
772
787
  const models = NewSessionStore.state.models || [];
@@ -784,12 +799,20 @@ const NewSessionView = (() => {
784
799
  models,
785
800
  currentId,
786
801
  onSelect: (m) => {
787
- NewSessionStore.updateAdvanced({ modelId: m.id || "" });
802
+ const levels = (m && m.reasoning_levels) || [];
803
+ const eff = NewSessionStore.state.advanced.reasoningEffort;
804
+ const next = { modelId: m.id || "" };
805
+ // Same nearest-stop rule the server clamps with, so the card can't lie.
806
+ if (eff && levels.length && levels.indexOf(eff) < 0) {
807
+ next.reasoningEffort = levels[ModelPicker.reasoningIndex(levels, eff)];
808
+ }
809
+ NewSessionStore.updateAdvanced(next);
788
810
  _dismissCtxPopover();
789
811
  _renderContextBar();
790
812
  },
813
+ reasoning: _newReasoningOpts(models, currentId),
791
814
  });
792
- });
815
+ }, "ns-ctx-popover--model");
793
816
  }
794
817
 
795
818
  // ── Working dir chip popover ──
@@ -83,10 +83,10 @@ const SkillsStore = (() => {
83
83
 
84
84
  // Resolve the next "Session N" name and create a session, then hand off to
85
85
  // Sessions. Used by every "open a session and run a command" action.
86
- async function _openSessionWith(message) {
86
+ async function _openSessionWith(message, agentProfile = null) {
87
87
  if (!WS.ready) { WS.connect(); Skills.load(); }
88
88
  try {
89
- return await Sessions.startWith(message, { source: "skill" });
89
+ return await Sessions.startWith(message, { source: "skill", agentProfile });
90
90
  } catch (e) {
91
91
  Modal.toast(I18n.t("tasks.sessionError") + (e.message || "unknown"), "error");
92
92
  return null;
@@ -262,9 +262,11 @@ const SkillsStore = (() => {
262
262
  }
263
263
  },
264
264
 
265
- /** Open a session and run a brand skill by sending "/{name}". */
266
- useInstalledSkill(name) {
267
- return _openSessionWith("/" + name);
265
+ /** Open a session and run a skill by sending "/{name}". Skills pinned to
266
+ * one agent (ext-develop → ext-developer) launch under that agent, since
267
+ * the session's skill list is filtered by the agent's scope. */
268
+ useInstalledSkill(name, agentProfile = null) {
269
+ return _openSessionWith("/" + name, agentProfile);
268
270
  },
269
271
 
270
272
  /** Create a new custom skill via a session running /skill-creator. */
@@ -17,6 +17,8 @@
17
17
  const SkillsView = (() => {
18
18
  let _domWired = false;
19
19
  let _searchQuery = "";
20
+ // Last brand-tab degradation notice: { code, text, empty } or null.
21
+ let _brandWarning = null;
20
22
 
21
23
  // ── Search filtering ─────────────────────────────────────────────────────
22
24
 
@@ -251,6 +253,12 @@ const SkillsView = (() => {
251
253
  return skill.source === "default" || skill.source === "brand";
252
254
  }
253
255
 
256
+ // A skill declared for one agent (e.g. ext-develop → ext-developer) must
257
+ // launch that agent — other sessions never see the skill in their list.
258
+ function _launchAgent(skill) {
259
+ return (skill.agents || []).find(a => a !== "all") || null;
260
+ }
261
+
254
262
  function _renderEmptyState() {
255
263
  const emptyWrapper = document.createElement("div");
256
264
  emptyWrapper.className = "skills-empty";
@@ -320,7 +328,7 @@ const SkillsView = (() => {
320
328
  });
321
329
 
322
330
  const useBtn = tile.querySelector(".skill-tile-use");
323
- if (useBtn) useBtn.addEventListener("click", () => Skills.useInstalledSkill(skill.name));
331
+ if (useBtn) useBtn.addEventListener("click", () => Skills.useInstalledSkill(skill.name, _launchAgent(skill)));
324
332
  const enableBtn = tile.querySelector(".skill-tile-enable");
325
333
  if (enableBtn) enableBtn.addEventListener("click", () => Skills.toggle(skill.name, true));
326
334
 
@@ -356,19 +364,50 @@ const SkillsView = (() => {
356
364
  container.innerHTML = `<div class="brand-skills-error">${msg}</div>`;
357
365
  }
358
366
 
359
- function _applyBrandWarning(warning, warningCode) {
360
- const warningBanner = $("brand-skills-warning");
361
- if (!warningBanner) return;
362
- const warningText = warningCode ? I18n.t("skills.brand.warning." + warningCode) : warning;
363
- if (warningText) {
364
- warningBanner.textContent = warningText;
365
- if (warningCode) warningBanner.setAttribute("data-i18n", "skills.brand.warning." + warningCode);
366
- else warningBanner.removeAttribute("data-i18n");
367
- warningBanner.style.display = "";
368
- } else {
369
- warningBanner.style.display = "none";
370
- warningBanner.removeAttribute("data-i18n");
367
+ function _applyBrandWarning(warning, warningCode, empty) {
368
+ if (warningCode) _brandWarning = { code: warningCode, text: warning, empty: !!empty };
369
+ else if (warning) _brandWarning = { code: null, text: warning, empty: !!empty };
370
+ else _brandWarning = null;
371
+ _renderBrandWarning();
372
+ }
373
+
374
+ function _renderBrandWarning() {
375
+ const banner = $("brand-skills-warning");
376
+ if (!banner) return;
377
+ banner.textContent = "";
378
+ if (!_brandWarning) {
379
+ banner.style.display = "none";
380
+ return;
371
381
  }
382
+
383
+ const i18nKey = _brandWarning.code
384
+ ? "skills.brand.warning." + _brandWarning.code + (_brandWarning.empty ? ".empty" : "")
385
+ : null;
386
+
387
+ const row = document.createElement("div");
388
+ row.className = "inline-notice-row";
389
+
390
+ const msg = document.createElement("span");
391
+ msg.className = "inline-notice-msg";
392
+ msg.textContent = i18nKey ? I18n.t(i18nKey) : _brandWarning.text;
393
+ if (i18nKey) msg.setAttribute("data-i18n", i18nKey);
394
+ row.appendChild(msg);
395
+
396
+ if (_brandWarning.code) {
397
+ const btn = document.createElement("button");
398
+ btn.type = "button";
399
+ btn.className = "inline-notice-action";
400
+ btn.textContent = I18n.t("skills.brand.warning.retry");
401
+ btn.setAttribute("data-i18n", "skills.brand.warning.retry");
402
+ btn.addEventListener("click", () => {
403
+ btn.disabled = true;
404
+ Skills.loadBrandSkills();
405
+ });
406
+ row.appendChild(btn);
407
+ }
408
+
409
+ banner.appendChild(row);
410
+ banner.style.display = "";
372
411
  }
373
412
 
374
413
  function _renderBrandSkills() {
@@ -382,7 +421,11 @@ const SkillsView = (() => {
382
421
  const paidSkillsCount = SkillsStore.state.paidSkillsCount;
383
422
 
384
423
  if (brandSkills.length === 0 && !(freeMode && paidSkillsCount > 0)) {
385
- container.innerHTML = `<div class="brand-skills-empty">${I18n.t("skills.brand.empty")}</div>`;
424
+ // When the license server is unreachable the notice above already explains
425
+ // the empty list — showing "no brand skills" as well would contradict it.
426
+ container.innerHTML = _brandWarning
427
+ ? ""
428
+ : `<div class="brand-skills-empty">${I18n.t("skills.brand.empty")}</div>`;
386
429
  return;
387
430
  }
388
431
 
@@ -934,7 +977,7 @@ const SkillsView = (() => {
934
977
  _wireDetailBack();
935
978
 
936
979
  const tryBtn = $("skill-detail-try");
937
- if (tryBtn) tryBtn.addEventListener("click", () => Skills.useInstalledSkill(skill.name));
980
+ if (tryBtn) tryBtn.addEventListener("click", () => Skills.useInstalledSkill(skill.name, _launchAgent(skill)));
938
981
 
939
982
  const chk = $("skill-detail-enabled");
940
983
  if (chk) chk.addEventListener("change", () => Skills.toggle(skill.name, chk.checked));
@@ -1067,6 +1110,7 @@ const SkillsView = (() => {
1067
1110
 
1068
1111
  document.addEventListener("langchange", () => {
1069
1112
  _renderMySkills();
1113
+ _renderBrandWarning();
1070
1114
  _renderBrandSkills();
1071
1115
  _renderCloudSkills();
1072
1116
  if (_detailName) _renderDetail();
@@ -1088,11 +1132,16 @@ const SkillsView = (() => {
1088
1132
 
1089
1133
  Skills.on("brandSkills:loading", _renderBrandLoading);
1090
1134
  Skills.on("brandSkills:error", (p) => {
1135
+ _applyBrandWarning(null);
1091
1136
  _renderBrandError(p);
1092
1137
  if (_detailBrand) _renderDetail();
1093
1138
  });
1094
1139
  Skills.on("brandSkills:changed", (p) => {
1095
- if (p) _applyBrandWarning(p.warning, p.warningCode);
1140
+ if (p) {
1141
+ const brandSkills = p.brandSkills || [];
1142
+ const noContent = brandSkills.length === 0 && !(p.freeMode && p.paidSkillsCount > 0);
1143
+ _applyBrandWarning(p.warning, p.warningCode, noContent);
1144
+ }
1096
1145
  _renderBrandSkills();
1097
1146
  if (_detailBrand) _renderDetail();
1098
1147
  });
@@ -143,7 +143,7 @@ const VersionView = (() => {
143
143
  <p class="vup-versions">v${s.current} <span class="vup-arrow">→</span> v${s.latest}</p>
144
144
  <div class="vup-actions">
145
145
  <button id="vup-btn-upgrade" class="vup-btn-primary">${I18n.t("upgrade.btn.upgrade")}</button>
146
- ${(typeof Brand !== "undefined" && Brand.branded) ? "" : `<a id="vup-btn-changelog" class="vup-btn-changelog" href="https://github.com/clacky-ai/openclacky/releases" target="_blank" rel="noopener noreferrer">${I18n.t("upgrade.btn.changelog")}</a>`}
146
+ <a id="vup-btn-changelog" class="vup-btn-changelog" href="https://github.com/clacky-ai/openclacky/releases" target="_blank" rel="noopener noreferrer">${I18n.t("upgrade.btn.changelog")}</a>
147
147
  </div>
148
148
  `;
149
149
  $("vup-btn-upgrade").addEventListener("click", () => Version.startUpgrade());
@@ -73,11 +73,15 @@ const WorkspaceStore = (() => {
73
73
  setSession(session) {
74
74
  const newId = session ? session.id : null;
75
75
  const newDir = session ? session.working_dir : null;
76
- const hadSession = _sessionId != null;
77
- const changed = newId !== _sessionId || newDir !== _workingDir;
76
+ const prevId = _sessionId;
77
+ const hadSession = prevId != null;
78
+ const changed = newId !== prevId || newDir !== _workingDir;
78
79
  _sessionId = newId;
79
80
  _workingDir = newDir;
80
- if (changed) _emit("workspace:sessionChanged", { sessionId: newId });
81
+ // prevSessionId lets a listener tell "another session" apart from "the
82
+ // same session pointed at a different directory"; only the latter
83
+ // invalidates the files on screen.
84
+ if (changed) _emit("workspace:sessionChanged", { sessionId: newId, prevSessionId: prevId });
81
85
  return { changed, hadSession };
82
86
  },
83
87
 
@@ -793,6 +793,17 @@ const WorkspaceView = (() => {
793
793
  try { localStorage.setItem(OPEN_TABS_KEY, JSON.stringify(data)); } catch (_e) { /* quota / private mode */ }
794
794
  }
795
795
 
796
+ // Tabs are paths under the working dir. Once that dir changes the record
797
+ // would reopen files from the old root, so it is dropped rather than left
798
+ // for restoreOpenTabs to fail on one path at a time.
799
+ function forgetOpenTabs(sessionId) {
800
+ if (!sessionId) return;
801
+ const data = readOpenTabs();
802
+ if (!(sessionId in data)) return;
803
+ delete data[sessionId];
804
+ writeOpenTabs(data);
805
+ }
806
+
796
807
  // Reopen what this session had on screen before the reload. A path that no
797
808
  // longer opens is skipped without a message: the record is a convenience, not
798
809
  // a promise that the file is still there.
@@ -844,6 +855,10 @@ const WorkspaceView = (() => {
844
855
  const tabs = [];
845
856
  let activeId = null;
846
857
  let treeHidden = false;
858
+ // Set while tabs are being dropped wholesale (working dir changed): the
859
+ // strip that remains is not this session's state, so writing it back would
860
+ // erase a record the session still owns.
861
+ let skipPersist = false;
847
862
  let releaseAsideWidth = null;
848
863
  const notify = () => {
849
864
  if (onTabsChanged) onTabsChanged({ count: tabs.length, activeId });
@@ -855,6 +870,7 @@ const WorkspaceView = (() => {
855
870
  // tabs stay out: reopening one is a request to launch an external
856
871
  // application, which a page reload must not do on its own.
857
872
  function persistTabs() {
873
+ if (skipPersist) return;
858
874
  const sessionId = Workspace.state.sessionId;
859
875
  if (!sessionId) return;
860
876
  const data = readOpenTabs();
@@ -1163,6 +1179,18 @@ const WorkspaceView = (() => {
1163
1179
  }
1164
1180
  }
1165
1181
 
1182
+ // Every tab points at a file under the working dir, so a dir switch leaves
1183
+ // nothing that could still open. Dropped without the unsaved-edit prompt:
1184
+ // that question is about closing a file, not about the whole root moving.
1185
+ function reset() {
1186
+ skipPersist = true;
1187
+ tabs.splice(0).forEach(disposeTab);
1188
+ activate(null);
1189
+ skipPersist = false;
1190
+ restoreAsideWidth();
1191
+ setTreeHidden(false);
1192
+ }
1193
+
1166
1194
  function closeAllTabs() {
1167
1195
  return closeTabs(tabs.slice());
1168
1196
  }
@@ -1706,7 +1734,7 @@ const WorkspaceView = (() => {
1706
1734
  activeId = null;
1707
1735
  }
1708
1736
 
1709
- return { root, openTab, activate, reloadOpenTabs, destroy };
1737
+ return { root, openTab, activate, reloadOpenTabs, reset, destroy };
1710
1738
  }
1711
1739
 
1712
1740
  // Draggable split between the file tree and the viewer. The tree width is a
@@ -1971,8 +1999,18 @@ const WorkspaceView = (() => {
1971
1999
  // working directory changes (status-bar dir switch) and when the agent
1972
2000
  // finishes a task (it may have created/edited files under the dir).
1973
2001
  if (_activeOff) _activeOff();
1974
- const offSessionChanged = Workspace.on("workspace:sessionChanged", () => {
1975
- // Another working dir: none of the rows on screen belong to it.
2002
+ const offSessionChanged = Workspace.on("workspace:sessionChanged", (payload) => {
2003
+ // Another working dir: neither the rows, the search results nor the open
2004
+ // tabs on screen belong to it. The search is dropped rather than re-run,
2005
+ // because a stale query would silently match files of the old root.
2006
+ const dirChanged = !!payload && payload.prevSessionId === payload.sessionId;
2007
+ clearTimeout(searchTimer);
2008
+ searchTimer = null;
2009
+ searchInput.value = "";
2010
+ showTree();
2011
+ treeState.activePath = null;
2012
+ if (dirChanged) forgetOpenTabs(payload.sessionId);
2013
+ viewer.reset();
1976
2014
  reloadTree({ reset: true });
1977
2015
  });
1978
2016
  const offTaskComplete = Workspace.on("workspace:taskCompleted", (payload) => {
@@ -2034,8 +2072,11 @@ const WorkspaceView = (() => {
2034
2072
  return Clacky.Preview.open(fileUrl(absPath));
2035
2073
  }
2036
2074
  if (window.Clacky && Clacky.Aside) Clacky.Aside.open();
2037
- const tabBtn = document.querySelector('.aside-tab[data-tab="files"]');
2038
- if (tabBtn) tabBtn.click();
2075
+ // Tabs open on demand, so the Files tab may not be on screen yet — ask the
2076
+ // slot to activate it rather than clicking a button that isn't there.
2077
+ if (window.Clacky && Clacky.ext && Clacky.ext.activateTab) {
2078
+ Clacky.ext.activateTab("session.aside", "files");
2079
+ }
2039
2080
  if (!_activeViewer) return false;
2040
2081
  _activeViewer.openTab(entry);
2041
2082
  revealTreePath(entry.path);