cheogram-www-2

created pr with cheogram-www-2/stop-simultaneous-tabs.1 on 2026-11-12T21:42:42Z · by 3c31bc8c
commented on 2026-11-12T21:42:42Z · by 3c31bc8c
Changes are available at https://tangled.org/mrry.band/cheogram-www on branch stop-simultaneous-tabs.
added cheogram-www-2/stop-simultaneous-tabs.2 on 2026-11-13T00:24:13Z · by 3c31bc8c
1: 737d18a ! 1: 6e7bffc Prevent running in multiple tabs
cmds
checkout latest patchset:
ssh pr.pico.sh pull cheogram-www-2:stop-simultaneous-tabs | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull cheogram-www-2:stop-simultaneous-tabs [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh cheogram-www-2:stop-simultaneous-tabs
add comment to patch request:
ssh pr.pico.sh comment cheogram-www-2:stop-simultaneous-tabs "lgtm!"

Patchset cheogram-www-2/stop-simultaneous-tabs.2 on 2026-11-13T00:24:13Z · commit 6e7bffc

Prevent running in multiple tabs
Eric Roberts 2026-11-12T01:09:42Z
Because it causes all kinds of problems. I do this regularly and then I
get confused why things are not working.

Separate stylesheet for now until our style update changes are shipped,
and then it can reuse the same root background styling that those
changes will bring.
Semantic diff summary
0 added, 1 modified, 0 signature changed, 0 removed across 1 analyzed file (2 files skipped: unsupported file type)
+1 -1 index.html #
......@@ -10,7 +10,7 @@
1010 <meta name="theme-color" content="#7401cf" />
1111 <base target="_blank" />
1212 <title>%VITE_APP_TITLE%</title>
13- <script type="module" src="/src/index.tsx"></script>
13+ <script type="module" src="/src/bootstrap.ts"></script>
1414 </head>
1515 <body>
1616 <noscript>You need to enable JavaScript to run this app.</noscript>
+38 -0 src/bootstrap.scss #
......@@ -0,0 +1,38 @@
1+.startup-message {
2+ position: fixed;
3+ inset: 0;
4+ overflow: auto;
5+ box-sizing: border-box;
6+ display: flex;
7+ flex-direction: column;
8+ align-items: center;
9+ justify-content: center;
10+ padding: 2rem;
11+ font-family: system-ui;
12+ text-align: center;
13+ background:
14+ url(/gloop01.svg) top left / min(50vh, 100vw) auto no-repeat,
15+ url(/gloop02.svg) bottom right / min(50vh, 100vw) auto no-repeat,
16+ #7401cf;
17+ color: white;
18+
19+ > p {
20+ max-width: 22rem;
21+ }
22+
23+ > button {
24+ border: 0;
25+ border-radius: 10em;
26+ padding: 1em 2em;
27+ margin-top: 1em;
28+ font: inherit;
29+ color: #1e0038;
30+ background: #ffc700;
31+ cursor: pointer;
32+
33+ &:focus-visible {
34+ outline: 2px solid white;
35+ outline-offset: 4px;
36+ }
37+ }
38+}
+36 -0 src/bootstrap.ts #
......@@ -0,0 +1,36 @@
1+import "./bootstrap.scss";
2+
3+(async () => {
4+ if (!navigator.locks) {
5+ await import("./index");
6+ return;
7+ }
8+ await navigator.locks.request(
9+ "cheogram-active-tab",
10+ { ifAvailable: true },
11+ async (lock) => {
12+ if (!lock) {
13+ const message = document.createElement("main");
14+ message.className = "startup-message";
15+
16+ const text = document.createElement("p");
17+ text.setAttribute("role", "status");
18+ text.textContent =
19+ "Cheogram is already running in another tab or window. Close it, then try again here.";
20+
21+ const retry = document.createElement("button");
22+ retry.textContent = "Try again";
23+ retry.onclick = () => window.location.reload();
24+
25+ message.append(text, retry);
26+ document.getElementById("root")!.replaceChildren(message);
27+
28+ return;
29+ }
30+ await import("./index").catch(console.error);
31+
32+ // https://github.com/w3c/web-locks/blob/main/EXPLAINER.md#can-you-hold-a-lock-for-the-lifetime-of-a-tab
33+ await new Promise<void>(() => {});
34+ },
35+ );
36+})();
Back to top