relay-companion 0.1.76 → 0.1.77
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/THIRD_PARTY_NOTICES.md +34 -0
- package/licenses/Apache-2.0.txt +201 -0
- package/overlay/inbox.html +32 -9
- package/overlay/main.cjs +249 -1
- package/overlay/preload.cjs +4 -0
- package/overlay/preview-preload-source.cjs +118 -0
- package/overlay/preview-preload.cjs +6487 -0
- package/overlay/preview-renderer.js +165 -0
- package/overlay/preview.html +252 -0
- package/package.json +12 -3
- package/src/mcp.js +10 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The Relay preview preload embeds the following open-source software in
|
|
4
|
+
`overlay/preview-preload.cjs`.
|
|
5
|
+
|
|
6
|
+
## markdown-it 14.3.0
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin.
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
## DOMPurify 3.4.13
|
|
29
|
+
|
|
30
|
+
Copyright (c) Cure53 and other contributors.
|
|
31
|
+
|
|
32
|
+
DOMPurify is distributed under the Apache License 2.0 or the Mozilla Public
|
|
33
|
+
License 2.0. Relay distributes its embedded copy under the Apache License 2.0.
|
|
34
|
+
The complete terms are included in [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/overlay/inbox.html
CHANGED
|
@@ -903,6 +903,9 @@
|
|
|
903
903
|
}
|
|
904
904
|
function playTink() {
|
|
905
905
|
if (REDUCED) return;
|
|
906
|
+
// A test overlay must never make noise on the developer's machine — the
|
|
907
|
+
// sound is indistinguishable from the real pill's and lands mid-work.
|
|
908
|
+
if (window.relay && window.relay.isTestOverlay) return;
|
|
906
909
|
if (!actx) initAudio();
|
|
907
910
|
if (!actx) return;
|
|
908
911
|
if (actx.state === "suspended") actx.resume();
|
|
@@ -1602,15 +1605,20 @@
|
|
|
1602
1605
|
}
|
|
1603
1606
|
}
|
|
1604
1607
|
|
|
1605
|
-
//
|
|
1606
|
-
//
|
|
1607
|
-
//
|
|
1608
|
-
function openActionsHtml(id, { thread } = {}) {
|
|
1608
|
+
// Preview plus the two host-open actions, as one small text-first menu.
|
|
1609
|
+
// Preview is the primary, non-navigation path; the other actions hand the
|
|
1610
|
+
// relay to a current or fresh host session.
|
|
1611
|
+
function openActionsHtml(id, { thread, previewable = true } = {}) {
|
|
1612
|
+
const preview = thread ? `data-thread-preview="${esc(id)}"` : `data-preview="${esc(id)}"`;
|
|
1609
1613
|
const cur = thread ? `data-thread-open-current="${esc(id)}"` : `data-open-current="${esc(id)}"`;
|
|
1610
1614
|
const fresh = thread ? `data-thread-open-fresh="${esc(id)}"` : `data-open-fresh="${esc(id)}"`;
|
|
1615
|
+
const previewItem = previewable
|
|
1616
|
+
? `<button class="oa-item oa-primary" type="button" role="menuitem" ${preview}>${thread ? "Preview Latest Received Relay" : "Preview"}</button><div class="oa-sep" role="separator"></div>`
|
|
1617
|
+
: "";
|
|
1611
1618
|
return `
|
|
1612
1619
|
<div class="open-actions row-open-card" data-stop="1" role="menu">
|
|
1613
|
-
|
|
1620
|
+
${previewItem}
|
|
1621
|
+
<button class="oa-item${previewable ? "" : " oa-primary"}" type="button" role="menuitem" ${cur}>${thread ? "Open Thread in Current Chat" : "Open in Current Chat"}</button>
|
|
1614
1622
|
<div class="oa-sep" role="separator"></div>
|
|
1615
1623
|
<button class="oa-item" type="button" role="menuitem" ${fresh}>${thread ? "Open Thread in New Chat" : "Open in New Chat"}</button>
|
|
1616
1624
|
</div>`;
|
|
@@ -1808,8 +1816,18 @@
|
|
|
1808
1816
|
openRelayFromUI(id);
|
|
1809
1817
|
});
|
|
1810
1818
|
}
|
|
1811
|
-
//
|
|
1812
|
-
//
|
|
1819
|
+
// Preview opens an independent, focusable render window. Main marks the
|
|
1820
|
+
// relay read only after that renderer confirms a successful body paint.
|
|
1821
|
+
for (const btn of relaysListEl.querySelectorAll("[data-preview]")) {
|
|
1822
|
+
const id = btn.getAttribute("data-preview");
|
|
1823
|
+
btn.addEventListener("click", () => {
|
|
1824
|
+
expandedRelayId = null;
|
|
1825
|
+
window.relay.preview(id);
|
|
1826
|
+
renderRelays();
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
// Host-open actions mark the relay read exactly like a normal open (main
|
|
1830
|
+
// acks on completion) and ride the existing opening spinner.
|
|
1813
1831
|
for (const btn of relaysListEl.querySelectorAll("[data-open-current]")) {
|
|
1814
1832
|
const id = btn.getAttribute("data-open-current");
|
|
1815
1833
|
btn.addEventListener("click", () => {
|
|
@@ -2643,8 +2661,11 @@
|
|
|
2643
2661
|
// Thread-level opens act on the newest inbound message (falling back to the
|
|
2644
2662
|
// newest message overall): "current" injects with the threadId so the agent
|
|
2645
2663
|
// fetches the whole exchange; "new chat" seeds the full transcript.
|
|
2646
|
-
const newestInbound = [...thread.msgs].reverse().find((m) => m.direction === "in") ||
|
|
2647
|
-
const
|
|
2664
|
+
const newestInbound = [...thread.msgs].reverse().find((m) => m.direction === "in") || null;
|
|
2665
|
+
const threadOpenTarget = newestInbound || thread.msgs[thread.msgs.length - 1];
|
|
2666
|
+
const threadActions = threadOpenTarget
|
|
2667
|
+
? openActionsHtml(threadOpenTarget.id, { thread: true, previewable: Boolean(newestInbound) })
|
|
2668
|
+
: "";
|
|
2648
2669
|
thHistoryEl.innerHTML = threadActions + thread.msgs.map((m) => `
|
|
2649
2670
|
<button class="th-msg${m.unread ? " unread" : ""}" type="button" data-msg="${esc(m.id)}" data-dir="${m.direction}">
|
|
2650
2671
|
<span class="th-msg-top">
|
|
@@ -2664,6 +2685,8 @@
|
|
|
2664
2685
|
if (curBtn) curBtn.addEventListener("click", () => openRelayFromUI(curBtn.getAttribute("data-thread-open-current"), "relay", "current"));
|
|
2665
2686
|
const freshBtn = thHistoryEl.querySelector("[data-thread-open-fresh]");
|
|
2666
2687
|
if (freshBtn) freshBtn.addEventListener("click", () => openRelayFromUI(freshBtn.getAttribute("data-thread-open-fresh"), "relay", "fresh"));
|
|
2688
|
+
const previewBtn = thHistoryEl.querySelector("[data-thread-preview]");
|
|
2689
|
+
if (previewBtn) previewBtn.addEventListener("click", () => window.relay.preview(previewBtn.getAttribute("data-thread-preview")));
|
|
2667
2690
|
}
|
|
2668
2691
|
thBackEl.addEventListener("click", () => {
|
|
2669
2692
|
threadDetailId = null;
|
package/overlay/main.cjs
CHANGED
|
@@ -91,10 +91,17 @@ const RELAY_CLI = path.resolve(__dirname, "..", "bin", "relay.js");
|
|
|
91
91
|
|
|
92
92
|
// Fixed transparent canvas, large enough to contain the inbox sheet + spring/shadow room.
|
|
93
93
|
const WIN = { width: 520, height: 840 };
|
|
94
|
+
const PREVIEW_WIN = { width: 720, height: 760, minWidth: 480, minHeight: 480 };
|
|
94
95
|
const MARGIN = 8;
|
|
95
96
|
const DEFAULT_WEB_BASE = "https://sendrelays.com";
|
|
96
97
|
|
|
97
98
|
let win = null;
|
|
99
|
+
let previewWin = null;
|
|
100
|
+
let previewPayload = null;
|
|
101
|
+
let previewRendererReady = false;
|
|
102
|
+
let previewRenderedRelayId = null;
|
|
103
|
+
let previewPayloadVersion = 0;
|
|
104
|
+
let previewSentVersion = -1;
|
|
98
105
|
let tray = null;
|
|
99
106
|
let trayAvailable = false;
|
|
100
107
|
let hostRunning = false; // Claude or Codex desktop app is running (either)
|
|
@@ -1270,6 +1277,24 @@ function rowById(packetId) {
|
|
|
1270
1277
|
return row ? { id: packetId, ...row } : null;
|
|
1271
1278
|
}
|
|
1272
1279
|
|
|
1280
|
+
// Preview is deliberately an allowlisted, human-facing projection of a staged
|
|
1281
|
+
// relay. Never pass the recipient-session briefing, local content paths, signed
|
|
1282
|
+
// attachment URLs, or arbitrary packet fields into the renderer.
|
|
1283
|
+
function previewPayloadForPacket(packetId) {
|
|
1284
|
+
const id = String(packetId || "");
|
|
1285
|
+
if (!id) return null;
|
|
1286
|
+
const row = rowById(id);
|
|
1287
|
+
if (!row || row.direction !== "inbound" || RELAY_HIDDEN_KINDS.has(row.relayNotificationKind)) return null;
|
|
1288
|
+
return {
|
|
1289
|
+
relayId: id,
|
|
1290
|
+
title: String(row.title || row.displayTitle || "Relay"),
|
|
1291
|
+
bodyMarkdown: String(row.bodyMarkdown || ""),
|
|
1292
|
+
senderName: String(row.senderName || "Relay"),
|
|
1293
|
+
createdAt: String(row.createdAt || ""),
|
|
1294
|
+
unread: row.state !== "read",
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1273
1298
|
// Find an approvalId for a share_approval row. The staged row may not carry it,
|
|
1274
1299
|
// in which case the renderer routes to the web detail page (Review) instead.
|
|
1275
1300
|
function approvalIdForRow(row) {
|
|
@@ -2360,8 +2385,14 @@ function startHitTest() {
|
|
|
2360
2385
|
}
|
|
2361
2386
|
|
|
2362
2387
|
function createWindow() {
|
|
2388
|
+
// Harness overlays share the user's screen with the real pill and are visually
|
|
2389
|
+
// identical — four "Relays" on screen at once reads as the product spazzing
|
|
2390
|
+
// out. Make sandbox runs unmistakable and unobtrusive: half-transparent and
|
|
2391
|
+
// never above the user's real windows. Production is untouched.
|
|
2392
|
+
const isHarness = process.env.RELAY_OVERLAY_TEST === "1" || process.env.RELAY_OVERLAY_PERF === "1";
|
|
2363
2393
|
win = new BrowserWindow({
|
|
2364
2394
|
...anchorTopRight(),
|
|
2395
|
+
...(isHarness ? { opacity: 0.55 } : {}),
|
|
2365
2396
|
frame: false,
|
|
2366
2397
|
transparent: true,
|
|
2367
2398
|
backgroundColor: "#00000000",
|
|
@@ -2395,7 +2426,8 @@ function createWindow() {
|
|
|
2395
2426
|
// Windows strips WS_EX_TOPMOST from a scheduled-task-launched overlay that only asks
|
|
2396
2427
|
// politely ("floating"); "screen-saver" is the level that survives. The periodic
|
|
2397
2428
|
// re-assert that recovers from later demotions lives in space-presence.cjs.
|
|
2398
|
-
|
|
2429
|
+
// Harness windows stay behind the user's work; only the real pill floats.
|
|
2430
|
+
if (!isHarness) win.setAlwaysOnTop(true, process.platform === "win32" ? "screen-saver" : "floating");
|
|
2399
2431
|
win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
|
2400
2432
|
// Empty canvas is click-through; startHitTest() below owns this from here on.
|
|
2401
2433
|
win.setIgnoreMouseEvents(true, { forward: true });
|
|
@@ -2513,6 +2545,163 @@ function createWindow() {
|
|
|
2513
2545
|
setTimeout(hostLoop, hostPollDelayMs({ testMode, engaged: true }));
|
|
2514
2546
|
}
|
|
2515
2547
|
|
|
2548
|
+
function previewWindowExists() {
|
|
2549
|
+
return Boolean(previewWin && !previewWin.isDestroyed());
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
function showPreviewWindow() {
|
|
2553
|
+
if (!previewWindowExists()) return;
|
|
2554
|
+
try {
|
|
2555
|
+
if (previewWin.isMinimized()) previewWin.restore();
|
|
2556
|
+
previewWin.show();
|
|
2557
|
+
previewWin.focus();
|
|
2558
|
+
} catch (error) {
|
|
2559
|
+
console.error("[preview] show failed:", error && error.message);
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
function sendPreviewPayload() {
|
|
2564
|
+
if (!previewWindowExists() || !previewRendererReady || !previewPayload) return false;
|
|
2565
|
+
if (previewSentVersion === previewPayloadVersion) return true;
|
|
2566
|
+
previewWin.webContents.send("relay:preview:content", previewPayload);
|
|
2567
|
+
previewSentVersion = previewPayloadVersion;
|
|
2568
|
+
return true;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
function previewWindowPosition() {
|
|
2572
|
+
try {
|
|
2573
|
+
let point = screen.getCursorScreenPoint();
|
|
2574
|
+
if (win && !win.isDestroyed()) {
|
|
2575
|
+
const bounds = win.getBounds();
|
|
2576
|
+
point = {
|
|
2577
|
+
x: Math.round(bounds.x + bounds.width / 2),
|
|
2578
|
+
y: Math.round(bounds.y + bounds.height / 2),
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
const workArea = screen.getDisplayNearestPoint(point).workArea;
|
|
2582
|
+
return {
|
|
2583
|
+
x: Math.round(workArea.x + Math.max(0, (workArea.width - PREVIEW_WIN.width) / 2)),
|
|
2584
|
+
y: Math.round(workArea.y + Math.max(0, (workArea.height - PREVIEW_WIN.height) / 2)),
|
|
2585
|
+
};
|
|
2586
|
+
} catch {
|
|
2587
|
+
return {};
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
function createPreviewWindow() {
|
|
2592
|
+
previewRendererReady = false;
|
|
2593
|
+
previewRenderedRelayId = null;
|
|
2594
|
+
previewSentVersion = -1;
|
|
2595
|
+
previewWin = new BrowserWindow({
|
|
2596
|
+
width: PREVIEW_WIN.width,
|
|
2597
|
+
height: PREVIEW_WIN.height,
|
|
2598
|
+
minWidth: PREVIEW_WIN.minWidth,
|
|
2599
|
+
minHeight: PREVIEW_WIN.minHeight,
|
|
2600
|
+
...previewWindowPosition(),
|
|
2601
|
+
show: false,
|
|
2602
|
+
frame: false,
|
|
2603
|
+
transparent: false,
|
|
2604
|
+
backgroundColor: "#f5f1e9",
|
|
2605
|
+
resizable: true,
|
|
2606
|
+
movable: true,
|
|
2607
|
+
minimizable: true,
|
|
2608
|
+
maximizable: true,
|
|
2609
|
+
fullscreenable: false,
|
|
2610
|
+
skipTaskbar: false,
|
|
2611
|
+
hasShadow: true,
|
|
2612
|
+
acceptFirstMouse: true,
|
|
2613
|
+
autoHideMenuBar: true,
|
|
2614
|
+
title: "Relay Preview",
|
|
2615
|
+
webPreferences: {
|
|
2616
|
+
preload: path.join(__dirname, "preview-preload.cjs"),
|
|
2617
|
+
contextIsolation: true,
|
|
2618
|
+
nodeIntegration: false,
|
|
2619
|
+
sandbox: true,
|
|
2620
|
+
},
|
|
2621
|
+
});
|
|
2622
|
+
|
|
2623
|
+
previewWin.setMenuBarVisibility(false);
|
|
2624
|
+
previewWin.webContents.setWindowOpenHandler(() => ({ action: "deny" }));
|
|
2625
|
+
previewWin.webContents.on("will-navigate", (event, url) => {
|
|
2626
|
+
const previewUrl = pathToFileURL(path.join(__dirname, "preview.html")).href;
|
|
2627
|
+
if (url !== previewUrl && event && typeof event.preventDefault === "function") event.preventDefault();
|
|
2628
|
+
});
|
|
2629
|
+
previewWin.webContents.on("console-message", (...args) => {
|
|
2630
|
+
const message = args[1] && typeof args[1] === "object" ? args[1].message : args[2];
|
|
2631
|
+
if (message) console.error("[preview-renderer]", message);
|
|
2632
|
+
});
|
|
2633
|
+
previewWin.webContents.on("preload-error", (_event, preloadPath, error) => {
|
|
2634
|
+
console.error("[preview-preload-error]", preloadPath, error && error.message);
|
|
2635
|
+
});
|
|
2636
|
+
let renderGoneAt = 0;
|
|
2637
|
+
previewWin.webContents.on("render-process-gone", (_event, details) => {
|
|
2638
|
+
console.error("[preview-render-gone]", JSON.stringify(details));
|
|
2639
|
+
previewRendererReady = false;
|
|
2640
|
+
previewSentVersion = -1;
|
|
2641
|
+
const crashedWindow = previewWin;
|
|
2642
|
+
const delay = Date.now() - renderGoneAt < 30000 ? 5000 : 250;
|
|
2643
|
+
renderGoneAt = Date.now();
|
|
2644
|
+
setTimeout(() => {
|
|
2645
|
+
if (!crashedWindow || crashedWindow !== previewWin || crashedWindow.isDestroyed()) return;
|
|
2646
|
+
crashedWindow.webContents.reload();
|
|
2647
|
+
}, delay);
|
|
2648
|
+
});
|
|
2649
|
+
previewWin.webContents.on("did-finish-load", () => resetWindowZoom(previewWin));
|
|
2650
|
+
previewWin.webContents.on("zoom-changed", (event) => {
|
|
2651
|
+
if (event && typeof event.preventDefault === "function") event.preventDefault();
|
|
2652
|
+
resetWindowZoom(previewWin);
|
|
2653
|
+
});
|
|
2654
|
+
previewWin.webContents.on("before-input-event", (event, input = {}) => {
|
|
2655
|
+
const key = String(input.key || "").toLowerCase();
|
|
2656
|
+
if ((input.meta || input.control) && (key === "+" || key === "=" || key === "-" || key === "_" || key === "0")) {
|
|
2657
|
+
if (event && typeof event.preventDefault === "function") event.preventDefault();
|
|
2658
|
+
resetWindowZoom(previewWin);
|
|
2659
|
+
}
|
|
2660
|
+
});
|
|
2661
|
+
previewWin.once("ready-to-show", () => {
|
|
2662
|
+
sendPreviewPayload();
|
|
2663
|
+
showPreviewWindow();
|
|
2664
|
+
});
|
|
2665
|
+
previewWin.on("closed", () => {
|
|
2666
|
+
previewWin = null;
|
|
2667
|
+
previewPayload = null;
|
|
2668
|
+
previewRendererReady = false;
|
|
2669
|
+
previewRenderedRelayId = null;
|
|
2670
|
+
previewSentVersion = -1;
|
|
2671
|
+
});
|
|
2672
|
+
previewWin.loadFile(path.join(__dirname, "preview.html"));
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
function openPreview(packetId) {
|
|
2676
|
+
const nextPayload = previewPayloadForPacket(packetId);
|
|
2677
|
+
if (!nextPayload) return false;
|
|
2678
|
+
previewPayload = nextPayload;
|
|
2679
|
+
previewRenderedRelayId = null;
|
|
2680
|
+
previewPayloadVersion += 1;
|
|
2681
|
+
if (!previewWindowExists()) {
|
|
2682
|
+
createPreviewWindow();
|
|
2683
|
+
} else {
|
|
2684
|
+
sendPreviewPayload();
|
|
2685
|
+
showPreviewWindow();
|
|
2686
|
+
}
|
|
2687
|
+
return true;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
function openPreviewExternal(url) {
|
|
2691
|
+
try {
|
|
2692
|
+
const parsed = new URL(String(url || ""));
|
|
2693
|
+
if (!new Set(["http:", "https:", "mailto:"]).has(parsed.protocol)) return false;
|
|
2694
|
+
shell.openExternal(parsed.href).catch((error) => console.error("[preview] external link failed:", error && error.message));
|
|
2695
|
+
return true;
|
|
2696
|
+
} catch {
|
|
2697
|
+
return false;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
function isPreviewEvent(event) {
|
|
2702
|
+
return Boolean(previewWindowExists() && event && event.sender === previewWin.webContents);
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2516
2705
|
function installActiveSpaceWatcher() {
|
|
2517
2706
|
if (process.platform !== "darwin") return;
|
|
2518
2707
|
subscribeActiveSpaceChanges(
|
|
@@ -2697,9 +2886,16 @@ function createTray() {
|
|
|
2697
2886
|
tray.on("click", toggleFromTray);
|
|
2698
2887
|
tray.on("right-click", () => {
|
|
2699
2888
|
try {
|
|
2889
|
+
const previewItem = previewWindowExists()
|
|
2890
|
+
? [{
|
|
2891
|
+
label: previewWin.isMinimized() ? "Restore Relay Preview" : "Focus Relay Preview",
|
|
2892
|
+
click: showPreviewWindow,
|
|
2893
|
+
}]
|
|
2894
|
+
: [];
|
|
2700
2895
|
tray.popUpContextMenu(
|
|
2701
2896
|
Menu.buildFromTemplate([
|
|
2702
2897
|
{ label: pillIsOnScreen() ? "Hide Relay" : "Show Relay", click: toggleFromTray },
|
|
2898
|
+
...previewItem,
|
|
2703
2899
|
{ type: "separator" },
|
|
2704
2900
|
{ label: "Quit Relay", click: quitRelayCompletely },
|
|
2705
2901
|
]),
|
|
@@ -2727,6 +2923,36 @@ ipcMain.on("relay:openFresh", (_e, id) => {
|
|
|
2727
2923
|
ipcMain.on("relay:openInCurrent", (_e, id) => {
|
|
2728
2924
|
openPacketInCurrent(id).catch((error) => console.error("[overlay] open-in-current failed:", error && error.message));
|
|
2729
2925
|
});
|
|
2926
|
+
ipcMain.on("relay:preview", (event, id) => {
|
|
2927
|
+
if (win && !win.isDestroyed() && event && event.sender !== win.webContents) return;
|
|
2928
|
+
if (!openPreview(id)) console.error("[preview] relay not found:", id);
|
|
2929
|
+
});
|
|
2930
|
+
ipcMain.on("relay:preview:ready", (event) => {
|
|
2931
|
+
if (!isPreviewEvent(event)) return;
|
|
2932
|
+
if (!previewRendererReady) previewSentVersion = -1;
|
|
2933
|
+
previewRendererReady = true;
|
|
2934
|
+
sendPreviewPayload();
|
|
2935
|
+
showPreviewWindow();
|
|
2936
|
+
});
|
|
2937
|
+
ipcMain.on("relay:preview:rendered", (event, relayId) => {
|
|
2938
|
+
if (!isPreviewEvent(event) || !previewPayload) return;
|
|
2939
|
+
const id = String(relayId || "");
|
|
2940
|
+
if (!id || id !== previewPayload.relayId || id === previewRenderedRelayId) return;
|
|
2941
|
+
previewRenderedRelayId = id;
|
|
2942
|
+
if (previewPayload.unread) {
|
|
2943
|
+
previewPayload.unread = false;
|
|
2944
|
+
ackPacket(id);
|
|
2945
|
+
}
|
|
2946
|
+
});
|
|
2947
|
+
ipcMain.on("relay:preview:minimize", (event) => {
|
|
2948
|
+
if (isPreviewEvent(event)) previewWin.minimize();
|
|
2949
|
+
});
|
|
2950
|
+
ipcMain.on("relay:preview:close", (event) => {
|
|
2951
|
+
if (isPreviewEvent(event)) previewWin.close();
|
|
2952
|
+
});
|
|
2953
|
+
ipcMain.on("relay:preview:openExternal", (event, url) => {
|
|
2954
|
+
if (isPreviewEvent(event)) openPreviewExternal(url);
|
|
2955
|
+
});
|
|
2730
2956
|
ipcMain.on("relay:openTask", (_e, taskId) => openTaskDetail(taskId));
|
|
2731
2957
|
ipcMain.on("relay:openUrl", (_e, url) => openUrlTarget(url));
|
|
2732
2958
|
ipcMain.on("relay:ack", (_e, id) => ackPacket(id));
|
|
@@ -2960,6 +3186,21 @@ if (!gotSingleInstanceLock) {
|
|
|
2960
3186
|
return pushInbox(true);
|
|
2961
3187
|
},
|
|
2962
3188
|
getWin: () => win,
|
|
3189
|
+
getPreviewWin: () => previewWin,
|
|
3190
|
+
openPreview,
|
|
3191
|
+
movePillAwayFromCursor: () => {
|
|
3192
|
+
if (!win || win.isDestroyed()) return null;
|
|
3193
|
+
const point = screen.getCursorScreenPoint();
|
|
3194
|
+
const workArea = screen.getDisplayNearestPoint(point).workArea;
|
|
3195
|
+
const x = point.x < workArea.x + workArea.width / 2
|
|
3196
|
+
? workArea.x + Math.max(0, workArea.width - WIN.width)
|
|
3197
|
+
: workArea.x;
|
|
3198
|
+
const y = point.y < workArea.y + workArea.height / 2
|
|
3199
|
+
? workArea.y + Math.max(0, workArea.height - WIN.height)
|
|
3200
|
+
: workArea.y;
|
|
3201
|
+
win.setPosition(Math.round(x), Math.round(y));
|
|
3202
|
+
return { point, bounds: win.getBounds() };
|
|
3203
|
+
},
|
|
2963
3204
|
confirmCurrentShow: () => {
|
|
2964
3205
|
// Harness shortcut: acknowledge the on-stage card exactly as the
|
|
2965
3206
|
// renderer would after an interacted dwell.
|
|
@@ -2985,6 +3226,13 @@ if (!gotSingleInstanceLock) {
|
|
|
2985
3226
|
burstShown,
|
|
2986
3227
|
rendererListening,
|
|
2987
3228
|
visible: win && !win.isDestroyed() ? win.isVisible() : null,
|
|
3229
|
+
preview: previewWindowExists()
|
|
3230
|
+
? {
|
|
3231
|
+
relayId: previewPayload && previewPayload.relayId,
|
|
3232
|
+
visible: previewWin.isVisible(),
|
|
3233
|
+
minimized: previewWin.isMinimized(),
|
|
3234
|
+
}
|
|
3235
|
+
: null,
|
|
2988
3236
|
}),
|
|
2989
3237
|
};
|
|
2990
3238
|
}
|
package/overlay/preload.cjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const { contextBridge, ipcRenderer } = require("electron");
|
|
2
2
|
|
|
3
3
|
contextBridge.exposeInMainWorld("relay", {
|
|
4
|
+
// Sandboxed harness overlays share the user's screen and speakers. The
|
|
5
|
+
// renderer needs to know it is one so it can stay silent.
|
|
6
|
+
isTestOverlay: process.env.RELAY_OVERLAY_TEST === "1" || process.env.RELAY_OVERLAY_PERF === "1",
|
|
4
7
|
// streams from main -> renderer
|
|
5
8
|
onInbox: (cb) => ipcRenderer.on("inbox", (_e, payload) => cb(payload)),
|
|
6
9
|
onNewRelay: (cb) => ipcRenderer.on("newRelay", (_e, relay, opts) => cb(relay, opts || {})),
|
|
@@ -21,6 +24,7 @@ contextBridge.exposeInMainWorld("relay", {
|
|
|
21
24
|
open: (id) => ipcRenderer.send("relay:open", id),
|
|
22
25
|
openSent: (id) => ipcRenderer.send("relay:openSent", id),
|
|
23
26
|
// expand-card actions: inject into the live Claude session / force a fresh one
|
|
27
|
+
preview: (id) => ipcRenderer.send("relay:preview", id),
|
|
24
28
|
openInCurrent: (id) => ipcRenderer.send("relay:openInCurrent", id),
|
|
25
29
|
openFresh: (id) => ipcRenderer.send("relay:openFresh", id),
|
|
26
30
|
ack: (id) => ipcRenderer.send("relay:ack", id),
|