Commit Graph

904 Commits

Author SHA1 Message Date
can1357 f10349a2f9 tweak(welcome): slim logo, diagonal gradient
- Trim logo from 14w to 12w (2-wide legs).
- Diagonal BL→TR gradient instead of per-line LTR.
- Truecolor: 3-stop magenta→violet→cyan path that skips the deep-blue valley.
- 256-color: same 6-stop ramp as fallback.
- Compute the colored logo once at module load instead of per render.
2026-05-10 04:53:53 +02:00
Can Bölük 3308fcbf03 Merge pull request #987 from apoc/feat/rpc-login-commands
feat(rpc): add get_login_providers and login commands
2026-05-10 04:52:52 +02:00
Can Bölük 7e106c2383 Merge pull request #971 from apoc/fix/anthropic-session-id-cloaking
fix(ai): stable metadata user_id per session to prevent session count inflation
2026-05-10 04:46:18 +02:00
Can Bölük c0990c9180 Merge pull request #979 from bjin/fix/plan-review-resubmit-rendering
fix(coding-agent): append plan review previews on resubmit
2026-05-10 04:45:51 +02:00
can1357 af8504d081 feat(coding-agent/modes): converted non-PNG tool images to PNG for Kitty terminal rendering
- Added asynchronous Kitty conversion for assistant tool images using `convertToPng`, keyed per tool-call entry with cached and in-flight tracking.
- Updated assistant image rendering to prefer converted PNGs for Kitty terminals while preserving existing behavior for other protocols.
- Added a unit test that verifies WebP tool images are converted and rendered as Kitty image output instead of the raw image/webp fallback.
2026-05-09 22:01:56 +02:00
Miroslav Drbal c68f90cc7d fix(rpc): give login() 10-minute client timeout vs 5-minute server window
The server-side OAuthCallbackFlow callback window is 300_000 ms, but the
client starts its #send timer before the RPC command is dispatched. By
the time the callback server actually starts, some time has already been
consumed on the client side. If the user takes the full callback window
plus token exchange, the client 300_000 ms timeout fires first, rejects
login(), cleans up the onOpenUrl listener, and the server response
arrives into a discarded pending entry.

Use 600_000 ms (10 min) on the client — double the server window. The
server will always return an error or success response within its own
window, so this timeout is purely a safety net against server crash or
connection loss and never fires during a normal login.
2026-05-09 20:15:24 +02:00
Miroslav Drbal ad1058772c fix(rpc): detect headless-incompatible providers at runtime
Replace the static RPC_LOGIN_PROVIDERS allowlist with runtime detection
based on callback ordering.

Providers that support headless login (OAuthCallbackFlow) always call
onAuth first (emit the browser URL), then onManualCodeInput only as a
fallback for manual redirect-URL entry. Providers that require interactive
input (API-key paste, device-flow prompts, GitHub Enterprise URL) call
onPrompt before any onAuth fires.

onPrompt now branches on authEmitted:
- false (onPrompt before onAuth): reject immediately with a clear 'not
  supported in RPC mode' error. The rejection propagates through
  authStorage.login and is caught by the try/catch, returning an error
  response. No deadlock.
- true (onPrompt after onAuth, inside OAuthCallbackFlow's fallback race):
  return a never-settling promise so the race defers to the callback
  server. A rejection here would be swallowed as null by .catch() and
  spin the while(true) loop.

New providers self-classify by their actual call order with no list to
maintain.
2026-05-09 19:07:26 +02:00
Miroslav Drbal 1152191297 fix(rpc): prevent onPrompt throw from spinning login retry loop
OAuthCallbackFlow.#waitForCallback races the browser callback against
onManualCodeInput and catches any rejection as null. When onPrompt
threw, the catch turned it into null, the while(true) loop saw a
falsy result, and immediately re-invoked onManualCodeInput — a tight
spin that starved the callback server and made browser-callback logins
hang until timeout even when the user completed auth successfully.

Replace the throw with a never-resolving Promise<string>. The race
then blocks waiting for the callback server to deliver the code,
with no busy-looping. When the server-side login eventually
times out or the browser callback arrives, the pending promise is
abandoned and GC'd.

Addresses: https://github.com/can1357/oh-my-pi/pull/987#discussion_r3213450206
2026-05-09 18:50:21 +02:00
Miroslav Drbal 3222952587 fix(rpc): extend login() timeout to 5 minutes
#send uses a hard-coded 30s timeout. OAuth flows require the user
to open a browser, authenticate with the provider, and wait for the
redirect — easily 1-3 minutes. Callers would see a spurious timeout
rejection while the server-side callback server was still live and
the user was still mid-flow.

Add optional timeoutMs parameter to #send (default 30_000, all
existing callers unaffected) and pass 300_000 from login().

