Skip to content

Use structuredClone instead of remeda's clone#14351

Merged
thdxr merged 4 commits intoanomalyco:devfrom
mhart:mhart/fix-cloning-slowness
Feb 20, 2026
Merged

Use structuredClone instead of remeda's clone#14351
thdxr merged 4 commits intoanomalyco:devfrom
mhart:mhart/fix-cloning-slowness

Conversation

@mhart
Copy link
Contributor

@mhart mhart commented Feb 19, 2026

Avoids pathological cases when cloning large objects

Issue for this PR

Closes #14344

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Changes all clone usages to structuredClone. Don't know the codebase well enough to know if that's correct behaviour or not, but it works for me™

How did you verify your code works?

Haven't verified extensively, just tested that it gets past the errors seen in #14344 and continues to work otherwise

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Avoids pathological cases when cloning large objects

Fixes anomalyco#14344
@github-actions
Copy link
Contributor

Hey! Your PR title Use structuredClone instead of remeda's clone doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Related PR Found:

PR #6623: "refactor: use structuredClone instead of JSON parse/stringify"
#6623

This PR is related because it also involves refactoring to use structuredClone, though it specifically replaces JSON parse/stringify patterns rather than remeda's clone. Both PRs are moving toward using structuredClone for object cloning operations. You may want to check if #6623 is already merged and whether it addresses similar performance concerns.

@thdxr thdxr enabled auto-merge (squash) February 20, 2026 00:18
@thdxr thdxr merged commit f73698b into anomalyco:dev Feb 20, 2026
8 checks passed
rekram1-node pushed a commit that referenced this pull request Feb 20, 2026
Co-authored-by: Dax Raad <d@ironbay.co>
Co-authored-by: Dax <mail@thdxr.com>
lacymorrow added a commit to lacymorrow/lash that referenced this pull request Feb 22, 2026
* upstream/dev: (476 commits)
  release: v1.2.9
  fix: issue from structuredClone addition by using unwrap (anomalyco#14359)
  tweak(ui): adjust session feed spacing
  tweak(ui): tone down reasoning emphasis
  tweak(ui): refine session feed spacing
  fix(desktop): restore settings header mask
  tweak(ui): nudge edited files chevron
  tweak(ui): stabilize collapsible chevron hover
  fix: add missing id/sessionID/messageID to MCP tool attachments (anomalyco#14345)
  Use structuredClone instead of remeda's clone (anomalyco#14351)
  remove unnecessary deep clones from session loop and LLM stream (anomalyco#14354)
  fix(web): correct config import path in Korean enterprise docs
  docs: update providers layout and Windows sidebar label
  core: remove User-Agent header assertion from LLM test to fix failing test
  release: v1.2.8
  fix(app): black screen on launch with sidecar server
  chore: generate
  feat(opencode): support adaptive thinking for claude sonnet 4.6 (anomalyco#14283)
  feat(tui): add custom tool and mcp call responses visible and collapsable (anomalyco#10649)
  chore: cleanup
  ...

# Conflicts:
#	bun.lock
#	packages/app/package.json
#	packages/console/app/package.json
#	packages/console/core/package.json
#	packages/console/function/package.json
#	packages/console/mail/package.json
#	packages/desktop/package.json
#	packages/enterprise/package.json
#	packages/extensions/zed/extension.toml
#	packages/function/package.json
#	packages/opencode/package.json
#	packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
#	packages/opencode/src/cli/cmd/tui/routes/home.tsx
#	packages/opencode/src/config/config.ts
#	packages/opencode/src/tool/lsp.ts
#	packages/opencode/src/tool/read.ts
#	packages/plugin/package.json
#	packages/sdk/js/package.json
#	packages/slack/package.json
#	packages/ui/package.json
#	packages/util/package.json
#	packages/web/package.json
#	sdks/vscode/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web session freezes, unresponsive, opencode at 100% CPU

2 participants