Skip to content

feat: кнопка Запустить с выводом stdout (P0.1) - #13

Merged
gon7187 merged 2 commits into
mainfrom
feat/run-button
Jul 28, 2026
Merged

feat: кнопка Запустить с выводом stdout (P0.1)#13
gon7187 merged 2 commits into
mainfrom
feat/run-button

Conversation

@gon7187

@gon7187 gon7187 commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Кнопка «▶ Запустить» + блок вывода stdout/stderr/timeout в редакторе кода. Backend: POST /api/code/run на существующем безопасном раннере без ослабления AST-фильтров. Тесты: 10 passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e082a5067

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/static/app.js Outdated
function showCodeOutput(questionId, result) {
const node = document.querySelector(`#output-${questionId}`);
if (!node) return;
node.textContent = result.timed_out ? 'Превышено время выполнения.' : result.error || result.stderr || result.stdout || 'Нет вывода.';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve stdout when execution also raises

When learner code prints output and then raises an exception, such as print('before'); 1 / 0, the endpoint returns both stdout and error, but this priority chain selects the error and discards everything printed before it. The new output pane therefore hides diagnostic output in precisely the failure cases where it is most useful; render stdout together with the error/stderr rather than selecting only the first nonempty field.

Useful? React with 👍 / 👎.

Comment thread app/evaluator.py
actual = eval(test['call'], namespace, namespace)
checks.append({'passed': actual == test['expected'], 'actual': repr(actual), 'expected': repr(test['expected'])})
print(json.dumps({'ok': all(item['passed'] for item in checks), 'checks': checks}, ensure_ascii=False))
print(json.dumps({'ok': all(item['passed'] for item in checks), 'checks': checks, 'stdout': output.getvalue()}, ensure_ascii=False))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape captured stdout before emitting runner JSON

When valid learner code prints a lone surrogate escape such as print('\ud800'), placing the raw captured value in an ensure_ascii=False JSON document makes the runner's final print raise UnicodeEncodeError; the exception handler then repeats the same failing serialization, and the parent reports a generic checker failure with no stdout. This also regresses ordinary code checks because raw stdout was not previously included in the payload; serialize with surrogate-safe escaping or sanitize the captured text.

Useful? React with 👍 / 👎.

@gon7187
gon7187 merged commit 10f3e2e into main Jul 28, 2026
2 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.

1 participant