Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: claude effort controls, ultrathink UI, and adapter robustness #1146

MergedJustYannicc(GitHub profile, opens in a new tab)merged 9 commits intocodething/648ca884-claude fromrefs/pull/1146/headmerged by juliusmarminge View on GitHub

What Changed

Claude Effort Controls & Ultrathink

  • Added ClaudeCodeEffort type with levels: low, medium, high, max, ultrathink
  • getEffectiveClaudeCodeEffort() maps effort levels to Claude SDK values
  • applyClaudePromptEffortPrefix() prepends "Ultrathink:" prefix to prompts
  • Generalized CodexTraitsPicker into a provider-aware traits picker with Claude effort labels
  • Ultrathink composer chrome: animated rainbow border, chroma pill badge, model picker glow effect

Adapter Robustness (Background Agents & Subagents)

  • Synthetic turn auto-start: Assistant messages arriving without an active turn (background agent/subagent responses between user prompts) now auto-start a synthetic turn so the response is visible in the UI
  • Stale turn cleanup: Auto-close orphaned synthetic turns in sendTurn to prevent session deadlock
  • Fragment leak prevention: Clear inFlightTools map in completeTurn to prevent stale JSON fragments from corrupting subsequent turns

Subagent Progress Surfacing

  • Claude task.progress events surface as activities with summary and lastToolName
  • collab_agent_tool_call classification for Agent/Task tools with "Subagent task" labels
  • Tests for tool classification and progress forwarding

Provider Health

  • Refreshed health check status probes with Fiber-based concurrent execution

Why

Background agent results, subagent responses, and tool call details were silently dropped because the adapter's turn state machine only handled user-initiated turns. When a background agent finished work and the lead generated a response, that response was invisible in the UI.

The effort controls bring feature parity with the Codex reasoning effort UI, adapted for Claude's effort model including the ultrathink mode.

UI Changes

  • Ultrathink mode shows an animated rainbow border around the composer and a chroma-animated "Ultrathink" pill badge
  • Effort dropdown shows Claude-specific labels (Low / Medium / High / Max / Ultrathink)
  • Provider model picker shows chroma animation when ultrathink is active

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • Type checks clean across web, server, and contracts
  • All 35 existing tests pass

Note

Add Claude effort controls and ultrathink UI to the chat composer

  • Adds ClaudeCodeEffort options (low, medium, high, max, ultrathink) to contracts and shared model utilities, with ultrathink mapping to max at runtime and prefixing outgoing prompts with 'Ultrathink:\n'.
  • The chat composer resolves effort per provider, dispatches modelOptions.claudeAgent.effort in turn payloads, and shows an animated 'Ultrathink' pill and rainbow frame when ultrathink is active.
  • ClaudeAdapter forwards effective effort into Claude SDK query options and auto-closes a stale active turn instead of returning a validation error when sendTurn is called.
  • ProviderCommandReactor restarts the Claude session when modelOptions change between turns, and carries cached model options forward on runtime-mode changes.
  • ProviderTraitsPicker replaces CodexTraitsPicker with a provider-agnostic picker that shows Fast Mode only for Codex and uses provider-specific effort labels.
  • Risk: default Claude effort changes from null to 'high'; existing sessions without a persisted effort will now send effort: 'high' to the Claude API.
