Commit Graph

243 Commits

Author SHA1 Message Date
jfmontanaro
87e19df9c5
feat: Add xonsh history import (#1678)
* add importers for xonsh JSON files and SQLite db

* rustfmt xonsh importers

* remove env-dependent tests from xonsh importers

* pass xonsh_data_dir into path resolver instead of looking up in env

* review: run format

* review: fix clippy errors

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-02-12 10:32:07 +00:00
Ellie Huxtable
8ef5f67f8b
perf: optimize history init-store (#1691)
Instead of lots of small sqlite transaction, do one monster one.

A single tx with 100s of 1000s of rows should be fine on all systems

A very unscientific test shows this to be roughly 10x faster
2024-02-12 09:56:42 +00:00
David
b4f8d1433b
docs: minor formatting updates to the default config.toml (#1689) 2024-02-12 09:26:29 +00:00
Eric Long
5a805dc22c
feat: use ATUIN_TEST_SQLITE_STORE_TIMEOUT to specify test timeout of SQLite store (#1703)
Low-end devices like RISC-V SBCs are sometimes too slow to initialize SQLite in 0.1s. Option to specify a higher value allows check to pass on such devices with relaxed restrictions.
2024-02-12 09:25:06 +00:00
Ellie Huxtable
1464cb657a
chore(release): prepare for release v18.0.1 (#1706) 2024-02-12 08:38:23 +00:00
Ellie Huxtable
5738d06282
chore(release): prepare for release v18.0.0 (#1685) 2024-02-09 12:42:34 +00:00
Ellie Huxtable
8460210202
feat: add progress bars to sync and store init (#1684)
Replace lots of logging with some progress bars. This looks much nicer

I'd like to move it out of the atuin-client crate and into the atuin
crate. But first, I want to decouple a lot of the record moving, so it
can wait until that's done.
2024-02-08 13:34:41 +00:00
Ellie Huxtable
1993653102
fix(tests): add Settings::utc() for utc settings (#1677)
Means we don't try and load timezones in tests, as this fails due to
multiple threads.

Also allow specifying '0' or 'utc' as a timezone
2024-02-06 17:47:00 +00:00
cyqsimon
318bdd8955
Add timezone configuration option & CLI overrides (#1517)
* Allow specifying a timezone in history search/list

* Fix clippy complaints

* Add a bit more comment on supporting named timezones

* Add rudimentary tests

* Ditch local timezone test

* Timezone configuration support

* Set default timezone to `local`

* `--tz` -> `--timezone`

`--tz` is kept as a visible alias
2024-02-06 15:34:03 +00:00
Ellie Huxtable
6a2576fc5b
chore(ci): run rust build/test/check on 3 platforms (#1675)
* chore(ci): run rust build/test/check on 3 platforms

* need to properly test windows

* do not need to strip here, and windows has a suffix anyway
2024-02-05 09:28:55 +00:00
Ellie Huxtable
3ff2e2552f
fix: correct download list for incremental builds (#1672) 2024-02-04 20:06:47 +00:00
Joe Ardent
b7bb583d8d
fix: set durability for sqlite to recommended settings (#1667)
Also do an optimize on connection close. Fixes lag on history insertion.
2024-02-04 18:42:48 +00:00
Ellie Huxtable
374255dd58 feat: add store pull
This allows the user to

1. Specify that they want to sync, but ONLY pull new data
2. Specify that they wish to force pull, which will wipe the local store
   and download it from the remote

With the other set of changes, this allows the user to perform
sufficient maintenance to recovery from most errors I can think of right
now.
2024-02-02 18:01:09 +00:00
Ellie Huxtable
c9a453289e feat: add store push --force
This will

1. Wipe the remote store
2. Upload all of the local store to remote

Imagine the scenario where you end up with some mixed keys locally :(

You confirm this with

```
atuin store verify
```

You then fix it locally with

```
atuin store purge
```

Ensure that your local changes are reflected remotely with

```
atuin store push --force
```

and then (another PR, coming soon), update all other hosts with

```
atuin store pull --force
```
2024-02-02 18:01:09 +00:00
Ellie Huxtable
3c420f85f6 feat: failure to decrypt history = failure to sync
Now that the user can purge their store and _do something_ about invalid
records, we should not tolerate mixed key records in store.
2024-02-02 18:01:09 +00:00
Ellie Huxtable
754f17ddb4 feat: add store purge command
This command will delete all records from the local store that cannot be
decrypted with the current key.

If a verify fails before running this, it should pass _after_ running
it.

Required afterwards:
- A `push --force`, to allow ensuring the remote store equals the local
  store (deletions have now occured!)
- A `pull --force`, as once remote has been forced then local needs the
  same

Nice to have:
- Provide "old" keys to purge, in case the are not lost. Or maybe rekey.
2024-02-02 18:01:09 +00:00
Ellie Huxtable
212dc928c9 feat: add verify command to local store
This ensures that the local store can be decrypted with the current
in-use key.

If it cannot, we can go on to perform maintenance operations and get
back into a happy state.
2024-02-02 18:01:09 +00:00
Conrad Ludgate
744f0059c2
feat: add prefers_reduced_motion flag (#1645)
* feat: add prefers_reduced_motion flag

* use NO_MOTION, and ensure type is bool

* update default config

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-02-01 15:17:29 +00:00
Ellie Huxtable
a6f1fe2c10
feat: reencrypt/rekey local store (#1662)
* feat: add record re-encrypting

* automatically re-encrypt store when logging in with a different key

* fix

* actually save the new key lmao

* add rekey

* save new key

* decode bip key

* "add test for sqlite store re encrypt"
2024-02-01 15:00:46 +00:00
Ellie Huxtable
335f2220c3
fix: never overwrite the key (#1657)
Now that local history is stored encrypted, new_key should not overwrite
an existing one. This may be frustrating, but will remove the risk of
Atuin generating a new key and the user losing their old one.
2024-01-30 14:01:20 +00:00
Ellie Huxtable
9597080825
feat: add store push (#1649)
* feat: add store push

* only push for the current host unless specified

* tidy up

* tidy up some more

* sort features
2024-01-30 13:41:01 +00:00
Ellie Huxtable
366b8ea97b
feat: automatically init history store when record sync is enabled (#1634)
* add support for getting the total length of a store

* tidy up sync

* auto call init if history is ahead

* fix import order, key regen

* fix import order, key regen

* do not delete key when user deletes account

* message output

* remote init store command; this is now automatic

* should probs make that function return u64 at some point
2024-01-29 16:38:24 +00:00
TymanWasTaken
0faf414cd9
feat: Add change-password command & support on server (#1615)
* Add change-password command & support on server

* Add a test for password change

* review: run format

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-01-29 11:17:10 +00:00
Dongxu Wang
e1c2b9c783
feat: make history list format configurable (#1638)
* feat: make history list format configurable

* Update atuin-client/config.toml

* review: run format

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-01-29 10:58:20 +00:00
Mag Mell
d21de3cd25
chore: add feature to allow always disable check update (#1628)
* chore: add feature to allow always disable check update

In the packaging rules of some distributions, the software's self-update check needs to be permanently turned off

This commit will make it easier for these users to

* fix: formatting

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-01-26 09:45:42 +00:00
Ellie Huxtable
d84f5b2d33
feat: don't stop with invalid key (#1612)
An issue with the old sync was that if there was _one_ record encrypted
with a different key, sync would stop. You'd need to delete your account
and start from scratch. This sucked.

This change means we will carry on, and try to encrypt and build with as
much of the history as we are able to decrypt.

This is possible because we can quite happily store data on disk that we
cannot decrypt. The old store couldn't do this.

In future, we might consider a keyring containing multiple keys.
2024-01-22 20:07:19 +00:00
Ellie Huxtable
6af6c9066b
fix(tui): dedupe was removing history (#1610)
Related: https://forum.atuin.sh/t/search-ignoring-commands/74/5?u=ellie

When a user ran a duplicated command, but in another session, it was
removed by filters. This is because the subquery that was once used did
not have the same filters applied as the main query.

Instead of messing with subqueries, `group by` instead. This aligns with
the search() function
2024-01-22 17:06:34 +00:00
Ellie Huxtable
600ebc33ab
feat: make store init idempotent (#1609) 2024-01-22 16:48:21 +00:00
Koichi Murase
e484a68b8b
feat(search): make cursor style configurable (#1595)
* feat(search): make cursor style configurable

The vim mode of the interactive Atuin search changes the cursor style
on a mode change, but the current implementation has the following
issues.

* The terminal's cursor style set by the Atuin search remains after
  Atuin exits.  This causes an inconsistency with the shell's setting
  for the cursor style.

* Also, the cursor style for each keymap mode is currently hardcoded
  in the source code, which is not necessarily consistent with the
  user's cursor-style setting in the shell.

* Since the current implementation does not set the cursor style for
  the initial keymap mode but only sets the cursor style when the
  keymap mode is changed, it also causes inconsistency in the cursor
  style and the actual keymap when the shell's keymap and Atuin's
  initial keymap mode are different.

This patch solves those issues by introducing an opt-in configuration
variable `keymap_cursor`.  By default, the vim mode does not change
the cursor style because there is no way to automatically determine
the cursor style consistent with the shell settings.  We enable the
feature only when the user specifies the preferred cursor style in
each mode in their config.  Also, the cursor style is set on the
startup of the Atuin search (based on the initial keymap mode) and is
reset on the termination of the Atuin search (based on the shell's
keymap mode that started the Atuin search).

* chore(settings): remove dependency on crossterm
2024-01-22 10:56:44 +00:00
Ellie Huxtable
8899ce5089
fix: add acquire timeout to sqlite database connection (#1590)
* fix: add acquire timeout to sqlite database connection

This should fix #1503

I wasn't able to trigger enough IO pressure for the SQL connection to be
a problem.

This adds `local_timeout` to the client config. This is a float, and
represents the number of seconds (units in line with the other timeouts,
though those are ints). Users may well want to reduce this if they
regularly have issues, but by default I think 2s is fine and avoids a
non-responsive system in bad situations.

* tests
2024-01-19 15:45:42 +00:00
Peter Holloway
10f465da8f
fix: Use existing db querying for history list (#1589)
When printing the history list with either the session or cwd filter
enabled, use to same query method as without either to ensure that the
other options (hide deleted entries etc) are respected.
2024-01-19 11:21:05 +00:00
Ellie Huxtable
d9317a1a9c
feat: make deleting from the UI work with record store sync (#1580)
* feat: make deleting from the UI work with record store sync

* sort cli delete too

* teeny bit more logs
2024-01-17 09:58:09 +00:00
Koichi Murase
6bff8c8e1a
feat(search): introduce keymap-dependent vim-mode (#1570)
* feat(search): introduce keymap-dependent vim-mode

* fix(zsh): provide widgets with specific keymaps

* fix(settings): unify "vim" and "keymap_mode"
2024-01-16 13:35:10 +00:00
Ellie Huxtable
a2578c4521
feat: add history rebuild (#1575)
* feat: add history rebuild

This adds a function that will

1. List all history from the store
2. Segment by create/delete
3. Insert all creates into the database
4. Delete all deleted

This replaces the old history sync.

Presently it's incomplete. There is no incremental rebuild, it can only
do the entire thing at once.

This is ran by `atuin store rebuild history`

* fix tests

* add incremental sync

* add auto sync
2024-01-16 11:25:09 +00:00
Ellie Huxtable
c2439d1ed6
fix(sync): save sync time when it starts, not ends (#1573)
Imagine the scenario where a sync fails. The function touched here will
never save the sync time.

That means that external to this function, the sync never happened. The
next command will try and start one immediately.

The happy scenario is that this succeeds. The unhappy scenario is that
this fails. Fails, and isn't saved, so we try again...

Should add proper backoff but this is a good start.
2024-01-15 13:10:10 +00:00
Ellie Huxtable
ecce55b445
feat: add better error handling for sync (#1572)
Hopefully this helps users get more descriptive errors, and give more
descriptive bug reports
2024-01-15 12:57:28 +00:00
YummyOreo
a56085f059
feat(ui): vim mode (#1553)
* feat(config): add vim option to config

* feat(ui): simple vim mode

* fix(windows): windows sadly doesn't support the stuff

* feat(ui): blinking

* fix(merge)

* revert: reverts some debugging stuff

* feat(ui): changes the defaut to insert, don't know what should be the default

* feat(ui): implements some vim parity

* doc: adds this to the docs

* docs(keybindings): adds vim mode keybindsings to the list of keybindings

* refactor: rustfmt and remove the docs for pr in own repo

* refactor: use execute!

* Update atuin/src/command/client/search/interactive.rs

---------

Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-01-13 17:15:49 +00:00
Ellie Huxtable
99249ea319
feat: Add interactive command inspector (#1296)
* Begin work on command inspector

This is a separate pane in the interactive mode that allows for
exploration and inspecting of specific commands.

I've restructured things a bit. It made logical sense that things
were nested under commands, however the whole point of `atuin` is to
provide commands. Breaking things out like this enables a bit less
crazy nesting as we add more functionality to things like interactive
search. I'd like to add a few more interactive things and it was
starting to feel very cluttered

* Some vague tab things

* functioning inspector with stats

* add interactive delete to inspector

* things

* clippy

* borders

* sus

* revert restructure for another pr

* Revert "sus"

This reverts commit d4bae8cf61.
2024-01-12 16:02:08 +00:00
Matthew Berryman
915bff6d28
feat: include atuin login in secret patterns (#1518)
* include atuin login in secret patterns

* doc catchup
2024-01-08 09:37:42 +00:00
Ellie Huxtable
4e56f5a41e
refactor: String -> HistoryId (#1512) 2024-01-06 17:19:31 +00:00
Ellie Huxtable
7bc6ccdd70
feat: rework record sync for improved reliability (#1478)
* feat: rework record sync for improved reliability

So, to tell a story

1. We introduced the record sync, intended to be the new algorithm to
   sync history.
2. On top of this, I added the KV store. This was intended as a simple
   test of the record sync, and to see if people wanted that sort of
   functionality
3. History remained syncing via the old means, as while it had issues it
   worked more-or-less OK. And we are aware of its flaws
4. If KV syncing worked ok, history would be moved across

KV syncing ran ok for 6mo or so, so I started to move across history.
For several weeks, I ran a local fork of Atuin + the server that synced
via records instead.

The record store maintained ordering via a linked list, which was a
mistake. It performed well in testing, but was really difficult to debug
and reason about. So when a few small sync issues occured, they took an
extremely long time to debug.

This PR is huge, which I regret. It involves replacing the "parent"
relationship that records once had (pointing to the previous record)
with a simple index (generally referred to as idx). This also means we
had to change the recordindex, which referenced "tails". Tails were the
last item in the chain.

Now that we use an "array" vs linked list, that logic was also replaced.
And is much simpler :D

Same for the queries that act on this data.

----

This isn't final - we still need to add

1. Proper server/client error handling, which has been lacking for a
   while
2. The actual history implementation on top
    This exists in a branch, just without deletions. Won't be much to
    add that, I just don't want to make this any larger than it already
    is

The _only_ caveat here is that we basically lose data synced via the old
record store. This is the KV data from before.

It hasn't been deleted or anything, just no longer hooked up. So it's
totally possible to write a migration script. I just need to do that.

* update .gitignore

* use correct endpoint

* fix for stores with length of 1

* use create/delete enum for history store

* lint, remove unneeded host_id

* remove prints

* add command to import old history

* add enable/disable switch for record sync

* add record sync to auto sync

* satisfy the almighty clippy

* remove file that I did not mean to commit

* feedback
2024-01-05 17:57:49 +00:00
Ellie Huxtable
9f79a34a9d
chore(release): prepare for release v17.2.1 (#1495) 2024-01-03 15:51:47 +00:00
Ellie Huxtable
999a98c577
chore(release): prepare for release v17.2.0 (#1492) 2024-01-03 12:46:08 +00:00
依云
c37147d619
fix(import/zsh): zsh use a special format to escape some characters (#1490)
* fix(import/zsh): zsh use a special format to escape some characters

unescape those correctly rather than throw them away.

zsh side code:
9f57ca4ac8/Src/utils.c (L4889-L4900)

* fix code style
2024-01-03 08:46:59 +00:00
Conrad Ludgate
e2a4e9cf13
fix(stats): time now_local not working 2024-01-01 16:42:36 +00:00
Ellie Huxtable
86f50e0356
feat: add semver checking to client requests (#1456)
* feat: add semver checking to client requests

This enforces that the client and the server run the same major version
in order to sync successfully.

We're using the `Atuin-Version` http header to transfer this information

If the user is not on the same MAJOR, then they will see an error like
this

> Atuin version mismatch! In order to successfully sync, the client and the server must run the same *major* version
> Client: 17.1.0
> Server: 18.1.0
> Error: could not sync records due to version mismatch

This change means two things

1. We will now only increment major versions if there is a breaking
   change for sync
2. We can now add breaking changes to sync, for any version >17.1.0.
   Clients will fail in a meaningful way.

* lint, fmt, etc

* only check for client newer than server

* Add version header to client too
2023-12-20 09:03:04 +00:00
Ramses
edc495895a
fix(stats): don't require all fields under [stats] (#1437)
Before this change, when configuring only `common_subcommands` and
not `common_prefix` (so it would take its default value),
atuin produces an error message:
```
Error: could not load client settings  Caused by:     failed to deserialize: missing field `common_prefix`  Location:     atuin-client/src/settings.rs:456:26
Error: could not load client settings

Caused by:
    failed to deserialize: missing field `common_prefix`

Location:
    atuin-client/src/settings.rs:456:26
Error:: command not found
```

With this change, the fields can be specified separately and missing
fields will take their default values.
2023-12-11 20:16:41 +00:00
Josef Friedrich
3c7f6991e3
fix(docs): fix typo (#1439) 2023-12-11 20:16:11 +00:00
Ellie Huxtable
da2e58fbb1
chore(release): prepare for release v17.1.0 (#1432) 2023-12-10 13:00:59 +00:00
Ellie Huxtable
839965a8d7
chore: update rusty_paseto and rusty_paserk (#1420) 2023-12-02 22:47:41 +00:00