diff --git a/.version b/.version index ce73bf7c0..3820668b1 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -25.08b1 +25.07.3 diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c22bc764a..b5dfe1d53 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -234,6 +234,8 @@ Emmanuel Ferdman Sunong2008 Marvin Kopf Kevin Nakamura +Bradley Szoke +jcznk ******************** diff --git a/Cargo.toml b/Cargo.toml index db5753893..2ff29cd1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -141,7 +141,7 @@ walkdir = "2.5.0" which = "8.0.0" widestring = "1.1.0" winapi = { version = "0.3", features = ["wincon", "winreg"] } -windows = { version = "0.61.3", features = ["Media_SpeechSynthesis", "Media_Core", "Foundation_Collections", "Storage_Streams", "Win32_System_Console", "Win32_System_Registry", "Win32_Foundation", "Win32_UI_Shell"] } +windows = { version = "0.61.3", features = ["Media_SpeechSynthesis", "Media_Core", "Foundation_Collections", "Storage_Streams", "Win32_System_Console", "Win32_System_Registry", "Win32_System_SystemInformation", "Win32_Foundation", "Win32_UI_Shell", "Wdk_System_SystemServices"] } wiremock = "0.6.3" xz2 = "0.1.7" zip = { version = "4.1.0", default-features = false, features = ["deflate", "time"] } diff --git a/build/runner/src/pyenv.rs b/build/runner/src/pyenv.rs index d64c8fb3f..efd58fd91 100644 --- a/build/runner/src/pyenv.rs +++ b/build/runner/src/pyenv.rs @@ -32,10 +32,19 @@ pub fn setup_pyenv(args: PyenvArgs) { } } + let mut command = Command::new(args.uv_bin); + + // remove UV_* environment variables to avoid interference + for (key, _) in std::env::vars() { + if key.starts_with("UV_") || key == "VIRTUAL_ENV" { + command.env_remove(key); + } + } + run_command( - Command::new(args.uv_bin) + command .env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone()) - .args(["sync", "--locked"]) + .args(["sync", "--locked", "--no-config"]) .args(args.extra_args), ); diff --git a/ftl/core-repo b/ftl/core-repo index a9216499b..b90ef6f03 160000 --- a/ftl/core-repo +++ b/ftl/core-repo @@ -1 +1 @@ -Subproject commit a9216499ba1fb1538cfd740c698adaaa3410fd4b +Subproject commit b90ef6f03c251eb336029ac7c5f551200d41273f diff --git a/ftl/core/preferences.ftl b/ftl/core/preferences.ftl index ce24df434..23b72f267 100644 --- a/ftl/core/preferences.ftl +++ b/ftl/core/preferences.ftl @@ -34,7 +34,7 @@ preferences-when-adding-default-to-current-deck = When adding, default to curren preferences-you-can-restore-backups-via-fileswitch = You can restore backups via File > Switch Profile. preferences-legacy-timezone-handling = Legacy timezone handling (buggy, but required for AnkiDroid <= 2.14) preferences-default-search-text = Default search text -preferences-default-search-text-example = eg. 'deck:current ' +preferences-default-search-text-example = e.g. "deck:current" preferences-theme = Theme preferences-theme-follow-system = Follow System preferences-theme-light = Light diff --git a/ftl/core/statistics.ftl b/ftl/core/statistics.ftl index 8da1aace8..c5551ef67 100644 --- a/ftl/core/statistics.ftl +++ b/ftl/core/statistics.ftl @@ -80,7 +80,7 @@ statistics-reviews = # This fragment of the tooltip in the FSRS simulation # diagram (Deck options -> FSRS) shows the total number of # cards that can be recalled or retrieved on a specific date. -statistics-memorized = {$memorized} memorized +statistics-memorized = {$memorized} cards memorized statistics-today-title = Today statistics-today-again-count = Again count: statistics-today-type-counts = Learn: { $learnCount }, Review: { $reviewCount }, Relearn: { $relearnCount }, Filtered: { $filteredCount } @@ -99,9 +99,9 @@ statistics-counts-relearning-cards = Relearning statistics-counts-title = Card Counts statistics-counts-separate-suspended-buried-cards = Separate suspended/buried cards -## Retention rate represents your actual retention rate from past reviews, in +## Retention represents your actual retention from past reviews, in ## comparison to the "desired retention" setting of FSRS, which forecasts -## future retention. Retention rate is the percentage of all reviewed cards +## future retention. Retention is the percentage of all reviewed cards ## that were marked as "Hard," "Good," or "Easy" within a specific time period. ## ## Most of these strings are used as column / row headings in a table. @@ -112,9 +112,9 @@ statistics-counts-separate-suspended-buried-cards = Separate suspended/buried ca ## N.B. Stats cards may be very small on mobile devices and when the Stats ## window is certain sizes. -statistics-true-retention-title = Retention rate +statistics-true-retention-title = Retention statistics-true-retention-subtitle = Pass rate of cards with an interval ≥ 1 day. -statistics-true-retention-tooltip = If you are using FSRS, your retention rate is expected to be close to your desired retention. Please keep in mind that data for a single day is noisy, so it's better to look at monthly data. +statistics-true-retention-tooltip = If you are using FSRS, your retention is expected to be close to your desired retention. Please keep in mind that data for a single day is noisy, so it's better to look at monthly data. statistics-true-retention-range = Range statistics-true-retention-pass = Pass statistics-true-retention-fail = Fail diff --git a/ftl/qt-repo b/ftl/qt-repo index a1134ab59..9aa63c335 160000 --- a/ftl/qt-repo +++ b/ftl/qt-repo @@ -1 +1 @@ -Subproject commit a1134ab59d3d23468af2968741aa1f21d16ff308 +Subproject commit 9aa63c335c61b30421d39cf43fd8e3975179059c diff --git a/proto/anki/scheduler.proto b/proto/anki/scheduler.proto index 01f092a39..1294b4543 100644 --- a/proto/anki/scheduler.proto +++ b/proto/anki/scheduler.proto @@ -404,6 +404,7 @@ message SimulateFsrsReviewRequest { repeated float easy_days_percentages = 10; deck_config.DeckConfig.Config.ReviewCardOrder review_order = 11; optional uint32 suspend_after_lapse_count = 12; + float historical_retention = 13; } message SimulateFsrsReviewResponse { diff --git a/pylib/pyproject.toml b/pylib/pyproject.toml index 23e10077f..fb7422694 100644 --- a/pylib/pyproject.toml +++ b/pylib/pyproject.toml @@ -7,7 +7,7 @@ dependencies = [ "decorator", "markdown", "orjson", - "protobuf>=4.21", + "protobuf>=6.0,<8.0", "requests[socks]", # remove after we update to min python 3.11+ "typing_extensions", diff --git a/qt/aqt/about.py b/qt/aqt/about.py index 228d3cfeb..03e989f2c 100644 --- a/qt/aqt/about.py +++ b/qt/aqt/about.py @@ -70,10 +70,10 @@ def show(mw: aqt.AnkiQt) -> QDialog: abouttext += f"

