Commit graph

284 commits

Author SHA1 Message Date
Debanjum Singh Solanky
1ff049599f Show current config on config screen. Load default config if config unset
- Track current (saved/loaded) config separate from the new config (to
  be written) when user clicks Start

- Fallback to using default config when no config for the specific
  content type or processor is specified in khoj.yml
  - Earlier were only loading default config on first run, not after

- Create Child CheckBox, LineEdit classes for Processor Widgets
  - Create ProcessorType, similar to SearchType
  - Track ProcessorType the widgets are associated with
  - Simplify update, save, load of config based on type
2022-08-11 19:11:25 +03:00
Debanjum Singh Solanky
23e06f483d Do not emit type tags when dumping config YAML to file 2022-08-11 19:08:36 +03:00
Debanjum Singh Solanky
678fb6a3c7 Add Settings Panel for Conversation Settings to Config Screen 2022-08-11 04:52:40 +03:00
Debanjum Singh Solanky
c1fcf44405 Initialize Settings on Config Screen with Existing Settings from File 2022-08-11 04:51:33 +03:00
Debanjum Singh Solanky
3cec6229ad Hot swap backend config via config screen start button click
- Update configuration to use by the backend, while app is running
- Trigger after user hits start button with their config.
  The config gets written to khoj.yml file first, then the updated
  config is loaded onto memory
2022-08-11 00:32:11 +03:00
Debanjum Singh Solanky
f7fdf8d8ce Refactor app start to start server even if backend not configured
- Decouple configuring backend from starting server.
  Backend search and processors can be configured after the backend
  server has started

- Set global state in main instead of in configure_server method.
  This allows the app to start even if configure_server exits early in
  the first run scenario, where no config available to configure server

- Now start server, even if no config, before GUI started in main

- This refactor of app startup flow will allow users to configure
  backend using the configure screen after server start
2022-08-11 00:13:14 +03:00
Debanjum Singh Solanky
34018c7d4b Store args passed from commandline at app start in global app state 2022-08-11 00:11:35 +03:00
Debanjum Singh Solanky
cc6ef0f450 Save configure screen settings to app config yaml on clicking Start 2022-08-10 23:10:39 +03:00
Debanjum Singh Solanky
dae65c5b6b Create child class of Qt CheckBox to track search type it enables/disables 2022-08-10 22:44:37 +03:00
Debanjum Singh Solanky
f42f54019b Type parent_layout passed as arguments to ConfigureScreen methods 2022-08-10 22:43:20 +03:00
Debanjum Singh Solanky
f63f11186f Pass config file for app to configure screen 2022-08-10 22:42:32 +03:00
Debanjum Singh Solanky
82a7059b6a Only setup conversation processor if it has configuration set 2022-08-10 22:34:03 +03:00
Debanjum Singh Solanky
9628ca073c Extract conversation processor from config into separate function
- Only pass processor config arg required by configure_processor. Not
  the unused full config object
- Type arguments passed to methods configure processors
- Import json for use by conversation processor to load logs
2022-08-10 22:33:33 +03:00
Debanjum Singh Solanky
62eb66b8ca Rename load_config_from_file to more descriptive parse_config_from_file 2022-08-10 22:28:51 +03:00
Debanjum Singh Solanky
328cc00439 Create global constant to store app root directory 2022-08-10 20:09:03 +03:00
Debanjum Singh Solanky
d2c7b28172 Extract code to load config from YAML file into new utils.yaml module 2022-08-10 20:07:44 +03:00
Debanjum Singh Solanky
daef276fd1 Add files for each search type. Extract config on clicking start
- Only allow adding files with appropriate file extension for each search type
  - e.g .org for org-mode search, directory for image search

- Extract file paths added to config and enablement state of each search type
  - This extracted state will be used to populate the khoj.yml config file
2022-08-10 03:27:22 +03:00
Debanjum Singh Solanky
d74134e6cc Reuse Single Method to Create Setting Panels for each Search Type 2022-08-09 23:50:43 +03:00
Debanjum Singh Solanky
509d52e2cd Toggle Editability instead of Visibility of Per Search Type Settings
- Simplifies the configure screen layout and allows it to be of constant width

- It was buggy, the configure screen would dynamically expand but not
  restore back to original size on disabling search type after enable
2022-08-09 23:34:54 +03:00
Debanjum Singh Solanky
3c788f1d29 Rename configure window to more generic configure screen 2022-08-09 22:44:05 +03:00
Debanjum Singh Solanky
c50ab7c3ad Split config settings GUI into functions. Convert Config Window to Dialog 2022-08-09 22:36:41 +03:00
Debanjum Singh Solanky
664713b24e Extract Qt GUI code from main.py into separate interface/desktop dir 2022-08-09 22:12:29 +03:00
Debanjum Singh Solanky
cd59982c9c Add Qt Button to save Khoj configuration in Khoj Configuration Window 2022-08-09 20:42:44 +03:00
Debanjum Singh Solanky
2c77caf06c Group ledger, org setting widgets into child Qt widgets of config window 2022-08-09 20:42:44 +03:00
Debanjum Singh Solanky
027da719aa Open Configure Window on First Run or from System Tray
- Trigger FRE if no config loaded. Open Configure Window automatically
- Else user can manually open config window from App on System Tray
2022-08-09 17:05:27 +03:00
Debanjum Singh Solanky
a588a8e21f Make config_file an optional argument. It can be generated on FRE
- Make config_file an optional arg. It defaults to default khoj config dir
- Return args.config as None if no config_file explicitly passed by user
- Parent can use args.config = None as signal to trigger first run experience
2022-08-09 17:02:02 +03:00
Debanjum Singh Solanky
21af122447 Clean up unused methods, module imports. Add comments 2022-08-09 16:59:38 +03:00
Debanjum Singh Solanky
80fa9fde6a Quit GUI via SysTray instead of sys.exit to cleanly terminate server 2022-08-08 23:49:26 +03:00
Debanjum Singh Solanky
e5691f9d1d PyInstaller Spec to Wrap Khoj into a Basic Native App
- Verified functionality on MacOS

