@lobehub/lobehub 2.0.0-next.214 → 2.0.0-next.216
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/.github/workflows/e2e.yml +1 -1
- package/.github/workflows/pr-build-desktop.yml +2 -2
- package/.github/workflows/release-desktop-beta.yml +2 -2
- package/.github/workflows/release.yml +1 -1
- package/.github/workflows/test.yml +2 -2
- package/CHANGELOG.md +51 -0
- package/apps/desktop/src/main/core/browser/Browser.ts +78 -14
- package/apps/desktop/src/main/core/browser/__tests__/Browser.test.ts +51 -0
- package/changelog/v1.json +18 -0
- package/package.json +1 -1
- package/src/features/Portal/Document/Header.tsx +11 -9
|
@@ -33,7 +33,7 @@ jobs:
|
|
|
33
33
|
uses: ./.github/actions/setup-node-bun
|
|
34
34
|
with:
|
|
35
35
|
node-version: 24.11.1
|
|
36
|
-
bun-version:
|
|
36
|
+
bun-version: latest
|
|
37
37
|
package-manager-cache: 'false'
|
|
38
38
|
|
|
39
39
|
- name: Install deps
|
|
@@ -224,7 +224,7 @@ jobs:
|
|
|
224
224
|
uses: ./.github/actions/setup-node-bun
|
|
225
225
|
with:
|
|
226
226
|
node-version: 24.11.1
|
|
227
|
-
bun-version:
|
|
227
|
+
bun-version: latest
|
|
228
228
|
package-manager-cache: 'false'
|
|
229
229
|
|
|
230
230
|
# 下载所有平台的构建产物
|
|
@@ -32,7 +32,7 @@ jobs:
|
|
|
32
32
|
- name: Install bun
|
|
33
33
|
uses: oven-sh/setup-bun@v2
|
|
34
34
|
with:
|
|
35
|
-
bun-version:
|
|
35
|
+
bun-version: latest
|
|
36
36
|
|
|
37
37
|
- name: Install deps
|
|
38
38
|
run: bun i
|
|
@@ -216,7 +216,7 @@ jobs:
|
|
|
216
216
|
- name: Install bun
|
|
217
217
|
uses: oven-sh/setup-bun@v2
|
|
218
218
|
with:
|
|
219
|
-
bun-version:
|
|
219
|
+
bun-version: latest
|
|
220
220
|
|
|
221
221
|
# 下载所有平台的构建产物
|
|
222
222
|
- name: Download artifacts
|
|
@@ -72,7 +72,7 @@ jobs:
|
|
|
72
72
|
- name: Install bun
|
|
73
73
|
uses: oven-sh/setup-bun@v2
|
|
74
74
|
with:
|
|
75
|
-
bun-version:
|
|
75
|
+
bun-version: latest
|
|
76
76
|
|
|
77
77
|
- name: Install deps
|
|
78
78
|
run: bun i
|
|
@@ -105,7 +105,7 @@ jobs:
|
|
|
105
105
|
- name: Install bun
|
|
106
106
|
uses: oven-sh/setup-bun@v2
|
|
107
107
|
with:
|
|
108
|
-
bun-version:
|
|
108
|
+
bun-version: latest
|
|
109
109
|
|
|
110
110
|
- name: Install deps
|
|
111
111
|
run: bun i
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.216](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.215...v2.0.0-next.216)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2026-01-05**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Restore window position safely.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Restore window position safely ([e0b555e](https://github.com/lobehub/lobe-chat/commit/e0b555e))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## [Version 2.0.0-next.215](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.214...v2.0.0-next.215)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2026-01-05**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Update CI bun version to v1.2.4, when the document filetype is agent/plan, not show the saveinto docs button.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Update CI bun version to v1.2.4, closes [#11232](https://github.com/lobehub/lobe-chat/issues/11232) ([dd022d5](https://github.com/lobehub/lobe-chat/commit/dd022d5))
|
|
46
|
+
- **misc**: When the document filetype is agent/plan, not show the saveinto docs button, closes [#11227](https://github.com/lobehub/lobe-chat/issues/11227) ([3a22f32](https://github.com/lobehub/lobe-chat/commit/3a22f32))
|
|
47
|
+
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
<div align="right">
|
|
51
|
+
|
|
52
|
+
[](#readme-top)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
5
56
|
## [Version 2.0.0-next.214](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.213...v2.0.0-next.214)
|
|
6
57
|
|
|
7
58
|
<sup>Released on **2026-01-05**</sup>
|
|
@@ -42,6 +42,13 @@ export interface BrowserWindowOpts extends BrowserWindowConstructorOptions {
|
|
|
42
42
|
width?: number;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
interface WindowState {
|
|
46
|
+
height?: number;
|
|
47
|
+
width?: number;
|
|
48
|
+
x?: number;
|
|
49
|
+
y?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
export default class Browser {
|
|
46
53
|
private app: App;
|
|
47
54
|
private _browserWindow?: BrowserWindow;
|
|
@@ -152,6 +159,46 @@ export default class Browser {
|
|
|
152
159
|
this._browserWindow.setTitleBarOverlay(config.titleBarOverlay);
|
|
153
160
|
}
|
|
154
161
|
|
|
162
|
+
private clampNumber(value: number, min: number, max: number) {
|
|
163
|
+
return Math.min(Math.max(value, min), max);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private resolveWindowState(
|
|
167
|
+
savedState: WindowState | undefined,
|
|
168
|
+
fallbackState: { height?: number; width?: number },
|
|
169
|
+
): WindowState {
|
|
170
|
+
const width = savedState?.width ?? fallbackState.width;
|
|
171
|
+
const height = savedState?.height ?? fallbackState.height;
|
|
172
|
+
const resolvedState: WindowState = { height, width };
|
|
173
|
+
|
|
174
|
+
const hasPosition = Number.isFinite(savedState?.x) && Number.isFinite(savedState?.y);
|
|
175
|
+
if (!hasPosition) return resolvedState;
|
|
176
|
+
|
|
177
|
+
const x = savedState?.x as number;
|
|
178
|
+
const y = savedState?.y as number;
|
|
179
|
+
|
|
180
|
+
const targetDisplay = screen.getDisplayMatching({
|
|
181
|
+
height: height ?? 0,
|
|
182
|
+
width: width ?? 0,
|
|
183
|
+
x,
|
|
184
|
+
y,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const workArea = targetDisplay?.workArea ?? screen.getPrimaryDisplay().workArea;
|
|
188
|
+
const resolvedWidth = typeof width === 'number' ? Math.min(width, workArea.width) : width;
|
|
189
|
+
const resolvedHeight = typeof height === 'number' ? Math.min(height, workArea.height) : height;
|
|
190
|
+
|
|
191
|
+
const maxX = workArea.x + Math.max(0, workArea.width - (resolvedWidth ?? 0));
|
|
192
|
+
const maxY = workArea.y + Math.max(0, workArea.height - (resolvedHeight ?? 0));
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
height: resolvedHeight,
|
|
196
|
+
width: resolvedWidth,
|
|
197
|
+
x: this.clampNumber(x, workArea.x, maxX),
|
|
198
|
+
y: this.clampNumber(y, workArea.y, maxY),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
155
202
|
private cleanupThemeListener(): void {
|
|
156
203
|
if (this.themeListenerSetup) {
|
|
157
204
|
// Note: nativeTheme listeners are global, consider using a centralized theme manager
|
|
@@ -323,12 +370,17 @@ export default class Browser {
|
|
|
323
370
|
|
|
324
371
|
// Load window state
|
|
325
372
|
const savedState = this.app.storeManager.get(this.windowStateKey as any) as
|
|
326
|
-
|
|
|
327
|
-
| undefined;
|
|
373
|
+
| WindowState
|
|
374
|
+
| undefined;
|
|
328
375
|
logger.info(`Creating new BrowserWindow instance: ${this.identifier}`);
|
|
329
376
|
logger.debug(`[${this.identifier}] Options for new window: ${JSON.stringify(this.options)}`);
|
|
330
377
|
logger.debug(
|
|
331
|
-
`[${this.identifier}] Saved window state
|
|
378
|
+
`[${this.identifier}] Saved window state: ${JSON.stringify(savedState)}`,
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const resolvedState = this.resolveWindowState(savedState, { height, width });
|
|
382
|
+
logger.debug(
|
|
383
|
+
`[${this.identifier}] Resolved window state: ${JSON.stringify(resolvedState)}`,
|
|
332
384
|
);
|
|
333
385
|
|
|
334
386
|
const browserWindow = new BrowserWindow({
|
|
@@ -337,7 +389,7 @@ export default class Browser {
|
|
|
337
389
|
backgroundColor: '#00000000',
|
|
338
390
|
darkTheme: this.isDarkMode,
|
|
339
391
|
frame: false,
|
|
340
|
-
height:
|
|
392
|
+
height: resolvedState.height,
|
|
341
393
|
show: false,
|
|
342
394
|
title,
|
|
343
395
|
vibrancy: 'sidebar',
|
|
@@ -348,7 +400,9 @@ export default class Browser {
|
|
|
348
400
|
preload: join(preloadDir, 'index.js'),
|
|
349
401
|
sandbox: false,
|
|
350
402
|
},
|
|
351
|
-
width:
|
|
403
|
+
width: resolvedState.width,
|
|
404
|
+
x: resolvedState.x,
|
|
405
|
+
y: resolvedState.y,
|
|
352
406
|
...this.getPlatformThemeConfig(),
|
|
353
407
|
});
|
|
354
408
|
|
|
@@ -405,12 +459,17 @@ export default class Browser {
|
|
|
405
459
|
logger.debug(`[${this.identifier}] App is quitting, allowing window to close naturally.`);
|
|
406
460
|
// Save state before quitting
|
|
407
461
|
try {
|
|
408
|
-
const
|
|
409
|
-
const sizeState = {
|
|
462
|
+
const bounds = browserWindow.getBounds();
|
|
463
|
+
const sizeState = {
|
|
464
|
+
height: bounds.height,
|
|
465
|
+
width: bounds.width,
|
|
466
|
+
x: bounds.x,
|
|
467
|
+
y: bounds.y,
|
|
468
|
+
};
|
|
410
469
|
logger.debug(
|
|
411
|
-
`[${this.identifier}] Saving window
|
|
470
|
+
`[${this.identifier}] Saving window state on quit: ${JSON.stringify(sizeState)}`,
|
|
412
471
|
);
|
|
413
|
-
this.app.storeManager.set(this.windowStateKey as any, sizeState);
|
|
472
|
+
this.app.storeManager.set(this.windowStateKey as any, sizeState);
|
|
414
473
|
} catch (error) {
|
|
415
474
|
logger.error(`[${this.identifier}] Failed to save window state on quit:`, error);
|
|
416
475
|
}
|
|
@@ -437,15 +496,20 @@ export default class Browser {
|
|
|
437
496
|
} else {
|
|
438
497
|
// Window is actually closing (not keepAlive)
|
|
439
498
|
logger.debug(
|
|
440
|
-
`[${this.identifier}] keepAlive is false, allowing window to close. Saving
|
|
499
|
+
`[${this.identifier}] keepAlive is false, allowing window to close. Saving state...`,
|
|
441
500
|
);
|
|
442
501
|
try {
|
|
443
|
-
const
|
|
444
|
-
const sizeState = {
|
|
502
|
+
const bounds = browserWindow.getBounds();
|
|
503
|
+
const sizeState = {
|
|
504
|
+
height: bounds.height,
|
|
505
|
+
width: bounds.width,
|
|
506
|
+
x: bounds.x,
|
|
507
|
+
y: bounds.y,
|
|
508
|
+
};
|
|
445
509
|
logger.debug(
|
|
446
|
-
`[${this.identifier}] Saving window
|
|
510
|
+
`[${this.identifier}] Saving window state on close: ${JSON.stringify(sizeState)}`,
|
|
447
511
|
);
|
|
448
|
-
this.app.storeManager.set(this.windowStateKey as any, sizeState);
|
|
512
|
+
this.app.storeManager.set(this.windowStateKey as any, sizeState);
|
|
449
513
|
} catch (error) {
|
|
450
514
|
logger.error(`[${this.identifier}] Failed to save window state on close:`, error);
|
|
451
515
|
}
|
|
@@ -56,9 +56,15 @@ const { mockBrowserWindow, mockNativeTheme, mockIpcMain, mockScreen, MockBrowser
|
|
|
56
56
|
themeSource: 'system',
|
|
57
57
|
},
|
|
58
58
|
mockScreen: {
|
|
59
|
+
getDisplayMatching: vi.fn().mockReturnValue({
|
|
60
|
+
workArea: { height: 1080, width: 1920, x: 0, y: 0 },
|
|
61
|
+
}),
|
|
59
62
|
getDisplayNearestPoint: vi.fn().mockReturnValue({
|
|
60
63
|
workArea: { height: 1080, width: 1920, x: 0, y: 0 },
|
|
61
64
|
}),
|
|
65
|
+
getPrimaryDisplay: vi.fn().mockReturnValue({
|
|
66
|
+
workArea: { height: 1080, width: 1920, x: 0, y: 0 },
|
|
67
|
+
}),
|
|
62
68
|
},
|
|
63
69
|
};
|
|
64
70
|
});
|
|
@@ -240,6 +246,47 @@ describe('Browser', () => {
|
|
|
240
246
|
);
|
|
241
247
|
});
|
|
242
248
|
|
|
249
|
+
it('should restore window position from store and clamp within display', () => {
|
|
250
|
+
mockStoreManagerGet.mockImplementation((key: string) => {
|
|
251
|
+
if (key === 'windowSize_test-window') {
|
|
252
|
+
return { height: 700, width: 900, x: 1800, y: 900 };
|
|
253
|
+
}
|
|
254
|
+
return undefined;
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
new Browser(defaultOptions, mockApp);
|
|
258
|
+
|
|
259
|
+
expect(MockBrowserWindow).toHaveBeenCalledWith(
|
|
260
|
+
expect.objectContaining({
|
|
261
|
+
height: 700,
|
|
262
|
+
width: 900,
|
|
263
|
+
x: 1020,
|
|
264
|
+
y: 380,
|
|
265
|
+
}),
|
|
266
|
+
);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('should clamp saved size when it exceeds current display bounds', () => {
|
|
270
|
+
mockScreen.getDisplayMatching.mockReturnValueOnce({
|
|
271
|
+
workArea: { height: 800, width: 1200, x: 0, y: 0 },
|
|
272
|
+
});
|
|
273
|
+
mockStoreManagerGet.mockImplementation((key: string) => {
|
|
274
|
+
if (key === 'windowSize_test-window') {
|
|
275
|
+
return { height: 1200, width: 2000, x: 0, y: 0 };
|
|
276
|
+
}
|
|
277
|
+
return undefined;
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
new Browser(defaultOptions, mockApp);
|
|
281
|
+
|
|
282
|
+
expect(MockBrowserWindow).toHaveBeenCalledWith(
|
|
283
|
+
expect.objectContaining({
|
|
284
|
+
height: 800,
|
|
285
|
+
width: 1200,
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
243
290
|
it('should use default size when no saved state', () => {
|
|
244
291
|
mockStoreManagerGet.mockReturnValue(undefined);
|
|
245
292
|
|
|
@@ -541,6 +588,8 @@ describe('Browser', () => {
|
|
|
541
588
|
expect(mockStoreManagerSet).toHaveBeenCalledWith('windowSize_test-window', {
|
|
542
589
|
height: 600,
|
|
543
590
|
width: 800,
|
|
591
|
+
x: 0,
|
|
592
|
+
y: 0,
|
|
544
593
|
});
|
|
545
594
|
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
|
546
595
|
});
|
|
@@ -572,6 +621,8 @@ describe('Browser', () => {
|
|
|
572
621
|
expect(mockStoreManagerSet).toHaveBeenCalledWith('windowSize_test-window', {
|
|
573
622
|
height: 600,
|
|
574
623
|
width: 800,
|
|
624
|
+
x: 0,
|
|
625
|
+
y: 0,
|
|
575
626
|
});
|
|
576
627
|
});
|
|
577
628
|
});
|
package/changelog/v1.json
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"children": {
|
|
4
|
+
"fixes": [
|
|
5
|
+
"Restore window position safely."
|
|
6
|
+
]
|
|
7
|
+
},
|
|
8
|
+
"date": "2026-01-05",
|
|
9
|
+
"version": "2.0.0-next.216"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"children": {
|
|
13
|
+
"fixes": [
|
|
14
|
+
"Update CI bun version to v1.2.4, when the document filetype is agent/plan, not show the saveinto docs button."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"date": "2026-01-05",
|
|
18
|
+
"version": "2.0.0-next.215"
|
|
19
|
+
},
|
|
2
20
|
{
|
|
3
21
|
"children": {},
|
|
4
22
|
"date": "2026-01-05",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/lobehub",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.216",
|
|
4
4
|
"description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -61,15 +61,17 @@ const Header = () => {
|
|
|
61
61
|
</Flexbox>
|
|
62
62
|
<Flexbox align={'center'} gap={8} horizontal>
|
|
63
63
|
<AutoSaveHint />
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
{document.fileType !== 'agent/plan' && (
|
|
65
|
+
<Button
|
|
66
|
+
icon={<ExternalLink size={14} />}
|
|
67
|
+
loading={loading}
|
|
68
|
+
onClick={handleOpenInPageEditor}
|
|
69
|
+
size={'small'}
|
|
70
|
+
type={'text'}
|
|
71
|
+
>
|
|
72
|
+
{t('openInPageEditor')}
|
|
73
|
+
</Button>
|
|
74
|
+
)}
|
|
73
75
|
</Flexbox>
|
|
74
76
|
</Flexbox>
|
|
75
77
|
);
|