Skip to content

feat(tui): add explicit next-turn follow-up submission - #992

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
loveRhythm1990:feat/tui-explicit-follow-ups
Oct 13, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
loveRhythm1990:feat/tui-explicit-follow-ups

Conversation

@loveRhythm1990

@loveRhythm1990 loveRhythm1990 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

During an active TUI turn, Enter can guide the current run, but users cannot explicitly select subsequent work while guidance is still admitted. Add Ctrl+Q to queue conversational input in the existing next-turn FIFO. The current run receives no guidance request for that input; subsequent Enter submissions can still guide it.

The shortcut operates only in the composer. Idle submission and local slash/shell controls use the ordinary dispatcher, and Shift+Enter/Alt+Enter keep their newline behavior. Reuse queue previews and add a local enqueue acknowledgement, /help keys guidance, and public/design documentation.

The lockfile also upgrades quinn-proto from 0.11.15 to 0.11.18, plus its required RNG dependency changes, to resolve RUSTSEC-2026-0338 through RUSTSEC-2026-0342. The initial CI run passed Clippy, formatting, and functional gates but failed dependency audit; the upstream main lockfile reproduces all five findings. Audit policy is unchanged.

Related issue

Closes #990 (the recommended TUI milestone). The queue remains process-local; durable API delivery, queue editing, and persistence across client restart are separate extensions.

Change type

  • Feature
  • Bug fix
  • Documentation
  • Refactor or performance improvement
  • Test
  • Build, CI, or maintenance

User and compatibility impact

  • Ctrl+Q queues conversational input while the foreground turn still owns execution, including startup, tool execution, guidance submission, and post-output settlement. When idle it submits normally.
  • Enqueueing does not arm the pre-bind ordering latch or close guidance admission. Enter retains its current routing and fallback behavior.
  • Existing FIFO, settlement, modal/draft, session-change, and recovery rules determine release. Failed/interrupted/not-started turns restore local input; server-owned guidance is never converted into a duplicate next turn.
  • The action is not global: focused views and ask_user retain their keys, approvals are not resolved, and incomplete paste bursts remain in the composer.
  • No configuration or API migration. This adds an available shortcut without changing either existing newline binding.

Architecture and complexity delta

  • Canonical owner changed or extended: composer action routing and the TUI's existing client-owned next-turn queue/handoff. The active turn loop, rather than the UI Busy/Idle indicator, determines whether explicit input must wait.
  • Existing implementations and callers searched: BottomPane::handle_key, queue_next_turn_submission, admit_idle_followup, settlement and modal/session release gates, pre-bind deferral, guidance custody/reconciliation, and local control dispatch.
  • Superseded code, states, tables, shims, or self-only tests removed: replace the misleading comment that any queued input changes Enter routing; no lifecycle/storage state was added or retired.
  • If parallel implementations remain, their boundary and retirement condition: no parallel queue, scheduler, or state machine. UserIntentDelivery, Server run admission, execution-slot fencing, cancellation, and provider/permission contracts are unchanged.

Verification

  • Commands and results:
    • CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib explicit_followup -- --test-threads=2: 13 passed, including a fresh run after the lockfile upgrade.
    • CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib tui:: -- --test-threads=2: 1977 passed, 1 existing ignored, 0 failed (includes the 13 new regressions).
    • CARGO_INCREMENTAL=0 RUST_MIN_STACK=16777216 cargo test --locked -p astra-cli --lib cli::turn::local_run_control:: -- --test-threads=2: 11 passed.
    • CARGO_INCREMENTAL=0 cargo clippy --locked -p astra-cli --all-targets -- -D warnings: passed.
    • CARGO_INCREMENTAL=0 make lint: passed for the full default workspace and all targets after the lockfile update.
    • cargo audit --no-fetch (cargo-audit 0.22.2, RustSec database d5f46becf4d442d460e1fce5e12f2c0f00924868): passed, 0 vulnerabilities, with only existing informational warnings. The unchanged main lockfile reports all five quinn-proto vulnerabilities against the same database.
    • make format-check: passed.
    • python3 scripts/ci/validate_repository.py: passed.
    • git diff --check: passed.
  • GitHub Static Checks passed on fff52054de101fb08822b0d8781444cda19728da, including dependency audit: https://github.com/matrixorigin/Astra/actions/runs/38372414920
  • Public entrypoint exercised: Ctrl+Q and Enter through BottomPane::handle_key, then the production active-queue, settlement, ordinary replay, and handoff helpers. The broader TUI suite also exercises the existing terminal reader and workbench paths.
  • Unhappy paths exercised: pending remote guidance, delayed definitive guidance rejection preserving submission position, failed/interrupted/exiting/not-started turns, modal and ask_user focus, pending approval, session rebound, existing drafts, empty/whitespace input, pasted blobs, and incomplete paste bursts. Existing guidance/reconciliation tests remain passing.
  • Database verification: not applicable; no Server API, schema, query, transaction, or durable runtime contract changed. All added tests are deterministic and offline.

