@celljs/ta-cloud-handoff 4.39.0 → 4.40.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-cloud-handoff",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "A pi package for Ta: a conversation of this computer goes on in a cloud workspace while the computer is away, by hand or by itself as it sleeps or runs low, its files and what was said carried over and back, checked the same on both sides",
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/core": "4.39.0",
31
- "@celljs/ta-protocol": "4.39.0",
32
- "@celljs/ta-web": "4.39.0",
30
+ "@celljs/core": "4.40.0",
31
+ "@celljs/ta-protocol": "4.40.0",
32
+ "@celljs/ta-web": "4.40.0",
33
33
  "@types/react": "^19.3.3"
34
34
  },
35
35
  "publishConfig": {
@@ -60,6 +60,8 @@
60
60
  "host": {
61
61
  "list": "chat.view",
62
62
  "away": "chat.view",
63
+ "copy": "owner",
64
+ "reach": "owner",
63
65
  "*": "hosts.use"
64
66
  },
65
67
  "tools": {
package/web/index.js CHANGED
@@ -1,36 +1,3 @@
1
- // web-src/handoff-protocol.ts
2
- var BOOK_KEY = "book";
3
- var SETTINGS_KEY = "settings";
4
- var HandoffSettingsUtil;
5
- ((HandoffSettingsUtil) => {
6
- HandoffSettingsUtil.AUTO_MINUTES = 15;
7
- HandoffSettingsUtil.AUTO_PERCENT = 10;
8
- HandoffSettingsUtil.PERCENTS = [10, 20, 30];
9
- function of(stored) {
10
- const value = stored && typeof stored === "object" ? stored : {};
11
- return {
12
- sleep: value.sleep !== false,
13
- battery: value.battery !== false,
14
- threshold: typeof value.threshold === "number" && HandoffSettingsUtil.PERCENTS.includes(value.threshold) ? value.threshold : "auto",
15
- bringBack: value.bringBack !== false
16
- };
17
- }
18
- HandoffSettingsUtil.of = of;
19
- function low(battery, settings) {
20
- if (!battery || battery.plugged) {
21
- return false;
22
- }
23
- if (settings.threshold !== "auto") {
24
- return battery.percent <= settings.threshold;
25
- }
26
- return battery.minutesLeft !== undefined ? battery.minutesLeft <= HandoffSettingsUtil.AUTO_MINUTES : battery.percent <= HandoffSettingsUtil.AUTO_PERCENT;
27
- }
28
- HandoffSettingsUtil.low = low;
29
- })(HandoffSettingsUtil ||= {});
30
- var HANDOFF_TOOL = "cloud_handoff";
31
- var LATER_TOOL = "later_on_computer";
32
- var NOTE_ENTRY = "ta-cloud-handoff";
33
-
34
1
  // ../ta-protocol/esm/common/language.js
35
2
  var TaLanguageUtil;
36
3
  (function(TaLanguageUtil2) {
@@ -72,6 +39,16 @@ var TaLanguageUtil;
72
39
 
73
40
  // web-src/i18n.ts
74
41
  var EN = {
42
+ lineMoving: "Moving to the cloud workspace {cloud}: it opens there in a moment",
43
+ lineCloud: "Going on in the cloud workspace {cloud}: it does not stop when this computer sleeps",
44
+ lineReturning: "Coming back from {cloud} with what it did there",
45
+ lineCopy: "Carried here from the computer {computer}: it goes back there once the computer is back",
46
+ lineCopyBack: "Back on the computer {computer}: it goes on there",
47
+ toComputer: "Back to the computer",
48
+ followThere: "Follow it in the cloud",
49
+ following: "Following it to the cloud workspace {cloud}…",
50
+ followFailed: "This phone could not follow it to the cloud: {reason}",
51
+ followedBack: "Back on the computer {computer}",
75
52
  handOff: "Go on in the cloud",
76
53
  handOffTo: "Go on in the cloud · {cloud}",
77
54
  takeBack: "Bring back to this computer",
@@ -114,6 +91,16 @@ var EN = {
114
91
  backHint: "Once the computer is back (awake, or plugged in) and the turn in the cloud ended, they come back here by themselves."
115
92
  };
116
93
  var ZH = {
94
+ lineMoving: "正在换到云端 {cloud},马上就在那边接着做",
95
+ lineCloud: "在云端 {cloud} 接着做,电脑合上也不会停",
96
+ lineReturning: "正在从云端 {cloud} 接回,带回那边做的改动",
97
+ lineCopy: "从电脑 {computer} 换到这里接着做,电脑回来后会自动接回",
98
+ lineCopyBack: "已接回电脑 {computer},在那边接着做",
99
+ toComputer: "回到电脑",
100
+ followThere: "到云端接着看",
101
+ following: "正在跟到云端 {cloud}…",
102
+ followFailed: "手机没能跟到云端:{reason}",
103
+ followedBack: "已回到电脑 {computer}",
117
104
  handOff: "交给云端接着做",
118
105
  handOffTo: "交给云端接着做 · {cloud}",
119
106
  takeBack: "接回本机",
@@ -156,6 +143,16 @@ var ZH = {
156
143
  backHint: "电脑醒来或接上电源,云端这一轮做完,就自动接回本机。"
157
144
  };
158
145
  var ZH_TW = {
146
+ lineMoving: "正在換到雲端 {cloud},馬上就在那邊接著做",
147
+ lineCloud: "在雲端 {cloud} 接著做,電腦闔上也不會停",
148
+ lineReturning: "正在從雲端 {cloud} 接回,帶回那邊做的改動",
149
+ lineCopy: "從電腦 {computer} 換到這裡接著做,電腦回來後會自動接回",
150
+ lineCopyBack: "已接回電腦 {computer},在那邊接著做",
151
+ toComputer: "回到電腦",
152
+ followThere: "到雲端接著看",
153
+ following: "正在跟到雲端 {cloud}…",
154
+ followFailed: "手機沒能跟到雲端:{reason}",
155
+ followedBack: "已回到電腦 {computer}",
159
156
  handOff: "交給雲端接著做",
160
157
  handOffTo: "交給雲端接著做 · {cloud}",
161
158
  takeBack: "接回本機",
@@ -198,6 +195,16 @@ var ZH_TW = {
198
195
  backHint: "電腦醒來或接上電源,雲端這一輪做完,就自動接回本機。"
199
196
  };
200
197
  var JA = {
198
+ lineMoving: "クラウド {cloud} へ移しています。まもなくそちらで続きます",
199
+ lineCloud: "クラウド {cloud} で続いています。パソコンがスリープしても止まりません",
200
+ lineReturning: "クラウド {cloud} から、そこでの変更と一緒に戻しています",
201
+ lineCopy: "パソコン {computer} から移ってきた会話です。パソコンが戻ると自動で戻ります",
202
+ lineCopyBack: "パソコン {computer} に戻りました。そちらで続きます",
203
+ toComputer: "パソコンに戻る",
204
+ followThere: "クラウドで続きを見る",
205
+ following: "クラウド {cloud} についていきます…",
206
+ followFailed: "このスマートフォンはクラウドについていけませんでした:{reason}",
207
+ followedBack: "パソコン {computer} に戻りました",
201
208
  handOff: "クラウドで続ける",
202
209
  handOffTo: "クラウドで続ける · {cloud}",
203
210
  takeBack: "このパソコンに戻す",
@@ -252,6 +259,191 @@ var HandoffWords;
252
259
  HandoffWords.format = format;
253
260
  })(HandoffWords ||= {});
254
261
 
262
+ // web-src/handoff-follow.ts
263
+ var FOLLOW_KEY = "ta-cloud-handoff:follow";
264
+ var OPEN_MS = 2 * 60000;
265
+ var RECENT_MS = 10 * 60000;
266
+ var MAX_DONE = 100;
267
+ var FollowBookUtil;
268
+ ((FollowBookUtil) => {
269
+ function read(storage) {
270
+ let kept;
271
+ try {
272
+ kept = JSON.parse(storage?.getItem(FOLLOW_KEY) ?? "null") ?? undefined;
273
+ } catch {
274
+ kept = undefined;
275
+ }
276
+ const record = (value) => value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter(([, one]) => typeof one === "string")) : {};
277
+ const open = kept?.open;
278
+ return {
279
+ clouds: record(kept?.clouds),
280
+ from: record(kept?.from),
281
+ ...open && typeof open.host === "string" && typeof open.sessionFile === "string" ? { open: { host: open.host, sessionFile: open.sessionFile, at: Number(open.at) || 0 } } : {},
282
+ done: Array.isArray(kept?.done) ? kept.done.filter((one) => typeof one === "string").slice(-MAX_DONE) : []
283
+ };
284
+ }
285
+ FollowBookUtil.read = read;
286
+ function write(storage, book) {
287
+ try {
288
+ storage?.setItem(FOLLOW_KEY, JSON.stringify({ ...book, done: book.done.slice(-MAX_DONE) }));
289
+ } catch {}
290
+ }
291
+ FollowBookUtil.write = write;
292
+ function deviceName(agent) {
293
+ return /iPhone/.test(agent) ? "iPhone" : /iPad/.test(agent) ? "iPad" : /Android/.test(agent) ? "Android" : "Ta";
294
+ }
295
+ FollowBookUtil.deviceName = deviceName;
296
+ })(FollowBookUtil ||= {});
297
+
298
+ class HandoffFollow {
299
+ pi;
300
+ storage;
301
+ now;
302
+ shown;
303
+ constructor(pi, storage = typeof localStorage === "undefined" ? undefined : localStorage, now = Date.now) {
304
+ this.pi = pi;
305
+ this.storage = storage;
306
+ this.now = now;
307
+ }
308
+ get words() {
309
+ return HandoffWords.of(this.pi.ui.language);
310
+ }
311
+ get able() {
312
+ return !!this.pi.hosts?.current()?.relay;
313
+ }
314
+ async toCloud(handoff, live, asked = false) {
315
+ const hosts = this.pi.hosts;
316
+ const here = hosts?.current();
317
+ if (!hosts || !here?.relay || handoff.state !== "cloud" || !handoff.cloudSessionFile || !asked && !live && this.now() - handoff.at > RECENT_MS) {
318
+ return;
319
+ }
320
+ const book = this.read();
321
+ if (book.done.includes(handoff.id) && !asked) {
322
+ return;
323
+ }
324
+ book.done.push(handoff.id);
325
+ this.write(book);
326
+ const key = `${here.id}
327
+ ${handoff.cloud}`;
328
+ this.pi.ui.notify(HandoffWords.format(this.words.following, { cloud: handoff.cloud }), "info", { key: `ta-cloud-handoff:follow:${handoff.id}` });
329
+ try {
330
+ let id = book.clouds[key];
331
+ if (!id || !hosts.list().some((one) => one.id === id)) {
332
+ const link = await this.pi.callHost("reach", handoff.cloud, FollowBookUtil.deviceName(navigator.userAgent));
333
+ id = hosts.keep(link, handoff.cloud);
334
+ }
335
+ const next = this.read();
336
+ next.clouds[key] = id;
337
+ next.from[id] = here.id;
338
+ next.open = { host: id, sessionFile: handoff.cloudSessionFile, at: this.now() };
339
+ this.write(next);
340
+ hosts.switchTo(id);
341
+ } catch (error) {
342
+ this.pi.ui.notify(HandoffWords.format(this.words.followFailed, { reason: error instanceof Error ? error.message : String(error) }), "warning", {
343
+ key: `ta-cloud-handoff:follow:${handoff.id}`
344
+ });
345
+ }
346
+ }
347
+ async arrive() {
348
+ const book = this.read();
349
+ const here = this.pi.hosts?.current();
350
+ const open = book.open;
351
+ if (!open || !here || open.host !== here.id) {
352
+ return;
353
+ }
354
+ delete book.open;
355
+ this.write(book);
356
+ if (this.now() - open.at > OPEN_MS) {
357
+ return;
358
+ }
359
+ for (let attempt = 0;attempt < 8; attempt++) {
360
+ if (await this.pi.openChat?.(open.sessionFile).catch(() => false)) {
361
+ return;
362
+ }
363
+ await new Promise((resolve) => setTimeout(resolve, 750));
364
+ }
365
+ }
366
+ computerOf(copy) {
367
+ const hosts = this.pi.hosts;
368
+ const here = hosts?.current();
369
+ if (!hosts || !here) {
370
+ return;
371
+ }
372
+ const from = this.read().from[here.id];
373
+ const list = hosts.list();
374
+ return list.find((one) => one.id === from)?.id ?? list.find((one) => one.id !== here.id && one.machine === copy.computer)?.id;
375
+ }
376
+ goBack(computer, sessionFile) {
377
+ const book = this.read();
378
+ book.open = { host: computer, sessionFile, at: this.now() };
379
+ this.write(book);
380
+ this.pi.hosts?.switchTo(computer);
381
+ }
382
+ back(copy, live) {
383
+ if (!copy.back || !live && this.now() - copy.back > RECENT_MS) {
384
+ return;
385
+ }
386
+ const book = this.read();
387
+ const mark = `back:${copy.sessionFile}:${copy.back}`;
388
+ if (book.done.includes(mark)) {
389
+ return;
390
+ }
391
+ book.done.push(mark);
392
+ this.write(book);
393
+ const computer = this.computerOf(copy);
394
+ const text = HandoffWords.format(this.words.followedBack, { computer: copy.computer });
395
+ if (computer && this.shown === copy.sessionFile) {
396
+ this.pi.ui.notify(text, "info", { key: `ta-cloud-handoff:back:${copy.sessionFile}` });
397
+ this.goBack(computer, copy.here);
398
+ return;
399
+ }
400
+ this.pi.ui.notify(text, "info", {
401
+ key: `ta-cloud-handoff:back:${copy.sessionFile}`,
402
+ ...computer ? { action: { label: this.words.toComputer, run: () => this.goBack(computer, copy.here) } } : {}
403
+ });
404
+ }
405
+ read() {
406
+ return FollowBookUtil.read(this.storage);
407
+ }
408
+ write(book) {
409
+ FollowBookUtil.write(this.storage, book);
410
+ }
411
+ }
412
+
413
+ // web-src/handoff-protocol.ts
414
+ var BOOK_KEY = "book";
415
+ var COPIES_KEY = "copies";
416
+ var SETTINGS_KEY = "settings";
417
+ var HandoffSettingsUtil;
418
+ ((HandoffSettingsUtil) => {
419
+ HandoffSettingsUtil.AUTO_MINUTES = 15;
420
+ HandoffSettingsUtil.AUTO_PERCENT = 10;
421
+ HandoffSettingsUtil.PERCENTS = [10, 20, 30];
422
+ function of(stored) {
423
+ const value = stored && typeof stored === "object" ? stored : {};
424
+ return {
425
+ sleep: value.sleep !== false,
426
+ battery: value.battery !== false,
427
+ threshold: typeof value.threshold === "number" && HandoffSettingsUtil.PERCENTS.includes(value.threshold) ? value.threshold : "auto",
428
+ bringBack: value.bringBack !== false
429
+ };
430
+ }
431
+ HandoffSettingsUtil.of = of;
432
+ function low(battery, settings) {
433
+ if (!battery || battery.plugged) {
434
+ return false;
435
+ }
436
+ if (settings.threshold !== "auto") {
437
+ return battery.percent <= settings.threshold;
438
+ }
439
+ return battery.minutesLeft !== undefined ? battery.minutesLeft <= HandoffSettingsUtil.AUTO_MINUTES : battery.percent <= HandoffSettingsUtil.AUTO_PERCENT;
440
+ }
441
+ HandoffSettingsUtil.low = low;
442
+ })(HandoffSettingsUtil ||= {});
443
+ var HANDOFF_TOOL = "cloud_handoff";
444
+ var LATER_TOOL = "later_on_computer";
445
+ var NOTE_ENTRY = "ta-cloud-handoff";
446
+
255
447
  // web-src/react.ts
256
448
  var React;
257
449
  function bind(react) {
@@ -370,6 +562,16 @@ var STYLE = `
370
562
  .tch-threshold > fieldset:disabled { opacity: 0.5; }
371
563
  .tch-now { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
372
564
  .tch-note-text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
565
+ /* Above the box of a conversation away: where it goes on and what happens now, the way back in a tap. */
566
+ .tch-line { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0 0 6px; padding: 6px 6px 6px 12px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-card); color: var(--ta-secondary); font-size: calc(13px * var(--ta-font-scale)); line-height: 1.5; }
567
+ .tch-line > i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ta-blue); }
568
+ .tch-line[data-state='moving'] > i, .tch-line[data-state='returning'] > i { animation: tch-pulse 1.2s var(--ta-ease, ease) infinite; }
569
+ .tch-line[data-state='back'] > i { background: var(--ta-green); }
570
+ .tch-line-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
571
+ .tch-line > .ta-button { flex: none; }
572
+ .tch-line > .ta-spinner { flex: none; margin-right: 6px; }
573
+ @keyframes tch-pulse { 50% { opacity: 0.3; } }
574
+ [data-layout='compact'] .tch-line-text { white-space: normal; }
373
575
  `;
374
576
  function injectStyle() {
375
577
  const element = document.createElement("style");
@@ -392,12 +594,17 @@ function reason(error) {
392
594
 
393
595
  class HandoffState {
394
596
  pi;
597
+ onCloud;
395
598
  handoffs = [];
396
599
  workspaces = [];
397
600
  listeners = new Set;
398
601
  stop;
399
- constructor(pi) {
602
+ loaded = false;
603
+ constructor(pi, onCloud = () => {
604
+ return;
605
+ }) {
400
606
  this.pi = pi;
607
+ this.onCloud = onCloud;
401
608
  this.stop = pi.storage.onChange((keys) => {
402
609
  if (keys.includes(BOOK_KEY)) {
403
610
  this.refresh();
@@ -411,8 +618,16 @@ class HandoffState {
411
618
  return;
412
619
  });
413
620
  if (listed) {
621
+ const before = new Map(this.handoffs.map((handoff) => [handoff.id, handoff.state]));
622
+ const live = this.loaded;
414
623
  this.handoffs = listed.handoffs;
415
624
  this.workspaces = listed.workspaces;
625
+ this.loaded = true;
626
+ for (const handoff of listed.handoffs) {
627
+ if (handoff.state === "cloud" && before.get(handoff.id) !== "cloud") {
628
+ this.onCloud(handoff, live);
629
+ }
630
+ }
416
631
  for (const listener of this.listeners) {
417
632
  listener();
418
633
  }
@@ -429,10 +644,118 @@ class HandoffState {
429
644
  this.stop();
430
645
  }
431
646
  }
647
+
648
+ class CopiesState {
649
+ pi;
650
+ onBack;
651
+ copies = [];
652
+ listeners = new Set;
653
+ stop;
654
+ loaded = false;
655
+ constructor(pi, onBack) {
656
+ this.pi = pi;
657
+ this.onBack = onBack;
658
+ this.stop = pi.storage.onChange((keys) => {
659
+ if (keys.includes(COPIES_KEY)) {
660
+ this.refresh();
661
+ }
662
+ });
663
+ this.refresh();
664
+ }
665
+ async refresh() {
666
+ const kept = await this.pi.storage.get(COPIES_KEY).catch(() => {
667
+ return;
668
+ });
669
+ const copies = Array.isArray(kept?.copies) ? kept.copies : [];
670
+ const before = new Map(this.copies.map((copy) => [copy.sessionFile, copy.back]));
671
+ const live = this.loaded;
672
+ this.copies = copies;
673
+ this.loaded = true;
674
+ for (const copy of copies) {
675
+ if (copy.back && before.get(copy.sessionFile) !== copy.back) {
676
+ this.onBack(copy, live);
677
+ }
678
+ }
679
+ for (const listener of this.listeners) {
680
+ listener();
681
+ }
682
+ }
683
+ of(sessionFile) {
684
+ return sessionFile ? this.copies.find((copy) => copy.sessionFile === sessionFile) : undefined;
685
+ }
686
+ subscribe(listener) {
687
+ this.listeners.add(listener);
688
+ return () => this.listeners.delete(listener);
689
+ }
690
+ dispose() {
691
+ this.stop();
692
+ }
693
+ }
694
+ function useNoBusy() {
695
+ return [false, async (action) => action()];
696
+ }
697
+ function CloudLine({ pi, state, copies, follow, takeBack, conversation }) {
698
+ const [, redraw] = React.useState(0);
699
+ React.useEffect(() => {
700
+ const again = () => redraw((n) => n + 1);
701
+ const stops = [state.subscribe(again), copies.subscribe(again)];
702
+ return () => {
703
+ for (const stop of stops) {
704
+ stop();
705
+ }
706
+ };
707
+ }, [state, copies]);
708
+ const file = conversation.sessionFile;
709
+ React.useEffect(() => {
710
+ follow.shown = file;
711
+ return () => {
712
+ if (follow.shown === file) {
713
+ follow.shown = undefined;
714
+ }
715
+ };
716
+ }, [follow, file]);
717
+ const [busy, run] = (pi.ui.useBusy ?? useNoBusy)();
718
+ const words = HandoffWords.of(pi.ui.language);
719
+ const handoff = state.of(file);
720
+ if (handoff) {
721
+ const text = handoff.state === "moving" ? words.lineMoving : handoff.state === "returning" ? words.lineReturning : words.lineCloud;
722
+ return /* @__PURE__ */ React.createElement("div", {
723
+ className: "tch-line",
724
+ "data-state": handoff.state
725
+ }, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
726
+ className: "tch-line-text"
727
+ }, HandoffWords.format(text, { cloud: handoff.cloud })), handoff.state === "cloud" ? /* @__PURE__ */ React.createElement("button", {
728
+ type: "button",
729
+ className: "ta-button",
730
+ disabled: busy,
731
+ onClick: () => void run(() => takeBack(handoff))
732
+ }, words.takeBack) : /* @__PURE__ */ React.createElement("span", {
733
+ className: "ta-spinner ta-busy-mark"
734
+ }));
735
+ }
736
+ const copy = copies.of(file);
737
+ if (!copy) {
738
+ return null;
739
+ }
740
+ const computer = follow.computerOf(copy);
741
+ return /* @__PURE__ */ React.createElement("div", {
742
+ className: "tch-line",
743
+ "data-state": copy.back ? "back" : "copy"
744
+ }, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
745
+ className: "tch-line-text"
746
+ }, HandoffWords.format(copy.back ? words.lineCopyBack : words.lineCopy, { computer: copy.computer })), computer && /* @__PURE__ */ React.createElement("button", {
747
+ type: "button",
748
+ className: "ta-button",
749
+ onClick: () => follow.goBack(computer, copy.here)
750
+ }, words.toComputer));
751
+ }
432
752
  function activate(pi) {
433
753
  bind(pi.React);
434
754
  const removeStyle = injectStyle();
435
- const state = new HandoffState(pi);
755
+ const follow = new HandoffFollow(pi);
756
+ const state = new HandoffState(pi, (handoff, live) => void follow.toCloud(handoff, live));
757
+ const copies = new CopiesState(pi, (copy, live) => follow.back(copy, live));
758
+ follow.arrive();
436
759
  const words = () => HandoffWords.of(pi.ui.language);
437
760
  const say = (text, values = {}) => HandoffWords.format(text, values);
438
761
  const handOff = (sessionFile, cloud) => {
@@ -444,11 +767,21 @@ function activate(pi) {
444
767
  };
445
768
  const takeBack = (handoff) => {
446
769
  pi.ui.notify(words().returning, "info", { key: `ta-cloud-handoff:${handoff.sessionFile}` });
447
- pi.callHost("takeBack", handoff.id).then((result) => pi.ui.notify(result.files === "conflict" ? words().backConflict : words().back, result.files === "conflict" ? "warning" : "info", {
770
+ return pi.callHost("takeBack", handoff.id).then((result) => pi.ui.notify(result.files === "conflict" ? words().backConflict : words().back, result.files === "conflict" ? "warning" : "info", {
448
771
  key: `ta-cloud-handoff:${handoff.sessionFile}`,
449
772
  action: { label: words().open, run: () => void pi.openChat?.(result.sessionFile) }
450
773
  })).catch((error) => pi.ui.notify(reason(error), "error", { key: `ta-cloud-handoff:${handoff.sessionFile}` }));
451
774
  };
775
+ pi.registerComposerAddon?.({
776
+ above: ({ conversation }) => /* @__PURE__ */ React.createElement(CloudLine, {
777
+ pi,
778
+ state,
779
+ copies,
780
+ follow,
781
+ takeBack,
782
+ conversation
783
+ })
784
+ });
452
785
  pi.registerSettings(handoffSettings(pi, () => state.workspaces.length > 0));
453
786
  pi.registerSessionMenu?.((session) => {
454
787
  const icons = pi.ui.icons;
@@ -469,7 +802,8 @@ function activate(pi) {
469
802
  ];
470
803
  }
471
804
  return [
472
- { key: "cloud-handoff-back", label: words().takeBack, icon: icons.Laptop ?? icons.Monitor, run: () => takeBack(handoff) },
805
+ { key: "cloud-handoff-back", label: words().takeBack, icon: icons.Laptop ?? icons.Monitor, run: () => void takeBack(handoff) },
806
+ ...follow.able ? [{ key: "cloud-handoff-follow", label: words().followThere, icon: icons.Cloud, run: () => void follow.toCloud(handoff, true, true) }] : [],
473
807
  ...page(handoff.cloudUrl) ? [{ key: "cloud-handoff-open", label: words().openCloud, icon: icons.ExternalLink, run: () => void pi.openLink(handoff.cloudUrl) }] : []
474
808
  ];
475
809
  }
@@ -524,6 +858,7 @@ function activate(pi) {
524
858
  });
525
859
  return () => {
526
860
  state.dispose();
861
+ copies.dispose();
527
862
  removeStyle();
528
863
  };
529
864
  }