Skip to content

General stabilization - #33

Open
RaySinner wants to merge 140 commits into
JegernOUTT:mainfrom
RaySinner:main
Open

RaySinner wants to merge 140 commits into
JegernOUTT:mainfrom
RaySinner:main

Conversation

@RaySinner

Copy link
Copy Markdown

Overview

This PR introduces comprehensive stabilization fixes for the task agent lifecycle, spawning process, and status monitoring. It resolves race conditions during agent initialization and prevents premature card failures.

Key Improvements

  1. Agent Spawn Race Condition Fixes

    • Added SessionState::Starting across the API, TUI, and engine core.
    • Spawned agent sessions now correctly initialize in the Starting state.
    • Added strict validation to ensure the worktree directory physically exists on disk before the spawn tool returns.
    • Introduced a 180-second grace period in check_agents and wait_agents for fresh agents (covers None, Starting, and fresh Idle states), preventing false-positive stuck classifications immediately after spawning.
  2. Task Board Protections

    • Guarded board_delete and board_move operations against destroying or moving cards that have active or starting agents assigned to them. Requires explicit cancel_agent first.
  3. Agent Streaming Error Resiliency

    • Implemented an automatic retry loop for task agent streaming errors.
    • Added task_agent_max_retries (default: 3) to runtime settings and GUI.
    • Fixed a bug in check_for_stuck_agents where a single Error state from a stream failure would immediately and permanently mark a card as failed without respecting the retry logic.
  4. Tool Improvements

    • Added cat_line_ranges_enabled setting and GUI switch to control reading partial files.

Refact Agent and others added 30 commits September 15, 2026 16:55
Introduces the `Starting` variant to the `SessionState` enum to track
session initialization. Also includes unit tests for serialization
and deserialization of the new state.
Adds the new `Starting` state to the session state machine.
This introduces the corresponding UI feedback including a custom
status prompt, working indicator, icon (◆), and color (Cyan).
Also updates state parsing to accept "starting" string values.
Add SessionState::Starting to the queue busy check to prevent
processing conflicts during initial session setup. Update telemetry,
logging, and UI labels across the engine to recognize and display
the starting state.
…tree validation

Add validation for worktree existence before returning created instances.
Set session runtime state to Starting immediately during initialization.
Adjust queue processing logic to account for the Starting state when the command queue is empty to prevent blocking.
Handle `Starting` session state as `Running` during agent classification.
Implement a 180-second grace period for agents in "doing" state without an
active session to prevent false "stuck" detections in both check_agents and
wait_agents tools.
Adds new configuration field to control line ranges enablement for trajectory operations. Updates runtime settings structure and settings API handlers.
Adds a boolean toggle option for the "File and log reading" group in the
trajectory settings panel to control line range capabilities.
Add validation to reject line range arguments when the setting is disabled.
Update AGENT_EXPLORATION_INSTRUCTIONS to prefer full file reads.
Provide clearer feedback to users about available options when limits are reached.
Adds configuration for task agent retry limit with a default value of 3
and a validation range of 0 to 10. Includes runtime settings and API
exposure in trajectory settings.
Adds the `task_agent_max_retries` configuration option to the Chat limits
section of the TrajectorySettingsPanel. Default value is set to 3.
Updates test data to include the new field definition.
Adds retry_count field to BoardCard struct. Initialized to 0 in all card creation contexts (tests, API routers, Board tools).
Adds automatic retry logic when task agents encounter streaming errors.
The system tracks retry counts and limits based on max_retries setting.
Upon retrying, the session stream is cleared and a "Continue" command
is queued to resume the failed task.
Refactor `check_for_stuck_agents` to handle streaming errors differently based on task metadata availability. This prevents the card from immediately failing when metadata is missing, allowing the agent to retry and maintain its state. Update `retry_agent_session` to clear the error state before retrying.
Creates a single-line text artifact to confirm agent reached its worktree.
Add round 2 artifact for smoke test execution. Confirms agent worktree
reachability during live spawn/wait with session-state capture.
Update the `in_grace_period` function to match against `SessionState::Idle`
in addition to `None` and `Starting` states. This ensures Idle agents
with recent activity are treated as Running during the grace period
instead of immediately flagged as stuck.