- Add ICNS Icon to use as MacOS App Icon
- Spec generated by PyInstaller:
  ```sh
  pyinstaller \
       src/main.py \
       --windowed \
       --onefile \
       --name "Khoj" \
       --target-arch arm64 \
       -i src/interface/web/assets/icons/favicon.icns \
       --add-data "src/interface/web:src/interface/web" \
       --copy-metadata tqdm \
       --copy-metadata regex \
       --copy-metadata requests \
       --copy-metadata packaging \
       --copy-metadata filelock \
       --copy-metadata numpy \
       --copy-metadata tokenizers
  ```
2022-08-08 23:23:02 +03:00
Debanjum Singh Solanky
ef009323e7 Use sys.exit to quit via system tray. Fix pip install cmd in Readme 2022-08-08 21:42:36 +03:00
Debanjum Singh Solanky
eacd95bebd Start Creating Native Configure Page using PyQt 2022-08-08 18:31:47 +03:00
Debanjum Singh Solanky
c5bf051a29 Rename initialize_{search,processor,server} to configure_{search,procesor,server}
- Search is being reconfigured multiple times in /regenerate and
  n/reload. More appropriate name is configure_ rather than initialize_
  for it
- Standardize name of methods under configure.py
2022-08-06 03:23:02 +03:00
Debanjum Singh Solanky
7b04978f52 Put global state variables into separate state module
- Variables storing app, device state aren't constants.
  Do not mix with actual constants like empty_escape_sequence, web_directory
2022-08-06 03:13:18 +03:00
Debanjum Singh Solanky
b04c84721b Extract configure and routers from main.py into separate modules
- Main.py was becoming too big to manage. It had both
  controllers/routers and component configurations (search, processors)
  in it

- Now that the native app GUI code is also getting added to the main
  path, good time to split/modularize/clean main.py

- Put global state into a separate file to share across modules
2022-08-06 02:39:18 +03:00
Debanjum Singh Solanky
083fefdd07 Create Native Menu Bar with PyQt to open Search, Config webpages
- Run FastAPI server in a separate thread.
  - This allows starting both the server and gui in parallel

- Create System Tray for Khoj
  - Contains menu items that open search or config pages in browser

- Rearrange code to have only the code required to start Backend and
  GUI in the run() method
  - Move the backend setup code into a separate method
2022-08-06 01:00:25 +03:00
Debanjum Singh Solanky
9fa3345000 Show available Khoj keybindings to customize search using which-key
Fallback to showing simple khoj keybindings info message in echo area
when which-key not available
2022-08-05 20:24:29 +03:00
Debanjum Singh Solanky
6a8b2a6936 Do not run incremental search when query is empty 2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
609cd6e8bb Show keybindings to set khoj search type in echo area to assist user 2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
48e4a983c5 Allow switching search type in the middle of querying Khoj on Emacs
- More generally, this allows configuring the khoj search anytime
  while in khoj minibuffer window
- Earlier could only configure search type at the start of the search
2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
48c33b93cc Generalize khoj keymap to func that can update existing keybdings 2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
19c4701f3f Default to ledger search from files with .beancount extensions 2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
cc9a395e0a Keep name of buffer for Khoj results in a variable 2022-08-05 19:35:42 +03:00
Debanjum Singh Solanky
0a5c6d067a Do not prompt user to set search type before querying Khoj via Emacs
- What
  - Default to last used search type, when no search type specified
  - Allow user to change search type before they enter query (and
    after they've called khoj), if they want

- Why
  - Reduce time from intent to results by using reasonable defaults
  - Make interactions smoother, more intuitive
2022-08-05 19:35:38 +03:00
Debanjum Singh Solanky
24ccba74d4 Put type dropdown, regenerate button on same row. Regain screen space 2022-08-05 06:17:43 +03:00
Debanjum Singh Solanky
017e287b8a Remove redundant query as title in results section
- Regain screen real-estate
- Remove unused parameters, html being returned by org.js
2022-08-05 06:17:25 +03:00
Debanjum Singh Solanky
06afeec7e2 Hide stars of org entry results on Emacs to reduce visual clutter
They've all been normlized to the same level and hence don't hold much
data. So good opportunity to reduce, non-useful visual clutter
2022-08-05 05:27:57 +03:00
Saba
d1fe6353b5 Check whether processor_config exists during shutdown event 2022-08-04 21:57:36 -04:00
Debanjum Singh Solanky
4d4d2ff921 Ensure all org entries are unfolded in results buffer on Emacs 2022-08-05 04:54:29 +03:00
Debanjum Singh Solanky
49ef741d4b Prevent Zoom on Input in Web Interface. Document Pip upgrade in Readme
- Name /Reload API Controller Reload
2022-08-05 03:51:34 +03:00
Debanjum Singh Solanky
675e821d95 Make embeddings, jsonl paths absolute. Create directories if non-existent 2022-08-05 02:57:59 +03:00