minecodex 2.0.28 → 2.0.30
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/README.md +1 -2
- package/features/images/src/adapters/codex/image-sources.mjs +3 -1
- package/features/images/src/adapters/codex/native-image-modules.mjs +24 -19
- package/features/model-slider/src/frontend/install.mjs +7 -6
- package/features/quick-chat/assets/pin.svg +1 -0
- package/features/quick-chat/codex-feature.json +23 -5
- package/features/quick-chat/src/adapters/codex/history.mjs +8 -0
- package/features/quick-chat/src/adapters/codex/pin.mjs +29 -0
- package/features/quick-chat/src/adapters/codex/renderer.mjs +17 -13
- package/features/quick-chat/src/adapters/codex/shortcut.mjs +118 -0
- package/features/quick-chat/src/frontend/entry.mjs +16 -7
- package/features/quick-chat/src/frontend/exit.mjs +14 -0
- package/features/quick-chat/src/frontend/pin.mjs +54 -0
- package/features/quick-chat/src/injection-source.mjs +7 -1
- package/package.json +3 -7
- package/packages/cli/src/config.mjs +3 -2
- package/packages/cli/src/control-server.mjs +1 -1
- package/features/quick-chat-repair/assets/history.svg +0 -17
- package/features/quick-chat-repair/codex-feature.json +0 -10
- package/features/quick-chat-repair/src/frontend/entry.mjs +0 -12
- package/features/quick-chat-repair/src/injection-source.mjs +0 -5
- package/features/quick-chat-repair/vendor/lucide-LICENSE +0 -15
- /package/features/{quick-chat-repair → quick-chat}/src/adapters/codex/presence.mjs +0 -0
package/README.md
CHANGED
|
@@ -18,8 +18,7 @@ MineCodex 给 Codex Desktop 增加一组轻量、本地优先的扩展功能。
|
|
|
18
18
|
| **文件级联浏览** · Cascading File Browser | 点击文件顶部路径,分列浏览文件夹并快速切换文件。 |
|
|
19
19
|
| **图片集合** · Image Collection | 集中浏览生成的图片,查看提示词并复用创作思路。 |
|
|
20
20
|
| **站点收藏** · Saved Sites | 发现项目正在运行的网页,收藏常用网址,随时打开。 |
|
|
21
|
-
|
|
|
22
|
-
| **快捷聊天增强** · Quick Chat | 发送后自动展开聊天,未发送时也能一键查看原生聊天历史。 |
|
|
21
|
+
| **快捷聊天增强** · Enhance Quick Chat | 补回 ⌘⌥N;关闭后开新聊天,最小化后恢复当前聊天,发送后展开。支持固定窗口、原生历史与退出遮罩修复。 |
|
|
23
22
|
| **侧栏聚焦** · Sidebar Focus | 一键收起侧栏中的其他分组,再次点击恢复原来的展开状态。 |
|
|
24
23
|
| **隐藏额度推广** · Hide Usage Promotions | 隐藏输入框上方的套餐升级推广,让对话更清爽。 |
|
|
25
24
|
|
|
@@ -15,7 +15,9 @@ export function createImageSourcesAdapter(codex) {
|
|
|
15
15
|
!node.closest("[data-minecodex-image-navigation]")
|
|
16
16
|
&& codex.props(node, isImageNavigation));
|
|
17
17
|
if (!tabs) return null;
|
|
18
|
-
|
|
18
|
+
// 26.1007 把来源工具栏包进独立 inset;图库仍是同级的 flex 内容区。
|
|
19
|
+
let navigation = tabs.parentElement?.parentElement;
|
|
20
|
+
while (navigation && !navigation.nextElementSibling) navigation = navigation.parentElement;
|
|
19
21
|
const content = navigation?.nextElementSibling;
|
|
20
22
|
const shell = navigation?.parentElement;
|
|
21
23
|
if (!content || !shell) return null;
|
|
@@ -18,7 +18,7 @@ export function discoverFilePreviewComposerBindings(source) {
|
|
|
18
18
|
if(found.length!==1)throw new Error("Native file preview Composer contract changed");
|
|
19
19
|
return found[0];
|
|
20
20
|
};
|
|
21
|
-
const scopeBody=requireBody(/draftId:[\w$]+,imageDataUrl:/);
|
|
21
|
+
const scopeBody=requireBody(/draftId:[\w$]+,(?:imageSrc|imageDataUrl):/);
|
|
22
22
|
const homeBody=requireBody(/homeComposerController:[\w$]+,homeComposerMode:/);
|
|
23
23
|
const composerBody=requireBody(/lockedLayout:`single-line`/);
|
|
24
24
|
const localBody=requireBody(/prepareLocalConversationAttachments:/);
|
|
@@ -36,7 +36,7 @@ export function discoverFilePreviewComposerBindings(source) {
|
|
|
36
36
|
const roles={
|
|
37
37
|
useComposerController:alias(scopeBody,controller,true),
|
|
38
38
|
useHomeComposer:homeBody.match(/let [\w$]+=([\w$]+)\([\w$]+\),[\w$]+=[\w$]+\?\.composerProps/)?.[1],
|
|
39
|
-
Composer:composerBody.match(/jsx\)\(([\w$]+),\{\.\.\.[\w$]+,
|
|
39
|
+
Composer:composerBody.match(/jsx\)\(([\w$]+),\{\.\.\.[\w$]+,[^;]+?lockedLayout:`single-line`/)?.[1],
|
|
40
40
|
ComposerSurface:composerBody.match(/jsx\)\(([\w$]+),\{placement:/)?.[1],
|
|
41
41
|
ScopeProvider:scopeProvider,
|
|
42
42
|
composerScope:alias(scopeBody,scopes[0][2]),
|
|
@@ -115,33 +115,34 @@ export function createNativeImageModules({read = async url => (await fetch(url))
|
|
|
115
115
|
async function gallery() {
|
|
116
116
|
if (!connecting) connecting = (async () => {
|
|
117
117
|
const {React,ReactDOM,module,component,binding,initialUrl,initialSource,initial}=await bootstrap();
|
|
118
|
-
const [masonry,layout,sourceImage,menu,
|
|
118
|
+
const [masonry,layout,sourceImage,menu,toolbar]=await Promise.all([
|
|
119
119
|
module("library-masonry"),module("library-item-layout"),module("generated-image-source"),
|
|
120
120
|
module("generated-image-context-menu"),module("library-selection-toolbar"),
|
|
121
121
|
]);
|
|
122
|
-
|
|
122
|
+
// 26.1007 将选择状态与图库动作移到 selectable-library-item;工具栏保留按钮与材质。
|
|
123
|
+
const selection=await module("selectable-library-item",toolbar.source);
|
|
124
|
+
const [moveDialog,dialogs]=await Promise.all([module("library-move-dialog",selection.source),module("library-item-dialogs",toolbar.source)]);
|
|
123
125
|
const routerLocal = selection.source.match(/get\(([\w$]+)\)\.prepareNavigation\(/)?.[1];
|
|
124
126
|
const routerAtom = await binding(selection.source, selection.url, routerLocal);
|
|
125
127
|
const switchLocal = discoverImageActionBinding(selection.source, "switchMode");
|
|
126
128
|
const switchMode = await binding(selection.source, selection.url, switchLocal);
|
|
127
|
-
const draftLocal = selection.source.match(/let
|
|
129
|
+
const draftLocal = selection.source.match(/let [\w$]+=([\w$]+)\([\w$]+,\[\]\);[\w$]+\.set/)?.[1];
|
|
128
130
|
const createChatDraft = await binding(selection.source, selection.url, draftLocal);
|
|
129
131
|
const dropdownLocal = selection.source.match(/\(0,[\w$]+\.jsxs?\)\(([\w$]+),\{contentWidth:`menu`/)?.[1];
|
|
130
132
|
const itemsLocal = selection.source.match(/\(0,[\w$]+\.jsxs?\)\(([\w$]+)\.Item,\{/)?.[1];
|
|
131
|
-
const buttonLocal =
|
|
132
|
-
const iconLocal =
|
|
133
|
-
const [Dropdown, Menu
|
|
133
|
+
const buttonLocal = toolbar.source.match(/jsx\)\(([\w$]+),\{color:`mediaSolid`/)?.[1];
|
|
134
|
+
const iconLocal = toolbar.source.match(/id:`libraryNext.selection.more`[^;]+?children:\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\)/)?.[1];
|
|
135
|
+
const [Dropdown, Menu] = await Promise.all([dropdownLocal, itemsLocal].map(local => binding(selection.source, selection.url, local)));
|
|
136
|
+
const [Button, MoreIcon] = await Promise.all([buttonLocal, iconLocal].map(local => binding(toolbar.source, toolbar.url, local)));
|
|
134
137
|
const checkboxFunction = component(selection.exports,source=>/onCheckedChange:/.test(source)&&/viewMode:/.test(source),"selection checkbox");
|
|
135
|
-
const checkboxLocal = String(checkboxFunction).match(
|
|
138
|
+
const checkboxLocal = String(checkboxFunction).match(/jsx\)\(([\w$]+),\{className:`cursor-interaction`,/)?.[1];
|
|
136
139
|
const Checkbox = await binding(selection.source,selection.url,checkboxLocal);
|
|
137
140
|
const rangeSelection = component(selection.exports,source=>/^function [\w$]+\(\{orderedIds:/.test(source)&&/extendRange:/.test(source),"range selection");
|
|
138
|
-
const selectionLocal =
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
if (!nativeSelectedIds) throw new Error("Native selection state contract changed");
|
|
142
|
-
const clearPrefix = selection.source.slice(selection.source.indexOf("id:`libraryNext.selection.clear`"));
|
|
141
|
+
const selectionLocal = toolbar.source.match(/\.set\(([\w$]+),new Set[,)]/)?.[1];
|
|
142
|
+
const nativeSelectedIds = await binding(toolbar.source,toolbar.url,selectionLocal);
|
|
143
|
+
const clearPrefix = toolbar.source.slice(toolbar.source.indexOf("id:`libraryNext.selection.clear`"));
|
|
143
144
|
const clearLocal = clearPrefix.match(/\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\)/)?.[1];
|
|
144
|
-
const ClearIcon = await binding(
|
|
145
|
+
const ClearIcon = await binding(toolbar.source,toolbar.url,clearLocal);
|
|
145
146
|
const dialogLocal = dialogs.source.match(/\(0,[\w$]+\.jsx\)\(([\w$]+),\{open:[^,]+,showDialogClose:!1/)?.[1];
|
|
146
147
|
const contentLocal = dialogs.source.match(/\(0,[\w$]+\.jsx\)\(([\w$]+),\{as:`form`,onSubmit:/)?.[1];
|
|
147
148
|
const [Dialog,DialogContent] = await Promise.all([dialogLocal,contentLocal].map(local=>binding(dialogs.source,dialogs.url,local)));
|
|
@@ -154,8 +155,9 @@ export function createNativeImageModules({read = async url => (await fetch(url))
|
|
|
154
155
|
const attachLocal = discoverImageActionBinding(imageActionSource, "attachChatImages");
|
|
155
156
|
const downloadLocal = imageActionSource.match(/await ([\w$]+)\(\{downloadSrc:/)?.[1];
|
|
156
157
|
const [imageFile,attachChatImages,downloadImage] = await Promise.all([imageFileLocal,attachLocal,downloadLocal].map(local=>binding(menuCoreSource,menuCoreUrl,local)));
|
|
157
|
-
const toolbarClass =
|
|
158
|
-
const
|
|
158
|
+
const toolbarClass = toolbar.source.match(/=\`(_Toolbar_[^`]+)\`/)?.[1];
|
|
159
|
+
const toolbarContainer = toolbar.source.match(/=\`(_Container_[^`]+)\`/)?.[1];
|
|
160
|
+
const toolbarPositionClass = toolbarContainer && `${toolbarContainer} fixed`;
|
|
159
161
|
if (!toolbarClass || !toolbarPositionClass) throw new Error("Native selection toolbar layout changed");
|
|
160
162
|
const libraryIcon = async label => {
|
|
161
163
|
const marker = selection.source.indexOf(`defaultMessage:\`${label}\``);
|
|
@@ -180,8 +182,11 @@ export function createNativeImageModules({read = async url => (await fetch(url))
|
|
|
180
182
|
const favoriteIconOwner = favoritePrefix.slice(0,favoriteIconLocal).match(/\(0,[\w$]+\.jsx\)\(([\w$]+),\{$/)?.[1];
|
|
181
183
|
const [FavoriteIcon, savedSmall, savedMedium, emptySmall, emptyMedium] = await Promise.all([favoriteIconOwner,...favoriteAsset.slice(1)].map(local => binding(selection.source,selection.url,local)));
|
|
182
184
|
const favoriteIcon = saved => React.createElement(FavoriteIcon,{icon:{assets:saved?{16:savedSmall,20:savedMedium}:{16:emptySmall,20:emptyMedium}}});
|
|
183
|
-
const [
|
|
184
|
-
|
|
185
|
+
const chatLocal = toolbar.source.match(/children:[\w$]+\?[^;]+?:\(0,[\w$]+\.jsxs\)\([\w$]+\.Fragment,\{children:\[\(0,[\w$]+\.jsx\)\(([\w$]+),\{\}\),\(0,[\w$]+\.jsx\)\([\w$]+,\{id:`libraryNext.selection.chat`/)?.[1];
|
|
186
|
+
const ChatIcon = await binding(toolbar.source,toolbar.url,chatLocal);
|
|
187
|
+
const chatIcon = React.createElement(ChatIcon,{});
|
|
188
|
+
const [downloadIcon, folderIcon, deleteIcon] = await Promise.all([
|
|
189
|
+
libraryIcon("Download"), libraryIcon("Move to folder"), libraryIcon("{kind, select, directory {Delete folder} other {Delete}}"),
|
|
185
190
|
]);
|
|
186
191
|
if (!React.createElement || !ReactDOM.createRoot || !Menu.Item) throw new Error("Native Images rendering contract changed");
|
|
187
192
|
return {
|
|
@@ -727,7 +727,7 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
727
727
|
.reduce((sum, value) => sum + (Number.parseFloat(value) || 0), 0);
|
|
728
728
|
const last = items[Math.max(1, maxVisibleItems) - 1];
|
|
729
729
|
const resultsHeight = last ? last.offsetTop + last.offsetHeight - content.offsetTop : content.offsetHeight;
|
|
730
|
-
const available = modelSelectorControllerMenu.parentMenu.getBoundingClientRect().bottom - 8;
|
|
730
|
+
const available = (modelSelectorControllerMenu.parentMenu.getBoundingClientRect().bottom - 8) / (menu.currentCSSZoom || 1);
|
|
731
731
|
menu.style.height = `${Math.ceil(Math.min(chrome + header.offsetHeight + resultsHeight, available))}px`;
|
|
732
732
|
menu.style.overflowY = "auto";
|
|
733
733
|
return;
|
|
@@ -1008,7 +1008,8 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
1010
|
function animateControllerModelMenu(record, opening, onFinish) {
|
|
1011
|
-
|
|
1011
|
+
// height 写入 CSS 动画,必须使用布局尺寸,不能重复计入原生 zoom 和开场 scale。
|
|
1012
|
+
const height = Number.parseFloat(getComputedStyle(record.menu).height);
|
|
1012
1013
|
clearTimeout(record.motionTimer);
|
|
1013
1014
|
record.animations?.forEach((animation) => animation.cancel());
|
|
1014
1015
|
record.animations = [];
|
|
@@ -1139,14 +1140,14 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1139
1140
|
resetKeyboard();
|
|
1140
1141
|
const record = modelSelectorControllerMenu;
|
|
1141
1142
|
if (!record || record.menu !== menu || record.closing) return;
|
|
1142
|
-
const previousHeight =
|
|
1143
|
+
const previousHeight = Number.parseFloat(getComputedStyle(menu).height);
|
|
1143
1144
|
clearTimeout(record.motionTimer);
|
|
1144
1145
|
record.animations?.forEach((animation) => animation.cancel());
|
|
1145
1146
|
record.animations = [];
|
|
1146
1147
|
menu.scrollTop = 0;
|
|
1147
1148
|
renderEnhancedModelMenu(menu, selector);
|
|
1148
1149
|
sizeModelMenuViewport(menu, selector.maxVisibleItems);
|
|
1149
|
-
record.listHeight =
|
|
1150
|
+
record.listHeight = Number.parseFloat(getComputedStyle(menu).height);
|
|
1150
1151
|
if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
1151
1152
|
const motion = menu.animate([{ height: `${previousHeight}px` }, { height: `${record.listHeight}px` }],
|
|
1152
1153
|
{ duration: 320, easing: "cubic-bezier(.19,1,.22,1)" });
|
|
@@ -1242,7 +1243,7 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1242
1243
|
placeholderText,
|
|
1243
1244
|
position: parentMenu.style.position,
|
|
1244
1245
|
overflow: parentMenu.style.overflow,
|
|
1245
|
-
sliderHeight:
|
|
1246
|
+
sliderHeight: Number.parseFloat(getComputedStyle(parentMenu).height),
|
|
1246
1247
|
};
|
|
1247
1248
|
parentMenu.style.position = "relative";
|
|
1248
1249
|
parentMenu.style.overflow = "visible";
|
|
@@ -1251,7 +1252,7 @@ export function installModelSlider(signal, { feature, ui, createIcon, requestRef
|
|
|
1251
1252
|
modelButton.setAttribute("aria-expanded", "true");
|
|
1252
1253
|
search.focus({ preventScroll: true });
|
|
1253
1254
|
const record = modelSelectorControllerMenu;
|
|
1254
|
-
record.listHeight =
|
|
1255
|
+
record.listHeight = Number.parseFloat(getComputedStyle(menu).height);
|
|
1255
1256
|
animateControllerModelMenu(record, true, () => {
|
|
1256
1257
|
if (modelSelectorControllerMenu !== record || record.closing) return;
|
|
1257
1258
|
record.animations.forEach((animation) => animation.cancel());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>
|
|
@@ -2,9 +2,27 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "quick-chat",
|
|
4
4
|
"version": "0.1.0",
|
|
5
|
-
"label": {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
5
|
+
"label": {
|
|
6
|
+
"en": "Enhance Quick Chat",
|
|
7
|
+
"zh-CN": "快捷聊天增强"
|
|
8
|
+
},
|
|
9
|
+
"description": {
|
|
10
|
+
"en": "Start fresh after closing, restore minimized chats, expand after sending, pin conversations, and repair native exit layers.",
|
|
11
|
+
"zh-CN": "关闭后开启全新聊天,恢复最小化输入框、发送后展开、固定聊天,并修复退出后的透明遮罩残留。"
|
|
12
|
+
},
|
|
13
|
+
"entry": {
|
|
14
|
+
"kind": "page-script",
|
|
15
|
+
"script": "src/frontend/entry.mjs",
|
|
16
|
+
"sourceFactory": "src/injection-source.mjs",
|
|
17
|
+
"resources": {
|
|
18
|
+
"history": "assets/history.svg",
|
|
19
|
+
"pin": "assets/pin.svg"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"icon": {
|
|
23
|
+
"resource": "assets/history.svg"
|
|
24
|
+
},
|
|
25
|
+
"placement": {
|
|
26
|
+
"order": 75
|
|
27
|
+
}
|
|
10
28
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// 统一解释原生历史列表;原始 React 节点不越过 Adapter 边界。
|
|
2
|
+
export function quickChatHistoryVisible(node) {
|
|
3
|
+
if (Array.isArray(node)) return node.some(quickChatHistoryVisible);
|
|
4
|
+
const props = node?.props;
|
|
5
|
+
if (!props || props.hidden || props.inert || props['aria-hidden']) return false;
|
|
6
|
+
if (Array.isArray(props.conversations) && typeof props.onConversationSelect === 'function' && typeof props.onNewChat === 'function') return true;
|
|
7
|
+
return quickChatHistoryVisible(props.children);
|
|
8
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {quickChatHistoryVisible} from "./history.mjs";
|
|
2
|
+
export function createQuickChatPinAdapter(codex) {
|
|
3
|
+
const layerSelector = '.fixed.inset-0.zoom-adjusted-viewport.pointer-events-auto';
|
|
4
|
+
|
|
5
|
+
function surfaces() {
|
|
6
|
+
const inCodex = [...document.querySelectorAll('button[aria-haspopup="menu"]')].some(button => button.checkVisibility({visibilityProperty:true})
|
|
7
|
+
&& codex.props(button, p => typeof p.onModeSelect === 'function' && typeof p.mode === 'string', 80)?.mode === 'codex');
|
|
8
|
+
if (!inCodex) return [];
|
|
9
|
+
return [...document.querySelectorAll('[data-floating-chat-surface]')].flatMap(surface => {
|
|
10
|
+
const layer = surface.closest(layerSelector);
|
|
11
|
+
if (!layer || layer.closest('[hidden], [inert], [aria-hidden="true"]')) return [];
|
|
12
|
+
if (!codex.props(surface, p => p.name === 'QuickChatWindow', 120)) return [];
|
|
13
|
+
const presence = codex.props(surface, p => typeof p.isPresent === 'boolean' && typeof p.onExitComplete === 'function', 120);
|
|
14
|
+
if (presence?.isPresent === false) return [];
|
|
15
|
+
const editable = surface.querySelector('[data-chatgpt-composer] [contenteditable="true"]');
|
|
16
|
+
const composer = editable && codex.props(editable, p => typeof p.isWorkConversation === 'boolean' && p.conversationId);
|
|
17
|
+
const session = codex.props(surface, p => p.session?.conversationId)?.session;
|
|
18
|
+
const floating = codex.props(surface, p => typeof p.onMinimizedChange === 'function' && typeof p.renderMenu === 'function');
|
|
19
|
+
if (!composer || composer.isWorkConversation || composer.annotationSubmitTarget || composer.isWidgetOverlay || !session?.hasConversation || !floating) return [];
|
|
20
|
+
const anchor = surface.querySelector('header button[data-quick-chat-drag-handle]');
|
|
21
|
+
const expanded = floating.presentation === 'expanded' || floating.forceExpanded;
|
|
22
|
+
const history = quickChatHistoryVisible(floating.renderTranscript?.());
|
|
23
|
+
return [{surface, layer, sessionId:session.conversationId, anchor, minimized:Boolean(floating.isMinimized), expanded:Boolean(expanded), history,
|
|
24
|
+
expand:() => floating.onPresentationChange('expanded'),
|
|
25
|
+
showPin:Boolean(anchor && expanded && !floating.isMinimized && !history)}];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {surfaces};
|
|
29
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import {quickChatHistoryVisible} from "./history.mjs";
|
|
1
2
|
export function createQuickChatAdapter(codex) {
|
|
2
|
-
const receipts = new WeakMap();
|
|
3
|
+
const receipts = new WeakMap(), subscriptions = new WeakMap(), emitters = new WeakMap();
|
|
4
|
+
let nextSubscription = 1;
|
|
3
5
|
let nextReceipt = 1;
|
|
4
6
|
const surfaceSelector = '[data-floating-chat-surface]';
|
|
5
|
-
|
|
6
|
-
if (Array.isArray(node)) return node.some(historyList);
|
|
7
|
-
const props = node?.props;
|
|
8
|
-
if (!props || props.hidden || props.inert || props['aria-hidden']) return false;
|
|
9
|
-
if (Array.isArray(props.conversations) && typeof props.onConversationSelect === 'function' && typeof props.onNewChat === 'function') return true;
|
|
10
|
-
return historyList(props.children);
|
|
11
|
-
}
|
|
7
|
+
|
|
12
8
|
function read(surface) {
|
|
13
9
|
if (!surface?.isConnected || surface.closest('[hidden], [inert], [aria-hidden="true"]')) return null;
|
|
14
10
|
const editable = surface.querySelector('[data-chatgpt-composer] [contenteditable="true"]');
|
|
@@ -31,7 +27,10 @@ export function createQuickChatAdapter(codex) {
|
|
|
31
27
|
if (fiber.memoizedProps?.session?.conversationId !== session.conversationId) continue;
|
|
32
28
|
for (let hook = fiber.memoizedState, count = 0; hook && count < 140; hook = hook.next, count++) {
|
|
33
29
|
const value = hook.memoizedState;
|
|
34
|
-
|
|
30
|
+
// 26.1007 的按会话订阅状态为 [value, store, atom],value 不再重复存 conversationId。
|
|
31
|
+
const record=Array.isArray(value) ? value[0] : value;
|
|
32
|
+
if (record && typeof record === "object" && "owner" in record && typeof record.presentation === "string"
|
|
33
|
+
&& (record.conversationId == null || record.conversationId === session.conversationId)) receipt = record;
|
|
35
34
|
}
|
|
36
35
|
if (receipt) break;
|
|
37
36
|
}
|
|
@@ -43,16 +42,21 @@ export function createQuickChatAdapter(codex) {
|
|
|
43
42
|
codex.props(button, props => props.variant === "composer" && typeof props.onProjectChange === "function"));
|
|
44
43
|
const projectRail = project?.closest('[data-composer-rail-item]') ?? null;
|
|
45
44
|
const expanded = Boolean(floating.presentation === "expanded" || floating.forceExpanded);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const emitter = controller?.eventEmitter;
|
|
46
|
+
const subscribable = typeof emitter?.addListener === "function" && typeof emitter?.removeListener === "function";
|
|
47
|
+
if (subscribable && !subscriptions.has(emitter)) subscriptions.set(emitter, nextSubscription++);
|
|
48
|
+
const snapshot = {surface, editable, minimize, projectRail, background:!session.hasConversation && floating.forceExpanded ? background : null, sessionId:session.conversationId, hasConversation:session.hasConversation,
|
|
49
|
+
canSubmit:Boolean(state && !state.submitDisabled && !state.submitLoading), receiptId:receipt ? receipts.get(receipt) : 0, receiptPresentation:receipt?.presentation ?? null, subscriptionId:subscribable ? subscriptions.get(emitter) : 0,
|
|
50
|
+
expanded, showHistory:Boolean(minimize && !expanded), historyVisible:quickChatHistoryVisible(floating.renderTranscript?.()),
|
|
49
51
|
expand:() => floating.onPresentationChange("expanded"),
|
|
50
52
|
// 历史动作通过 forceExpanded 临时展开;不要覆盖最小化后的恢复形态。
|
|
51
53
|
history:() => history.onSelect()};
|
|
54
|
+
if (subscribable) emitters.set(snapshot, emitter);
|
|
55
|
+
return snapshot;
|
|
52
56
|
}
|
|
53
57
|
function surfaces() { return [...document.querySelectorAll(surfaceSelector)].map(read).filter(Boolean); }
|
|
54
58
|
function subscribe(snapshot, listener) {
|
|
55
|
-
const emitter = snapshot
|
|
59
|
+
const emitter = emitters.get(snapshot);
|
|
56
60
|
if (!emitter?.addListener || !emitter?.removeListener) return () => {};
|
|
57
61
|
// 不改变原生 emit 的 handled 结果,也不接管发送。
|
|
58
62
|
const submit = () => { listener(); return false; };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// 通过原生能力检查与已有会话分支定位打开动作,不依赖构建哈希或压缩名称。
|
|
2
|
+
export function quickChatOpenExport(source) {
|
|
3
|
+
const match = source.match(/function ([\w$]+)\(([\w$]+),[\w$]+=\{\}\)\{if\(!\2\.get\([\w$]+,\{name:[`"']chatgpt\.quick-chat[`"']\}\)\.isCapable\)return;let [\w$]+=\2\.get\([\w$]+\),[\w$]+=\2\.get\([\w$]+\);if\(/);
|
|
4
|
+
if (!match) throw new Error('quick-chat-open-contract-unavailable');
|
|
5
|
+
const escaped = match[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
6
|
+
const name = source.slice(source.lastIndexOf('export{')).match(new RegExp(`(?:\\{|,)${escaped} as ([\\w$]+)(?:,|\\})`))?.[1];
|
|
7
|
+
if (!name) throw new Error('quick-chat-open-export-unavailable');
|
|
8
|
+
return name;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 新建和恢复共用原生打开状态;退出动画残留的 DOM 不代表会话仍打开。
|
|
12
|
+
export function quickChatLifecycleExports(source) {
|
|
13
|
+
const open = quickChatOpenExport(source);
|
|
14
|
+
const exports = source.slice(source.lastIndexOf('export{'));
|
|
15
|
+
const escaped = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
const local = exports.match(new RegExp(`(?:\\{|,)([\\w$]+) as ${escaped(open)}(?:,|\\})`))?.[1];
|
|
17
|
+
const start = source.indexOf(`function ${local}(`);
|
|
18
|
+
const body = source.slice(start, source.indexOf('function ', start + 9));
|
|
19
|
+
const create = body.match(/if\([\w$]+==null\)\{([\w$]+)\([\w$]+,[\w$]+\);return\}/)?.[1];
|
|
20
|
+
const state = body.match(/[\w$]+\.get\(([\w$]+)\)\|\|/)?.[1];
|
|
21
|
+
const exportOf = name => name && exports.match(new RegExp(`(?:\\{|,)${escaped(name)} as ([\\w$]+)(?:,|\\})`))?.[1];
|
|
22
|
+
const createExport = exportOf(create), openState = exportOf(state);
|
|
23
|
+
if (!createExport || !openState) throw new Error('quick-chat-lifecycle-contract-unavailable');
|
|
24
|
+
return {open, create:createExport, openState};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function installQuickChatShortcut(signal, codex, discover = null) {
|
|
28
|
+
let bindings = null, disposed = false, pendingFocus = null;
|
|
29
|
+
function activateExisting() {
|
|
30
|
+
// 原生恢复按钮同时恢复 presentation、取消最小化并聚焦输入框。
|
|
31
|
+
for (const button of document.querySelectorAll('button')) {
|
|
32
|
+
if (!button.checkVisibility({visibilityProperty:true})) continue;
|
|
33
|
+
const floating = codex.props(button, p => p.unifiedDocking === true && typeof p.onMinimizedChange === 'function' && typeof p.onPresentationChange === 'function');
|
|
34
|
+
if (!floating?.isMinimized || floating.isHidden) continue;
|
|
35
|
+
const restore = codex.props(button, p => p.uniform === true && p.size === 'composer' && typeof p.onClick === 'function'
|
|
36
|
+
&& typeof p.onPointerEnter === 'function' && typeof p.onPointerDown === 'function' && typeof p.onKeyDown === 'function');
|
|
37
|
+
if (!restore) continue;
|
|
38
|
+
button.click();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
for (const surface of document.querySelectorAll('[data-floating-chat-surface]')) {
|
|
42
|
+
if (surface.closest('[hidden], [inert], [aria-hidden="true"]')) continue;
|
|
43
|
+
const floating = codex.props(surface, p => p.unifiedDocking === true && typeof p.onMinimizedChange === 'function' && typeof p.onPresentationChange === 'function');
|
|
44
|
+
if (!floating || floating.isMinimized || floating.isHidden) continue;
|
|
45
|
+
const editable = surface.querySelector('[data-chatgpt-composer] [contenteditable="true"]');
|
|
46
|
+
if (!editable?.checkVisibility({visibilityProperty:true})) continue;
|
|
47
|
+
editable.focus({preventScroll:true});
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
function sessionId(surface) { return codex.props(surface,p=>p.session?.conversationId)?.session?.conversationId; }
|
|
53
|
+
function focusNew() {
|
|
54
|
+
if (!pendingFocus || disposed || signal.aborted) return;
|
|
55
|
+
if (!bindings.isOpen(pendingFocus.scope)) { pendingFocus=null; return; }
|
|
56
|
+
for (const surface of document.querySelectorAll('[data-floating-chat-surface]')) {
|
|
57
|
+
const id=sessionId(surface);
|
|
58
|
+
if (!id || pendingFocus.previous.has(id) || surface.closest('[hidden], [inert], [aria-hidden="true"]')) continue;
|
|
59
|
+
const editable=surface.querySelector('[data-chatgpt-composer] [contenteditable="true"]');
|
|
60
|
+
if (!editable?.checkVisibility({visibilityProperty:true})) continue;
|
|
61
|
+
pendingFocus=null;
|
|
62
|
+
editable.focus({preventScroll:true});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function context() {
|
|
67
|
+
for (const button of document.querySelectorAll('button[aria-haspopup="menu"]')) {
|
|
68
|
+
if (!button.checkVisibility({visibilityProperty:true})) continue;
|
|
69
|
+
const mode = codex.props(button, p => typeof p.onModeSelect === 'function' && typeof p.mode === 'string', 80)?.mode;
|
|
70
|
+
if (mode !== 'codex') continue;
|
|
71
|
+
for (let fiber = codex.currentFiber(button), depth = 0; fiber && depth++ < 200; fiber = fiber.return) {
|
|
72
|
+
const values = [];
|
|
73
|
+
for (let hook = fiber.memoizedState, n = 0; hook && n++ < 150; hook = hook.next) values.push(hook.memoizedState?.current);
|
|
74
|
+
for (const row of fiber.updateQueue?.memoCache?.data ?? []) values.push(...row);
|
|
75
|
+
const scope = values.find(v => typeof v?.get === 'function' && typeof v.set === 'function' && v.scope?.__scopeBrand === 'AppScope');
|
|
76
|
+
if (scope) return scope;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
async function load() {
|
|
82
|
+
const url = [...document.querySelectorAll('link[rel="modulepreload"],script[src]')].map(e => e.href || e.src).find(url => /\/app-initial-[^/]+\.js(?:$|\?)/.test(url));
|
|
83
|
+
if (!url) throw new Error('quick-chat-module-unavailable');
|
|
84
|
+
const source = await (await fetch(url, {signal})).text();
|
|
85
|
+
const module = await import(url);
|
|
86
|
+
const commands = Object.values(module).find(v => Array.isArray(v) && v.some(c => c?.id === 'temporaryChat') && v.some(c => c?.id === 'newTask'));
|
|
87
|
+
if (!commands) throw new Error('quick-chat-command-catalog-unavailable');
|
|
88
|
+
if (commands.some(c => c.id === 'quickChat')) return {native:true};
|
|
89
|
+
const roles = quickChatLifecycleExports(source);
|
|
90
|
+
const open = module[roles.open], create = module[roles.create], openState = module[roles.openState];
|
|
91
|
+
if (typeof open !== 'function' || typeof create !== 'function' || !openState) throw new Error('quick-chat-open-action-unavailable');
|
|
92
|
+
return {native:false, open, create, isOpen:scope => scope.get(openState)};
|
|
93
|
+
}
|
|
94
|
+
const ready = (discover ?? load)().then(value => {
|
|
95
|
+
if (disposed || signal.aborted) return;
|
|
96
|
+
bindings = value;
|
|
97
|
+
codex.report('quick-chat-shortcut', true);
|
|
98
|
+
}).catch(() => { if (!disposed && !signal.aborted) codex.report('quick-chat-shortcut', false, 'native-shortcut-contract-unavailable'); });
|
|
99
|
+
function keydown(event) {
|
|
100
|
+
if (disposed || signal.aborted || bindings?.native || event.defaultPrevented || event.repeat || event.isComposing
|
|
101
|
+
|| !event.metaKey || !event.altKey || event.ctrlKey || event.shiftKey || event.code !== 'KeyN') return;
|
|
102
|
+
const scope = bindings && context();
|
|
103
|
+
if (scope && bindings.isOpen(scope) === false) {
|
|
104
|
+
pendingFocus={scope,previous:new Set([...document.querySelectorAll('[data-floating-chat-surface]')].map(sessionId))};
|
|
105
|
+
bindings.create(scope);
|
|
106
|
+
focusNew();
|
|
107
|
+
} else if (!activateExisting()) {
|
|
108
|
+
if (!scope) return;
|
|
109
|
+
bindings.open(scope);
|
|
110
|
+
}
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
}
|
|
114
|
+
document.addEventListener('keydown', keydown, {signal});
|
|
115
|
+
function dispose() { disposed = true; document.removeEventListener('keydown', keydown); bindings = null; pendingFocus=null; }
|
|
116
|
+
signal.addEventListener('abort', dispose, {once:true});
|
|
117
|
+
return {ready, dispose, sync:focusNew};
|
|
118
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
const exitRepair = installQuickChatExitRepair(signal, createQuickChatExitAdapter(config.codex));
|
|
1
2
|
const native = createQuickChatAdapter(config.codex);
|
|
3
|
+
const shortcut = installQuickChatShortcut(signal, config.codex);
|
|
4
|
+
const pin = installQuickChatPin(signal, config);
|
|
2
5
|
const instances = new Map();
|
|
3
6
|
let scheduled = false, disposed = false;
|
|
4
7
|
const text = (en,zh) => (document.documentElement.lang || navigator.language).startsWith('zh') ? zh : en;
|
|
@@ -22,14 +25,16 @@ function releaseProjectRail(instance) { instance.projectRail?.removeAttribute('d
|
|
|
22
25
|
function remove(instance) { releaseBackground(instance); releaseProjectRail(instance); instance.minimize?.removeAttribute('data-mcx-quick-chat-minimize'); instance.unsubscribe(); instance.button?.remove(); instance.tracker.clear(); instance.historyTracker.clear(); }
|
|
23
26
|
function sync() {
|
|
24
27
|
if (disposed) return;
|
|
28
|
+
shortcut.sync();
|
|
29
|
+
pin.sync();
|
|
25
30
|
const snapshots = native.surfaces(), active = new Set();
|
|
26
31
|
for (const snapshot of snapshots) {
|
|
27
32
|
active.add(snapshot.surface);
|
|
28
33
|
let instance = instances.get(snapshot.surface);
|
|
29
34
|
const selected = instance?.historyTracker.selected(snapshot);
|
|
30
|
-
if (!instance || instance.sessionId !== snapshot.sessionId || instance.
|
|
35
|
+
if (!instance || instance.sessionId !== snapshot.sessionId || instance.subscriptionId !== snapshot.subscriptionId) {
|
|
31
36
|
if (instance) remove(instance);
|
|
32
|
-
instance = {sessionId:snapshot.sessionId,
|
|
37
|
+
instance = {sessionId:snapshot.sessionId, subscriptionId:snapshot.subscriptionId, tracker:createSubmissionTracker(), historyTracker:createHistoryTracker(), button:null};
|
|
33
38
|
const begin = () => { const current = native.read(snapshot.surface); if (current) instance.tracker.begin(current); };
|
|
34
39
|
instance.unsubscribe = native.subscribe(snapshot, begin);
|
|
35
40
|
instances.set(snapshot.surface, instance);
|
|
@@ -89,9 +94,13 @@ const observer = new MutationObserver(schedule);
|
|
|
89
94
|
observer.observe(document.documentElement,{subtree:true,childList:true,attributes:true,attributeFilter:['aria-hidden','inert','hidden','lang']});
|
|
90
95
|
sync();
|
|
91
96
|
config.registerSelfCheck?.(() => {
|
|
92
|
-
const snapshots = native.surfaces(), anchors = snapshots.filter(item => item.showHistory)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
const snapshots = native.surfaces(), anchors = snapshots.filter(item => item.showHistory);
|
|
98
|
+
const history = anchors.some(item => instances.get(item.surface)?.button?.isConnected), pinned = pin.status();
|
|
99
|
+
const applicable = anchors.length > 0 || pinned.applicable;
|
|
100
|
+
const available = (!anchors.length || history) && (!pinned.applicable || pinned.available);
|
|
101
|
+
return {state:applicable ? available ? 'available' : 'unavailable' : 'not-applicable',
|
|
102
|
+
reason:applicable ? available ? null : 'quick-chat-controls-unavailable' : 'no-classic-quick-chat-floating-controls',
|
|
103
|
+
checks:[{name:"native-exit-observer",available:exitRepair.status()}, ...(anchors.length ? [{name:'quick-chat-history',available:history}] : []), ...(pinned.applicable ? [{name:'quick-chat-pin',available:pinned.available}] : [])],
|
|
104
|
+
scopes:snapshots.map(item=>({name:'quick-chat',element:item.surface}))};
|
|
96
105
|
});
|
|
97
|
-
return () => { disposed = true; observer.disconnect(); for (const instance of instances.values()) remove(instance); instances.clear(); style.remove(); };
|
|
106
|
+
return () => { disposed = true; exitRepair.dispose(); shortcut.dispose(); pin.dispose(); observer.disconnect(); for (const instance of instances.values()) remove(instance); instances.clear(); style.remove(); };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function installQuickChatExitRepair(signal, native) {
|
|
2
|
+
let scheduled = false, disposed = false;
|
|
3
|
+
function schedule() {
|
|
4
|
+
if (scheduled || disposed) return;
|
|
5
|
+
scheduled = true;
|
|
6
|
+
queueMicrotask(() => { scheduled = false; if (!disposed) native.reconcile(); });
|
|
7
|
+
}
|
|
8
|
+
const observer = new MutationObserver(schedule);
|
|
9
|
+
observer.observe(document.documentElement, {subtree:true, childList:true, attributes:true, attributeFilter:['style']});
|
|
10
|
+
schedule();
|
|
11
|
+
function dispose() { disposed = true; observer.disconnect(); }
|
|
12
|
+
signal.addEventListener('abort',dispose,{once:true});
|
|
13
|
+
return {dispose,status:()=>!disposed};
|
|
14
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function installQuickChatPin(signal, config) {
|
|
2
|
+
const native = createQuickChatPinAdapter(config.codex), instances = new Map();
|
|
3
|
+
const style = document.createElement('style');
|
|
4
|
+
// 保留原生可交互子元素的 pointer-events-auto,仅让透明背景穿透。
|
|
5
|
+
style.textContent = '[data-mcx-quick-chat-pinned-layer]{pointer-events:none!important}';
|
|
6
|
+
document.head.append(style);
|
|
7
|
+
const text = (en,zh) => (document.documentElement.lang || navigator.language).startsWith('zh') ? zh : en;
|
|
8
|
+
function render(instance) {
|
|
9
|
+
if (instance.pinned) instance.layer.setAttribute('data-mcx-quick-chat-pinned-layer','');
|
|
10
|
+
else instance.layer.removeAttribute('data-mcx-quick-chat-pinned-layer');
|
|
11
|
+
const button = instance.button;
|
|
12
|
+
if (!button) return;
|
|
13
|
+
button.setAttribute('aria-pressed',String(instance.pinned));
|
|
14
|
+
const label = instance.pinned ? text('Unpin chat','取消固定聊天') : text('Pin chat','固定聊天');
|
|
15
|
+
button.setAttribute('aria-label',label); button.setAttribute('data-minecodex-tooltip',label);
|
|
16
|
+
button.querySelector('svg path:last-child')?.setAttribute('fill',instance.pinned ? 'currentColor' : 'none');
|
|
17
|
+
}
|
|
18
|
+
function release(instance) { instance.layer.removeAttribute('data-mcx-quick-chat-pinned-layer'); instance.button?.remove(); }
|
|
19
|
+
function sync() {
|
|
20
|
+
const live = new Set();
|
|
21
|
+
for (const snapshot of native.surfaces()) {
|
|
22
|
+
live.add(snapshot.sessionId);
|
|
23
|
+
let instance = instances.get(snapshot.sessionId);
|
|
24
|
+
if (!instance) { instance={pinned:false,layer:snapshot.layer,button:null}; instances.set(snapshot.sessionId,instance); }
|
|
25
|
+
if (instance.layer !== snapshot.layer) { release(instance); instance.layer=snapshot.layer; instance.button=null; }
|
|
26
|
+
if (snapshot.minimized || snapshot.history) instance.pinned=false;
|
|
27
|
+
if (instance.pinned && !snapshot.minimized && !snapshot.expanded && !snapshot.history) snapshot.expand();
|
|
28
|
+
if (!snapshot.showPin) { instance.button?.remove(); instance.button=null; render(instance); continue; }
|
|
29
|
+
const anchor = snapshot.anchor;
|
|
30
|
+
if (!instance.button?.isConnected || instance.button.parentElement !== anchor.parentElement) {
|
|
31
|
+
instance.button?.remove();
|
|
32
|
+
const button = document.createElement('button');
|
|
33
|
+
button.type='button'; button.setAttribute('data-mcx-quick-chat-pin',''); button.innerHTML=config.resources.pin;
|
|
34
|
+
const icon=button.querySelector('svg'), original=anchor.querySelector('svg');
|
|
35
|
+
for (const attr of ['width','height','class']) if (original?.hasAttribute(attr)) icon?.setAttribute(attr,original.getAttribute(attr));
|
|
36
|
+
icon?.setAttribute('aria-hidden','true');
|
|
37
|
+
button.addEventListener('pointerdown',event=>event.stopPropagation(),{signal});
|
|
38
|
+
button.addEventListener('click',event=>{event.stopPropagation();instance.pinned=!instance.pinned;render(instance);},{signal});
|
|
39
|
+
anchor.before(button); instance.button=button;
|
|
40
|
+
}
|
|
41
|
+
if (instance.button.className !== anchor.className) instance.button.className=anchor.className;
|
|
42
|
+
render(instance);
|
|
43
|
+
}
|
|
44
|
+
for (const [id,instance] of instances) if (!live.has(id)) { release(instance); instances.delete(id); }
|
|
45
|
+
}
|
|
46
|
+
function escape(event) {
|
|
47
|
+
if (event.key !== 'Escape' || event.defaultPrevented || event.repeat || event.isComposing) return;
|
|
48
|
+
for (const instance of instances.values()) if (instance.layer.contains(event.target)) { instance.pinned=false; render(instance); }
|
|
49
|
+
}
|
|
50
|
+
document.addEventListener('keydown',escape,{capture:true,signal});
|
|
51
|
+
function dispose() { document.removeEventListener('keydown',escape,true); for (const instance of instances.values()) release(instance); instances.clear(); style.remove(); }
|
|
52
|
+
function status() { const applicable=native.surfaces().some(snapshot=>snapshot.showPin); return {applicable,available:applicable && [...instances.values()].some(instance=>instance.button?.isConnected)}; }
|
|
53
|
+
return {sync,dispose,status};
|
|
54
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import {quickChatHistoryVisible} from "./adapters/codex/history.mjs";
|
|
2
|
+
import {createQuickChatExitAdapter} from "./adapters/codex/presence.mjs";
|
|
3
|
+
import {installQuickChatExitRepair} from "./frontend/exit.mjs";
|
|
1
4
|
import { readFile } from "node:fs/promises";
|
|
2
5
|
import { createQuickChatAdapter } from "./adapters/codex/renderer.mjs";
|
|
6
|
+
import { quickChatOpenExport, quickChatLifecycleExports, installQuickChatShortcut } from "./adapters/codex/shortcut.mjs";
|
|
3
7
|
import { createSubmissionTracker } from "./domain/submission.mjs";
|
|
8
|
+
import { createQuickChatPinAdapter } from "./adapters/codex/pin.mjs";
|
|
9
|
+
import { installQuickChatPin } from "./frontend/pin.mjs";
|
|
4
10
|
import { createHistoryTracker } from "./domain/history.mjs";
|
|
5
11
|
export async function createPageScriptSource() {
|
|
6
12
|
const source = await readFile(new URL("./frontend/entry.mjs", import.meta.url), "utf8");
|
|
7
|
-
return `const createQuickChatAdapter=${createQuickChatAdapter.toString()};\nconst createSubmissionTracker=${createSubmissionTracker.toString()};\nconst createHistoryTracker=${createHistoryTracker.toString()};\n${source}`;
|
|
13
|
+
return `const quickChatHistoryVisible=${quickChatHistoryVisible.toString()};\nconst createQuickChatExitAdapter=${createQuickChatExitAdapter.toString()};\nconst installQuickChatExitRepair=${installQuickChatExitRepair.toString()};\nconst createQuickChatPinAdapter=${createQuickChatPinAdapter.toString()};\nconst installQuickChatPin=${installQuickChatPin.toString()};\nconst quickChatOpenExport=${quickChatOpenExport.toString()};\nconst quickChatLifecycleExports=${quickChatLifecycleExports.toString()};\nconst installQuickChatShortcut=${installQuickChatShortcut.toString()};\nconst createQuickChatAdapter=${createQuickChatAdapter.toString()};\nconst createSubmissionTracker=${createSubmissionTracker.toString()};\nconst createHistoryTracker=${createHistoryTracker.toString()};\n${source}`;
|
|
8
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minecodex",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.30",
|
|
4
4
|
"description": "Lightweight, local-first plugins for the Codex desktop app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -76,18 +76,14 @@
|
|
|
76
76
|
"apps/dashboard/transport.js",
|
|
77
77
|
"packages/plugin/src",
|
|
78
78
|
"packages/plugin/assets",
|
|
79
|
-
"packages/plugin/plugin.json"
|
|
80
|
-
"features/quick-chat-repair/src",
|
|
81
|
-
"features/quick-chat-repair/assets",
|
|
82
|
-
"features/quick-chat-repair/vendor/lucide-LICENSE",
|
|
83
|
-
"features/quick-chat-repair/codex-feature.json"
|
|
79
|
+
"packages/plugin/plugin.json"
|
|
84
80
|
],
|
|
85
81
|
"engines": {
|
|
86
82
|
"node": ">=22.5.0"
|
|
87
83
|
},
|
|
88
84
|
"scripts": {
|
|
89
85
|
"start": "node packages/cli/bin/mcx.mjs serve",
|
|
90
|
-
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs
|
|
86
|
+
"test": "node --test packages/cli/test/*.test.mjs packages/runtime-host/test/*.test.mjs features/model-slider/test/*.test.mjs features/notes/test/*.test.mjs features/images/test/*.test.mjs features/hide-upsell-banner/test/*.test.mjs features/session-status/test/*.test.mjs features/usage-meter/test/*.test.mjs apps/dashboard/test/*.test.mjs features/unread-inbox/test/*.test.mjs features/quick-chat/test/*.test.mjs features/sidebar-focus/test/*.test.mjs features/sites/test/*.test.mjs packages/ui/test/*.test.mjs packages/codex-adapter/test/*.test.mjs features/markdown-reading/test/*.test.mjs features/file-navigation/test/*.test.mjs packages/plugin/test/*.test.mjs",
|
|
91
87
|
"test:cli": "node --test packages/cli/test/*.test.mjs",
|
|
92
88
|
"test:runtime": "node --test packages/runtime-host/test/*.test.mjs",
|
|
93
89
|
"check": "node scripts/check-syntax.mjs",
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
-
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "file-navigation", "quick-chat"
|
|
5
|
+
export const FEATURE_IDS = Object.freeze(["model-slider", "notes", "images", "hide-upsell-banner", "session-status", "usage-meter", "sidebar-focus", "sites", "markdown-reading", "file-navigation", "quick-chat"]);
|
|
6
6
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
7
7
|
schemaVersion: 1,
|
|
8
8
|
features: Object.freeze({
|
|
@@ -17,7 +17,6 @@ export const DEFAULT_CONFIG = Object.freeze({
|
|
|
17
17
|
"markdown-reading": true,
|
|
18
18
|
"file-navigation": true,
|
|
19
19
|
"quick-chat": true,
|
|
20
|
-
"quick-chat-repair": true,
|
|
21
20
|
}),
|
|
22
21
|
});
|
|
23
22
|
|
|
@@ -43,6 +42,8 @@ export function normalizeConfig(value = {}) {
|
|
|
43
42
|
};
|
|
44
43
|
// 暂停的 Task 通知不继承旧配置,也不再提供开启入口。
|
|
45
44
|
delete features["unread-inbox"];
|
|
45
|
+
// 退出修复归入 Quick Chat,统一沿用 quick-chat 开关。
|
|
46
|
+
delete features["quick-chat-repair"];
|
|
46
47
|
return {
|
|
47
48
|
...value,
|
|
48
49
|
schemaVersion: 1,
|
|
@@ -14,7 +14,7 @@ import { createDataTransfer, MAX_TRANSFER_BYTES } from "./data-transfer/service.
|
|
|
14
14
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
|
15
15
|
const packageMetadata = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8"));
|
|
16
16
|
const MAX_BODY_BYTES = 64 * 1024;
|
|
17
|
-
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "file-navigation", "images", "sites", "quick-chat", "
|
|
17
|
+
const DASHBOARD_FEATURE_ORDER = ["model-slider", "notes", "usage-meter", "session-status", "markdown-reading", "file-navigation", "images", "sites", "quick-chat", "sidebar-focus", "hide-upsell-banner"];
|
|
18
18
|
const CONTENT_TYPES = new Map([
|
|
19
19
|
[".css", "text/css; charset=utf-8"],
|
|
20
20
|
[".html", "text/html; charset=utf-8"],
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!-- @license lucide-static v0.468.0 - ISC -->
|
|
2
|
-
<svg
|
|
3
|
-
class="lucide lucide-history"
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
width="24"
|
|
6
|
-
height="24"
|
|
7
|
-
viewBox="0 0 24 24"
|
|
8
|
-
fill="none"
|
|
9
|
-
stroke="currentColor"
|
|
10
|
-
stroke-width="2"
|
|
11
|
-
stroke-linecap="round"
|
|
12
|
-
stroke-linejoin="round"
|
|
13
|
-
>
|
|
14
|
-
<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
|
|
15
|
-
<path d="M3 3v5h5" />
|
|
16
|
-
<path d="M12 7v5l4 2" />
|
|
17
|
-
</svg>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schemaVersion": 1,
|
|
3
|
-
"id": "quick-chat-repair",
|
|
4
|
-
"version": "0.1.0",
|
|
5
|
-
"label": {"en":"Quick Chat Exit Repair", "zh-CN":"Quick Chat 退出修复"},
|
|
6
|
-
"description": {"en":"Fix the native transparent layer that blocks clicks after closing Quick Chat.", "zh-CN":"修复关闭 Quick Chat 后透明层残留、主页面无法点击的问题。"},
|
|
7
|
-
"entry": {"kind":"page-script", "script":"src/frontend/entry.mjs", "sourceFactory":"src/injection-source.mjs"},
|
|
8
|
-
"icon": {"resource":"assets/history.svg"},
|
|
9
|
-
"placement": {"order":76}
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const native = createQuickChatExitAdapter(config.codex);
|
|
2
|
-
let scheduled = false, disposed = false;
|
|
3
|
-
function schedule() {
|
|
4
|
-
if (scheduled || disposed) return;
|
|
5
|
-
scheduled = true;
|
|
6
|
-
queueMicrotask(() => { scheduled = false; if (!disposed) native.reconcile(); });
|
|
7
|
-
}
|
|
8
|
-
const observer = new MutationObserver(schedule);
|
|
9
|
-
observer.observe(document.documentElement, {subtree:true, childList:true, attributes:true, attributeFilter:['style']});
|
|
10
|
-
schedule();
|
|
11
|
-
config.registerSelfCheck?.(() => ({state:'available', checks:[{name:'native-exit-observer', available:!disposed}], scopes:[]}));
|
|
12
|
-
return () => { disposed = true; observer.disconnect(); };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {readFile} from 'node:fs/promises';
|
|
2
|
-
import {createQuickChatExitAdapter} from './adapters/codex/presence.mjs';
|
|
3
|
-
export async function createPageScriptSource() {
|
|
4
|
-
return `const createQuickChatExitAdapter=${createQuickChatExitAdapter.toString()};\n${await readFile(new URL('./frontend/entry.mjs', import.meta.url), 'utf8')}`;
|
|
5
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
File without changes
|