diff-chat 0.1.0__py3-none-any.whl
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.
- adapters/README.md +28 -0
- adapters/__init__.py +48 -0
- adapters/_base.py +102 -0
- adapters/_cli.py +405 -0
- adapters/claude.py +141 -0
- adapters/gemini.py +323 -0
- adapters/gpt.py +217 -0
- adapters/local.py +146 -0
- adapters/registry.py +33 -0
- api_fallback.py +189 -0
- app.py +827 -0
- app_preferences.py +205 -0
- archive_schema.py +142 -0
- attachments.py +129 -0
- chat_titles.py +60 -0
- connection_handoff.py +64 -0
- context_engine.py +256 -0
- conversation_actions.py +160 -0
- diff_chat-0.1.0.dist-info/METADATA +101 -0
- diff_chat-0.1.0.dist-info/RECORD +91 -0
- diff_chat-0.1.0.dist-info/WHEEL +4 -0
- diff_chat-0.1.0.dist-info/entry_points.txt +2 -0
- diff_chat-0.1.0.dist-info/licenses/LICENSE +21 -0
- diff_chat_assets/memory.example.md +1 -0
- diff_chat_assets/prompts/about_you_export.md +19 -0
- diff_chat_assets/settings.json +6 -0
- diff_chat_assets/static/about-you-parser.js +46 -0
- diff_chat_assets/static/about-you.js +171 -0
- diff_chat_assets/static/actions.css +275 -0
- diff_chat_assets/static/actions.js +650 -0
- diff_chat_assets/static/app.css +345 -0
- diff_chat_assets/static/app.js +1344 -0
- diff_chat_assets/static/attachments.js +80 -0
- diff_chat_assets/static/brand/favicon-32.png +0 -0
- diff_chat_assets/static/brand/icon.svg +11 -0
- diff_chat_assets/static/brand/wordmark-dark.svg +15 -0
- diff_chat_assets/static/brand/wordmark-light.svg +13 -0
- diff_chat_assets/static/characters/CREDITS.md +7 -0
- diff_chat_assets/static/characters/characters.css +37 -0
- diff_chat_assets/static/characters/claude.json +507 -0
- diff_chat_assets/static/characters/claude.png +0 -0
- diff_chat_assets/static/characters/claude.webp +0 -0
- diff_chat_assets/static/characters/gemini.json +54 -0
- diff_chat_assets/static/characters/gemini.png +0 -0
- diff_chat_assets/static/characters/gemini.webp +0 -0
- diff_chat_assets/static/characters/gpt.json +507 -0
- diff_chat_assets/static/characters/gpt.png +0 -0
- diff_chat_assets/static/characters/gpt.webp +0 -0
- diff_chat_assets/static/characters/local.json +387 -0
- diff_chat_assets/static/characters/local.png +0 -0
- diff_chat_assets/static/characters/local.webp +0 -0
- diff_chat_assets/static/characters/player.js +318 -0
- diff_chat_assets/static/chat-filing.js +84 -0
- diff_chat_assets/static/controls.js +194 -0
- diff_chat_assets/static/corners.css +59 -0
- diff_chat_assets/static/craft.css +246 -0
- diff_chat_assets/static/drafts.js +41 -0
- diff_chat_assets/static/index.html +208 -0
- diff_chat_assets/static/library.css +30 -0
- diff_chat_assets/static/library.js +181 -0
- diff_chat_assets/static/memory.js +81 -0
- diff_chat_assets/static/preference-dialog.js +21 -0
- diff_chat_assets/static/preferences.css +56 -0
- diff_chat_assets/static/session.js +46 -0
- diff_chat_assets/static/settings.css +111 -0
- diff_chat_assets/static/settings.js +463 -0
- diff_chat_assets/static/setup.js +238 -0
- diff_chat_assets/static/utility.js +64 -0
- diff_chat_assets/static/vendor/LICENSES.txt +531 -0
- diff_chat_assets/static/vendor/highlight.min.js +1262 -0
- diff_chat_assets/static/vendor/markdown-it.min.js +13 -0
- diff_chat_assets/static/vendor/plex-mono.woff2 +0 -0
- diff_chat_assets/static/vendor/plex-sans.woff2 +0 -0
- diff_launcher.py +93 -0
- discussion.py +239 -0
- history_search.py +68 -0
- library_manager.py +251 -0
- model_options.py +132 -0
- plan_usage.py +72 -0
- private_store.py +71 -0
- probe.py +195 -0
- runtime_paths.py +195 -0
- server_security.py +100 -0
- setup_status.py +123 -0
- shared_memory.py +189 -0
- storage.py +185 -0
- usage_budget.py +77 -0
- usage_claude.py +110 -0
- usage_codex.py +170 -0
- usage_gemini.py +70 -0
- utility_models.py +104 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title>diff</title>
|
|
8
|
+
<link rel="icon" href="/static/brand/favicon-32.png" type="image/png" sizes="32x32">
|
|
9
|
+
<link rel="icon" href="/static/brand/icon.svg" type="image/svg+xml" sizes="any">
|
|
10
|
+
<link rel="stylesheet" href="/static/corners.css">
|
|
11
|
+
<link rel="stylesheet" href="/static/app.css">
|
|
12
|
+
<link rel="stylesheet" href="/static/library.css">
|
|
13
|
+
<link rel="stylesheet" href="/static/actions.css">
|
|
14
|
+
<link rel="stylesheet" href="/static/preferences.css">
|
|
15
|
+
<link rel="stylesheet" href="/static/settings.css">
|
|
16
|
+
<link rel="stylesheet" href="/static/craft.css">
|
|
17
|
+
<link rel="stylesheet" href="/static/characters/characters.css">
|
|
18
|
+
<script src="/static/session.js"></script>
|
|
19
|
+
<script src="/static/controls.js" defer></script>
|
|
20
|
+
<script src="/static/vendor/markdown-it.min.js" defer></script>
|
|
21
|
+
<script src="/static/vendor/highlight.min.js" defer></script>
|
|
22
|
+
<script src="/static/drafts.js" defer></script>
|
|
23
|
+
<script src="/static/characters/player.js" defer></script>
|
|
24
|
+
<script src="/static/app.js" defer></script>
|
|
25
|
+
<script src="/static/attachments.js" defer></script>
|
|
26
|
+
<script src="/static/actions.js" defer></script>
|
|
27
|
+
<script src="/static/library.js" defer></script>
|
|
28
|
+
<script src="/static/preference-dialog.js" defer></script>
|
|
29
|
+
<script src="/static/about-you-parser.js" defer></script>
|
|
30
|
+
<script src="/static/about-you.js" defer></script>
|
|
31
|
+
<script src="/static/memory.js" defer></script>
|
|
32
|
+
<script src="/static/setup.js" defer></script>
|
|
33
|
+
<script src="/static/utility.js" defer></script>
|
|
34
|
+
<script src="/static/settings.js" defer></script>
|
|
35
|
+
<script src="/static/chat-filing.js" defer></script>
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
<svg class="symbols" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
39
|
+
<symbol id="i-panel" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" />
|
|
40
|
+
<path d="M9 3v18" /></symbol>
|
|
41
|
+
<symbol id="i-compose" viewBox="0 0 24 24"><path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
|
|
42
|
+
<path d="M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z" /></symbol>
|
|
43
|
+
<symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8" />
|
|
44
|
+
<path d="m21 21-4.3-4.3" /></symbol>
|
|
45
|
+
<symbol id="i-download" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
46
|
+
<polyline points="7 10 12 15 17 10" />
|
|
47
|
+
<line x1="12" x2="12" y1="15" y2="3" /></symbol>
|
|
48
|
+
<symbol id="i-adjust" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" />
|
|
49
|
+
<path d="M15 3v18" /></symbol>
|
|
50
|
+
<symbol id="i-arrow" viewBox="0 0 24 24"><path d="m5 12 7-7 7 7" />
|
|
51
|
+
<path d="M12 19V5" /></symbol>
|
|
52
|
+
<symbol id="i-rotate-cw" viewBox="0 0 24 24"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" />
|
|
53
|
+
<path d="M21 3v5h-5" /></symbol>
|
|
54
|
+
<symbol id="i-arrow-right-left" viewBox="0 0 24 24"><path d="m16 3 4 4-4 4" />
|
|
55
|
+
<path d="M20 7H4" />
|
|
56
|
+
<path d="m8 21-4-4 4-4" />
|
|
57
|
+
<path d="M4 17h16" /></symbol>
|
|
58
|
+
<symbol id="i-messages-square" viewBox="0 0 24 24"><path d="M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z" />
|
|
59
|
+
<path d="M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1" /></symbol>
|
|
60
|
+
<symbol id="i-handshake" viewBox="0 0 24 24"><path d="m11 17 2 2a1 1 0 1 0 3-3" />
|
|
61
|
+
<path d="m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4" />
|
|
62
|
+
<path d="m21 3 1 11h-2" />
|
|
63
|
+
<path d="M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3" />
|
|
64
|
+
<path d="M3 4h8" /></symbol>
|
|
65
|
+
<symbol id="i-git-merge" viewBox="0 0 24 24"><circle cx="18" cy="18" r="3" />
|
|
66
|
+
<circle cx="6" cy="6" r="3" />
|
|
67
|
+
<path d="M6 21V9a9 9 0 0 0 9 9" /></symbol>
|
|
68
|
+
<symbol id="i-columns-2" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" />
|
|
69
|
+
<path d="M12 3v18" /></symbol>
|
|
70
|
+
<symbol id="i-chevron" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6" /></symbol>
|
|
71
|
+
<symbol id="i-copy" viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
|
|
72
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" /></symbol>
|
|
73
|
+
<symbol id="i-challenge" viewBox="0 0 24 24"><polyline points="14.5 17.5 3 6 3 3 6 3 17.5 14.5" />
|
|
74
|
+
<line x1="13" x2="19" y1="19" y2="13" />
|
|
75
|
+
<line x1="16" x2="20" y1="16" y2="20" />
|
|
76
|
+
<line x1="19" x2="21" y1="21" y2="19" />
|
|
77
|
+
<polyline points="14.5 6.5 18 3 21 3 21 6 17.5 9.5" />
|
|
78
|
+
<line x1="5" x2="9" y1="14" y2="18" />
|
|
79
|
+
<line x1="7" x2="4" y1="17" y2="20" />
|
|
80
|
+
<line x1="3" x2="5" y1="19" y2="21" /></symbol>
|
|
81
|
+
<symbol id="i-retry" viewBox="0 0 24 24"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
|
82
|
+
<path d="M3 3v5h5" /></symbol>
|
|
83
|
+
<symbol id="i-edit" viewBox="0 0 24 24"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />
|
|
84
|
+
<path d="m15 5 4 4" /></symbol>
|
|
85
|
+
<symbol id="i-branch" viewBox="0 0 24 24"><line x1="6" x2="6" y1="3" y2="15" />
|
|
86
|
+
<circle cx="18" cy="6" r="3" />
|
|
87
|
+
<circle cx="6" cy="18" r="3" />
|
|
88
|
+
<path d="M18 9a9 9 0 0 1-9 9" /></symbol>
|
|
89
|
+
<symbol id="i-check" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5" /></symbol>
|
|
90
|
+
<symbol id="i-x" viewBox="0 0 24 24"><path d="M18 6 6 18" />
|
|
91
|
+
<path d="m6 6 12 12" /></symbol>
|
|
92
|
+
<symbol id="i-paperclip" viewBox="0 0 24 24"><path d="M13.234 20.252 21 12.3" />
|
|
93
|
+
<path d="m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486" /></symbol>
|
|
94
|
+
<symbol id="i-settings" viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
|
|
95
|
+
<circle cx="12" cy="12" r="3" /></symbol>
|
|
96
|
+
<symbol id="i-more" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1" />
|
|
97
|
+
<circle cx="19" cy="12" r="1" />
|
|
98
|
+
<circle cx="5" cy="12" r="1" /></symbol>
|
|
99
|
+
<symbol id="i-file" viewBox="0 0 24 24"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" />
|
|
100
|
+
<path d="M14 2v4a2 2 0 0 0 2 2h4" /></symbol>
|
|
101
|
+
<symbol id="i-image" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
|
|
102
|
+
<circle cx="9" cy="9" r="2" />
|
|
103
|
+
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" /></symbol>
|
|
104
|
+
</svg>
|
|
105
|
+
<div class="desk" id="desk">
|
|
106
|
+
<aside class="library" id="library" aria-labelledby="library-heading">
|
|
107
|
+
<div class="library-head">
|
|
108
|
+
<h2 id="library-heading">
|
|
109
|
+
<picture>
|
|
110
|
+
<source id="dark-wordmark" media="(prefers-color-scheme: dark)" srcset="/static/brand/wordmark-dark.svg">
|
|
111
|
+
<img class="wordmark" src="/static/brand/wordmark-light.svg" width="110" height="28" alt="diff">
|
|
112
|
+
</picture>
|
|
113
|
+
</h2>
|
|
114
|
+
<button type="button" class="quiet-button" id="hide-chats" aria-controls="library" aria-label="Hide chats" title="Hide chats"><svg class="icon" aria-hidden="true"><use href="#i-panel"/></svg></button>
|
|
115
|
+
</div>
|
|
116
|
+
<button type="button" class="new-chat" id="new-chat" disabled>
|
|
117
|
+
<svg class="icon" aria-hidden="true"><use href="#i-compose"/></svg>New chat
|
|
118
|
+
</button>
|
|
119
|
+
<button type="button" class="new-chat" id="search-chats">
|
|
120
|
+
<svg class="icon" aria-hidden="true"><use href="#i-search"/></svg>Search chats<span id="search-shortcut" aria-hidden="true"></span>
|
|
121
|
+
</button>
|
|
122
|
+
<nav id="chat-list" aria-label="Saved chats"></nav>
|
|
123
|
+
<button type="button" class="new-chat" id="export-chat" disabled><svg class="icon" aria-hidden="true"><use href="#i-download"/></svg>Export chat as Markdown</button>
|
|
124
|
+
<div class="library-foot">
|
|
125
|
+
<button type="button" class="new-chat" id="open-settings" aria-haspopup="dialog"><svg class="icon" aria-hidden="true"><use href="#i-settings"/></svg>Settings</button>
|
|
126
|
+
|
|
127
|
+
</div>
|
|
128
|
+
</aside>
|
|
129
|
+
<div class="workspace">
|
|
130
|
+
<header class="header">
|
|
131
|
+
<div class="title-area">
|
|
132
|
+
<div class="document-heading"><h1 id="chat-title">New chat</h1><span id="chat-stats" hidden></span></div>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="header-actions">
|
|
135
|
+
<button type="button" class="open-chats" id="open-chats" aria-controls="library" aria-expanded="false">
|
|
136
|
+
<svg class="icon" aria-hidden="true"><use href="#i-panel"/></svg>Chats
|
|
137
|
+
</button>
|
|
138
|
+
<button type="button" id="inspect" aria-label="Model settings" aria-controls="inspector" aria-expanded="false">
|
|
139
|
+
<svg class="icon" aria-hidden="true"><use href="#i-adjust"/></svg><span class="long-model-label">Model settings</span><span class="short-model-label">Models</span>
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</header>
|
|
143
|
+
<div class="stage" id="stage">
|
|
144
|
+
<div class="document">
|
|
145
|
+
<main id="reader" tabindex="-1" aria-label="Chat transcript">
|
|
146
|
+
<div class="column transcript">
|
|
147
|
+
<p class="empty" id="empty" hidden>Choose a participant to start chatting.</p>
|
|
148
|
+
<div id="setup-notice" hidden></div>
|
|
149
|
+
<div id="entries"></div>
|
|
150
|
+
<section id="round-actions" aria-label="Conversation actions" hidden></section>
|
|
151
|
+
</div>
|
|
152
|
+
</main>
|
|
153
|
+
<footer class="composer">
|
|
154
|
+
<div class="column">
|
|
155
|
+
<p class="discussion-status" id="discussion-status" role="status" hidden></p>
|
|
156
|
+
<div class="history-notice" id="history-notice" hidden>
|
|
157
|
+
<span>This chat has passed your transcript threshold.</span>
|
|
158
|
+
<button type="button" id="carry">Start a new chat with a summary</button>
|
|
159
|
+
</div>
|
|
160
|
+
<p class="feedback" id="context-warning" hidden></p>
|
|
161
|
+
<p id="feedback" class="feedback" role="status" hidden></p>
|
|
162
|
+
<form id="compose-form">
|
|
163
|
+
<input type="file" id="attach-input" hidden multiple aria-label="Choose attachments">
|
|
164
|
+
<div id="attachment-tray" class="attachment-tray" aria-label="Attached files" hidden></div>
|
|
165
|
+
<label class="sr-only" for="draft">Your message</label>
|
|
166
|
+
<textarea id="draft" rows="1" placeholder="Message participants…" spellcheck="true" disabled></textarea>
|
|
167
|
+
<div class="compose-toolbar">
|
|
168
|
+
<button type="button" id="attach-files" aria-label="Attach files" title="Attach files"><svg class="icon" aria-hidden="true"><use href="#i-paperclip"/></svg></button>
|
|
169
|
+
<div class="participants-tools" role="group" aria-label="Include in the next turn">
|
|
170
|
+
</div>
|
|
171
|
+
<div class="submit-tools">
|
|
172
|
+
<button type="button" id="stop" hidden disabled>Stop</button>
|
|
173
|
+
<button type="submit" class="send" id="send" disabled>Send<svg class="icon" aria-hidden="true"><use href="#i-arrow"/></svg></button>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</form>
|
|
177
|
+
<div class="composer-meta">
|
|
178
|
+
<span id="char-count" hidden></span>
|
|
179
|
+
<span class="key-hint">Shift+Enter for a new line</span>
|
|
180
|
+
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
</footer>
|
|
184
|
+
</div>
|
|
185
|
+
<aside class="inspector" id="inspector" aria-labelledby="inspector-title" hidden>
|
|
186
|
+
<div class="inspector-toolbar">
|
|
187
|
+
<div class="inspector-head"><h2 id="inspector-title">Participants</h2><button class="quiet-button" type="button" id="close-inspector" aria-label="Close participants" title="Close participants"><svg class="icon" aria-hidden="true"><use href="#i-x"/></svg></button></div>
|
|
188
|
+
<div class="search-setting">
|
|
189
|
+
<span id="web-search-label">Web search</span>
|
|
190
|
+
<button type="button" class="participant-switch" id="web-search" role="switch" aria-checked="true" aria-labelledby="web-search-label" aria-description="Allow participants with web search to use it in this chat." disabled>
|
|
191
|
+
<span id="search-state">On</span><span class="track" aria-hidden="true"></span>
|
|
192
|
+
</button>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<button type="button" class="connection-action" id="connect-models" aria-haspopup="dialog">Connect models</button>
|
|
196
|
+
<div id="model-fields"></div>
|
|
197
|
+
<div class="inspector-links">
|
|
198
|
+
<button type="button" id="open-memory" aria-haspopup="dialog">Shared memory</button>
|
|
199
|
+
<button type="button" id="open-utility" aria-haspopup="dialog">Summary model<span id="utility-choice">Automatic</span></button>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="inspector-foot"><button type="button" class="quiet-button" id="refresh-usage">Refresh usage</button></div>
|
|
202
|
+
</aside>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
<div class="sr-only" id="announcement" role="status"></div>
|
|
207
|
+
</body>
|
|
208
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.history-search {
|
|
2
|
+
width: min(540px, calc(100% - 28px));
|
|
3
|
+
max-height: min(70dvh, 560px);
|
|
4
|
+
margin: min(15dvh, 110px) auto auto;
|
|
5
|
+
padding: 18px;
|
|
6
|
+
border: 1px solid var(--edge);
|
|
7
|
+
--corner-radius: 15px;
|
|
8
|
+
color: var(--ink);
|
|
9
|
+
background: var(--surface);
|
|
10
|
+
font: 14px/1.5 var(--ui);
|
|
11
|
+
overflow: auto;
|
|
12
|
+
}
|
|
13
|
+
.history-search::backdrop { background: rgb(12 14 18 / 29%); }
|
|
14
|
+
.search-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
|
|
15
|
+
.search-top h2 { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -.025em; }
|
|
16
|
+
.history-search input {
|
|
17
|
+
width: 100%; padding: 9px 11px; border: 1px solid var(--edge); --corner-radius: 7px;
|
|
18
|
+
background: var(--paper); color: inherit; font: inherit;
|
|
19
|
+
}
|
|
20
|
+
.search-notice { margin: 12px 3px 4px; color: var(--metadata); font-size: 12px; }
|
|
21
|
+
.search-results { padding: 0; margin: 0; list-style: none; }
|
|
22
|
+
.search-hit { display: block; padding: 8px; width: 100%; text-align: left; }
|
|
23
|
+
.search-title, .search-excerpt { display: block; overflow-wrap: anywhere; }
|
|
24
|
+
.search-title { font-size: 14px; font-weight: 550; }
|
|
25
|
+
.search-excerpt { margin-top: 2px; font-size: 13px; color: var(--secondary); }
|
|
26
|
+
.search-speaker { color: var(--metadata); }
|
|
27
|
+
.search-hit mark, ::highlight(transcript-match) { background: var(--selected); color: var(--ink); }
|
|
28
|
+
.search-hit mark { font-weight: 650; }
|
|
29
|
+
.search-more { margin: 4px 0 0; }
|
|
30
|
+
.message.search-jump { outline: 1px solid var(--edge); outline-offset: 5px; }
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
(() => {
|
|
4
|
+
const trigger = byId("search-chats");
|
|
5
|
+
const dialog = document.createElement("dialog");
|
|
6
|
+
dialog.className = "history-search";
|
|
7
|
+
dialog.setAttribute("aria-labelledby", "history-search-heading");
|
|
8
|
+
dialog.innerHTML = `
|
|
9
|
+
<div class="search-top">
|
|
10
|
+
<h2 id="history-search-heading">Search chats and commands</h2>
|
|
11
|
+
<button type="button" class="quiet-button" data-close>Close</button>
|
|
12
|
+
</div>
|
|
13
|
+
<input type="search" maxlength="160" aria-label="Search chats and commands"
|
|
14
|
+
placeholder="Search chats and commands" autocomplete="off" spellcheck="false">
|
|
15
|
+
<ul class="search-commands search-results" aria-label="Conversation commands"></ul>
|
|
16
|
+
<p class="search-notice" role="status"></p>
|
|
17
|
+
<ul class="search-results" aria-label="Search results"></ul>
|
|
18
|
+
<button type="button" class="search-more" hidden>Show more</button>`;
|
|
19
|
+
document.body.append(dialog);
|
|
20
|
+
const input = dialog.querySelector("input");
|
|
21
|
+
const results = dialog.querySelector(".search-results:not(.search-commands)");
|
|
22
|
+
const commandList = dialog.querySelector(".search-commands");
|
|
23
|
+
const notice = dialog.querySelector("[role=status]");
|
|
24
|
+
const more = dialog.querySelector(".search-more");
|
|
25
|
+
let timer, controller, selection;
|
|
26
|
+
let count = 0;
|
|
27
|
+
|
|
28
|
+
function clearJump() {
|
|
29
|
+
selection?.classList.remove("search-jump");
|
|
30
|
+
selection = null;
|
|
31
|
+
window.CSS?.highlights?.delete("transcript-match");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function focusHit(index, term) {
|
|
35
|
+
const record = visibleRecords[index];
|
|
36
|
+
if (!record) return;
|
|
37
|
+
clearJump();
|
|
38
|
+
followNewText = false;
|
|
39
|
+
selection = record.article;
|
|
40
|
+
selection.classList.add("search-jump");
|
|
41
|
+
selection.tabIndex = -1;
|
|
42
|
+
selection.focus({ preventScroll: true });
|
|
43
|
+
selection.scrollIntoView({ block: "center" });
|
|
44
|
+
|
|
45
|
+
// A match may cross an inline emphasis or link boundary.
|
|
46
|
+
const walker = document.createTreeWalker(record.prose, NodeFilter.SHOW_TEXT);
|
|
47
|
+
const parts = [];
|
|
48
|
+
let text = "";
|
|
49
|
+
while (walker.nextNode()) {
|
|
50
|
+
const node = walker.currentNode;
|
|
51
|
+
parts.push({ node, offset: text.length });
|
|
52
|
+
text += node.data;
|
|
53
|
+
}
|
|
54
|
+
const words = term.trim().split(/\s+/).map(word => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
55
|
+
const hit = new RegExp(words.join("\\s+"), "iu").exec(text);
|
|
56
|
+
if (!hit) return;
|
|
57
|
+
const end = hit.index + hit[0].length;
|
|
58
|
+
const first = parts.find(p => p.offset + p.node.length > hit.index);
|
|
59
|
+
const last = parts.find(p => p.offset + p.node.length >= end);
|
|
60
|
+
if (!first || !last) return;
|
|
61
|
+
const range = new Range();
|
|
62
|
+
range.setStart(first.node, hit.index - first.offset);
|
|
63
|
+
range.setEnd(last.node, end - last.offset);
|
|
64
|
+
if (window.CSS?.highlights && window.Highlight) CSS.highlights.set("transcript-match", new Highlight(range));
|
|
65
|
+
reader.scrollTop += range.getBoundingClientRect().top - reader.getBoundingClientRect().top - reader.clientHeight / 3;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function addHit(hit) {
|
|
69
|
+
const li = element("li");
|
|
70
|
+
const button = element("button", "search-hit");
|
|
71
|
+
button.type = "button";
|
|
72
|
+
const title = element("span", "search-title", hit.title);
|
|
73
|
+
button.append(title);
|
|
74
|
+
if (hit.speaker) {
|
|
75
|
+
const line = element("span", "search-excerpt");
|
|
76
|
+
line.append(element("span", "search-speaker", names[hit.speaker] + " · "), hit.before,
|
|
77
|
+
element("mark", "", hit.match), hit.after);
|
|
78
|
+
button.append(line);
|
|
79
|
+
}
|
|
80
|
+
button.addEventListener("click", async () => {
|
|
81
|
+
dialog.close();
|
|
82
|
+
clearJump();
|
|
83
|
+
if (mobile.matches) showPanel(false);
|
|
84
|
+
await openChat(hit.chat_id);
|
|
85
|
+
if (chat?.id !== hit.chat_id) return;
|
|
86
|
+
if (hit.message_index != null) focusHit(hit.message_index, hit.match);
|
|
87
|
+
else reader.focus({ preventScroll: true });
|
|
88
|
+
});
|
|
89
|
+
li.append(button);
|
|
90
|
+
results.append(li);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function recent() {
|
|
94
|
+
notice.textContent = chatList.length ? "Recent chats" : "Your saved chats will appear here.";
|
|
95
|
+
chatList.filter(c => c.chars >= 0).slice(0, 6).forEach(c => addHit({ chat_id: c.id, title: c.title }));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function query(append = false) {
|
|
99
|
+
const term = input.value.trim();
|
|
100
|
+
const request = new AbortController();
|
|
101
|
+
controller?.abort();
|
|
102
|
+
controller = request;
|
|
103
|
+
more.disabled = true;
|
|
104
|
+
try {
|
|
105
|
+
const params = new URLSearchParams({ q: term, offset: String(append ? count : 0) });
|
|
106
|
+
const response = await fetch("/api/search?" + params, { signal: request.signal });
|
|
107
|
+
if (!response.ok) throw new Error();
|
|
108
|
+
const page = await response.json();
|
|
109
|
+
if (request.signal.aborted || !dialog.open) return;
|
|
110
|
+
page.items.forEach(addHit);
|
|
111
|
+
count += page.items.length;
|
|
112
|
+
more.hidden = !page.more;
|
|
113
|
+
notice.textContent = count ? count + (page.more ? "+" : "") + (count === 1 ? " match" : " matches") : "No matching chats or messages.";
|
|
114
|
+
if (append && page.items.length) results.children[count - page.items.length].firstElementChild.focus();
|
|
115
|
+
} catch {
|
|
116
|
+
if (!request.signal.aborted) notice.textContent = "Search could not reach the local server. Try again.";
|
|
117
|
+
} finally {
|
|
118
|
+
if (controller === request) more.disabled = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function changed() {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
controller?.abort();
|
|
125
|
+
const term = input.value.trim().toLowerCase().replace(/^\//,"");
|
|
126
|
+
commandList.replaceChildren();
|
|
127
|
+
for (const item of window.chatActions.commands.filter(c => c.name.includes(term) || c.title.toLowerCase().includes(term))) {
|
|
128
|
+
const li = element("li"), control = element("button","search-hit");
|
|
129
|
+
control.type="button";
|
|
130
|
+
control.append(element("span","search-title",item.title),element("span","search-excerpt",item.hint+" · /"+item.name));
|
|
131
|
+
control.addEventListener("click", () => {dialog.close();window.chatActions.runCommand(item.name);});
|
|
132
|
+
li.append(control);commandList.append(li);
|
|
133
|
+
}
|
|
134
|
+
count = 0;
|
|
135
|
+
results.replaceChildren();
|
|
136
|
+
more.hidden = true;
|
|
137
|
+
if (!input.value.trim()) { recent(); return; }
|
|
138
|
+
notice.textContent = "Searching…";
|
|
139
|
+
timer = setTimeout(query, 140);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function open() {
|
|
143
|
+
if (dialog.open) { input.focus(); input.select(); return; }
|
|
144
|
+
dialog.showModal();
|
|
145
|
+
input.value = "";
|
|
146
|
+
changed();
|
|
147
|
+
input.focus();
|
|
148
|
+
}
|
|
149
|
+
input.addEventListener("input", changed);
|
|
150
|
+
more.addEventListener("click", () => query(true));
|
|
151
|
+
trigger.addEventListener("click", open);
|
|
152
|
+
dialog.querySelector("[data-close]").addEventListener("click", () => dialog.close());
|
|
153
|
+
dialog.addEventListener("close", () => { clearTimeout(timer); controller?.abort(); });
|
|
154
|
+
dialog.addEventListener("click", event => {
|
|
155
|
+
if (event.target !== dialog) return;
|
|
156
|
+
const rect = dialog.getBoundingClientRect();
|
|
157
|
+
if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) dialog.close();
|
|
158
|
+
});
|
|
159
|
+
dialog.addEventListener("keydown", event => {
|
|
160
|
+
if (event.isComposing) return;
|
|
161
|
+
if (event.key === "Escape") {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
dialog.close();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const hits = [...commandList.querySelectorAll("button"), ...results.querySelectorAll("button")];
|
|
168
|
+
if (event.target === input && event.key === "Enter" && hits[0]) {
|
|
169
|
+
event.preventDefault(); hits[0].click(); return;
|
|
170
|
+
}
|
|
171
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
172
|
+
const current = hits.indexOf(document.activeElement);
|
|
173
|
+
const next = event.key === "ArrowDown" ? hits[Math.min(current + 1, hits.length - 1)] : hits[current - 1] || input;
|
|
174
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
175
|
+
});
|
|
176
|
+
document.addEventListener("keydown", event => {
|
|
177
|
+
if ((event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "k") {
|
|
178
|
+
event.preventDefault(); open();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
})();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const panel = preferenceDialog('shared-memory', 'Shared memory', `
|
|
3
|
+
<p class="preference-description">Participants receive these notes on their next turn.</p>
|
|
4
|
+
<form><label for="memory-scope">Use these notes in</label>
|
|
5
|
+
<select id="memory-scope"><option value="chat">This chat</option><option value="all">All chats</option></select>
|
|
6
|
+
<label for="memory-note">Shared notes</label><textarea id="memory-note" rows="5" maxlength="4000" placeholder="Preferences, facts, or decisions to remember"></textarea>
|
|
7
|
+
<details id="memory-summary" hidden><summary>Earlier conversation summary</summary><small></small><p></p></details>
|
|
8
|
+
<div><button type="button" class="settings-action" id="memory-import" aria-haspopup="dialog">Import from another AI</button></div>
|
|
9
|
+
<div class="preference-footer"><small id="memory-length"></small><button class="preference-save" type="submit">Save notes</button></div>
|
|
10
|
+
</form>`);
|
|
11
|
+
const scope = byId('memory-scope'), note = byId('memory-note');
|
|
12
|
+
const form = panel.body.querySelector('form'), summary = byId('memory-summary');
|
|
13
|
+
let id, generation = 0, values, drafts, current;
|
|
14
|
+
function count() { byId('memory-length').textContent = `${Array.from(note.value).length.toLocaleString()} / 4,000`; }
|
|
15
|
+
note.addEventListener('input', count);
|
|
16
|
+
scope.addEventListener('change', () => {
|
|
17
|
+
drafts[current] = note.value;
|
|
18
|
+
current = scope.value;
|
|
19
|
+
note.value = drafts[current];
|
|
20
|
+
count();
|
|
21
|
+
});
|
|
22
|
+
byId('memory-import').onclick = async () => {
|
|
23
|
+
const button = byId('memory-import');
|
|
24
|
+
button.disabled = true;
|
|
25
|
+
try {
|
|
26
|
+
drafts[current] = note.value;
|
|
27
|
+
if (drafts.all !== values.all.value) {
|
|
28
|
+
if (!await window.diffConfirm('Save your shared notes first?', 'The import will be added to these all-chat notes.', 'Save and continue')) return;
|
|
29
|
+
values.all = await api('/api/settings/memory', {text:drafts.all, revision:values.all.revision}, 'PATCH');
|
|
30
|
+
drafts.all = values.all.value;
|
|
31
|
+
}
|
|
32
|
+
const saved = await window.openDiffAboutYou();
|
|
33
|
+
if (saved) {
|
|
34
|
+
values.all = saved; drafts.all = saved.value;
|
|
35
|
+
current = scope.value = 'all'; scope.dispatchEvent(new Event('diff-select-sync'));
|
|
36
|
+
note.value = saved.value; count(); panel.status.textContent = 'Profile saved to all chats.';
|
|
37
|
+
}
|
|
38
|
+
} catch (error) { panel.status.textContent = error.message; }
|
|
39
|
+
finally { button.disabled = false; }
|
|
40
|
+
};
|
|
41
|
+
byId('open-memory').addEventListener('click', async () => {
|
|
42
|
+
if (!chat) return;
|
|
43
|
+
const sequence = ++generation;
|
|
44
|
+
id = chat.id;
|
|
45
|
+
form.hidden = true;
|
|
46
|
+
panel.show(); panel.status.textContent = 'Loading notes…';
|
|
47
|
+
try {
|
|
48
|
+
const result = await api(`/api/chats/${id}/memory`);
|
|
49
|
+
if (sequence !== generation) return;
|
|
50
|
+
values = result;
|
|
51
|
+
drafts = {chat: values.chat.value, all: values.all.value};
|
|
52
|
+
current = scope.value = 'chat'; scope.dispatchEvent(new Event('diff-select-sync'));
|
|
53
|
+
note.value = drafts.chat; count();
|
|
54
|
+
const item = result.summary;
|
|
55
|
+
summary.hidden = !item?.text; summary.open = false;
|
|
56
|
+
if (item?.text) {
|
|
57
|
+
summary.querySelector('p').textContent = item.text;
|
|
58
|
+
const label = catalog[item.provider || item.speaker]?.models.find(m => m.id === item.model)?.label || item.model;
|
|
59
|
+
summary.querySelector('small').textContent = label ? `Summarized by ${label}` : '';
|
|
60
|
+
}
|
|
61
|
+
form.hidden = false; panel.status.textContent = ''; note.focus();
|
|
62
|
+
} catch (error) { if (sequence === generation) panel.status.textContent = error.message; }
|
|
63
|
+
});
|
|
64
|
+
form.addEventListener('submit', async event => {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
const target = id, sequence = generation;
|
|
67
|
+
const button = form.querySelector('[type=submit]');
|
|
68
|
+
drafts[current] = note.value; button.disabled = scope.disabled = note.disabled = true;
|
|
69
|
+
try {
|
|
70
|
+
for (const key of ['chat', 'all']) {
|
|
71
|
+
if (values[key].value !== drafts[key]) {
|
|
72
|
+
const saved = await api(`/api/chats/${target}/memory`, {scope:key, text:drafts[key], revision:values[key].revision}, 'PATCH');
|
|
73
|
+
if (sequence !== generation) return;
|
|
74
|
+
values[key] = saved; drafts[key] = saved.value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
panel.dialog.close(); feedback('Shared notes saved.');
|
|
78
|
+
} catch (error) { if (sequence === generation) panel.status.textContent = error.message; }
|
|
79
|
+
finally {button.disabled = scope.disabled = note.disabled = false;}
|
|
80
|
+
});
|
|
81
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* A native dialog keeps keyboard navigation and focus restoration in the browser. */
|
|
2
|
+
function preferenceDialog(id, title, markup) {
|
|
3
|
+
const dialog = document.createElement('dialog');
|
|
4
|
+
dialog.id = id;
|
|
5
|
+
dialog.className = 'preference-dialog';
|
|
6
|
+
dialog.setAttribute('aria-labelledby', `${id}-heading`);
|
|
7
|
+
const head = element('div', 'preference-head');
|
|
8
|
+
const heading = element('h2', '', title);
|
|
9
|
+
heading.id = `${id}-heading`;
|
|
10
|
+
const close = element('button', 'quiet-button', 'Close');
|
|
11
|
+
close.type = 'button';
|
|
12
|
+
close.addEventListener('click', () => dialog.close());
|
|
13
|
+
head.append(heading, close);
|
|
14
|
+
const body = element('div', 'preference-body');
|
|
15
|
+
body.innerHTML = markup; // Static form markup supplied by the caller.
|
|
16
|
+
const status = element('p', 'preference-status');
|
|
17
|
+
status.setAttribute('role', 'status');
|
|
18
|
+
dialog.append(head, body, status);
|
|
19
|
+
document.body.append(dialog);
|
|
20
|
+
return {dialog, body, status, show() {status.textContent = ''; dialog.showModal();}};
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.preference-dialog {
|
|
2
|
+
box-sizing: border-box; width: min(438px, calc(100vw - 32px)); max-height: calc(100dvh - 40px);
|
|
3
|
+
padding: 22px; background: var(--surface, Canvas); color: var(--ink, CanvasText); border: 1px solid var(--rule);
|
|
4
|
+
--corner-radius: 16px; font: 14px/1.5 var(--ui, system-ui); box-shadow: 0 18px 70px #0003;
|
|
5
|
+
}
|
|
6
|
+
.preference-dialog::backdrop {background: rgb(0 0 0 / 30%);}
|
|
7
|
+
.preference-head, .preference-footer, .connection-command {display: flex; align-items: center; gap: 12px; justify-content: space-between;}
|
|
8
|
+
.preference-head h2 {margin: 0; font: 620 19px/1.3 var(--ui, system-ui); letter-spacing: -.025em;}
|
|
9
|
+
.preference-description, .preference-hint, .preference-status, #connection-list small, #memory-length, #memory-summary small {color: var(--secondary);}
|
|
10
|
+
.preference-description {margin: 12px 0 20px;}
|
|
11
|
+
.preference-dialog form {display: grid; gap: 7px;}
|
|
12
|
+
.preference-dialog [hidden] {display: none;}
|
|
13
|
+
.preference-dialog label, .connection-row h3 {font: 560 13px/1.4 var(--ui, system-ui);}
|
|
14
|
+
.preference-dialog label:not(:first-child) {margin-top: 9px;}
|
|
15
|
+
.preference-dialog select, .preference-dialog textarea {
|
|
16
|
+
display: block; box-sizing: border-box; width: 100%; padding: 9px 10px; border: 1px solid var(--edge, var(--rule));
|
|
17
|
+
background: var(--paper, Canvas); color: var(--ink); font: inherit; --corner-radius: 7px;
|
|
18
|
+
}
|
|
19
|
+
.preference-dialog textarea {resize: vertical; min-height: 86px; max-height: 32vh;}
|
|
20
|
+
.preference-dialog select {appearance: auto;}
|
|
21
|
+
.preference-dialog .preference-save, #setup-notice button:not(.quiet-button) {background: var(--ink); color: var(--paper); border: 0; --corner-radius: 7px; padding: 8px 13px; font: 550 13px/1.3 var(--ui, system-ui); cursor: pointer;}
|
|
22
|
+
.preference-save:disabled {opacity: .55;}
|
|
23
|
+
.preference-footer {margin-top: 12px;}
|
|
24
|
+
.preference-footer .preference-save {margin-inline-start: auto;}
|
|
25
|
+
.preference-status:empty {display: none;} .preference-status {margin: 12px 0 0;}
|
|
26
|
+
.preference-hint {font-size: 12px; margin: 4px 0;}
|
|
27
|
+
#memory-length, #memory-summary small, .connection-command code {font-family: var(--mono, monospace); font-size: 11px;}
|
|
28
|
+
#memory-summary {margin-top: 8px;} #memory-summary summary {cursor: pointer;}
|
|
29
|
+
#memory-summary p {white-space: pre-wrap; overflow-wrap: anywhere;}
|
|
30
|
+
.connection-row {border-top: 1px solid var(--rule); padding: 13px 0;}
|
|
31
|
+
.connection-row h3, .connection-row p {margin: 0;} .connection-row p {color: var(--secondary);}
|
|
32
|
+
.connection-command {background: var(--paper); margin-top: 6px; --corner-radius: 7px; padding: 6px 9px;}
|
|
33
|
+
.connection-command code {user-select: all; overflow-wrap: anywhere;}
|
|
34
|
+
#setup-notice:not([hidden]) {display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--secondary); font: 13px/1.5 var(--ui, system-ui); padding-block: 10px;}
|
|
35
|
+
#about-you-import {width:min(560px, calc(100vw - 32px));}
|
|
36
|
+
#about-you-import .settings-kicker {margin:16px 0 12px;}
|
|
37
|
+
#about-you-import [data-stage] > textarea {margin:8px 0 12px; line-height:1.5;}
|
|
38
|
+
#profile-prompt {font:13px/1.5 var(--mono, monospace);}
|
|
39
|
+
#profile-checklist {max-height:36dvh; overflow:auto; overscroll-behavior:contain; padding:4px;}
|
|
40
|
+
#profile-checklist fieldset {min-width:0; border:0; padding:0; margin:0 0 16px;}
|
|
41
|
+
#profile-checklist fieldset:last-child {margin-bottom:0;}
|
|
42
|
+
#profile-checklist legend {padding:0; margin-bottom:4px; font-weight:500;}
|
|
43
|
+
.profile-fact {display:grid; grid-template-columns:20px minmax(0,1fr); gap:8px; align-items:start; padding:4px 0;}
|
|
44
|
+
#profile-checklist .profile-fact input {appearance:none; width:16px; height:16px; margin:8px 0; border-radius:4px; background:var(--surface); border:1px solid var(--secondary); cursor:pointer;}
|
|
45
|
+
#profile-checklist .profile-fact input:checked {background:var(--ink); border-color:var(--ink);}
|
|
46
|
+
#profile-checklist .profile-fact input::after {content:none;}
|
|
47
|
+
#profile-checklist .profile-fact input:checked::after {content:""; display:block; width:4px; height:8px; inset:1px auto auto 5px; border:solid var(--paper); border-width:0 1.5px 1.5px 0; border-radius:0; transform:rotate(45deg); background:none; transition:none;}
|
|
48
|
+
#about-you-import .profile-fact textarea {min-height:32px; max-height:96px; field-sizing:content; resize:vertical; padding:4px 8px; font:13px/1.5 var(--ui);}
|
|
49
|
+
.profile-fact textarea:disabled {opacity:.55;}
|
|
50
|
+
#profile-size {display:grid; grid-template-columns:1fr auto; align-items:baseline; gap:4px; margin:16px 0;}
|
|
51
|
+
#profile-count {font:11px var(--mono); color:var(--secondary); font-variant-numeric:tabular-nums;}
|
|
52
|
+
#profile-meter {display:block; width:100%; grid-column:1/-1; height:8px; accent-color:var(--ink);}
|
|
53
|
+
#profile-meter::-webkit-meter-bar {background:var(--rule); border:0;}
|
|
54
|
+
#profile-meter::-webkit-meter-optimum-value {background:var(--secondary);}
|
|
55
|
+
#profile-meter::-moz-meter-bar {background:var(--secondary);}
|
|
56
|
+
#about-you-import [hidden] {display:none;}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* Launch fragments stay on the device. Reloads retain access in this tab. */
|
|
2
|
+
(() => {
|
|
3
|
+
"use strict";
|
|
4
|
+
const storageKey = "diff.launch-session";
|
|
5
|
+
const supplied = new URLSearchParams(location.hash.slice(1)).get("token");
|
|
6
|
+
let token = "";
|
|
7
|
+
if (supplied) {
|
|
8
|
+
history.replaceState(history.state, "", location.pathname + location.search);
|
|
9
|
+
if (/^[\w-]{43}$/.test(supplied)) {
|
|
10
|
+
token = supplied;
|
|
11
|
+
try { sessionStorage.setItem(storageKey, token); } catch {}
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
try { token = sessionStorage.getItem(storageKey) || ""; } catch {}
|
|
15
|
+
}
|
|
16
|
+
function localAPI(input) {
|
|
17
|
+
const url = new URL(input, location.href);
|
|
18
|
+
return url.origin === location.origin && url.pathname.startsWith("/api/") ? url : null;
|
|
19
|
+
}
|
|
20
|
+
const rawFetch = window.fetch.bind(window);
|
|
21
|
+
window.fetch = (input, init = {}) => {
|
|
22
|
+
if (!token || !localAPI(input instanceof Request ? input.url : input)) return rawFetch(input, init);
|
|
23
|
+
const headers = new Headers(init.headers ?? (input instanceof Request ? input.headers : undefined));
|
|
24
|
+
headers.set("Authorization", "Bearer " + token);
|
|
25
|
+
return rawFetch(input, {...init, headers, redirect:"error"});
|
|
26
|
+
};
|
|
27
|
+
window.diffSession = Object.freeze({
|
|
28
|
+
streamURL(path) {
|
|
29
|
+
const url = localAPI(path);
|
|
30
|
+
if (!url) throw Error("Stream must belong to this window.");
|
|
31
|
+
url.searchParams.set("session", token);
|
|
32
|
+
return url.href;
|
|
33
|
+
},
|
|
34
|
+
async download(path, filename) {
|
|
35
|
+
if (!localAPI(path)) throw Error("Invalid download.");
|
|
36
|
+
const response = await fetch(path);
|
|
37
|
+
if (!response.ok) throw Error("Open diff again and retry the export.");
|
|
38
|
+
const url = URL.createObjectURL(await response.blob());
|
|
39
|
+
const a = document.createElement("a");
|
|
40
|
+
a.href = url;
|
|
41
|
+
a.download = filename;
|
|
42
|
+
a.click();
|
|
43
|
+
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
})();
|