Addresses: https://github.com/can1357/oh-my-pi/pull/987#discussion_r3213435093
2026-05-09 18:46:54 +02:00
Miroslav Drbal ae3aa36e3c fix(rpc): forward open_url events to RpcClient.login callers
RpcClient#handleLine was dropping extension_ui_request frames
(no isAgentEvent match → early return). Callers of login() had
no way to learn the auth URL, so the callback-server flow never
got a browser visit and the command hung until timeout.

- Add isRpcExtensionUiRequest type guard
- Add #extensionUiListeners set to RpcClient
- Dispatch extension_ui_request frames through that set in #handleLine
- login() accepts optional { onOpenUrl } callback; registers/
  deregisters a listener scoped to the command's lifetime

Addresses: https://github.com/can1357/oh-my-pi/pull/987#discussion_r3213428270
2026-05-09 18:32:18 +02:00
Miroslav Drbal 254739ce0e feat(rpc): add get_login_providers and login commands
- RpcCommand: add get_login_providers and login { providerId }
- RpcResponse: add typed responses for both commands
- RpcExtensionUIRequest: add open_url { url, instructions } event
  (fire-and-forget; host opens the URL in system browser)
- rpc-mode: handle get_login_providers (returns provider list with
  per-provider authenticated status) and login (drives authStorage.login
  using RpcExtensionUIContext for onPrompt dialogs and notify for
  onProgress; emits open_url for the auth page URL)
- rpc-client: add getLoginProviders() and login(providerId) methods
2026-05-09 18:28:00 +02:00
Miroslav Drbal fc70a45c46 fix(ai): stable metadata.user_id per session for Anthropic OAuth
Anthropic counts sessions by metadata.user_id. Without this fix, OMP
generated fresh random entropy on every API request, inflating the
session count and preventing backend attribution to the authenticated
account.

Changes:

packages/ai:
- resolveAnthropicMetadataUserId() now accepts JSON-format user_id
  matching real Claude Code's getAPIMetadata shape
  ({ session_id, account_uuid, ... }). Previously only the legacy
  cloaking format was accepted on OAuth, causing stable caller-supplied
  values to be silently discarded.
- AnthropicOAuthFlow.exchangeToken() and refreshAnthropicToken() now
  populate OAuthCredentials.{accountId, email} from the token response
  account block, removing the need for a separate /api/oauth/profile
  round-trip.
- AuthStorage.getOAuthAccountId(provider, sessionId) returns the OAuth
  accountId for the session-sticky credential, used to build
  account_uuid in metadata.user_id. Guards against misattribution for
  API-key, runtime-override, env-key, and fallback-resolver paths that
  do not record a session credential.

packages/agent:
- Agent.metadataForProvider(provider) resolves request metadata for
  the given provider via the installed resolver, or returns the static
  metadata value. The plain metadata getter now returns only the static
  value; provider-aware resolution is explicit.
- Agent.setMetadataResolver(fn) installs a (provider: string) resolver
  evaluated per LLM request in agent-loop, after getApiKey records the
  session-sticky credential, so account_uuid reflects the credential
  actually used.
- AgentLoopConfig.metadataResolver is called with config.model.provider
  after getApiKey, overriding the static metadata field.

packages/coding-agent:
- AgentSession.#syncAgentSessionId installs a metadata resolver that
  builds { user_id: JSON.stringify({ session_id, account_uuid? }) },
  matching the Anthropic session attribution format. account_uuid is
  only included for provider="anthropic" to avoid leaking the OAuth
  identity to third-party Anthropic-format-compatible providers.
- sessionId getter prefers providerSessionId when supplied via
  AgentSessionConfig so all API paths (getApiKey, direct calls,
  metadata resolver) share the same provider-facing session ID.
- prepareSimpleStreamOptions stamps session metadata on direct calls
  (runEphemeralTurn, compaction, branch summary, title generation) so
  they share the same session bucket as Agent.prompt requests.
- generateBranchSummary and generateSessionTitle accept a
  (provider: string) metadata resolver evaluated after their own
  getApiKey call for correct credential attribution.
2026-05-09 09:48:10 +02:00
can1357 e4b801590d refactor(coding-agent): tightened custom editor factory typing in interactive mode
- Updated ExtensionUIContext, InteractiveModeContext, and InteractiveMode to require editor factories to return CustomEditor instances.
- Removed the runtime compatibility guard and warning for non-CustomEditor implementations in setEditorComponent.
- Removed the test that verified rejection of non-CustomEditor factories in interactive-mode editor-component tests.
2026-05-09 07:03:37 +02:00
Can Bölük f9cc082ef2 Merge pull request #909 from quickserve-ai/fix/pi-vim-editor-component-hook
Fix ExtensionUIContext.setEditorComponent in interactive mode
2026-05-09 06:58:14 +02:00
Can Bölük abf13a8450 Merge pull request #964 from rburketaylor/fix-sync-slash-autocomplete
Fix sync slash autocomplete submission
2026-05-09 06:50:20 +02:00
Bin Jin 6218032820 fix(coding-agent): append plan review previews on resubmit
- Render each exit_plan_mode submission as a fresh plan review entry so refined plans are emitted into terminal scrollback.
- Keep external-editor edits replacing the current preview instead of adding duplicate review entries.
- Updated the plan review regression test to preserve the first preview and append the second one after intervening chat content.
2026-05-09 12:47:07 +08:00
can1357 1068612495 feat(ai): generic openai-compatible model discovery for custom providers
Add an explicit openai-models-list discovery type for custom providers while keeping lm-studio as a compatible alias. Custom providers can now point baseUrl at an OpenAI-compatible /v1 endpoint, provide an api key, and auto-populate models via GET {baseUrl}/models.

Discovered models merge cleanly with user-defined models from models.yml/models.json, so YAML entries still win for display name and token limits. The provider picker now explains when discovery succeeds but returns zero models, and when the configured /models endpoint responds with 404.

Fixes #970
2026-05-09 04:02:20 +02:00
can1357 7272907c33 fix(coding-agent): /mcp test enumerates connected servers
Interactive /mcp test only consulted getMCPConfigPath("user"|"project")
configs and missed servers defined in standalone .mcp.json. /mcp reauth
already resolved through #findConfiguredServer, which includes that
fallback path. Route /mcp test through the same resolver so both
commands enumerate the same set of servers.

Fixes #956
2026-05-09 03:11:19 +02:00
can1357 4cf6d9a274 fix(coding-agent): correct cache write/read icons
The custom status line rendered cache_read with the input icon and
cache_write with the output icon — backwards relative to Anthropic's
cache_creation_input_tokens (write) / cache_read_input_tokens (read)
semantics. Swap the icon pairings in status-line/segments.ts and the
labels in status-line-segment-editor.ts to match.

Fixes #953
2026-05-09 03:11:19 +02:00
can1357 9e8ad8148f feat: added hideThinkingSummary across stream, agent, session payloads
- Added hideThinkingSummary options across stream, agent, and session payload paths.
- Routed Coding-Agent hideThinkingBlock toggles to agent hideThinkingSummary during session updates.
- Updated OpenAI, Azure OpenAI, and Codex requests to omit reasoning.summary when hide/ summary is null.
- Reworked system-prompt preparation with per-step timeouts, fallback defaults, and step-level warnings.
2026-05-07 23:23:08 +02:00
Burke T eec0449997 Fix sync slash autocomplete submission 2026-05-07 15:06:39 -03:00
can1357 9943a280db feat(coding-agent): added /loop count/duration arg parsing and budgeting
- Added optional `/loop` `count|duration` command arguments and wired `command.args` into loop handling.
- Implemented `loop-limit` parsing and runtime types/helpers for iteration and duration budget limits with validation.
- Updated interactive mode to enforce loop limits per iteration, check duration expiry, and clear budget state on disable.
- Added loop-limit parse/runtime tests and fixed `/loop` arg errors plus macOS `MallocStackLogging` environment leakage.
2026-05-07 15:40:45 +02:00
can1357 052a8bd10c feat(coding-agent): added hashline section-diff API for external use
- Exported hashline section interfaces and helpers, including a new section-diff API for external callers.
- Refactored `computeHashlineDiff` to split input sections, propagate split errors, and delegate each section via helper.
- Added context-highlight caching and batched highlighting for unchanged lines, with `replaceTabs` fallback on unknown files.
- Fixed hashline streaming preview so completed sections stay visible when a new `@PATH` header appears mid-stream.
- Added hashline streaming tests for section persistence, malformed trailing `+ 7`, and dual sections.
2026-05-07 05:03:49 +02:00
can1357 0988ad2763 fix(ai): removed streaming throttles for immediate assistant delta delivery
- Removed delta-event throttling and merge logic so AssistantMessageEventStream now enqueues assistant deltas without batching.
- Stopped debouncing preview-diff generation in ToolExecutionComponent so apply_patch argument updates trigger immediate preview refresh.
- Added tests covering immediate delta queueing and confirming streaming arg updates no longer schedule setTimeout callbacks.
2026-05-06 21:42:10 +02:00
can1357 f4732522cd fix(interactive-mode): cleared spinner when extension command skips model turn
- Stopped the loading animation and cleared optimistic state in `finishPendingSubmission` when no streaming session was started. Fixes #927.
2026-05-06 20:32:07 +02:00
Can Bölük 26829c780a Merge pull request #934 from phanthh/feat/plan-mode-enabled-setting
feat: add plan.enabled setting to toggle plan mode
2026-05-06 18:54:32 +02:00
can1357 5aea7ee9e7 Fix extension dashboard shadowed toggle state 2026-05-06 18:16:02 +02:00
can1357 f2684b7a18 fix: harden plan enabled toggle 2026-05-06 18:16:01 +02:00
tycronk e17cced933 fix extension dashboard toggles 2026-05-06 18:08:53 +02:00
phanthh 1b5e1bc129 fix: address PR review comments for plan.enabled setting
- Move planModeEnabled check before plan.enabled guard so /plan can
  still exit an active session even if setting toggled off mid-session
- Clear stale plan/plan_paused mode_change entries when plan.enabled
  is off during session restore, preventing unexpected re-entry when
  the setting is later re-enabled
