Skip to content

templates/bill.html: кнопка Остановить расчет, серийный режим при ошибке, 3 попытки#16

Merged
ideav merged 2 commits into
ideav:mainfrom
konard:issue-15-1c553902286d
May 20, 2026
Merged

templates/bill.html: кнопка Остановить расчет, серийный режим при ошибке, 3 попытки#16
ideav merged 2 commits into
ideav:mainfrom
konard:issue-15-1c553902286d

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented May 20, 2026

Summary

Fixes #15

Three changes to templates/bill.html requested in the issue title:

  1. Кнопка «Остановить расчет» — adds a red outline button that appears
    while processArtists is running. Clicking it sets stopRequested = true,
    which short-circuits the parallel loop, the per-artist task, and any
    pending retry delay. The button hides automatically when processing
    finishes (success, stop, or critical error).
  2. Параллель не больше 1 запроса, пока есть ошибка — once any error is
    encountered, maxConcurrent drops to 1 and is not restored to its
    initial value (2) for the rest of the run, so every following request
    (retry or new artist) is serial while the system is unhealthy. The
    previous behavior (introduced in Fix: Issue #9 - Make maxConcurrent variable and restore after retry #10) restored concurrency after a single
    retry. processWithLimit now reads the current maxConcurrent on each
    iteration so the drop takes effect immediately for the next artist.
  3. 3 попытки перерасчета после ошибки — replaces the isRetry boolean
    with a retryCount counter. The function recurses with retryCount + 1
    up to maxRetries = 3, keeping the existing 5-second delay between
    attempts. After exhausting the 3 retries the error is propagated as
    before.

Changes

  • templates/bill.html:
    • New #stopBill link below the bill table.
    • New module-level stopRequested flag, reset to false at the start of
      each processArtists run.
    • processArtist(artist, retryCount = 0) with a 3-retry loop and stop
      checks before/after the retry delay.
    • maxConcurrent is forced to 1 on the first error of a run and stays at
      1; the post-retry restoration is removed.
    • processWithLimit reads the closure variable maxConcurrent per
      iteration instead of taking it as a parameter.
    • End-of-run code path handles the stopped, errored, and successful
      states and hides the Stop button in all of them.
  • experiments/test_issue15_logic.js: standalone Node script that asserts
    (a) up to 3 retries occur before an error is thrown, (b) maxConcurrent
    becomes 1 on the first failure and is never restored, and (c)
    stopRequested = true halts processing.

Test plan

  • node experiments/test_issue15_logic.js passes all 4 cases.
  • Manual smoke test on a live /bill page:
    • Click "Остановить расчет" while artists are processing — progress
      label switches to "Остановлено пользователем" and no more requests fire.
    • Trigger a failing request — the log shows three retries (1/3, 2/3, 3/3)
      with 5 s delays, then either succeeds or reports an error.
    • After any error, the parallelism stays at 1 for the rest of the run.

🤖 Generated with Claude Code

konard added 2 commits May 20, 2026 06:19
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: ideav#15
…v#15)

- Adds a "Остановить расчет" button that halts ongoing processing and
  is shown only while processArtists is running.
- After any error, maxConcurrent drops to 1 and is no longer restored to
  the initial value mid-run, so all subsequent and retry requests are
  serial while errors are occurring.
- After an error, up to 3 retry attempts are performed (was 1), each
  with the existing 5-second delay; retries also honor the stop flag.
- processWithLimit now reads the current maxConcurrent on each
  iteration so the post-error drop to 1 takes effect immediately.
@konard konard changed the title [WIP] templates/bill.html Сделать: кнопку Остановить расчет, Пока есть ошибка, а параллель выполнять не больше 1 запроса, после ошибки сделать 3 попытки перерасчета templates/bill.html: кнопка Остановить расчет, серийный режим при ошибке, 3 попытки May 20, 2026
@konard konard marked this pull request as ready for review May 20, 2026 06:24
@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 20, 2026

Working session summary

PR is ready for review.

Summary

Implemented the three requirements from issue #15 in templates/bill.html:

  1. «Остановить расчет» button — appears while processArtists runs, sets a stopRequested flag that halts the parallel loop, the per-artist task, and the retry sleep.
  2. maxConcurrent = 1 while errors persist — first error drops concurrency to 1 and keeps it there for the rest of the run (the post-retry restoration from Fix: Issue #9 - Make maxConcurrent variable and restore after retry #10 is removed). processWithLimit now reads the current maxConcurrent per iteration so the drop applies immediately to the next artist.
  3. 3 retry attemptsprocessArtist(artist, retryCount = 0) recurses up to maxRetries = 3 with the existing 5 s delay; only after exhausting retries does it throw.

Also added experiments/test_issue15_logic.js covering the retry count, the non-restoration of maxConcurrent, and the stop flag (all 4 cases pass).

PR is now ready for review: #16


This summary was automatically extracted from the AI working session output.

@ideav ideav merged commit 8e9dce5 into ideav:main May 20, 2026
@konard
Copy link
Copy Markdown
Contributor Author

konard commented May 20, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.885220

📊 Context and tokens usage:

  • 79.0K / 1M (8%) input tokens, 16.2K / 128K (13%) output tokens

Total: (4.3K new + 87.8K cache writes + 1.8M cache reads) input tokens, 16.2K output tokens, $1.885220 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.7 (claude-opus-4-7)

📎 Log file uploaded as Gist (1164KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants