Skip to content

Consolidate duplicated kill-ring and timeout-race modules (CL-6790) - #608

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-6790-consolidate-duplicated-modules-two-kill-rings-two-repetition
Aug 24, 2026
Merged

Consolidate duplicated kill-ring and timeout-race modules (CL-6790)#608
TheGreatAxios merged 1 commit into
mainfrom
cl-6790-consolidate-duplicated-modules-two-kill-rings-two-repetition

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

CL-6790 dedup pass. Net line delta (excluding tests/docs): -119 lines (60 insertions, 179 deletions across non-test files).

Consolidated

  1. Kill rings — deleted src/tui/kill-ring.ts (the Ink-era copy) and its test. It had zero production callers; src/tui/prompt-kill-ring.ts (used by shell.ts) is the sole, more complete implementation (it also has the killedTextForward/killedTextBackward diff helpers the deleted copy lacked).
  2. OAuth helpers — already consolidated in this codebase: the Codex and xAI OAuth modules already import buildAuthorizeUrl/baseTokensFromResponse/exchangeCode/refreshTokenRequest from the generic src/auth/oauth/client.ts and only add provider-specific mapping. No changes needed.
  3. REASONING_EFFORTS — already consolidated: src/provider/reasoning-effort.ts re-exports the constant from src/agent/profile-types.ts. No changes needed.
  4. mapReactorLikeruntime-bridge.ts now re-exports mapReactorLike from stream-event-map.ts directly instead of wrapping it in an identical local function.
  5. Timeout race — extracted src/util/budget-race.ts (BUDGET_EXPIRED, budgetExpiry, withTimeout), consumed by both src/plugins/shell-guard-plugin.ts and src/tui/tool-execution-watchdog.ts, replacing two independent copies of the same AbortController+setTimeout race. Both now reference the shared TIMEOUT_PREFIX constant (exported from tool-time-budget.ts) instead of a hardcoded "[timed out before completing]" string.

Stopped / not touched

  • Atomic-write chain (item 6) — the low-level atomicWrite (mkdir + temp file + rename) is already shared: src/workflows/state.ts imports it from src/session/state.ts. The surrounding write-chaining wrapper genuinely differs in behavior between the two: session state's chain is keyed by sessionId, gates writes on isCrashed(), and deletes its map entry once the chain drains; workflow state's chain is keyed by path, has no crash gate, and never evicts entries (relying on flushWorkflowStateWrites for explicit awaiting). Forcing these into one helper would either add a crash gate to workflow writes or drop cleanup from session writes — both are behavior changes, so left as-is per the "stop and report" instruction.
  • detectRepetition (two copies) — explicitly out of scope per the ticket; a sibling lane (CL-6995) is removing repetition detection entirely. Not touched (src/subagent/repetition.ts, src/util/period-detection.ts, TUI stall watchdog repetition code all untouched).

Follow-up (not done in this pass)

  • A CI check that fails on duplicate exports was requested by the ticket but is out of scope for this pass.

Test plan

  • Targeted bun test runs across all touched modules pass.
  • bun run check (lint + typecheck + build + full test suite) passes: 5444 pass, 0 fail.
  • No changes under vendor/.

@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

CL-6790

@TheGreatAxios
TheGreatAxios enabled auto-merge (squash) August 24, 2026 06:48
@TheGreatAxios
TheGreatAxios force-pushed the cl-6790-consolidate-duplicated-modules-two-kill-rings-two-repetition branch from e2ce1ca to 5cc63ae Compare August 24, 2026 06:50
- Delete the dead Ink-era kill ring (src/tui/kill-ring.ts + test); the
  OpenTUI prompt-kill-ring.ts is the sole implementation.
- Extract shared timeout-race primitives (src/util/budget-race.ts) used
  by shell-guard's search budget and the tool-execution watchdog,
  replacing two copies of the same AbortController+setTimeout race and
  BUDGET_EXPIRED sentinel; both now reference the shared timeout-prefix
  string constant instead of a hardcoded literal.
- runtime-bridge.ts re-exports mapReactorLike from stream-event-map.ts
  instead of wrapping it in an identical local function.
@TheGreatAxios
TheGreatAxios force-pushed the cl-6790-consolidate-duplicated-modules-two-kill-rings-two-repetition branch from 5cc63ae to 8b2b221 Compare August 24, 2026 08:13
@TheGreatAxios
TheGreatAxios merged commit 5ee62cf into main Aug 24, 2026
5 checks passed
TheGreatAxios added a commit that referenced this pull request Aug 27, 2026
)

- Delete the dead Ink-era kill ring (src/tui/kill-ring.ts + test); the
  OpenTUI prompt-kill-ring.ts is the sole implementation.
- Extract shared timeout-race primitives (src/util/budget-race.ts) used
  by shell-guard's search budget and the tool-execution watchdog,
  replacing two copies of the same AbortController+setTimeout race and
  BUDGET_EXPIRED sentinel; both now reference the shared timeout-prefix
  string constant instead of a hardcoded literal.
- runtime-bridge.ts re-exports mapReactorLike from stream-event-map.ts
  instead of wrapping it in an identical local function.
TheGreatAxios added a commit that referenced this pull request Aug 27, 2026
)

- Delete the dead Ink-era kill ring (src/tui/kill-ring.ts + test); the
  OpenTUI prompt-kill-ring.ts is the sole implementation.
- Extract shared timeout-race primitives (src/util/budget-race.ts) used
  by shell-guard's search budget and the tool-execution watchdog,
  replacing two copies of the same AbortController+setTimeout race and
  BUDGET_EXPIRED sentinel; both now reference the shared timeout-prefix
  string constant instead of a hardcoded literal.
- runtime-bridge.ts re-exports mapReactorLike from stream-event-map.ts
  instead of wrapping it in an identical local function.
@TheGreatAxios
TheGreatAxios deleted the cl-6790-consolidate-duplicated-modules-two-kill-rings-two-repetition branch August 28, 2026 00:09
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