2026-05-06 18:08:49 +02:00
phanthh bd6113a01d feat 2026-05-06 18:08:49 +02:00
can1357 4e3ff73d89 feat(coding-agent): add approve and keep context plan option
Fixes #948
2026-05-06 17:13:11 +02:00
can1357 8c323666be feat: added ordered systemPrompt arrays and normalized context prompts
- Converted systemPrompt APIs and state types to ordered `string[]` across agent, AI, and coding-agent surfaces.
- Added `normalizeSystemPrompts` and applied it to context normalization before building provider request payloads.
- Updated AI providers to emit separate normalized prompt blocks/messages instead of a single merged system prompt.
- Removed dedicated `projectPrompt` state and remapped that context into system-context buckets in session, dump, and token accounting.
- Aligned tests and changelogs to pass and assert `systemPrompt` as arrays with ordered prompt semantics.
2026-05-04 15:20:26 +02:00
can1357 1cce2ee96b feat(coding-agent/edit): added opt-in setting for pure-insert hashline duplicate dropping
- Added a new `edit.hashlineAutoDropPureInsertDuplicates` boolean setting with default `false` for hashline edits.
- Threaded the setting through tool execution contexts so hashline previews and execution honor the configured option.
- Changed pure-insert duplicate boundary absorption to run only when enabled and added tests for default-disabled and enabled behavior.
2026-05-04 05:58:43 +02:00
can1357 a019994091 feat: added tree-sitter summarizeCode support and N-API summary exports
- Updated read schema, path utilities, and dispatch to parse selectors from :raw/:L suffixes on path, removing standalone sel usage.
- Changed truncation/error notices to continue with :<nextOffset> and :1 guidance for read and sqlite pagination.
- Added summarizeCode support with tree-sitter summaries, read.summarize settings, and N-API Summary types/exports.
- Added tests and docs updates for path-embedded selectors, summary behavior, and explicit raw/offset SQL/read cases.
2026-05-04 04:24:33 +02:00
can1357 c2a0253028 feat(coding-agent): added unsent editor draft persistence for resumed sessions
- Added session-draft persistence methods in SessionManager to write unsent editor text to an artifacts-sidecar draft file and delete it after single-shot consumption.
- Persisted editor text during interactive shutdown and restored that draft on resume when the editor was empty, enabling Ctrl+D draft recovery.
- Updated Ctrl+D handling in the editor/controller path and added tests covering draft round-trip, artifact cleanup, stale-draft eviction, and in-memory no-op behavior.
2026-05-04 02:20:29 +02:00
can1357 39f299ad40 refactor(coding-agent): extracted local-submission tracking into reusable helpers
- Added `recordLocalSubmission` and `withLocalSubmission` to replace inline signature set mutations across input and compaction flush paths.
- Signatures are now cleaned up automatically on delivery failure, preventing stale entries from suppressing editor-draft protection on retries.
- Extended test fixtures and added cases covering signature lifecycle for idle, streaming, and fire-and-forget submission paths.
2026-05-04 00:19:06 +02:00
can1357 0e761ef9e0 feat(coding-agent/hindsight): added per-session HindsightSessionState
- Added `HindsightSessionState` to `AgentSession` and bound hindsight lifecycle hooks to session state.
- Removed global hindsight state/queue handling and replaced it with per-session `HindsightRetainQueue` batching and scoped flushing.
- Reworked recall, reflect, and retain tools to use `session.getHindsightSessionState()` instead of sessionId-based lookup.
- Updated SDK/task/backend/controller flows to pass `session`/`parentHindsightSessionState`, scope `/memory` behavior, and document it in changelog.
2026-05-03 10:27:06 +02:00
can1357 255ef926cf feat(coding-agent): added /memory mm handlers for mental-model seeds
- Added mental-model settings and config defaults for enablement, auto-seed, refresh interval, and render budget.
- Added built-in mental-model seeds and scope-aware rendering with `<mental_models>` extraction, truncation, and tag handling.
- Added `/memory mm` aliases and handlers for list, show, refresh, history, seed, reload, and delete commands.
- Added client APIs and bootstrap/cache wiring so snippets refresh and inject into prompts on startup.
- Added tests covering seed scope behavior, rendering caps, diffs, and backend/session reload behavior.
2026-05-03 09:48:11 +02:00
can1357 51dc178be8 feat(hindsight): implemented per-session hindsight retain queue auto-flush
- Added per-session retain queues with size/time auto-flush, recursive drain, and lifecycle flushes on end/clear/enqueue.
- Changed `hindsight-retain` to validate session state, enqueue writes, and return `Memory queued.` immediately.
- Added `notice` event support and handlers that route error/warning/status messages with source-aware formatting.
- Updated client and tests with shared request mapping, `RequestOptions`, `buildMemoryItem`, and expanded batch/list/doc APIs.
2026-05-03 08:51:53 +02:00
can1357 067c8eb8f2 fix(coding-agent): unified plugin cache clearing and registry path resolution for plugin roots
- Replaced duplicated plugin-registry cache invalidation blocks with clearPluginRootsAndCaches in command and selector setup paths.
- Updated OMP plugin registry path resolution to use getPluginsDir for reads and cache invalidation, matching marketplace write locations.
- Removed a redundant project-scope marketplace test after centralizing cache-root invalidation logic.
2026-05-03 07:51:53 +02:00
can1357 e398f83163 fix(coding-agent): removed settings entries and derived submenu options
- Removed settings UI entries for `display.tabWidth`, `stt.language`, and similar values lacking valid `ui.options`.
- Refactored `pathToSettingDef()` in `settings-defs.ts` to derive submenu options directly from schema metadata.
- Introduced `SubmenuOption`/`AnyUiMetadata` in `settings-schema.ts` and added `options: "runtime"` support for dynamic lists.
2026-05-03 07:39:52 +02:00
can1357 0518955e0a ux(coding-agent/modes): removed token_total from default status-line preset
- Removed the token_total segment from the default status-line preset.
- Kept the remaining left-side segment order unchanged, including cost at the end.
2026-05-03 07:39:52 +02:00
can1357 76a02c385a feat(coding-agent): added hindsight scoping modes with bank scope tags
- Added `hindsight.scoping` and `HINDSIGHT_SCOPING` with global, per-project, and per-project-tagged modes.
- Migrated legacy `raw.hindsight` handling to scoping-based behavior and removed deprecated `dynamicBankId`/`agentName` keys.
- Replaced `deriveBankId` with `computeBankScope`, returning `bankId` plus optional retain/recall tags by mode.
- Forwarded scoped tags through memory ops so recall and retain/reflect calls use `tags`, `tagsMatch`, and `recallTags`.
- Validated `scoping` values from env/settings, warning and defaulting to `per-project-tagged` when invalid.
2026-05-03 07:39:52 +02:00
can1357 fea97766dd fix(coding-agent/modes): applied setting visibility conditions to all setting variants
- Refactored setting definitions so the optional visibility predicate now lives on the shared base interface.
- Updated path-to-def mapping to pass the shared condition through every setting variant.
- Adjusted SettingsSelectorComponent to evaluate condition for all setting types before rendering items.
2026-05-03 07:39:52 +02:00
can1357 ce2a109c09 feat(coding-agent): added hindsight memory backends and tools
- Added `memory.backend` and `hindsight.*` settings schema with migration from `memories.enabled` legacy mode.
- Added Hindsight memory backend runtime modules for resolved config, client creation, bank ID derivation, and state lifecycle.
- Added off/local/hindsight backends and resolver wiring across SDK, commands, and compaction context.
- Added `hindsight_recall`, `hindsight_reflect`, and `hindsight_retain` tools with schema validation and backend gating.
- Added Memory tab metadata and symbols to expose backend selection in the settings UI.
- Added package export barrels and tests for bank ID, content formatting, and hindsight config env precedence.
2026-05-03 07:39:52 +02:00
can1357 ee8b4ec252 fix(coding-agent): adjusted status-line session accent handling for border gaps
- Status-line rendering now treats `statusLine.sessionAccent` as disabled only when explicitly set to false.
- Updated status-line overflow tests to assert gap colors use session accent when enabled and theme border when disabled.
- Test teardown now restores `WSL_INTEROP` and `WSL_DISTRO_NAME` environment variables after mutation.
2026-05-03 04:59:43 +02:00
can1357 581148452c fix(coding-agent/modes): prevented status-line accent lookup before settings initialization
- Added an isSettingsInitialized helper to expose whether global settings were created.
- Updated interactive mode to use the session name when settings are not yet initialized.
- Guarded the status-line accent lookup behind settings initialization to avoid premature access.
2026-05-03 04:58:12 +02:00
can1357 a1a2331d5a fix(tui): avoided OSC 11 polling on Windows Subsystem for Linux
- Added WSL detection in terminal initialization and skipped periodic OSC 11 polling when running under Windows Subsystem for Linux.
- Removed mode 2031 activity tracking and stopped OSC 11 polling immediately when DA1/Mode 2031 reports were received.
- Extended OSC 11 appearance tests to restore platform/env state and verify no polling is started under WSL.

Fixes #914
2026-05-03 04:53:38 +02:00
can1357 24b150cf8e feat(coding-agent): added session accent toggle for status line and border colors
- Added a new boolean statusLine.sessionAccent setting to settings schema and propagated it through status-line preview, controller, and component setting updates.
- Updated status line rendering and interactive border coloring to disable session-based accent colors when the setting is false.
- Added a regression test verifying the status-line gap uses theme border color instead of session accent when session accents are disabled.

Fixes #918
2026-05-03 04:52:10 +02:00