@sma1lboy/kobe 0.5.3 → 0.5.5

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.
package/dist/bin/kobed.js CHANGED
@@ -2355,6 +2355,7 @@ var init_env = () => {};
2355
2355
  var exports_repos = {};
2356
2356
  __export(exports_repos, {
2357
2357
  statePath: () => statePath,
2358
+ sameRepoToplevel: () => sameRepoToplevel,
2358
2359
  resolveRepoRoot: () => resolveRepoRoot,
2359
2360
  removeSavedRepo: () => removeSavedRepo,
2360
2361
  normalizeSavedRepos: () => normalizeSavedRepos,
@@ -2381,6 +2382,19 @@ function resolveRepoRoot(absPath) {
2381
2382
  } catch {}
2382
2383
  return top;
2383
2384
  }
2385
+ function sameRepoToplevel(a, b) {
2386
+ if (a === b)
2387
+ return true;
2388
+ const topA = resolveRepoRoot(a);
2389
+ const topB = resolveRepoRoot(b);
2390
+ if (topA === topB)
2391
+ return true;
2392
+ try {
2393
+ return realpathSync(topA) === realpathSync(topB);
2394
+ } catch {
2395
+ return false;
2396
+ }
2397
+ }
2384
2398
  function statePath() {
2385
2399
  return kvStatePath();
2386
2400
  }
@@ -3024,13 +3038,13 @@ class Orchestrator {
3024
3038
  throw new Error("ensureMainTask: repo is required");
3025
3039
  const normalized = resolveRepoRoot(repo);
3026
3040
  const all = this.store.list();
3027
- const candidates = all.filter((t) => t.kind === "main" && (t.repo === normalized || resolveRepoRoot(t.repo) === normalized));
3041
+ const candidates = all.filter((t) => t.kind === "main" && sameRepoToplevel(t.repo, normalized));
3028
3042
  const winner = candidates.find((t) => t.repo === normalized) ?? candidates[0];
3029
3043
  if (winner) {
3030
3044
  for (const dup of candidates) {
3031
3045
  if (dup.id !== winner.id) {
3032
3046
  try {
3033
- await this.deleteTask(dup.id);
3047
+ await this.store.remove(dup.id);
3034
3048
  } catch (err) {
3035
3049
  console.error(`[kobe orchestrator] ensureMainTask: failed to remove duplicate ${dup.id}:`, err);
3036
3050
  }
@@ -3431,6 +3445,15 @@ class Orchestrator {
3431
3445
  await this.store.update(task.id, { tabs });
3432
3446
  return tab;
3433
3447
  }
3448
+ async clearTab(id, tabId) {
3449
+ const task = this.requireTask(id);
3450
+ if (!task.tabs.some((t) => t.id === tabId)) {
3451
+ throw new Error(`clearTab: tab ${tabId} not found on task ${task.id}`);
3452
+ }
3453
+ await this.stopTab(task.id, tabId);
3454
+ await this.updateTab(task.id, tabId, { sessionId: null });
3455
+ this.dispatchEvent(task.id, tabId, { type: "chat.tab.cleared" });
3456
+ }
3434
3457
  async closeTab(id, tabId) {
3435
3458
  const task = this.requireTask(id);
3436
3459
  if (task.tabs.length <= 1) {
@@ -4681,6 +4704,12 @@ async function startDaemonServer(orch, options = {}) {
4681
4704
  broadcastTaskUpdated(orch, clients, taskId);
4682
4705
  return {};
4683
4706
  }
4707
+ case "chat.tab.clear": {
4708
+ const taskId = requireString2(payload, "taskId");
4709
+ await orch.clearTab(taskId, requireString2(payload, "tabId"));
4710
+ broadcastTaskUpdated(orch, clients, taskId);
4711
+ return {};
4712
+ }
4684
4713
  case "chat.sessions": {
4685
4714
  const sessions = await orch.listSessions(requireString2(payload, "taskId"));
4686
4715
  return { sessions };