Macroscope summarized 3e5371c.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 47233b76-5c43-4f45-849f-ab43bdcef837

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      📝 Coding Plan
      • Generate coding plan for human review comments

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/abb5d9c2737a41561b0feb379edbe1535d6da824/apps/server/src/provider/Layers/ProviderService.ts#L247

      In recoverSessionForThread, upsertSessionBinding is called at line 247 without passing persistedModelOptions and persistedProviderOptions, even though these values were extracted and used to start the session. After recovery, the runtime payload drops these options, so subsequent operations that read the persisted binding won't see the original model/provider configuration.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ProviderService.ts around line 247:
      
      In `recoverSessionForThread`, `upsertSessionBinding` is called at line 247 without passing `persistedModelOptions` and `persistedProviderOptions`, even though these values were extracted and used to start the session. After recovery, the runtime payload drops these options, so subsequent operations that read the persisted binding won't see the original model/provider configuration.
      
      Evidence trail:
      - apps/server/src/provider/Layers/ProviderService.ts lines 229-230 (REVIEWED_COMMIT): `persistedModelOptions` and `persistedProviderOptions` are extracted from `input.binding.runtimePayload`
      - apps/server/src/provider/Layers/ProviderService.ts lines 235-236 (REVIEWED_COMMIT): These values are passed to `adapter.startSession()`
      - apps/server/src/provider/Layers/ProviderService.ts line 247 (REVIEWED_COMMIT): `upsertSessionBinding(resumed, input.binding.threadId)` - called WITHOUT `extra` parameter
      - apps/server/src/provider/Layers/ProviderService.ts lines 162-174 (REVIEWED_COMMIT): `upsertSessionBinding` signature shows optional `extra` parameter with modelOptions/providerOptions
      - apps/server/src/provider/Layers/ProviderService.ts lines 89-101 (REVIEWED_COMMIT): `toRuntimePayloadFromSession` only includes modelOptions/providerOptions if provided in `extra` (lines 98-99)
      - apps/server/src/provider/Layers/ProviderService.ts lines 308-311 (REVIEWED_COMMIT): Correct usage in `startSession` passes the extra parameter
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High Layers/ClaudeCodeAdapter.ts:816

      In completeTurn, context.inFlightTools.clear() is called at line 818 before iterating over context.inFlightTools.entries() at line 843. Since the map is cleared first, the loop never executes and in-flight tools are silently dropped without emitting item.completed events. The clear() should be moved after the loop or removed, since the loop already deletes each tool after processing.

          const completeTurn = (
            context: ClaudeSessionContext,
            status: ProviderRuntimeTurnStatus,
            errorMessage?: string,
            result?: SDKResultMessage,
          ): Effect.Effect<void> =>
            Effect.gen(function* () {
      -        // Clear any stale in-flight tools from interrupted content blocks
      -        context.inFlightTools.clear();
               const turnState = context.turnState;
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file apps/server/src/provider/Layers/ClaudeCodeAdapter.ts around lines 816-826:
      
      In `completeTurn`, `context.inFlightTools.clear()` is called at line 818 before iterating over `context.inFlightTools.entries()` at line 843. Since the map is cleared first, the loop never executes and in-flight tools are silently dropped without emitting `item.completed` events. The `clear()` should be moved after the loop or removed, since the loop already deletes each tool after processing.
      
      Evidence trail:
      apps/server/src/provider/Layers/ClaudeCodeAdapter.ts lines 810-860 at REVIEWED_COMMIT: Line 818 shows `context.inFlightTools.clear();` and line 843 shows `for (const [index, tool] of context.inFlightTools.entries())`. No code between these lines repopulates the map, confirming the loop operates on an already-cleared map.
    5. had to do some sweeping changes to align with anthropic branding guidelines. can you resolve the conflicts?

    6. @juliusmarminge done. you should be able to merge it no problem now.

    7. juliusmarminge reviewed

      @@ -146,4 +146,4 @@
      146146 export const ClaudeAI: Icon = (props) => (
      147147 <svg {...props} preserveAspectRatio="xMidYMid" viewBox="0 0 256 257">
      148148 <path
      149- fill="#D97757"
      149+ fill="currentColor"
      juliusmarmingecommented

      why?

      the Claude icon needs to inherit Tailwind text color from the caller. Icons.tsx (line 146) so the styling in ProviderModelPicker.tsx (line 120) actually works, including the normal Claude orange and the ultrathink-chroma state. With a hardcoded fill, those classes were ignored.

      @@ -13,4 +13,3 @@
      1313 MenuTrigger,
      1414 } from "../ui/menu";
      1515
      16-export const CodexTraitsPicker = memo(function CodexTraitsPicker(props: {
      juliusmarmingecommented

      hmm not sure it's worth compacting these as one just yet... we don't really know what the future will look like so keeping them separate for now is the best. iirc i separated them when i had all codex/claude/cursor working because they had differernt enough logic to justify separate components instead of single component with switch statements internalyl

      the reason for the refactor is that ChatView only renders one traits-picker slot, and the current UI shape is still the same for both providers: one menu, one effort selector, plus Codex-only fast mode in the same surface. You can point at ChatView.tsx (line 3630) and CodexTraitsPicker.tsx (line 37).

      But if you want I can change the implementation to be less of an abstraction

      @@ -439,3 +439,4 @@
      439439 const TaskProgressPayload = Schema.Struct({
      440440 taskId: RuntimeTaskId,
      441441 description: TrimmedNonEmptyStringSchema,
      442+ summary: Schema.optional(TrimmedNonEmptyStringSchema),
      juliusmarmingecommented

      what does this cover that "description" doesn't? is it something claude specific? not opposed to keeping mostly curious

      description is the provider’s raw task label, while summary is an optional more user-facing progress line when the provider gives both. Claude does give both on task_progress; see ClaudeAdapter.ts (line 1698). The ingestion layer then prefers summary for the activity detail and falls back to description; see ProviderRuntimeIngestion.ts (line 363). it is an optional field that preserves richer provider data without overloading description.

    8. @juliusmarminge let me know if you have any other concerns.

    9. juliusmarminge merged thise6254a8

    10. juliusmarminge closed this

Sign in to join this conversation.