Skip to content

feat: Wordgun API v2 — новая модель и выбор сложности - #127

Merged
AnnaCodit merged 6 commits into
AnnaCodit:devfrom
Ars-Mond:wordgun-v2
Jul 29, 2026
Merged

feat: Wordgun API v2 — новая модель и выбор сложности#127
AnnaCodit merged 6 commits into
AnnaCodit:devfrom
Ars-Mond:wordgun-v2

Conversation

@Ars-Mond

@Ars-Mond Ars-Mond commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

✨Новое:

Игра на бэкенде wordgun.ru теперь создаётся через POST /v2/create_game на модели ru-context-v1, подсказки идут на POST /v2/hint.

В настройках появился выбор сложности: список тянется из GET /v2/list_model, значение сохраняется в localStorage и уезжает в ссылку для OBS параметром wg_difficulty. Пустое значение означает загадывание из всего словаря.

Поля «Источник слов» и «Сложность» перенесены в правую колонку настроек — сложность видна только при выбранном wordgun.ru.

Summary by CodeRabbit

  • New Features

    • Added a Wordgun-only “difficulty” selector to the settings panel, loaded dynamically and saved for future sessions.
    • OBS links now include the selected Wordgun difficulty when set.
    • Improved Wordgun game handling for model/difficulty selection and hint/score behavior.
  • Bug Fixes

    • Preserved the saved Wordgun difficulty if options can’t be loaded.
    • Improved user-facing handling of Wordgun/game errors so messages display more reliably.
  • UI/Style

    • Updated the error overlay with a smaller font and a close (“Закрыть”) button.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 938865d7-3e47-426b-9791-b43c32057ed7

📥 Commits

Reviewing files that changed from the base of the PR and between 97296f7 and 8dc3b02.

📒 Files selected for processing (4)
  • css/style.css
  • index.html
  • js/api.js
  • js/settings.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • index.html
  • js/api.js
  • js/settings.js

📝 Walkthrough

Walkthrough

Wordgun now uses versioned v1/v2 API endpoints, supports model and difficulty metadata, and exposes a lazily loaded difficulty setting. Selected difficulty values are persisted and included in generated OBS links, with dismissible fullscreen error messages.

Changes

Wordgun integration

Layer / File(s) Summary
Wordgun API flow
js/api.js, js/config.js
Wordgun game creation, guesses, hints, and metadata use versioned routes with model and difficulty support.
Difficulty settings contract
index.html, js/settings.js, js/init.js
The settings UI includes a Wordgun-only difficulty selector and initializes related option loading.
Difficulty loading and persistence
js/settings.js
Difficulty options load lazily, stored values remain selectable, settings are persisted, and generated links include wg_difficulty.
Wordgun error display
js/api.js, css/style.css
User-facing initialization errors are shown immediately, and the fullscreen error overlay includes a dismiss button with updated styling.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingsPanel
  participant wordgun_list_models
  participant WordgunAPI
  SettingsPanel->>wordgun_list_models: Load difficulty options when Wordgun settings open
  wordgun_list_models->>WordgunAPI: Request /v2/list_model
  WordgunAPI-->>wordgun_list_models: Return models and difficulties
  wordgun_list_models-->>SettingsPanel: Populate difficulty selector
  SettingsPanel->>SettingsPanel: Persist selection and update OBS link
Loading

Suggested reviewers: annacodit

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: Wordgun API v2 integration plus new model and difficulty selection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR migrates Wordgun game creation and hints to API v2 and adds configurable game difficulty.

  • Loads available difficulties lazily from Wordgun and preserves the selection in local storage.
  • Includes non-empty difficulty selections in generated OBS links.
  • Shows Wordgun-specific settings and handles unsupported saved difficulties with a dismissible error.

Confidence Score: 4/5

The PR appears safe to merge, with only the previously reported redundant concurrent model-list requests remaining.

The stale-difficulty behavior is fixed because a Wordgun OBS URL without wg_difficulty now clears the local value before game creation; however, overlapping option-loading calls can still issue duplicate requests because the loaded and API cache flags are populated only after awaiting the network response.

Files Needing Attention: js/settings.js, js/api.js

Important Files Changed

Filename Overview
js/api.js Migrates Wordgun creation and hint operations to v2, adds model discovery, and improves unsupported-difficulty error handling.
js/settings.js Adds difficulty loading, persistence, visibility, and OBS-link integration; the stale OBS difficulty behavior is corrected.
js/init.js Lazily loads Wordgun options when the settings panel is initially displayed.
js/config.js Defines the fixed Wordgun model and mutable difficulty setting.
index.html Adds the Wordgun difficulty control and reorganizes backend-specific settings.
css/style.css Adjusts error-overlay typography and styles its new close button.

Reviews (2): Last reviewed commit: "возможность сохранить форму при изменени..." | Re-trigger Greptile

Comment thread js/settings.js
Comment thread js/settings.js
@AnnaCodit
AnnaCodit changed the base branch from main to dev July 29, 2026 00:40
Не использовать сохраненную сложность, если она отсутствует в OBS-ссылке. Прерывать повторные запросы при unknown difficulty и показывать закрываемое сообщение с просьбой обновить настройки и ссылку OBS.
@AnnaCodit

Copy link
Copy Markdown
Owner

Пофиксила потенциальную ошибку при изменении списка сложностей на беке.
Названия сложностей надо выводить на русском. сейчас я захардкодила это, но по хорошему надо с бэка присылать ру-названия. не все люди знают английский =)
И баг что только лишь изменение сложности нельзя было сохранить.

@AnnaCodit
AnnaCodit merged commit c4f6f61 into AnnaCodit:dev Jul 29, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants