Skip to content

Commit

Permalink
hideOnStartup
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed Sep 18, 2024
1 parent e5d29b8 commit fa1a999
Show file tree
Hide file tree
Showing 9 changed files with 777 additions and 43 deletions.
789 changes: 754 additions & 35 deletions CREDITS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/build_number.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
217
218
1 change: 1 addition & 0 deletions defaults/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"general": {
"keepRunning": true,
"hideOnStartup": false,
"language": "",
"tips": {
"engineSelector": true,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "witsy",
"productName": "Witsy",
"version": "1.13.1",
"version": "1.13.2",
"description": "Witsy: desktop AI assistant",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ app.whenReady().then(() => {
registerShortcuts();

// create the main window
// TODO detect when lauched from login item
const hidden = false;//app.getLoginItemSettings().wasOpenedAtLogin();
if (!hidden) {
const settings = config.loadSettings(app);
if (!settings.general.hideOnStartup || process.env.DEBUG) {
log.info('Creating initial main window');
window.openMainWindow();
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/settings/SettingsGeneral.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<label>Run at login</label>
<input type="checkbox" v-model="runAtLogin" @change="save" />
</div>
<div class="group hide-on-startup">
<label>Hide chat on start</label>
<input type="checkbox" v-model="hideOnStartup" @change="save" />
</div>
<div class="group keep-running">
<label>Keep in Status Bar</label>
<input type="checkbox" v-model="keepRunning" @change="save" />
Expand All @@ -41,12 +45,14 @@ import LangSelect from '../components/LangSelect.vue'
const llmEngine = ref(null)
const language = ref(null)
const runAtLogin = ref(false)
const hideOnStartup = ref(false)
const keepRunning = ref(false)
const load = () => {
llmEngine.value = store.config.llm.engine || 'openai'
language.value = store.config.general.language
runAtLogin.value = window.api.runAtLogin.get()
hideOnStartup.value = store.config.general.hideOnStartup
keepRunning.value = store.config.general.keepRunning
}
Expand All @@ -59,6 +65,7 @@ const save = () => {
store.config.llm.engine = llmEngine.value
store.config.general.language = language.value
window.api.runAtLogin.set(runAtLogin.value)
store.config.general.hideOnStartup = hideOnStartup.value
store.config.general.keepRunning = keepRunning.value
store.saveSettings()
}
Expand Down
1 change: 1 addition & 0 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Configuration {
}

interface GeneralConfig {
hideOnStartup: boolean
keepRunning: boolean
language: string
tips: {[key: string]: boolean}
Expand Down
9 changes: 8 additions & 1 deletion tests/screens/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ test('Settings close', async () => {
test('Settings General', async () => {

const tab = await switchToTab(0)
expect(tab.findAll('.group')).toHaveLength(5)
expect(tab.findAll('.group')).toHaveLength(6)

expect(store.config.llm.engine).not.toBe('anthropic')
expect(tab.findAll('.group.engine select option')).toHaveLength(availableEngines.length)
Expand All @@ -132,6 +132,13 @@ test('Settings General', async () => {
expect(store.saveSettings).toHaveBeenCalledOnce()
vi.clearAllMocks()

expect(store.config.general.hideOnStartup).not.toBe(true)
tab.find('.group.hide-on-startup input').setValue(true)
expect(store.config.general.hideOnStartup).toBe(true)
expect(window.api.runAtLogin.set).toHaveBeenCalledOnce()
expect(store.saveSettings).toHaveBeenCalledOnce()
vi.clearAllMocks()

expect(store.config.general.keepRunning).not.toBe(false)
tab.find('.group.keep-running input').setValue(false)
expect(store.config.general.keepRunning).toBe(false)
Expand Down

0 comments on commit fa1a999

Please sign in to comment.