Add tests to verify Idle agents remain Running while within the grace
period and are correctly classified as Stuck once it expires.
Invalidate thread.auto_compression_cap when model or context_tokens_cap
changes, unless the patch explicitly provides auto_compression_cap.
Set the pending flag and inject a null value into the sanitized patch.
Distinguish auto-set and explicit context caps when switching models.
Reset auto_compression_cap when model max changes; preserve explicit
user-set context_tokens_cap in middleware and reducer.
Add Model2 and TaskPlanner variants to ChatModelType, wire config-level
model overrides in resolve_model, and replace free-text input with a
dropdown in the SubagentForm GUI component.
Update version strings in BUILD.md, Gradle properties, VS Code package,
Rust engine Cargo files, and GUI package manifests. Add v8.6.5 release
notes documenting expanded subagent model-slot support.
Add Windows binary (refact.exe), compiled out/ artifacts, and updated
.gitignore/package-lock for release packaging. Points
refact-chat-js dependency to the packaged tarball.
Delete the Whisper transcription stack entirely: the refact-voice crate,
the /v1/voice/* HTTP routes, the transcription VoiceService held on
GlobalContext and ChatServices, the voice cargo feature, and the dangling
voice/stream SSE arm in the daemon proxy. Regenerate Cargo.lock so
whisper-rs, symphonia and rubato are no longer dependencies.

Buddy's voice_service is untouched: it is LLM text generation for mascot
lines, not speech recognition, and resolves through a different module and
type (crate::buddy::voice_service). CSS bubble styles named whisper,
the buddy_security_whisperer workflow, and the provider model-name filters
are likewise unrelated and unchanged.

Verified: cargo check --workspace exits 0; cargo tree -p refact-lsp shows
no whisper, symphonia or rubato.
Delete the microphone button, the three recording hooks and the
transcription API client, and strip the composer's voice wiring: the
microphone ref, live-transcript state, disable memo, Ctrl+Shift+Space
shortcut, transcript-aware displayed value and the read-only prop.
The composer now behaves exactly as it did before voice existed.

Also drop the now-dead /v1/voice/status MSW handlers from eight test
files plus the e2e showcase, and remove voice from the engine endpoint
segment allowlist in apiUrl.ts.

Buddy is untouched: its speech bubble UI and the whisper bubble styles
are text rendering, not speech recognition.

Verified on the merged tree: npm run types exits 0, eslint over the 13
changed files reports no errors or warnings with --max-warnings 0, and
ChatForm.test.tsx passes 20/20.
Builder and others added 30 commits October 12, 2026 21:42
- Assistant role mapped to theme accent slot 1 (--room-stripe-1 / soft indigo)
- Deduplicate badge & author name when identical or standard user/assistant
- Remove double borders and backgrounds on UserInput inside RoomAttributionFrame
- Increase left padding on RoomAttributionFrame to 18px matching tool cards
…er byline (T-9)

- Move copy, branch, delete, checkpoints and token/cost usage into RoomAttributionFrame byline
- Hover on card reveals action buttons smoothly alongside token stats and clock
- Remove empty bottom footer strips from UserInput and AssistantInput
- Add data-mirrored for user role messages
- Move stripe to the right edge and flip byline flow (USER pill on right)
- Set 24px conversation margin split: margin-left on user, margin-right on assistant/peers
- Revert user message frame mirroring and side margin offsets (restore uniform left stripe and full width)
- Bridge VS Code native CSS variables (--vscode-*) into Refact design tokens (--rf-*) in tokens.css and custom-theme.css
- Adapt chat background, foreground, borders, glass, and role stripes dynamically to the active VS Code color theme
…themes (T-12)

- Add universal ::selection styling in base.css
- Define --rf-selection-bg and --rf-selection-fg in tokens.css with tinted accent contrast
- Bridge --vscode-editor-selectionBackground with dark tint fallback in custom-theme.css
Remove the idle-or-error restriction for transform apply. The handler
now aborts active generation or tool execution, resets compaction and
provider state, and applies the transformation from any session state.
Expected trajectory version conflicts are still rejected.
Add transform error state to useTrajectoryOps and render it as an alert
in the trajectory popover when applying compression fails. Error messages
are cleared on chat changes and preview resets, and tests verify the
alert appears only after a failed apply.
Use notify_one instead of notify_waiters when background agent state
changes, so completion events release only the next waiting agent_wait.
Add a test verifying agent_wait unblocks when the agent completes
concurrently.
- strip_reasoning_from_prompt_effective() defaults to false (OFF)
- GUI selector selectStripReasoningFromPromptById defaults to false
- Fix typo: Resoning -> Reasoning in ChatSettingsDropdown
- When strip is active with OpenAI Responses API, skip tail optimization
  and previous_response_id chaining so full history is resubmitted
  without reasoning tokens (server-side context is invalidated)
- Update tests to reflect new default
- Allow foreignObject overflow so node labels are not cut off.
- Increase Mermaid flowchart padding to 24px.
- Await document.fonts.ready before rendering to stabilize text metrics.
- Add a CSS rule test.

Refs T-6
- Raise room-stripe border mix from 35% to 45%
- Add a 12% role-tinted background to improve frame contrast
- Use accent color for tool command names and muted color for
  file paths in Read, Search, and file operation cards.
- Brighten composer icon buttons and SVGs in VS Code dark to full
  foreground color for better readability.
Locale: pin number formatting to en-US in SummarizationMessage, formatters,
UsagePage, HealthTab, and ReconstructedHistory so separators do not follow
the host locale. Cap: only clear auto_compression_cap when it still equals
the previous model max. Fonts: skip MermaidBlock font wait in test env.
Dropdown: use findAllByRole for switch to avoid ambiguity.
…tyling

Update --rf-color-accent to use VS Code native variables for better
dark mode contrast. Fix composer button visibility by lifting top
controls to full-contrast foreground. Refine tool card colors by
applying muted color to filenames and paths, and accent color to
command names.
Add deterministic compaction fallback to handle context limit errors
when the LLM is unavailable. Increase default context window to
1,000,000 tokens. Improve error classification for rebuild failures.
Adds configuration options to control tool loop behavior and investigation budget limits. Includes parameters for max investigation tool calls per turn, hard stop on block, stagnation detection, and stagnation threshold.
…t in trajectory

Route interactive user messages in subagent views to the active runner via
the unified delivery system. Ensure messages are persisted into the session
trajectory by mirroring them in `drain_background_agent_inbox` and
`runner_model_turn`.
Add a "Tool loop & investigation limits" group to the trajectory
settings panel with toggles for loop guard, hard stop on block, and
stagnation detection, plus numeric thresholds including max
investigation tool calls per turn. Include tests for rendering the
group and saving edited values.
Introduce TurnInvestigationTracker in the tool loop guard as a
turn-scoped complement to the existing digest-based guard, stopping
agents that spend a whole turn on read-only investigation without
acting.

Per turn the tracker:
- counts consecutive investigation calls (cat, tree, glob, search_*,
  codegraph_*, web, knowledge, ...) and blocks further reads once
  max_investigation_tool_calls_per_turn is exhausted
- detects stagnation when the same tool target repeats past the
  configured threshold with no state mutation in between
- treats mutation tools (shell, apply_patch, textdocs, board_*,
  spawn_agent, ...) as progress, resetting the streak and the
  stagnation window
- hard-stops the rest of the batch when the base loop guard issues a
  Block and tool_loop_hard_stop_on_block is enabled

Checks run both before execution (blocking pending calls in the
current batch) and on result application; state resets at the turn
boundary via release_turn_only_state so every turn starts fresh.
Covered by new tracker and integration-path tests.
Resolve compile regressions after T-4 added `push` to
ChatCommand::UserMessage:
- add `push: _` to destructuring patterns in queue.rs and handlers.rs
- initialize `push: None` in test struct literals
- make user_message_with_client_message_id pub(crate) and import
  content helpers directly in handlers.rs

Refs T-4
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