Commit graph

190 commits

Author SHA1 Message Date
Abdo
93f38924a6 Merge branch 'main' into editor-3830 2025-08-09 03:25:42 +03:00
Luc Mcgrady
1af3c58d40
Feat/Desired retention info graphs (#4199)
* backend part

* split memorised and cost

* slapdash frontend

* extract some simulator logic

* Add zoomed version of graph

* ./check

* Fix: Tooltip

* Fix: Simulator/workload transition

* remove "time"

* Update ts/routes/graphs/simulator.ts

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Added: Mode toggle

* Disable Dr in workload mode

* keep button order consistant between modes

* dont clear points on mode swap

* add review count graph

* Revert "dont clear points on mode swap"

This reverts commit fc89efb1d9.

* "Help me pick" button

* unrelated title case change

* Add translation strings

* fix: missing translation string

* Fix: Layout shift

* Add: Experimental

* Fix Time / Memorized

* per day values

* set review limit to 9999 on open

* keep default at currently set value

* Do DR calculation in parallel (dae)

Approx 5x faster on my machine

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-07-28 18:55:08 +10:00
Abdo
9a054d6924 Complete noteCanBeAdded() 2025-07-28 10:17:12 +03:00
Abdo
f379aa742e Implement History button 2025-07-25 14:41:27 +03:00
Abdo
e71f789958 Remove duplicate lines in mediasrv.py again
Turned out to be a race condition when the ruff/black/isort extensions
are installed.

https://github.com/astral-sh/ruff-vscode/issues/651
2025-07-24 11:41:27 +03:00
Abdo
7dac2fc4ff Add back legacy code as separate screens 2025-07-21 22:30:25 +03:00
Abdo
6cf8196513 Remove unintended change in mediasrv.py 2025-07-10 14:05:10 +03:00
Abdo
c2374dcc24 Implement help button 2025-07-09 06:29:06 +03:00
Abdo
a8a2e4ee32 Implement close button 2025-07-09 05:32:46 +03:00
Abdo
b1771895c5 Merge branch 'main' into editor-3830 2025-07-09 03:33:30 +03:00
Luc Mcgrady
f5285f359a
Feat/Add legacy evaluate config bool (#4149)
* Feat/Add legacy evaluate config bool

* Minor tweaks based on PR suggestions (dae)

New enabling command:

from anki.config import Config
mw.col.set_config_bool(Config.Bool.FSRS_LEGACY_EVALUATE, True)
2025-07-04 15:32:09 +07:00
Abdo
d0bb1ffd9a Tweak naming 2025-07-03 11:03:03 +03:00
Abdo
dbd8737f0a Fix undo ops of add_note/update_notetype 2025-07-03 10:58:30 +03:00
Abdo
1f002134fe Add a basic fieldsAreBlank() 2025-06-30 11:50:26 +03:00
Abdo
939d833e12 Merge branch 'main' into editor-3830 2025-06-29 22:01:28 +03:00
Abdo
f94d05bcbe
Switch to Ruff (#4119)
* Add check:ruff build action

* Add fix:ruff action

* Add Ruff config

Mostly generated by Cursor

* Handle rest of lints

* Fix formatting

* Replace black and isort with ruff-format

* Run ruff-format

* Fix lint errors

* Remove pylint disables

* Remove .pylintrc

* Update docs

* Fix check:format not just checking

* Fix isort rule being ignored

* Sort imports

* Ensure ./ninja format also handles import sorting

* Remove unused isort cfg

* Enable unsafe fixes in fix:ruff, and enable unused var warning

* Re-run on config change; enable unnecessary ARG ignores

* Use all pycodestyle errors, and add some more commented-out ones

Latter logged on https://github.com/ankitects/anki/issues/4135
2025-06-29 14:38:35 +07:00
Abdo
70264bd23f Fix lint errors 2025-06-28 16:56:54 +03:00
Abdo
dd673851db Go back to using QClipboard 2025-06-28 16:46:13 +03:00
Abdo
bc26b283a0 Reimplement sticky field saving 2025-06-24 15:51:05 +03:00
Abdo
fa0c4b11ab Merge branch 'main' into editor-3830 2025-06-20 21:33:31 +03:00
Damien Elmes
04996c77f3
Migrate build system to uv (#4074)
* Migrate build system to uv

Closes #3787, and is a step towards #3081 and #4022

This change breaks our PyOxidizer bundling process. While we probably
could update it to work with the new venvs & lockfile, my intention
is to use this as a base to try out a uv-based packager/installer.

Some notes about the changes:

- Use uv for python download + venv installation
- Drop python/requirements* in favour of pyproject files / uv.lock
- Bumped to latest Python 3.9 version. The move to 3.13 should be
a fairly trivial change when we're ready.
- Dropped the old write_wheel.py in favour of uv/hatchling. This has
the unfortunate side-effect of dropping leading zeros in our wheels,
which we could try hack around in the future.
- Switch to Qt 6.7 for the dev repo, as it's the first PyQt version
with a Linux/ARM WebEngine wheel.
- Unified our macOS deployment target with minimum required for ARM.
- Dropped unused fluent python files
- Dropped unused python license generation
- Dropped helpers to run under Qt 5, as our wheels were already
requiring Qt 6 to install.

* Build action to create universal uv binary

* Drop some PyOxidizer-related files

* Use Windows ARM64 cargo/node binaries during build

We can't provide ARM64 wheels to users yet due to #4079, but we can
at least speed up the build.

The rustls -> native-tls change on Windows is because ring requires
clang to compile for ARM64, and I figured it's best to keep our Windows
deps consistent. We already built the wheels with native-tls.

* Make libankihelper a universal library

We were shipping a single arch library in a purelib, leading to
breakages when running on a different platform.

* Use Python wheel for mpv/lame on Windows/Mac

This is convenient, but suboptimal on a Mac at the moment. The first
run of mpv will take a number of seconds for security checks to run,
and our mpv code ends up timing out, repeating the process each time.
Our installer stub will need to invoke mpv once first to get it validated.

We could address this by distributing the audio with the installer/stub,
or perhaps by putting the binaries in a .pkg file that's notarized+stapled
and then included in the wheel.

* Add some helper scripts to build a fully-locked wheel

* Initial macOS launcher prototype

* Add a hidden env var to preload our libs and audio helpers on macOS

* qt/bundle -> qt/launcher

- remove more of the old bundling code
- handle app icon

* Fat binary, notarization & dmg

* Publish wheels on testpypi for testing

* Use our Python pin for the launcher too

* Python cleanups

* Extend launcher to other platforms + more

- Switch to Qt 6.8 for repo default, as 6.7 depends on an older
libwebp/tiff which is unavailable on newer installs
- Drop tools/mac-x86, as we no longer need to test against Qt 5
- Add flags to cross compile wheels on Mac and Linux
- Bump glibc target to 2_36, building on Debian Stable
- Increase mpv timeout on macOS to allow for initial gatekeeper checks
- Ship both arm64 and amd64 uv on Linux, with a bash stub to pick
the appropriate arch.

* Fix pylint on Linux

* Fix failure to run from /usr/local/bin

* Remove remaining pyoxidizer refs, and clean up duplicate release folder

* Rust dep updates

- Rust 1.87 for now (1.88 due out in around a week)
- Nom looks involved, so I left it for now
- prost-reflect depends on a new prost version that got yanked

* Python 3.13 + dep updates

Updated protoc binaries + add helper in order to try fix build breakage.
Ended up being due to an AI-generated update to pip-system-certs that
was not reviewed carefully enough:
https://gitlab.com/alelec/pip-system-certs/-/issues/36

The updated mypy/black needed some tweaks to our files.

* Windows compilation fixes

* Automatically run Anki after installing on Windows

* Touch pyproject.toml upon install, so we check for updates

* Update Python deps

- urllib3 for CVE
- pip-system-certs got fixed
- markdown/pytest also updated
2025-06-19 14:03:16 +07:00
Abdo
f8ce1c3526 Fix lint errors 2025-06-18 23:57:19 +03:00
Abdo
cf099ea508 Move Record Audio button 2025-06-18 23:55:33 +03:00
Abdo
70a69cfdbe Move context menu logic 2025-06-18 23:55:26 +03:00
Abdo
d585916313 Fix lint errors 2025-06-12 05:00:33 +03:00
Abdo
13c2dd201a Move more image occlusion calls 2025-06-12 04:33:29 +03:00
Abdo
99396e5811 Start work on copy & paste handling 2025-06-09 18:04:57 +03:00
Abdo
05360e2d19 Add a temporary workaround for addcards 2025-06-02 06:04:17 +03:00
Abdo
795aef09ee Move fields_check() 2025-06-02 03:59:29 +03:00
Abdo
b13a1d1639 Merge branch 'main' into editor-3830 2025-06-02 02:41:47 +03:00
Damien Elmes
757247d424 Use more secure API key
https://github.com/ankitects/anki/pull/3925#discussion_r2051494659
2025-05-31 16:01:03 +07:00
Abdo
79f803c4e7 Use orjson helpers 2025-05-30 10:52:55 +03:00
Abdo
7dbbbad914 Fix lint errors 2025-05-28 16:51:29 +03:00
Abdo
0198a58a1c Fix wrong exception being catched in get_config_json() 2025-05-28 11:37:46 +03:00
Abdo
544b5f54d7 Move setMathjaxEnabled() 2025-05-28 11:28:36 +03:00
Abdo
15cbbeea24 Move setTagsCollapsed() 2025-05-28 10:35:43 +03:00
Abdo
9395b89b92 Move setColorButtons() 2025-05-28 09:25:47 +03:00
Abdo
3ae7484610 Merge branch 'main' into editor-3830 2025-05-28 06:40:53 +03:00
Luc Mcgrady
f29bcb743b
Feat/Desired retention warning improvements (#3995)
* Feat/90% desired retention warning

* Update ftl/core/deck-config.ftl

* show on newly enabled

* Show warning on focus

* Never hide warning

* Display relative change

* Add: Separate warning for too long and short

* Revert unchanged text changes

* interval -> workload

* Remove dead code

* fsrs-rs/@L-M-Sherlock's workload calculation

* Added: delay

* CONSTANT_CASE

* Fix: optimized state

* Removed "Processing"

* Remove dead code

* 1 digit precision

* bump fsrs-rs

* typo

* Apply suggestions from code review

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Improve rounding

* improve comment

* rounding <1%

* decrease rounding precision

* bump ts-fsrs

* use actual cost values

* ./check

* typo

* include relearning

* change factor wording

* simplify sql

* ./check

* Apply suggestions from code review

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Fix: missing search_cids

* @dae's style patch

* Fix: Doesn't update on arrow keys change

* force two lines

* center two lines

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2025-05-27 13:07:21 +10:00
Abdo
35f0bc5af6 Reimplement editor_will_munge_html callbacks 2025-05-26 02:51:02 +03:00
Abdo
3073ef02b5 Remove editorReady()
bridgeCommand() looks cleaner here
2025-05-25 21:14:10 +03:00
Abdo
48fb272700 Fix error on late editor_update_note() call 2025-05-25 21:10:02 +03:00
Abdo
1809e793e6 Move note saving to TS 2025-05-25 19:23:55 +03:00
Abdo
12e222b66e Fix encodeIriPaths() not allowed 2025-05-25 15:21:42 +03:00
Abdo
053bd4380f Move some JS calls in loadNote() 2025-05-25 14:54:01 +03:00
Abdo
5cbb5242c8 Move editor code to ts/routes 2025-05-22 02:46:01 +03:00
Damien Elmes
b23a6af63e Restore ability to check pages externally on other devices
Broken by the recent security changes
2025-04-24 18:33:09 +10:00
Aristotelis
79b19a17a3
Add add-on scripts to editor CSP (#3942) 2025-04-24 15:28:25 +10:00
Damien Elmes
ddb8573e8d
Use CSP to block inline JS content in editor (#3939)
* Revert "Sanitize field content in editor"

This reverts commit 1c156905f8.

* Use CSP to block inline JS content in editor

This blocks inline scripts, scripts in the media folder, and
handlers like onclick in the editor. This is nicer than the previous
solution - it doesn't make any permanent changes, and leaves other
content like SVGs alone. Thanks to Nil Admirari for the suggestion.
2025-04-23 16:21:48 +10:00
Damien Elmes
1a68c9f5d5
Harden access to internal API (#3925)
* Sanitize field content in editor

The editor already strips script tags from fields, but was allowing
through Javascript in things like onclick handlers. We block this now,
as the editor context has access to internal APIs that we don't want to
expose to untrusted third-party code.

* Require an auth token for API access

We were previously inspecting the referrer, but that is spoofable,
and doesn't guard against other processes on the machine.

To accomplish this, we use a request interceptor to automatically
add an auth token to webviews with the right context. Some related
changes were required:

- We avoid storing _page, which was leading to leaks & warning on exit
- At webview creation (or set_kind() invocation), we assign either
an authenticated or unauthenticated web profile.
- Some of our screens initialize the AnkiWebView when calling, e.g.,
aqt.forms.stats.Ui_Dialog(). They then immediately call .set_kind().
This reveals a race condition in our DOM handling code: the webview
initialization creates an empty page with the injected script, which
causes a domDone signal to be sent back. This signal arrives after
we've created another page with .set_kind(), causing our code to think
the DOM is ready when it's not. Then when we try to inject the dynamic
styling, we get an error, as the DOM is not ready yet. In the absence
of better solutions, I've added a hack to set_kind() to deal with this
for now.

* Provide AnkiWebPage init defaults for existing add-on callers

* Inject bridge script when profile set-up skipped

Some add-ons fully override AnkiWebPage.__init__ and thus depend on _setupBridge injecting the JS bridge script.

With this change we account for these cases, while giving add-ons the opportunity to look for solutions that do not require overriding AnkiWebPage.__init__ completely.

* Add some missed pages/endpoints (thanks to iamllama)

* Avoid sending API key for remote resources

Thanks to Abdo for the report

---------

Co-authored-by: Aristotelis P <201596065+aps-amboss@users.noreply.github.com>
2025-04-17 11:15:10 +10:00