@celljs/ta-channels 4.11.0 → 4.12.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 (2) hide show
  1. package/package.json +4 -4
  2. package/web/index.js +54 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-channels",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "A pi package for Ta: agents with roles of their own and channels where the user, Ta and the agents talk; Ta builds the team for what the user wants",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,9 +27,9 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.11.0",
31
- "@celljs/ta-relay": "4.11.0",
32
- "@celljs/ta-web": "4.11.0",
30
+ "@celljs/ta-protocol": "4.12.0",
31
+ "@celljs/ta-relay": "4.12.0",
32
+ "@celljs/ta-web": "4.12.0",
33
33
  "@types/react": "^19.3.0"
34
34
  },
35
35
  "publishConfig": {
package/web/index.js CHANGED
@@ -1644,6 +1644,20 @@ function useServerCwd(pi) {
1644
1644
  }
1645
1645
  var SidebarUtil;
1646
1646
  ((SidebarUtil) => {
1647
+ function homeSections(items) {
1648
+ const sections = new Map;
1649
+ for (const item of items) {
1650
+ if (!item.section) {
1651
+ continue;
1652
+ }
1653
+ const id = `home:${item.extension ?? ""}:${item.section}`;
1654
+ const section = sections.get(id) ?? { id, title: item.section, items: [] };
1655
+ section.items.push(item);
1656
+ sections.set(id, section);
1657
+ }
1658
+ return [...sections.values()];
1659
+ }
1660
+ SidebarUtil.homeSections = homeSections;
1647
1661
  function needsLook(task, seen) {
1648
1662
  if (task.status === "waiting") {
1649
1663
  return true;
@@ -4324,8 +4338,14 @@ function useUnseen(storage, latest, busy, shown, answered, known) {
4324
4338
  }
4325
4339
  function useSessionLines(context, changed) {
4326
4340
  const { pi } = context;
4341
+ const listed = pi.ui.useSavedSessions?.();
4342
+ const follows = !!listed;
4327
4343
  const [lines, setLines] = React.useState(context.sessionLines);
4344
+ const again = follows ? "" : changed;
4328
4345
  React.useEffect(() => {
4346
+ if (follows && context.sessionLines) {
4347
+ return;
4348
+ }
4329
4349
  let live = true;
4330
4350
  const read = () => Promise.all([pi.server.listSessions().catch(() => []), pi.server.listSavedSessions().catch(() => [])]).then(([open, saved]) => {
4331
4351
  context.sessionLines = [...saved, ...open];
@@ -4334,14 +4354,19 @@ function useSessionLines(context, changed) {
4334
4354
  }
4335
4355
  });
4336
4356
  read();
4337
- const again = () => document.visibilityState === "visible" && void read();
4338
- document.addEventListener("visibilitychange", again);
4357
+ if (follows) {
4358
+ return () => {
4359
+ live = false;
4360
+ };
4361
+ }
4362
+ const onShow = () => document.visibilityState === "visible" && void read();
4363
+ document.addEventListener("visibilitychange", onShow);
4339
4364
  return () => {
4340
4365
  live = false;
4341
- document.removeEventListener("visibilitychange", again);
4366
+ document.removeEventListener("visibilitychange", onShow);
4342
4367
  };
4343
- }, [context, pi, changed]);
4344
- return lines;
4368
+ }, [context, pi, follows, again]);
4369
+ return React.useMemo(() => lines && listed ? [...lines, ...listed] : lines, [lines, listed]);
4345
4370
  }
4346
4371
  function useTaskSelection(pi, tasks) {
4347
4372
  const [chosen, setChosen] = React.useState();
@@ -4428,13 +4453,16 @@ var NO_HOME_ITEMS = [];
4428
4453
  function HomeRow({ pi, item }) {
4429
4454
  const [opening, setOpening] = React.useState(false);
4430
4455
  const Glyph = item.icon;
4456
+ const Own = item.face;
4431
4457
  const open = () => {
4432
4458
  setOpening(true);
4433
4459
  Promise.resolve().then(() => item.open()).catch((error) => pi.ui.notify(ChannelViews.message(error), "error")).finally(() => setOpening(false));
4434
4460
  };
4435
4461
  return /* @__PURE__ */ React.createElement(Row, {
4436
4462
  pi,
4437
- avatar: /* @__PURE__ */ React.createElement("span", {
4463
+ avatar: Own && !opening ? /* @__PURE__ */ React.createElement(Own, {
4464
+ size: 40
4465
+ }) : /* @__PURE__ */ React.createElement("span", {
4438
4466
  className: "tac-home-icon",
4439
4467
  style: { background: `var(--ta-tint-${item.tone})`, color: `var(--ta-tint-ink-${item.tone})` }
4440
4468
  }, opening ? /* @__PURE__ */ React.createElement("span", {
@@ -4465,6 +4493,8 @@ function AgentsSidebar({ context }) {
4465
4493
  const agentPage = pi.ui.useView(AGENT_PAGE);
4466
4494
  const tasks = pi.ui.useTasks();
4467
4495
  const homeItems = pi.ui.useHomeItems?.() ?? NO_HOME_ITEMS;
4496
+ const homeShown = homeItems.filter((item) => SidebarUtil.matches(query, item.title, item.detail));
4497
+ const homeSections = SidebarUtil.homeSections(homeShown);
4468
4498
  const [folded, fold] = useFolded();
4469
4499
  const [byDirectory, setByDirectory] = useStored(pi.storage, BY_DIRECTORY_KEY, false);
4470
4500
  const language = pi.ui.language;
@@ -4535,7 +4565,7 @@ function AgentsSidebar({ context }) {
4535
4565
  return opening === agent.id || !pageShown && !!sessionId && sessionId === shownSession;
4536
4566
  };
4537
4567
  const ended = allEnded || selection.selecting ? groups.ended : groups.ended.slice(0, ENDED_SHOWN);
4538
- const nothing = query && shownTasks.length === 0 && channels.length === 0 && agents.length === 0;
4568
+ const nothing = query && shownTasks.length === 0 && channels.length === 0 && agents.length === 0 && homeShown.length === 0;
4539
4569
  const running = tasks.filter((task) => task.status === "running").length;
4540
4570
  const waiting = tasks.filter((task) => task.status === "waiting").length;
4541
4571
  const fresh = tasks.filter((task) => task.status !== "waiting" && seen.needsLook(task)).length;
@@ -4586,7 +4616,7 @@ function AgentsSidebar({ context }) {
4586
4616
  items: () => (double.menu?.() ?? []).map((section) => section.map(({ icon: Icon, ...item }) => ({ ...item, icon: Icon && /* @__PURE__ */ React.createElement(Icon, {
4587
4617
  size: 15
4588
4618
  }) })))
4589
- })), homeItems.filter((item) => SidebarUtil.matches(query, item.title, item.detail)).map((item) => /* @__PURE__ */ React.createElement(HomeRow, {
4619
+ })), homeShown.filter((item) => !item.section).map((item) => /* @__PURE__ */ React.createElement(HomeRow, {
4590
4620
  key: item.key,
4591
4621
  pi,
4592
4622
  item
@@ -4738,7 +4768,19 @@ function AgentsSidebar({ context }) {
4738
4768
  }),
4739
4769
  swipe: swipePinDelete(pi, !!channel.pinned, (pinned) => context.service.updateChannel(channel.id, { pinned }), () => deleteChannel(context, channel))
4740
4770
  });
4741
- }))), selection.selecting && SelectBar && /* @__PURE__ */ React.createElement(SelectBar, {
4771
+ })), homeSections.map((section) => /* @__PURE__ */ React.createElement(Section, {
4772
+ key: section.id,
4773
+ id: section.id,
4774
+ title: section.title,
4775
+ count: section.items.length,
4776
+ folded,
4777
+ onFold: fold,
4778
+ alert: section.items.some((item) => item.unseen)
4779
+ }, section.items.map((item) => /* @__PURE__ */ React.createElement(HomeRow, {
4780
+ key: item.key,
4781
+ pi,
4782
+ item
4783
+ }))))), selection.selecting && SelectBar && /* @__PURE__ */ React.createElement(SelectBar, {
4742
4784
  count: selection.selected.length,
4743
4785
  total: selection.removable.length,
4744
4786
  onSelectAll: selection.selectAll,
@@ -4871,6 +4913,9 @@ button.tac-notice-line:disabled { cursor: default; }
4871
4913
  .tac-live-faces { display: inline-flex; }
4872
4914
  .tac-live-faces > * + * { margin-left: -4px; }
4873
4915
  .tac-chat-bottom { width: 100%; max-width: calc(var(--ta-col) + 48px); margin: 0 auto; padding: 8px 24px calc(16px + env(safe-area-inset-bottom)); box-sizing: border-box; flex: none; display: flex; flex-direction: column; gap: 8px; }
4916
+ /* Above the keyboard the home indicator is not there: no room for it, as under the box of a conversation. */
4917
+ :root[data-keyboard] .tac-chat-bottom { padding-bottom: 8px; }
4918
+ :root[data-keyboard-moving] .tac-chat-bottom { transition: padding-bottom 450ms cubic-bezier(0.15, 0.75, 0.2, 1); }
4874
4919
  @media (max-width: 720px) {
4875
4920
  .tac-head-topic, .tac-head-face:nth-child(n + 4), .tac-head-more { display: none; }
4876
4921
  .tac-chat-col, .tac-chat-bottom { padding-left: 14px; padding-right: 14px; }