Commit Graph
11905 Commits
Author SHA1 Message Date
Mathews-Tom c1ea6ca7dc test: fix azure msg-id preservation and retry-diagnostics log shape
Second upstream merge (upstream/main advanced 24 more commits) pulled
in two independent behavior changes that broke tests I'd already
touched or that existed:

- packages/ai: commits cda6df81d/d7f070d44 added
  preserveAssistantMessageIds for Azure specifically (azure sets it
  true), so the earlier fix stripping msg ids in
  azure-openai-responses-stream.test.ts is now wrong for Azure — it
  should preserve them, unlike the plain OpenAI path. Restored the
  id/phase assertions and renamed both tests to describe the
  preserve-not-omit contract.

- packages/coding-agent: commit 0e2feab74 (refactor: reduced session
  log footprint) deleted the
  '#agentContinueState'/'agent.continue failed state after
  scheduling' debug diagnostics and changed
  'agent active context assistant removal' to fire only on a miss,
  renamed to 'agent active context assistant removal missed' with a
  smaller payload (no more removed/beforeLength/afterLength/etc).
  agent-session-retry-diagnostics.test.ts still asserted the old
  shape and waited on a debug call that no longer exists, so it hung
  for the full 5s timeout. Updated to match the new log name/payload
  and dropped the removed diagnostic assertion; the retry-recovery
  behavior itself is unchanged and still exercised end to end.
2026-07-02 06:46:17 +05:30
Mathews-Tom 4aac8640fa Merge remote-tracking branch 'upstream/main' into feat/error-notify
# Conflicts:
#	packages/coding-agent/src/eval/agent-bridge.ts
#	packages/coding-agent/test/interactive-mode-plan-review.test.ts
2026-07-02 06:20:42 +05:30
Mathews-Tom 9ce2bc6774 test(coding-agent): widen timeout for clone tests exercising real fs work
Both clone-path tests in git-subprocess-safety.test.ts await a real
async gap (fs.promises.mkdir before Bun.spawn is invoked) before
advancing fake timers, unlike the show/fetch variants that mock
Bun.spawn directly. Under GitHub Actions CI load this occasionally
exceeds Bun's default 5000ms per-test timeout even though the test
logic itself completes in milliseconds locally — observed twice in a
row on this PR's Linux CI runs with different underlying diffs, never
locally. Widen to 20000ms, matching the project's existing convention
for tests with a real async/IO dependency (e.g.
agent-session-python-cleanup.test.ts).
2026-07-02 06:17:05 +05:30
can1357 7e4d27a9e8 fix(coding-agent): fixed cross-file write batching regression in apply_patch
- Reverted to flushing only on the last file write or explicitly on early failure paths within `apply_patch` multi-file operations.
- Refactored error counting logic within single path entries to use clean booleans instead of numeric counters.
- Replaced custom preview capping logic in task progress rendering with `capPreviewLines` and added an option to hide the expand hint.
2026-07-02 02:46:55 +02:00
can1357 7a1e8fb087 feat(coding-agent/prompts): forbid testing defaults and allow skipping trivial tests
- Instructed the tester agent to never write assertions or tests for default values, configurations, or fallback properties.
- Allowed the tester agent to skip writing tests entirely if the changes are trivial, already covered, or if any new tests would be worthless.
- Required the deletion of existing default-testing assertions or entire tests when modifying code that currently contains them.
2026-07-02 02:40:34 +02:00
can1357 dbe232f643 refactor(tui): optimized render pipeline allocations and simplified input parsing
- Bypasses frame array allocation and merging during render except when hosted under ConPTY.
- Reuses the active window array slice for DECCARA calculations to avoid redundant array copies.
- Simplifies the `stdin-buffer` CSI sequence scanner by removing unnecessary resume search logic and redundant SGR mouse validation regexes.
2026-07-02 02:40:08 +02:00
can1357 e7be361148 fix(collab): isolated editor state to preserve draft input
- Extracted `AskEditor` into a standalone, key-bound component keyed by `reqId`.
- Preserved user-typed draft state across duplicate incoming host requests of the same ID.
- Reset the editor draft state only when a genuinely new request ID arrives.
- Simplified `Composer` autosizing logic and state orchestration by isolating editor-specific hooks.
- Adjusted integration tests to match HTML structure changes of the submit action.
2026-07-02 02:40:08 +02:00
can1357 ad4f82eb8f test(coding-agent): unified collab test infrastructure and refined guest ui dialog fallback
- Introduced the `CollabGuestUiResult` type to distinguish between answers and unavailable states during guest UI requests.
- Updated the remote dialog race logic to ignore unavailable guest results and fallback to the local host dialog.
- Centralized the `FakeWebSocket` and `InMemoryRelay` test infrastructure into a shared test helpers file.
- Cleaned up duplicate mock implementations and updated existing test suites to utilize the shared in-memory relay helpers.
2026-07-02 02:40:08 +02:00
can1357 0e2feab742 refactor(coding-agent): reduced session log footprint
- Projected full tool-call arguments down to a compact summary containing only `command` and `path`.
- Truncated summarized argument fields to 200 characters to prevent inflating session log sizes.
- Replaced routine clean session disposal warnings with debug logs to reduce noise.
- Streamlined debug context in assistant message removal and agent continuation skip paths.
- Extracted duplicate user-facing compaction warning strings into a helper function.
2026-07-02 02:40:08 +02:00
can1357 51684b4b1d refactor(coding-agent): streamlined codebase by deduplicating helper logic and shims
- Consolidated duplicated inline thinking level comparisons into a unified `concreteThinkingLevel` helper.
- Enhanced legacy tool shims to respect isolated session settings and support legacy options.
- Cleaned up redundant UI render requests and extra status-line updates.
- Refactored `grep` tool shim to configure context dynamically via isolated settings.
- Disabled platform-incompatible shell shim tests on Windows environments.
2026-07-02 02:40:08 +02:00
can1357 d84a54e579 fix(coding-agent): introduced a shutdown coordinator to manage background tasks
- Introduced `RpcShutdownCoordinator` to track background tasks and manage deferred shutdowns safely.
- Guaranteed all background bash task response frames are fully written before the process exits.
- Re-checked shutdown requests automatically as each tracked background task settles.
- Latched the shutdown sequence to prevent concurrent execution from duplicate triggers.
- Updated `mock-rpc-agent` to consume stdin via an async iterator to match standard behavior.
- Added comprehensive unit tests in `rpc-input-frame.test.ts` covering background task coordination.
2026-07-02 02:40:07 +02:00
can1357 1ded0d3759 fix(coding-agent): restricted key extraction to top-level json depth
- Introduced JSON depth tracking to ensure string keys are only extracted at the top level.
- Prevented nested keys matching designated streaming keys from being prematurely or incorrectly captured.
- Added comprehensive unit tests validating nested key exclusion and correct top-level extraction order.
2026-07-02 02:40:07 +02:00
can1357 2b8f6bd568 fix(coding-agent): prevented terminal layout breakage from long error strings
- Introduces `sanitizeErrorLine` to collapse newlines, replace tabs, and shorten absolute paths.
- Truncates remote error and notice text to the available terminal width to prevent layout breaking.
- Corrects a potential runtime exception in status-line by safely accessing JSON stringified length.
2026-07-02 02:40:07 +02:00
can1357 b6300cb07b fix(coding-agent): introduced overwrite options for file creation in patch edits
- Introduced the `allowCreateOverwrite` option to permit `op: "create"` to replace existing files.
- Enabled `allowCreateOverwrite` specifically for the JSON-based `patch` edit mode to support full-file restructures.
- Maintained the strict non-overwriting behavior for Codex `apply_patch` envelope-based file additions.
- Configured patch diff previews to respect the configured overwrite permission during streaming.
- Fixed an issue where stopping a multi-file patch application early skipped flushing the active LSP writethrough batch.
2026-07-02 02:40:07 +02:00
can1357 b4cb78304c feat(coding-agent): introduced configurable soft request budget steering notices
- Introduced the `task.softRequestBudgetNotice` boolean setting to opt into budget steering notices.
- Disabled the wrap-up steering notice by default when a subagent crosses its soft request budget.
- Maintained the 1.5x graceful abort safety guard regardless of whether the steering notice option is enabled.
- Updated the settings schema to document the conditional steering notice behavior.
2026-07-02 02:40:07 +02:00
can1357 36656766e4 fix(catalog): unified ssl fetch overrides under discoveryFetch
- Added `discoveryFetch` utility to wrap global fetch with `NODE_EXTRA_CA_CERTS` support.
- Consolidated SSL-stable fetch overrides across all catalog discovery models.
- Replaced direct `wrapFetchForExtraCa` calls with the unified `discoveryFetch` helper.
- Patched models.dev metadata and Ollama native probes to support private CA gateways.
2026-07-02 02:40:07 +02:00
can1357 d7f070d444 feat(ai): renamed openai compatibility flag and updated history rebuilding logic
- Renamed `requiresJuiceZeroHack` to `requiresReasoningSuppressionPrompt` across the catalog codebase.
- Dropped legacy non-msg string signature IDs during historical replay rebuilding when reasoning items are missing.
- Maintained legacy signature IDs in rebuilding fallback history when paired with matching reasoning items.
- Cleaned up obsolete GPT-5 reasoning-disable assertions from the test suite.
2026-07-02 02:40:07 +02:00
can1357 388534802c chore(repo): corrected invalid test script paths in ci configuration
- Replaced the non-existent `ci-test-ts.test.ts` with the active `link-omp.test.ts` in `package.json` and `ci-test-ts.ts`.
- Documented that the invalid test path was previously ignored silently by the bun test runner.
2026-07-02 02:40:07 +02:00
can1357 ec69edad5d refactor(natives): enabled disk logging for background task panics
- Downgraded `blocking_task_panic_scope` panics from silent to logged recoverable.
- Persists panic reports of caught worker task panics to the disk crash log while keeping stderr silent.
- Consolidated panic payload message extraction by reusing `crash_handler::panic_payload` in the task runner.
- Promoted the `SilenceHook` test helper to the shared testing module for use across multiple test suites.
2026-07-02 02:40:07 +02:00
Mathews-Tom 662d9138bc style(coding-agent): sort worktree test imports
Two independently-landed upstream fixes each added an import to this
file (utils/git, utils/jj); merged together they landed out of biome's
sort order. Fix with biome's organizeImports.
2026-07-02 06:02:26 +05:30
can1357 cd840303a1 fix(ai): formatted demoted thinking as italic prose for Claude Fable
- Avoid using `.
2026-07-02 02:30:43 +02:00
Mathews-Tom 906c81d4d4 Merge remote-tracking branch 'upstream/main' into feat/error-notify 2026-07-02 06:00:36 +05:30
Mathews-Tom db703d68a5 fix(coding-agent): omit outputSchemaOverridesAgent when eval agent() has no schema
Upstream commit 00ef58f84 set outputSchemaOverridesAgent unconditionally
to the structured boolean, so callers without a schema got false instead
of undefined, diverging from the existing outputSchema handling and
breaking the sibling test's undefined expectation.

Also update interactive-mode-plan-review.test.ts's in-overlay-edit case:
upstream commit 6cd93546c switched the plan-approved synthetic prompt to
reference the durable plan file instead of embedding plan content inline
(see plan-mode/approved-plan-prompt.test.ts), but missed updating this
duplicate scenario. Assert the prompt references the file path and that
the on-disk file carries the edit, matching the new contract.
2026-07-02 05:53:04 +05:30
can1357 e8a8c2402c fix(coding-agent): prevented asynchronous write races in plan reviews
- Ensures in-memory overlay edits are durably written to the plan file before proceeding with approval.
- Avoids asynchronous write races by awaiting the final plan file serialization.
- Aligns synthetic approved-plan prompts with reference-only expectations.
2026-07-02 02:19:26 +02:00
can1357 507328af36 fix(tui): implemented in-place viewport rewrites during overlay scrolling
- Rewrites viewport in-place rather than shifting native history when window position moves while overlays are visible.
- Prevents scrolling native terminal history during frozen commit tape states.
- Re-baselines terminal cursor safely to the top row using viewport-clamped cursor up sequences during virtual scroll rewrites.
- Syncs the internal window tracking row state and commits the redrawn frame on virtual scroll rewrites.
2026-07-02 02:18:54 +02:00
can1357 0da0d7d66c docs(natives): documented parallel execution behaviors and rayon pool bounds
- Documented the bounded Rayon global pool initialization and fallback behavior.
- Updated the `count_tokens` documentation to clarify parallel execution constraints when the global pool is unavailable.
2026-07-02 02:18:54 +02:00
can1357 237b672849 refactor(coding-agent): conditionalized output schema properties
- Conditionalized output schema properties using object spreading to avoid passing explicit undefined values.
2026-07-02 02:18:54 +02:00
can1357 cda6df81d6 feat(ai): enabled preservation of assistant message IDs for azure openai fallbacks
- Added `preserveAssistantMessageIds` option to response input building to retain original assistant message IDs.
- Enabled message ID preservation in `azure-openai-responses.ts` to prevent regeneration of message IDs during fallback replay.
2026-07-02 02:18:54 +02:00
can1357 db53707b8e Merge remote-tracking branch 'origin/farm/32976ff8/anthropic-fable-fallback' 2026-07-02 02:04:02 +02:00
can1357 0fb1dcbc1a Merge remote-tracking branch 'origin/farm/edc4af0a/markdown-edit-escape-prompt' 2026-07-02 02:03:01 +02:00
can1357 d6342cda94 Merge remote-tracking branch 'origin/farm/ed0f1c7d/fix-macos-image-command-v' 2026-07-02 02:02:42 +02:00
can1357 620304c070 Merge remote-tracking branch 'origin/farm/86d90585/fix-stash-pop-index-corruption' 2026-07-02 02:02:17 +02:00
Mathews-Tom 422588197a test(ai): align azure replay-history msg id expectations with upstream fix
Upstream commit 5244b8bdc (fix(ai): omitted stale responses replay
ids) updated the sibling openai-responses-history-payload.test.ts
expectations to drop synthetic msg_ ids from rebuilt fallback replay
history when no reasoning item is replayed, but missed the
duplicate scenario in azure-openai-responses-stream.test.ts. Both
tests exercise the same shared convertResponsesAssistantMessage
logic, so bring the Azure expectations and test title in line.
2026-07-02 05:22:45 +05:30
can1357 1b458f2e61 fix(coding-agent): preserved teardown exit reasons during session disposal
- Thread the postmortem reason through the session teardown pipeline to the session dispose process.
- Prevent generic "dispose" logs from overwriting real triggers like SIGTERM, SIGHUP, or uncaught exceptions.
- Ensure the first teardown trigger's reason is preserved when concurrent disposal calls occur.
- Add comprehensive test coverage verifying signal-specific reason mapping inside exit diagnostics.
- Fix a minor unhandled-exception test utility expectation in input controller tests.
2026-07-02 01:51:10 +02:00
can1357 ac9e85564f fix(coding-agent): resolved hashline snapshot tag collisions using exact matches
- Guard against 16-bit snapshot tag collisions by requiring live text to be byte-identical to the retained snapshot.
- Transition base text resolution to query exact matches via `snapshots.byHashExact`.
- Prevent applying incorrect preview edits when live file contents drift to a colliding state.
2026-07-02 01:51:10 +02:00
can1357 e12a8f161a fix(catalog): wrapped model discovery fetches to support extra ca certificates
- Wraps fallback fetch implementations with `wrapFetchForExtraCa` to respect `NODE_EXTRA_CA_CERTS`.
- Prevents `/models` probe failures behind private-CA gateways by aligning discovery with provider chat requests.
- Consolidates the `FetchImpl` type by re-exporting it from `@oh-my-pi/pi-utils`.
- Adds test cases verifying that fallback fetch operations load extra CA bundles.
2026-07-02 01:51:10 +02:00
can1357 978b950804 fix(coding-agent): resolved path resolution and fetch errors for fuzzy urls
- Fixed grep and ast-grep tools rejecting fuzzy url-shaped paths like schemeless www. or collapsed-scheme spellings.
- Applied the extra-CA wrapper to the model registry default fetch to respect the NODE_EXTRA_CA_CERTS environment variable.
- Moved isReadableUrlPath utility to path-utils to share recognition logic between reading and searching pipelines.
- Implemented a fallback that checks if a directory matching a fuzzy URL path exists locally before resolving it as an external URL.
- Added explicit errors for unsupported URL schemes to replace misleading local-path errors.
2026-07-02 01:51:09 +02:00
can1357 9a49612c27 fix(coding-agent): prevented concurrency permit leakage on cancelled queued jobs
- Implemented safe `releasePermit` helper to track whether a concurrency permit has been acquired before releasing.
- Guarded against double-releasing or releasing unacquired semaphore permits during queued job cancellation or abort events.
- Added comprehensive unit tests validating concurrency cap enforcement when queued jobs are cancelled.
2026-07-02 01:51:09 +02:00
can1357 efbdb23581 fix(coding-agent): enabled closed union validation for yield labels
- Extends output schema validation to support `oneOf` and `anyOf` closed union schemas.
- Prevents unknown section label submissions when all union variants constraint allowed properties.
- Permits arbitrary yield labels when at least one union variant remains open.
- Supports JTD discriminator output schemas by treating union constraints disjunctively.
2026-07-02 01:51:09 +02:00
can1357 22bfccfda8 fix(collab-web): terminated guest connections immediately on pre-welcome errors
- Prevents connection hangs during initial join by immediately failing when a host rejects a guest prior to welcome.
- Short-circuits the connection welcome timeout upon receiving a pre-welcome error frame.
- Surfaces exact protocol mismatch and hello rejection reasons directly to the joining guest interface.
- Ensures `CollabGuestLink` and `GuestClient` transition immediately to ended/failed states with host error details.
2026-07-02 01:51:09 +02:00
can1357 3ff65ead6b feat(wire): bumped collaborative protocol to version 3
- Bumped the collaborative protocol version (`COLLAB_PROTO`) from 2 to 3.
- Required protocol-3 to coordinate `ui-request`, `ui-request-end`, and `ui-response` frames.
- Rejected older protocol-2 guests at handshake to prevent host-asked requests from hanging.
- Updated verification tests and CI installation check scripts to expect protocol version 3.
2026-07-02 01:51:09 +02:00
can1357 d4182835dc fix(tui): bounded escape sequence scanning to chunk limits
- Replaced unbounded `String#indexOf` lookups with structured byte loops to enforce `MAX_STRING_SEQ_BYTES` cap.
- Stopped unterminated OSC, DCS, and APC sequences from scanning past their limits and blocking the event loop.
- Maintained a one-byte overlap when checking chunk boundaries to ensure split escape terminators are correctly reassembled.
- Added comprehensive unit tests covering split boundary terminators and oversized payload scenarios.
2026-07-02 01:51:09 +02:00
can1357 b821aa977e fix(hashline): introduced collision-safe tag lookup by exact hash
- Added `byHashExact` to `SnapshotStore` to resolve historical versions only when a tag is unambiguous.
- Prevented recovery and edit-preview paths from incorrectly applying anchors against colliding tags.
- Implemented `InMemorySnapshotStore.byHashExact` returning null when multiple recorded versions share a tag.
- Added comprehensive unit tests validating single-match resolution and multi-collider rejection.
2026-07-02 01:51:09 +02:00
can1357 f5d090829f refactor(hashline): optimized anchor validation and added collision safety
- Accelerates duplicate-line verification from quadratic $O(N^2)$ to linear $O(N \log N)$ by precomputing anchor neighbors in a single sorted pass.
- Optimizes duplicate checks to $O(1)$ by collecting line values into a pre-allocated Set instead of repeatedly searching arrays.
- Prevents silent content corruption by aborting recovery if multiple historical snapshots share the same 16-bit hash tag.
- Validates the optimized duplicate-line shifting behavior and collision rejection logic with new test coverage.
2026-07-02 01:51:09 +02:00
can1357 d5b26b6b97 build(utils): relocated tls-fetch utility to the utilities package
- Extracted the `tls-fetch` implementation and tests from `@oh-my-pi/pi-ai` to `@oh-my-pi/pi-utils`.
- Exported the `wrapFetchForExtraCa` and `withExtraCaFetch` utilities publicly from `@oh-my-pi/pi-utils`.
- Introduced `ExtraCaError` to replace the AI-specific `ValidationError` for missing `NODE_EXTRA_CA_CERTS` paths.
- Updated imports in `packages/ai/src/stream.ts` to consume the relocated utility.
2026-07-02 01:51:09 +02:00
roboomp 1bbd0c92f6 feat(anthropic): opt-in server-side fallback beta chain
Added AnthropicOptions.fallbacks + wire types + response parsing gated on the opt-in — server-side fallback stays fully inert on every request that does not set the option.

Coding-agent surfaces the feature via providers.anthropic.serverSideFallback (default off). When enabled, Fable/Mythos requests inject fallbacks: [{ model: claude-opus-4-8 }]; caller-supplied fallbacks always win.

transformMessages centrally strips persisted fallback blocks on cross-provider hops and non-official Anthropic replays so a stored fallback turn never wedges downstream converters. Retry resets restore output.model to the requested id.

Fixes #4177
2026-07-01 23:34:48 +00:00
Mathews-Tom 6637a5514a Merge remote-tracking branch 'upstream/main' into feat/error-notify 2026-07-02 04:55:51 +05:30
can1357 cc78244217 fix(coding-agent): shared streamed-arg decode across render paths
- Extracted decodeStreamedToolArgs into tool-args-reveal.ts and used it from both the live event path and transcript rebuilds, so mid-write theme/settings/focus replays no longer show stale streamed write/edit/eval content.
- Fixed the smoothing-off live path returning stale provider-parsed args.
- Documented the mandatory shared decode in the AGENTS.md streaming-preview hazard note; added changelog entries for this batch.
2026-07-02 01:03:48 +02:00
can1357 321e023d60 fix(collab-web): surfaced terminal transcript errors instead of hot-retrying
- fetchTranscript returns a typed rows/error union; terminal frame errors stop AgentDrawer polling and render below already-loaded rows via the extracted decideTranscriptPoll helper.
2026-07-02 00:33:05 +02:00
can1357 06df2d4f30 fix(collab): presented host ui requests in the tui guest
- CollabGuestLink now handles ui-request/ui-request-end frames via the existing hook selector/editor dialogs and round-trips ui-response; cancellation, resync replay, and read-only peers are handled.
2026-07-02 00:33:05 +02:00