mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-05 18:20:39 -08:00
* feat: new config for tidgi mini window * chore: upgrade electron-forge * fix: use 汉语 和 漢語 * feat: shortcut to open mini window * test: TidGiMenubarWindow * feat: allow updateWindowProperties on the fly * fix: wrong icon path * fix: log not showing error message and stack * refactor: directly log error when using logger.error * feat: shortcut to open window * fix: menubar not closed * test: e2e for menubar * test: keyboard shortcut * test: wiki web content, and refactor to files * test: update command * Update Testing.md * test: menubar settings about menubarSyncWorkspaceWithMainWindow, menubarFixedWorkspaceId * test: simplify menubar test and cleanup test config * fix: view missing when execute several test all together * refactor: use hook to cleanup menubar setting * refactor: I clear test ai settings to before hook * Add option to show title bar on menubar window Introduces a new preference 'showMenubarWindowTitleBar' allowing users to toggle the title bar visibility on the menubar window. Updates related services, interfaces, and UI components to support this feature, and adds corresponding localization strings for English and Chinese. * refactor: tidgiminiwindow * refactor: preference keys to right order * Refactor window dimension checks to use constants Replaces hardcoded window dimensions with values from windowDimension and WindowNames constants for improved maintainability and consistency in window identification and checks. * I cleanup test wiki * Update defaultPreferences.ts * test: mini window workspace switch * fix: image broken by ai, and lint * fix: can't switch to mini window * refactor: useless todo * Update index.ts * refactor: reuse serialize-error * Update index.ts * Update testKeyboardShortcuts.ts * refactor: dup logic * Update ui.ts * fix: electron-ipc-cat
74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
import { Given } from '@cucumber/cucumber';
|
|
import fs from 'fs-extra';
|
|
import { omit } from 'lodash';
|
|
import path from 'path';
|
|
import type { ISettingFile } from '../../src/services/database/interface';
|
|
import { settingsPath } from '../supports/paths';
|
|
|
|
Given('I configure tidgi mini window with shortcut', async function() {
|
|
let existing = {} as ISettingFile;
|
|
if (await fs.pathExists(settingsPath)) {
|
|
existing = await fs.readJson(settingsPath) as ISettingFile;
|
|
} else {
|
|
// ensure settings directory exists so writeJsonSync won't fail
|
|
await fs.ensureDir(path.dirname(settingsPath));
|
|
}
|
|
|
|
// Convert CommandOrControl to platform-specific format
|
|
const isWindows = process.platform === 'win32';
|
|
const isLinux = process.platform === 'linux';
|
|
let shortcut = 'CommandOrControl+Shift+M';
|
|
if (isWindows || isLinux) {
|
|
shortcut = 'Ctrl+Shift+M';
|
|
} else {
|
|
shortcut = 'Cmd+Shift+M';
|
|
}
|
|
|
|
const updatedPreferences = {
|
|
...existing.preferences,
|
|
tidgiMiniWindow: true,
|
|
keyboardShortcuts: {
|
|
...(existing.preferences?.keyboardShortcuts || {}),
|
|
'Window.toggleTidgiMiniWindow': shortcut,
|
|
},
|
|
};
|
|
const finalSettings = { ...existing, preferences: updatedPreferences } as ISettingFile;
|
|
await fs.writeJson(settingsPath, finalSettings, { spaces: 2 });
|
|
});
|
|
|
|
// Cleanup function to be called after tidgi mini window tests (after app closes)
|
|
function clearTidgiMiniWindowSettings() {
|
|
if (!fs.existsSync(settingsPath)) return;
|
|
const parsed = fs.readJsonSync(settingsPath) as ISettingFile;
|
|
// Remove tidgi mini window-related preferences to avoid affecting other tests
|
|
const cleanedPreferences = omit(parsed.preferences || {}, [
|
|
'tidgiMiniWindow',
|
|
'tidgiMiniWindowSyncWorkspaceWithMainWindow',
|
|
'tidgiMiniWindowFixedWorkspaceId',
|
|
'tidgiMiniWindowAlwaysOnTop',
|
|
'tidgiMiniWindowShowSidebar',
|
|
'tidgiMiniWindowShowTitleBar',
|
|
]);
|
|
// Also clean up the tidgi mini window shortcut from keyboardShortcuts
|
|
if (cleanedPreferences.keyboardShortcuts) {
|
|
cleanedPreferences.keyboardShortcuts = omit(cleanedPreferences.keyboardShortcuts, ['Window.toggleTidgiMiniWindow']);
|
|
}
|
|
|
|
// Reset active workspace to first wiki workspace to avoid agent workspace being active
|
|
const workspaces = parsed.workspaces || {};
|
|
const workspaceEntries = Object.entries(workspaces);
|
|
// Set all workspaces to inactive first
|
|
for (const [, workspace] of workspaceEntries) {
|
|
workspace.active = false;
|
|
}
|
|
// Find first non-page-type workspace (wiki) and activate it
|
|
const firstWikiWorkspace = workspaceEntries.find(([, workspace]) => !workspace.pageType);
|
|
if (firstWikiWorkspace) {
|
|
firstWikiWorkspace[1].active = true;
|
|
}
|
|
|
|
const cleaned = { ...parsed, preferences: cleanedPreferences, workspaces };
|
|
fs.writeJsonSync(settingsPath, cleaned, { spaces: 2 });
|
|
}
|
|
|
|
export { clearTidgiMiniWindowSettings };
|