Final checklist

  • I added or updated tests at the layer that owns the behavior, or explained why no test is needed.
  • I updated public or design documentation for contract changes, or the change needs no documentation update.
  • I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

@loveRhythm1990 loveRhythm1990 added the kind/feature New feature or request label Oct 13, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Deep review completed against ec3cc04d056da887732e64cc9cef4e5fecea6729 (base 2873a950f2c9fea00343757933e96070d1631596), including the latest slash-completion follow-up commit. No actionable findings.

The implementation keeps ownership in the existing TUI submission and handoff paths:

  • Explicit follow-ups enter the existing client-owned FIFO before guidance admission. They do not acquire remote guidance custody or arm the pre-bind deferral latch, so subsequent Enter submissions can still guide an admitting run.
  • The active event loop owns the routing decision, including startup, tool execution, in-flight guidance, and post-output settlement. It does not rely on the displayed Busy/Idle state.
  • Traced FIFO release, delayed guidance rejection placement, unsuccessful-settlement recovery, server-owned guidance exclusion, and modal/draft/session handoff gates. I found no newly introduced duplicate-submission or input-loss path.
  • Composer routing preserves modal/AskUser ownership, approval behavior, paste custody, and ordinary local slash/shell dispatch. In the latest commit, Ctrl+Q uses the highlighted slash completion, refreshes completion after flushing a due paste, and preserves arguments or unmatched drafts through the ordinary composer path. The new regression cases cover those boundaries and additional control modifiers.
  • The feature reuses the existing queue and scheduler. No new durable state, database operation, network request, or background task is introduced. The process-local lifetime is documented.

Validation: inspected source and regression tests and ran git diff --check. I previously verified the actual CI logs for fff52054: all 13 then-new explicit-follow-up tests passed; the shared CLI job reported 4,723 passed and 10 skipped; Static Checks, including dependency audit, passed. The latest ec3cc04d adds four keyboard regressions; its Test Suite is in progress and Static Checks are queued at submission time. Those earlier results are not being represented as validation of the latest commit. Rust tests were not rerun locally because this review environment has no Rust toolchain.

Approve from the code-review perspective; the latest commit's required CI checks still need to complete.

@mergify mergify Bot added the queued label Oct 13, 2026
@mergify

mergify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-13 10:02 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-10-13 10:03 UTC · at a41e48a4c6fe7b4e2c6bd0d734eef358860fb0e6 · squash

This pull request spent 18 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Check PR title
    • check-neutral = Check PR title
    • check-skipped = Check PR title
  • any of [🛡 GitHub branch protection]:
    • check-success = check
    • check-neutral = check
    • check-skipped = check
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-skipped = Test: core crates + bridge hooks
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-runtime
    • check-neutral = Test: astra-runtime
    • check-skipped = Test: astra-runtime
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-fs-tools)
    • check-neutral = Test: astra-cli (edge-fs-tools)
    • check-skipped = Test: astra-cli (edge-fs-tools)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-git-gix)
    • check-neutral = Test: astra-cli (edge-git-gix)
    • check-skipped = Test: astra-cli (edge-git-gix)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-rest)
    • check-neutral = Test: astra-cli (edge-rest)
    • check-skipped = Test: astra-cli (edge-rest)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-shell)
    • check-neutral = Test: astra-cli (edge-shell)
    • check-skipped = Test: astra-cli (edge-shell)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (non-edge)
    • check-neutral = Test: astra-cli (non-edge)
    • check-skipped = Test: astra-cli (non-edge)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (core)
    • check-neutral = Test: online (core)
    • check-skipped = Test: online (core)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (integration)
    • check-neutral = Test: online (integration)
    • check-skipped = Test: online (integration)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: turn-core + services + plan
    • check-neutral = Test: turn-core + services + plan
    • check-skipped = Test: turn-core + services + plan
  • any of [🛡 GitHub branch protection]:
    • check-skipped = web (typecheck, test, build)
    • check-neutral = web (typecheck, test, build)
    • check-success = web (typecheck, test, build)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Astra SDK (typecheck, test+coverage, build)
    • check-neutral = Astra SDK (typecheck, test+coverage, build)
    • check-success = Astra SDK (typecheck, test+coverage, build)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: macOS workspace coordination
    • check-neutral = Test: macOS workspace coordination
    • check-skipped = Test: macOS workspace coordination

@mergify
mergify Bot merged commit a41e48a into matrixorigin:main Oct 13, 2026
@mergify mergify Bot removed the queued label Oct 13, 2026
mergify Bot pushed a commit that referenced this pull request Oct 13, 2026
## Summary

Fix the Ask User / follow-up guidance lifecycle conflict reported in #985.

An exact live Ask User, approval or provider interaction can be superseded by newer durable guidance. Previously, interaction resolution recorded the superseded receipt but left the run in `waiting`. The executor then returned from the interaction and attempted to acknowledge guidance at its next action boundary; the database store rejected that acknowledgement because the run was not `running`, ending the turn with `contract_violation`.

Release that exact live wait in the existing resolution transaction while preserving its `superseded` receipt. Old answers/provider responses are not applied and old approvals are denied, even when their recorded decision was allow. The same owner can then acknowledge guidance before admitting its next fresh action. Also distinguish supersession from a late response or lost execution ownership in the existing runtime consumers and Edge approval sink.

Review follow-up `4edabe37` also classifies shared Edge approval receipts explicitly. A `superseded` receipt observed before the guidance poll wakes enters the existing supersession continuation, not `FailedClosed`. The recorded old decision is never replayed as approval; `authority_lost`, invalid decisions/kinds and mismatched request/tool identities remain rejected. Both the ordinary shared wait and the nested shared wait after a local callback hint use this classification.

## Related issue

Closes #985

## Change type

- [x] Bug fix
- [x] Test
- [x] Documentation
- [ ] Feature
- [ ] Refactor or performance improvement
- [ ] Build, CI, or maintenance

## User and compatibility impact

Waiting for Ask User and then sending follow-up guidance no longer leaves an already-resolved questionnaire blocking guidance acknowledgement. This requires a Server update; no CLI protocol, configuration or database schema changes are introduced.

The same exact-wait release rule applies to all three existing interaction kinds; the duplicated AskUser-only predicates are removed rather than introducing a separate policy mechanism. This does not broaden the database guidance-apply status guard, convert guidance into an answer/approval, or auto-resume a terminal, cancelled, stale-frontier or ownership-lost run. Existing HTTP superseded conflict codes remain unchanged.

## Architecture and complexity delta

- Canonical owner changed or extended: existing `resolve_run_interaction` implementations in the in-memory and database Run stores, plus the existing durable interaction consumers and Edge approval sink.
- Existing implementations and callers searched: interaction registration/wait/resolution, exact frontier/owner/lease validation, resolution receipts, projection/replay, guidance acknowledgement, and questionnaire/approval/provider tests.
- Superseded code, states, tables, shims, or self-only tests removed: none; the existing transaction and events are reused.
- If parallel implementations remain, their boundary and retirement condition: existing deterministic in-memory fixture and production database implementation retain the same interaction behavior; no new lifecycle implementation is added.

## Verification

- UT correction `3522749b` updates the sole failing runtime regression, `newer_guidance_fences_an_approved_stale_tool_before_execution`: the superseded exact wait must now be running with no waiting reason, while the old approval remains denied with a superseded receipt. The test additionally checks exactly one resume and idempotent durable guidance acknowledgement using the existing helper. Merge commit `b58267e9` includes upstream `main` at `a41e48a4` without conflicts, including the already-reviewed `quinn-proto 0.11.18` security fix from #992. Formatting, diff checks and repository metadata validation passed; source review covered this one changed test with no blocking findings. The focused local test is still compiling, so no passing result on this updated head is claimed. New CI must validate the merged head.
- Previous-head evidence (`4edabe37`): GitHub runtime execution ran 5914 tests, with 5913 passed and one failed due to the stale `waiting` expectation fixed above. The shared supersession race regression and authority-lost rejection regression passed. CI Clippy and formatting passed; Static Checks failed only at dependency audit on the old `quinn-proto 0.11.15`. Serial local Clippy also completed successfully. Upstream #992 security audit passed, but that is not a passing audit result for this new PR head.
- Review follow-up `4edabe37`: added `shared_superseded_approval_wins_before_guidance_poll_wakes`, with six paused-clock cases (local hint present/absent × old allow/deny/timeout); it exercises the reader/wait path rather than calling the settlement sink directly. Existing authority-lost denial rejection coverage is retained. Both regressions subsequently passed in CI as recorded above. The earlier local `cargo test --locked -p astra-runtime --lib shared_` was stopped during compilation under severe memory pressure; serial `CARGO_BUILD_JOBS=1 cargo clippy --locked -p astra-runtime --lib --tests -- -D warnings` later passed. This follow-up changes no database code/schema, and no new database verification is claimed.
- Commands and results: formatting and `git diff --check` passed. `cargo test --locked -p astra-services --lib runs::tests::`: 191 passed, 0 failed, 67 ignored. The MatrixOne-backed `database_superseded_interaction_releases_wait_for_guidance` regression passed (six cases across all three kinds), and `database_terminal_statuses_close_all_interactions_and_replay_authority_loss_on_matrixone` passed. `cargo clippy --locked -p astra-services -p astra-runtime --lib --tests -- -D warnings` passed, including runtime test type checking. The initial runtime test build and CI failed because the new test imported a nonexistent `RunControl` trait; follow-up commit `5e99ef9d` fixed that import. Full local runtime execution was stopped after excessive compilation time; runtime regression execution and broader gates must run in CI. No passing runtime execution is claimed.
- Public entrypoint exercised: production durable questionnaire gate and Run store registration/resolution/guidance APIs in targeted tests; no authenticated production interaction was replayed or mutated.
- Unhappy paths covered: guidance arriving after an exact interaction wait starts; approval/answer/provider-response and timeout supersession; callback replay; exactly-once guidance acknowledgement; admission of a fresh subsequent action. Runtime regressions cover Server and Edge approvals, provider submission and Ask User timeout, preserving rejection of old responses and ownership-lost waits.
- Database verification: targeted regression uses a dedicated disposable local MatrixOne database. No schema change. Existing owner/generation/lease/frontier checks and atomic status/event/session-slot update are retained.

## Final checklist

- [x] I added or updated tests at the layer that owns the behavior.
- [x] I updated design documentation for the lifecycle contract.
- [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
- [x] The PR title follows the repository's Conventional Commit format.


Approved-by: XuPeng-SH <[email protected]>
mergify Bot pushed a commit that referenced this pull request Oct 13, 2026
…ecall (#995)

## Summary

Session closure could purge working memories after its final snapshot read failed. Preserve typed read errors in the canonical snapshot loader and stop session-end governance before any subsequent write, purge or reflection when that read fails. Optional prompt/local-context consumers continue to treat failed reads as absent context.

Session-start profile/episode recall capped candidates before validating prompt eligibility. Apply the existing three-entry cap to admitted evidence instead, preserving ranking, type checks, deduplication and the shared interactive deadline.

## Related issue

Closes #994

## Change type

- [x] Bug fix
- [x] Documentation
- [x] Test

## User and compatibility impact

Working memories survive transient snapshot read failures, unavailable authorization and a memory-disable race during session closure. Successful empty reads retain existing cleanup behavior. Valid recall candidates remain usable when higher-scoring rows are malformed, inactive or inconsistent with their declared type. No public HTTP API, configuration, database schema, credentials or deployment changes.

## Architecture and complexity delta

- Canonical owner changed or extended: existing session-memory snapshot loader and session-end governance; existing typed prompt admission.
- Existing implementations and callers searched: optional remote/local snapshot consumers, session-close scheduling and debounce completion, scoped MemoriaPort reads, profile/episode recall and contract tests.
- Superseded code, states, tables, shims, or self-only tests removed: error-to-empty projection is removed from the shared snapshot boundary; optional consumers make that projection explicitly. Candidate truncation moves after canonical prompt validation.
- If parallel implementations remain, their boundary and retirement condition: none added.

## Verification

- `make format-check`: passed.
- `git diff --check`: passed.
- Independently compiled source-module memory-prefetch tests: 15 passed, including the new mixed-candidate regression.
- CI on memory-fix commit `431c30ef`: `Test: astra-runtime`, `Test: MOI fresh-Astra compatibility`, clippy and formatting passed. The previous local whole-runtime compilation was stopped after these CI checks completed.
- Rebased onto current `main` (`a41e48a4`), which includes the dependency security fix from #992. `git range-diff` confirms the Memoria patch is unchanged; this PR contains no `Cargo.lock` changes and no duplicate dependency commit.
- Security audit after rebasing (cargo-audit 0.22.2, current advisory database): passed with zero reported vulnerabilities; audit policy is unchanged.
- `cargo check --locked -p astra-core`: passed with the same lockfile now supplied by #992.
- `make format-check` and `git diff --check` passed after rebasing. CI is rerunning on the rebased Memoria-only branch; final results are pending.

- Public entrypoint exercised: `run_session_end_governance`, used by authenticated session closure, and `prefetch_session_start_memories_with_client`, used by first-turn context assembly.
- Unhappy paths exercised: failed snapshot transport, unavailable authority and disabled reads with both empty and nonempty session facts; mixed malformed/archived/type-mismatched/unranked recall candidates. Positive paths cover successful empty reads and existing snapshot consolidation, write failure retention, ranking and per-bucket bounds.
- Database verification: not applicable; no schema, query, transaction or database-routing changes. The regressions use deterministic MemoriaPort fixtures without live credentials or cluster mutation.

## Final checklist

- [x] I added or updated tests at the layer that owns the behavior.
- [x] I updated the memory design contract.
- [x] I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
- [x] The PR title follows the repository's Conventional Commit format.


Approved-by: XuPeng-SH <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Explicitly queue next-turn follow-ups separately from current-run guidance

2 participants