{lede}" abouttext += f"

{tr.about_anki_is_licensed_under_the_agpl3()}" abouttext += f"

{tr.about_version(val=version_with_build())}
" - abouttext += ("Python %s Qt %s PyQt %s
") % ( + abouttext += ("Python %s Qt %s Chromium %s
") % ( platform.python_version(), qVersion(), - PYQT_VERSION_STR, + (qWebEngineChromiumVersion() or "").split(".")[0], ) abouttext += ( without_unicode_isolation(tr.about_visit_website(val=aqt.appWebsite)) @@ -225,6 +225,7 @@ def show(mw: aqt.AnkiQt) -> QDialog: "Adnane Taghi", "Anon_0000", "Bilolbek Normuminov", + "Sagiv Marzini", ) ) diff --git a/qt/aqt/forms/preferences.ui b/qt/aqt/forms/preferences.ui index 807d4093c..0035e1f42 100644 --- a/qt/aqt/forms/preferences.ui +++ b/qt/aqt/forms/preferences.ui @@ -1292,9 +1292,10 @@ daily_backups weekly_backups monthly_backups - tabWidget syncAnkiHubLogout syncAnkiHubLogin + buttonBox + tabWidget diff --git a/qt/aqt/package.py b/qt/aqt/package.py index 968218741..c8d481312 100644 --- a/qt/aqt/package.py +++ b/qt/aqt/package.py @@ -124,17 +124,14 @@ def launcher_executable() -> str | None: def trigger_launcher_run() -> None: - """Bump the mtime on pyproject.toml in the local data directory to trigger an update on next run.""" + """Create a trigger file to request launcher UI on next run.""" try: root = launcher_root() if not root: return - pyproject_path = Path(root) / "pyproject.toml" - - if pyproject_path.exists(): - # Touch the file to update its mtime - pyproject_path.touch() + trigger_path = Path(root) / ".want-launcher" + trigger_path.touch() except Exception as e: print(e) diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index bd87ef830..afce6d489 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -82,11 +82,14 @@ class Preferences(QDialog): ) group = self.form.preferences_answer_keys group.setLayout(layout := QFormLayout()) + tab_widget: QWidget = self.form.url_schemes for ease, label in ease_labels: layout.addRow( label, line_edit := QLineEdit(self.mw.pm.get_answer_key(ease) or ""), ) + QWidget.setTabOrder(tab_widget, line_edit) + tab_widget = line_edit qconnect( line_edit.textChanged, functools.partial(self.mw.pm.set_answer_key, ease), diff --git a/qt/aqt/stylesheets.py b/qt/aqt/stylesheets.py index a262e18b9..6b4eff1f5 100644 --- a/qt/aqt/stylesheets.py +++ b/qt/aqt/stylesheets.py @@ -177,9 +177,13 @@ class CustomStyles: QPushButton:default {{ border: 1px solid {tm.var(colors.BORDER_FOCUS)}; }} + QPushButton {{ + margin: 1px; + }} QPushButton:focus {{ border: 2px solid {tm.var(colors.BORDER_FOCUS)}; outline: none; + margin: 0px; }} QPushButton:hover, QTabBar::tab:hover, diff --git a/qt/launcher/addon/__init__.py b/qt/launcher/addon/__init__.py index 63a2cc5a9..799406e86 100644 --- a/qt/launcher/addon/__init__.py +++ b/qt/launcher/addon/__init__.py @@ -69,17 +69,14 @@ def add_python_requirements(reqs: list[str]) -> tuple[bool, str]: def trigger_launcher_run() -> None: - """Bump the mtime on pyproject.toml in the local data directory to trigger an update on next run.""" + """Create a trigger file to request launcher UI on next run.""" try: root = launcher_root() if not root: return - pyproject_path = Path(root) / "pyproject.toml" - - if pyproject_path.exists(): - # Touch the file to update its mtime - pyproject_path.touch() + trigger_path = Path(root) / ".want-launcher" + trigger_path.touch() except Exception as e: print(e) diff --git a/qt/launcher/lin/build.sh b/qt/launcher/lin/build.sh index 7bd78c27d..f38f6defe 100755 --- a/qt/launcher/lin/build.sh +++ b/qt/launcher/lin/build.sh @@ -13,7 +13,8 @@ HOST_ARCH=$(uname -m) # Define output paths OUTPUT_DIR="../../../out/launcher" -LAUNCHER_DIR="$OUTPUT_DIR/anki-linux" +ANKI_VERSION=$(cat ../../../.version | tr -d '\n') +LAUNCHER_DIR="$OUTPUT_DIR/anki-launcher-$ANKI_VERSION-linux" # Clean existing output directory rm -rf "$LAUNCHER_DIR" @@ -77,8 +78,8 @@ chmod +x \ chmod -R a+r "$LAUNCHER_DIR" ZSTD="zstd -c --long -T0 -18" -TRANSFORM="s%^.%anki-linux%S" -TARBALL="$OUTPUT_DIR/anki-linux.tar.zst" +TRANSFORM="s%^.%anki-launcher-$ANKI_VERSION-linux%S" +TARBALL="$OUTPUT_DIR/anki-launcher-$ANKI_VERSION-linux.tar.zst" tar -I "$ZSTD" --transform "$TRANSFORM" -cf "$TARBALL" -C "$LAUNCHER_DIR" . diff --git a/qt/launcher/mac/Info.plist b/qt/launcher/mac/Info.plist index ac0ab2f09..a48960208 100644 --- a/qt/launcher/mac/Info.plist +++ b/qt/launcher/mac/Info.plist @@ -5,7 +5,7 @@ CFBundleDisplayName Anki CFBundleShortVersionString - 1.0 + ANKI_VERSION LSMinimumSystemVersion 12 LSApplicationCategoryType diff --git a/qt/launcher/mac/build.sh b/qt/launcher/mac/build.sh index 470b5cd25..d521e155b 100755 --- a/qt/launcher/mac/build.sh +++ b/qt/launcher/mac/build.sh @@ -31,7 +31,8 @@ lipo -create \ cp "$OUTPUT_DIR/uv" "$APP_LAUNCHER/Contents/MacOS/" # Copy support files -cp Info.plist "$APP_LAUNCHER/Contents/" +ANKI_VERSION=$(cat ../../../.version | tr -d '\n') +sed "s/ANKI_VERSION/$ANKI_VERSION/g" Info.plist > "$APP_LAUNCHER/Contents/Info.plist" cp icon/Assets.car "$APP_LAUNCHER/Contents/Resources/" cp ../pyproject.toml "$APP_LAUNCHER/Contents/Resources/" cp ../../../.python-version "$APP_LAUNCHER/Contents/Resources/" diff --git a/qt/launcher/mac/dmg/build.sh b/qt/launcher/mac/dmg/build.sh index 16b48c06a..7eeba9948 100755 --- a/qt/launcher/mac/dmg/build.sh +++ b/qt/launcher/mac/dmg/build.sh @@ -6,7 +6,8 @@ set -e # base folder with Anki.app in it output="$1" dist="$1/tmp" -dmg_path="$output/Anki.dmg" +ANKI_VERSION=$(cat ../../../.version | tr -d '\n') +dmg_path="$output/anki-launcher-$ANKI_VERSION-mac.dmg" if [ -d "/Volumes/Anki" ] then diff --git a/qt/launcher/src/bin/build_win.rs b/qt/launcher/src/bin/build_win.rs index 96688f190..4c2ca4413 100644 --- a/qt/launcher/src/bin/build_win.rs +++ b/qt/launcher/src/bin/build_win.rs @@ -22,6 +22,11 @@ const NSIS_PATH: &str = "C:\\Program Files (x86)\\NSIS\\makensis.exe"; fn main() -> Result<()> { println!("Building Windows launcher..."); + // Read version early so it can be used throughout the build process + let version = std::fs::read_to_string("../../../.version")? + .trim() + .to_string(); + let output_dir = PathBuf::from(OUTPUT_DIR); let launcher_exe_dir = PathBuf::from(LAUNCHER_EXE_DIR); let nsis_dir = PathBuf::from(NSIS_DIR); @@ -31,16 +36,20 @@ fn main() -> Result<()> { extract_nsis_plugins()?; copy_files(&output_dir)?; sign_binaries(&output_dir)?; - copy_nsis_files(&nsis_dir)?; + copy_nsis_files(&nsis_dir, &version)?; build_uninstaller(&output_dir, &nsis_dir)?; sign_file(&output_dir.join("uninstall.exe"))?; generate_install_manifest(&output_dir)?; build_installer(&output_dir, &nsis_dir)?; - sign_file(&PathBuf::from("../../../out/launcher_exe/anki-install.exe"))?; + + let installer_filename = format!("anki-launcher-{version}-windows.exe"); + let installer_path = PathBuf::from("../../../out/launcher_exe").join(&installer_filename); + + sign_file(&installer_path)?; println!("Build completed successfully!"); println!("Output directory: {}", output_dir.display()); - println!("Installer: ../../../out/launcher_exe/anki-install.exe"); + println!("Installer: ../../../out/launcher_exe/{installer_filename}"); Ok(()) } @@ -235,11 +244,13 @@ fn generate_install_manifest(output_dir: &Path) -> Result<()> { Ok(()) } -fn copy_nsis_files(nsis_dir: &Path) -> Result<()> { +fn copy_nsis_files(nsis_dir: &Path, version: &str) -> Result<()> { println!("Copying NSIS support files..."); - // Copy anki.template.nsi as anki.nsi - copy_file("anki.template.nsi", nsis_dir.join("anki.nsi"))?; + // Copy anki.template.nsi as anki.nsi and substitute version placeholders + let template_content = std::fs::read_to_string("anki.template.nsi")?; + let substituted_content = template_content.replace("ANKI_VERSION", version); + write_file(nsis_dir.join("anki.nsi"), substituted_content)?; // Copy fileassoc.nsh copy_file("fileassoc.nsh", nsis_dir.join("fileassoc.nsh"))?; diff --git a/qt/launcher/src/main.rs b/qt/launcher/src/main.rs index 5679f8f71..903cc2b60 100644 --- a/qt/launcher/src/main.rs +++ b/qt/launcher/src/main.rs @@ -46,6 +46,8 @@ struct State { dist_python_version_path: std::path::PathBuf, uv_lock_path: std::path::PathBuf, sync_complete_marker: std::path::PathBuf, + launcher_trigger_file: std::path::PathBuf, + pyproject_modified_by_user: bool, previous_version: Option, resources_dir: std::path::PathBuf, } @@ -70,7 +72,6 @@ pub enum MainMenuChoice { ToggleBetas, ToggleCache, Uninstall, - Quit, } fn main() { @@ -106,6 +107,8 @@ fn run() -> Result<()> { dist_python_version_path: resources_dir.join(".python-version"), uv_lock_path: uv_install_root.join("uv.lock"), sync_complete_marker: uv_install_root.join(".sync_complete"), + launcher_trigger_file: uv_install_root.join(".want-launcher"), + pyproject_modified_by_user: false, // calculated later previous_version: None, resources_dir, }; @@ -125,15 +128,15 @@ fn run() -> Result<()> { &state.user_python_version_path, )?; - let pyproject_has_changed = !state.sync_complete_marker.exists() || { - let pyproject_toml_time = modified_time(&state.user_pyproject_path)?; - let sync_complete_time = modified_time(&state.sync_complete_marker)?; - Ok::(pyproject_toml_time > sync_complete_time) - } - .unwrap_or(true); + let launcher_requested = state.launcher_trigger_file.exists(); - if !pyproject_has_changed { - // If venv is already up to date, launch Anki normally + // Calculate whether user has custom edits that need syncing + let pyproject_time = file_timestamp_secs(&state.user_pyproject_path); + let sync_time = file_timestamp_secs(&state.sync_complete_marker); + state.pyproject_modified_by_user = pyproject_time > sync_time; + let pyproject_has_changed = state.pyproject_modified_by_user; + if !launcher_requested && !pyproject_has_changed { + // If no launcher request and venv is already up to date, launch Anki normally let args: Vec = std::env::args().skip(1).collect(); let cmd = build_python_command(&state, &args)?; launch_anki_normally(cmd)?; @@ -143,6 +146,11 @@ fn run() -> Result<()> { // If we weren't in a terminal, respawn ourselves in one ensure_terminal_shown()?; + if launcher_requested { + // Remove the trigger file to make request ephemeral + let _ = remove_file(&state.launcher_trigger_file); + } + print!("\x1B[2J\x1B[H"); // Clear screen and move cursor to top println!("\x1B[1mAnki Launcher\x1B[0m\n"); @@ -190,6 +198,7 @@ fn extract_aqt_version( ) -> Option { let output = Command::new(uv_path) .current_dir(uv_install_root) + .env("VIRTUAL_ENV", uv_install_root.join(".venv")) .args(["pip", "show", "aqt"]) .output() .ok()?; @@ -255,29 +264,21 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re None }; - // `uv sync` sometimes does not pull in Python automatically - // This might be system/platform specific and/or a uv bug. + // Prepare to sync the venv let mut command = Command::new(&state.uv_path); - command - .current_dir(&state.uv_install_root) - .env("UV_CACHE_DIR", &state.uv_cache_dir) - .env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir) - .args(["python", "install", "--managed-python"]); + command.current_dir(&state.uv_install_root); - // Add python version if .python-version file exists - if let Some(version) = &python_version_trimmed { - command.args([version]); + // remove UV_* environment variables to avoid interference + for (key, _) in std::env::vars() { + if key.starts_with("UV_") || key == "VIRTUAL_ENV" { + command.env_remove(key); + } } - command.ensure_success().context("Python install failed")?; - - // Sync the venv - let mut command = Command::new(&state.uv_path); command - .current_dir(&state.uv_install_root) .env("UV_CACHE_DIR", &state.uv_cache_dir) .env("UV_PYTHON_INSTALL_DIR", &state.uv_python_install_dir) - .args(["sync", "--upgrade", "--managed-python"]); + .args(["sync", "--upgrade", "--managed-python", "--no-config"]); // Add python version if .python-version file exists if let Some(version) = &python_version_trimmed { @@ -321,9 +322,11 @@ fn main_menu_loop(state: &State) -> Result<()> { let menu_choice = get_main_menu_choice(state)?; match menu_choice { - MainMenuChoice::Quit => std::process::exit(0), MainMenuChoice::KeepExisting => { - // Skip sync, just launch existing installation + if state.pyproject_modified_by_user { + // User has custom edits, sync them + handle_version_install_or_update(state, MainMenuChoice::KeepExisting)?; + } break; } MainMenuChoice::ToggleBetas => { @@ -380,14 +383,28 @@ fn write_sync_marker(sync_complete_marker: &std::path::Path) -> Result<()> { Ok(()) } +/// Get mtime of provided file, or 0 if unavailable +fn file_timestamp_secs(path: &std::path::Path) -> i64 { + modified_time(path) + .map(|t| t.duration_since(UNIX_EPOCH).unwrap_or_default().as_secs() as i64) + .unwrap_or_default() +} + fn get_main_menu_choice(state: &State) -> Result { loop { println!("1) Latest Anki (press Enter)"); println!("2) Choose a version"); + if let Some(current_version) = &state.current_version { let normalized_current = normalize_version(current_version); - println!("3) Keep existing version ({normalized_current})"); + + if state.pyproject_modified_by_user { + println!("3) Sync project changes"); + } else { + println!("3) Keep existing version ({normalized_current})"); + } } + if let Some(prev_version) = &state.previous_version { if state.current_version.as_ref() != Some(prev_version) { let normalized_prev = normalize_version(prev_version); @@ -408,7 +425,6 @@ fn get_main_menu_choice(state: &State) -> Result { ); println!(); println!("7) Uninstall"); - println!("8) Quit"); print!("> "); let _ = stdout().flush(); @@ -448,7 +464,6 @@ fn get_main_menu_choice(state: &State) -> Result { "5" => MainMenuChoice::ToggleBetas, "6" => MainMenuChoice::ToggleCache, "7" => MainMenuChoice::Uninstall, - "8" => MainMenuChoice::Quit, _ => { println!("Invalid input. Please try again."); continue; @@ -706,9 +721,6 @@ fn update_pyproject_for_version(menu_choice: MainMenuChoice, state: &State) -> R MainMenuChoice::Version(version_kind) => { apply_version_kind(&version_kind, state)?; } - MainMenuChoice::Quit => { - std::process::exit(0); - } } Ok(()) } diff --git a/qt/launcher/src/platform/windows.rs b/qt/launcher/src/platform/windows.rs index 3c060a9de..ebdff6261 100644 --- a/qt/launcher/src/platform/windows.rs +++ b/qt/launcher/src/platform/windows.rs @@ -8,6 +8,7 @@ use anyhow::Context; use anyhow::Result; use widestring::u16cstr; use windows::core::PCWSTR; +use windows::Wdk::System::SystemServices::RtlGetVersion; use windows::Win32::System::Console::AttachConsole; use windows::Win32::System::Console::GetConsoleWindow; use windows::Win32::System::Console::ATTACH_PARENT_PROCESS; @@ -18,8 +19,25 @@ use windows::Win32::System::Registry::HKEY; use windows::Win32::System::Registry::HKEY_CURRENT_USER; use windows::Win32::System::Registry::KEY_READ; use windows::Win32::System::Registry::REG_SZ; +use windows::Win32::System::SystemInformation::OSVERSIONINFOW; use windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID; +/// Returns true if running on Windows 10 (not Windows 11) +fn is_windows_10() -> bool { + unsafe { + let mut info = OSVERSIONINFOW { + dwOSVersionInfoSize: std::mem::size_of::() as u32, + ..Default::default() + }; + if RtlGetVersion(&mut info).is_ok() { + // Windows 10 has build numbers < 22000, Windows 11 >= 22000 + info.dwBuildNumber < 22000 && info.dwMajorVersion == 10 + } else { + false + } + } +} + pub fn ensure_terminal_shown() -> Result<()> { unsafe { if !GetConsoleWindow().is_invalid() { @@ -29,6 +47,14 @@ pub fn ensure_terminal_shown() -> Result<()> { } if std::env::var("ANKI_IMPLICIT_CONSOLE").is_ok() && attach_to_parent_console() { + // This black magic triggers Windows to switch to the new + // ANSI-supporting console host, which is usually only available + // when the app is built with the console subsystem. + // Only needed on Windows 10, not Windows 11. + if is_windows_10() { + let _ = Command::new("cmd").args(["/C", ""]).status(); + } + // Successfully attached to parent console reconnect_stdio_to_console(); return Ok(()); diff --git a/qt/launcher/win/anki.template.nsi b/qt/launcher/win/anki.template.nsi index 84dedf9c8..36b32a893 100644 --- a/qt/launcher/win/anki.template.nsi +++ b/qt/launcher/win/anki.template.nsi @@ -24,7 +24,7 @@ Name "Anki" Unicode true ; The file to write (relative to nsis directory) -OutFile "..\launcher_exe\anki-install.exe" +OutFile "..\launcher_exe\anki-launcher-ANKI_VERSION-windows.exe" ; Non elevated RequestExecutionLevel user @@ -214,7 +214,7 @@ Section "" ; Write the uninstall keys for Windows WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "DisplayName" "Anki Launcher" - WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "DisplayVersion" "1.0.0" + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "DisplayVersion" "ANKI_VERSION" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "QuietUninstallString" '"$INSTDIR\uninstall.exe" /S' WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Anki" "NoModify" 1 diff --git a/qt/pyproject.toml b/qt/pyproject.toml index 8802d3025..c3876a75c 100644 --- a/qt/pyproject.toml +++ b/qt/pyproject.toml @@ -40,8 +40,8 @@ qt67 = [ qt = [ "pyqt6==6.9.1", "pyqt6-qt6==6.9.1", - "pyqt6-webengine==6.9.0", - "pyqt6-webengine-qt6==6.9.1", + "pyqt6-webengine==6.8.0", + "pyqt6-webengine-qt6==6.8.2", "pyqt6_sip==13.10.2", ] qt68 = [ diff --git a/rslib/src/scheduler/fsrs/memory_state.rs b/rslib/src/scheduler/fsrs/memory_state.rs index 425d8da69..b2640fa3e 100644 --- a/rslib/src/scheduler/fsrs/memory_state.rs +++ b/rslib/src/scheduler/fsrs/memory_state.rs @@ -377,6 +377,7 @@ pub(crate) fn fsrs_item_for_memory_state( Ok(None) } } else { + // no revlogs (new card or caused by ignore_revlogs_before or deleted revlogs) Ok(None) } } diff --git a/rslib/src/scheduler/fsrs/simulator.rs b/rslib/src/scheduler/fsrs/simulator.rs index 34cc925d6..e032ecaf3 100644 --- a/rslib/src/scheduler/fsrs/simulator.rs +++ b/rslib/src/scheduler/fsrs/simulator.rs @@ -10,11 +10,14 @@ use fsrs::simulate; use fsrs::PostSchedulingFn; use fsrs::ReviewPriorityFn; use fsrs::SimulatorConfig; +use fsrs::FSRS; use itertools::Itertools; use rand::rngs::StdRng; use rand::Rng; use crate::card::CardQueue; +use crate::card::CardType; +use crate::card::FsrsMemoryState; use crate::prelude::*; use crate::scheduler::states::fuzz::constrained_fuzz_bounds; use crate::scheduler::states::load_balancer::calculate_easy_days_modifiers; @@ -129,7 +132,7 @@ impl Collection { fn is_included_card(c: &Card) -> bool { c.queue != CardQueue::Suspended && c.queue != CardQueue::PreviewRepeat - && c.queue != CardQueue::New + && c.ctype != CardType::New } // calculate any missing memory state for c in &mut cards { @@ -143,13 +146,29 @@ impl Collection { let days_elapsed = self.timing_today().unwrap().days_elapsed as i32; let new_cards = cards .iter() - .filter(|c| c.memory_state.is_none() || c.queue == CardQueue::New) + .filter(|c| c.ctype == CardType::New && c.queue != CardQueue::Suspended) .count() + req.deck_size as usize; + let fsrs = FSRS::new(Some(&req.params))?; let mut converted_cards = cards .into_iter() .filter(is_included_card) - .filter_map(|c| Card::convert(c, days_elapsed)) + .filter_map(|c| { + let memory_state = match c.memory_state { + Some(state) => state, + // cards that lack memory states after compute_memory_state have no FSRS items, + // implying a truncated or ignored revlog + None => fsrs + .memory_state_from_sm2( + c.ease_factor(), + c.interval as f32, + req.historical_retention, + ) + .ok()? + .into(), + }; + Card::convert(c, days_elapsed, memory_state) + }) .collect_vec(); let introduced_today_count = self .search_cards(&format!("{} introduced:1", &req.search), SortMode::NoOrder)? @@ -251,39 +270,34 @@ impl Collection { } impl Card { - fn convert(card: Card, days_elapsed: i32) -> Option { - match card.memory_state { - Some(state) => match card.queue { - CardQueue::DayLearn | CardQueue::Review => { - let due = card.original_or_current_due(); - let relative_due = due - days_elapsed; - let last_date = (relative_due - card.interval as i32).min(0) as f32; - Some(fsrs::Card { - id: card.id.0, - difficulty: state.difficulty, - stability: state.stability, - last_date, - due: relative_due as f32, - interval: card.interval as f32, - lapses: card.lapses, - }) - } - CardQueue::New => None, - CardQueue::Learn | CardQueue::SchedBuried | CardQueue::UserBuried => { - Some(fsrs::Card { - id: card.id.0, - difficulty: state.difficulty, - stability: state.stability, - last_date: 0.0, - due: 0.0, - interval: card.interval as f32, - lapses: card.lapses, - }) - } - CardQueue::PreviewRepeat => None, - CardQueue::Suspended => None, - }, - None => None, + fn convert(card: Card, days_elapsed: i32, memory_state: FsrsMemoryState) -> Option { + match card.queue { + CardQueue::DayLearn | CardQueue::Review => { + let due = card.original_or_current_due(); + let relative_due = due - days_elapsed; + let last_date = (relative_due - card.interval as i32).min(0) as f32; + Some(fsrs::Card { + id: card.id.0, + difficulty: memory_state.difficulty, + stability: memory_state.stability, + last_date, + due: relative_due as f32, + interval: card.interval as f32, + lapses: card.lapses, + }) + } + CardQueue::New => None, + CardQueue::Learn | CardQueue::SchedBuried | CardQueue::UserBuried => Some(fsrs::Card { + id: card.id.0, + difficulty: memory_state.difficulty, + stability: memory_state.stability, + last_date: 0.0, + due: 0.0, + interval: card.interval as f32, + lapses: card.lapses, + }), + CardQueue::PreviewRepeat => None, + CardQueue::Suspended => None, } } } diff --git a/ts/lib/tslib/platform.ts b/ts/lib/tslib/platform.ts index 7aa5e137d..d055bcb53 100644 --- a/ts/lib/tslib/platform.ts +++ b/ts/lib/tslib/platform.ts @@ -13,3 +13,20 @@ export function isApplePlatform(): boolean { export function isDesktop(): boolean { return !(/iphone|ipad|ipod|android/i.test(window.navigator.userAgent)); } + +export function chromiumVersion(): number | null { + const userAgent = window.navigator.userAgent; + + // Check if it's a Chromium-based browser (Chrome, Edge, Opera, etc.) + // but exclude Safari which also contains "Chrome" in its user agent + if (userAgent.includes("Safari") && !userAgent.includes("Chrome")) { + return null; // Safari + } + + const chromeMatch = userAgent.match(/Chrome\/(\d+)/); + if (chromeMatch) { + return parseInt(chromeMatch[1], 10); + } + + return null; // Not a Chromium-based browser +} diff --git a/ts/routes/deck-options/EasyDaysInput.svelte b/ts/routes/deck-options/EasyDaysInput.svelte index fb5d9cd2d..c5fb4909a 100644 --- a/ts/routes/deck-options/EasyDaysInput.svelte +++ b/ts/routes/deck-options/EasyDaysInput.svelte @@ -85,6 +85,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } .easy-days-settings input[type="range"] { width: 100%; + cursor: pointer; } .day { diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 706407889..cfdea341c 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -95,6 +95,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html newCardsIgnoreReviewLimit: $newCardsIgnoreReviewLimit, easyDaysPercentages: $config.easyDaysPercentages, reviewOrder: $config.reviewOrder, + historicalRetention: $config.historicalRetention, }); const DESIRED_RETENTION_LOW_THRESHOLD = 0.8; diff --git a/ts/routes/editor/ClozeButtons.svelte b/ts/routes/editor/ClozeButtons.svelte index e9faae540..dfe4fb7c3 100644 --- a/ts/routes/editor/ClozeButtons.svelte +++ b/ts/routes/editor/ClozeButtons.svelte @@ -4,7 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -->