fix: refine sidebar search and composer shortcut hints

This commit is contained in:
mesalogo
2026-09-28 22:38:35 +08:00
parent 4baf4ec142
commit 86347af0b1
14 changed files with 505 additions and 134 deletions
+14 -1
View File
@@ -520,7 +520,8 @@ describe('registerIpcHandlers computer capabilities', () => {
let browserStateListener:
| ((state: BrowserLiveState) => void)
| undefined
const shortcutSnapshot = {
const shortcutSnapshot: import('../shared/shortcut').GlobalShortcutSettingsSnapshot = {
platform: 'win32',
settings: {
enabled: true,
accelerator: 'Control+Alt+K'
@@ -609,6 +610,18 @@ describe('registerIpcHandlers computer capabilities', () => {
shortcut: 'Ctrl + Alt + K',
shortcutStatus: 'registered'
})
for (const status of ['disabled', 'conflict', 'failed'] as const) {
shortcutSettingsService.getSnapshot.mockReturnValueOnce({
...shortcutSnapshot,
registered: false,
registeredAccelerator: undefined,
status
})
expect(electronMocks.handlers.get(ipcChannels.appInfo)?.(event)).toMatchObject({
shortcut: '',
shortcutStatus: status
})
}
expect(
electronMocks.handlers.get(ipcChannels.shortcutSettingsGet)?.(
event
@@ -102,6 +102,23 @@ describe('ShortcutSettingsService', () => {
)
})
it.each(['disabled', 'conflict', 'failed'] as const)('reports an unavailable shortcut at startup when %s', async (status) => {
const fixture = createFixture({
enabled: status !== 'disabled',
accelerator: 'CommandOrControl+Shift+Space'
})
if (status === 'conflict') fixture.registry.register.mockReturnValueOnce(false)
if (status === 'failed') fixture.registry.register.mockImplementationOnce(() => { throw new Error('Registration failed') })
await expect(fixture.service.initialize()).resolves.toMatchObject({
registered: false,
displayAccelerator: 'Ctrl+Shift+Space',
status
})
expect(fixture.service.getSnapshot().registeredAccelerator).toBeUndefined()
if (status === 'disabled') expect(fixture.registry.register).not.toHaveBeenCalled()
})
it.each([
[
'win32',