Skip to content

bun-types: rename Bun.WebView back()/forward() to goBack()/goForward() - #30755

Closed
robobun wants to merge 2 commits into
mainfrom
farm/a450ade8/webview-goback-types
Closed

robobun wants to merge 2 commits into
mainfrom
farm/a450ade8/webview-goback-types

Conversation

@robobun

@robobun robobun commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #30754

What

Bun.WebView registers goBack / goForward on its prototype, but the
type declarations in @types/bun advertised them as back / forward.
Following the types got you TypeError: view.back is not a function at
runtime; calling the real view.goBack() got you a "property does not
exist" error in the IDE.

// From the issue.
await view.goBack();   // works at runtime, but IDE says 'does not exist'
await view.back();     // type-checks, throws TypeError at runtime

Cause

Method registration in src/runtime/webview/JSWebViewPrototype.cpp:

{ "goBack"_s,    ..., jsWebViewProtoFuncBack,    0 },
{ "goForward"_s, ..., jsWebViewProtoFuncForward, 0 },

All internal C++ code (WebViewHost::goBack, CDP::Ops::goBack,
WK::Ops::goBack) and existing tests (webview-chrome.test.ts) use
goBack/goForward. The .d.ts was the only place that deviated.

Fix

Rename the two methods in packages/bun-types/bun.d.ts to match the
runtime. This is a types-only change, no native behavior changes.

Verification

Adds test/integration/bun-types/fixture/webview.ts, which the bun-types
integration suite (test/integration/bun-types/bun-types.test.ts)
type-checks along with the other fixtures. It asserts goBack() /
goForward() resolve as Promise<void>, and marks back() / forward()
with @ts-expect-error so reintroducing either legacy name also fails.

Reverting the bun.d.ts rename makes the fixture fail to type-check
(goBack/goForward error with TS2551, and the @ts-expect-error
directives become unused, TS2578), so the suite turns red.

$ bun test test/integration/bun-types/bun-types.test.ts
12 pass, 0 fail

@robobun

robobun commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 1:24 PM PT - Jul 2nd, 2026

❌ @robobun, your commit 65caf03 has 1 failures in Build #68000 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 30755

That installs a local version of the PR into your bun-30755 executable, so you can run:

bun-30755 --bun

@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Bun.WebView session-history navigation methods back() and forward() are renamed to goBack() and goForward() in packages/bun-types/bun.d.ts. A new integration test verifies the updated typings via tsc, and the CI workflow is updated to run the new test file.

Changes

WebView Navigation API Rename

Layer / File(s) Summary
WebView navigation method signature update
packages/bun-types/bun.d.ts
back(): Promise<void> and forward(): Promise<void> are removed from Bun.WebView and replaced with goBack(): Promise<void> and goForward(): Promise<void>.
Integration test and CI wiring
test/integration/bun-types/webview-goback.test.ts, .github/workflows/bun-types.yml
Adds a typecheck integration test that symlinks the in-repo bun-types into a temp project, calls goBack()/goForward() normally, and marks back()/forward() calls with @ts-expect-error to assert they produce type errors; tsc is run with no-emit and the test asserts a clean exit and no error TS output. The CI workflow bun test command is extended to include this new test file.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: renaming WebView methods from back()/forward() to goBack()/goForward() in the type definitions.
Linked Issues check ✅ Passed The PR fully addresses issue #30754 by renaming methods in type declarations from back()/forward() to goBack()/goForward(), and adds test validation confirming the fix resolves the type-runtime mismatch.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the WebView API mismatch: updated type declarations, modified workflow test invocation, and added integration test validation—no unrelated changes.
Description check ✅ Passed The PR description explains the change and includes verification, covering the template's required intent despite using different section headings.

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — types-only rename matching the runtime's goBack/goForward, with a fixture to lock it in.

Extended reasoning...

Overview

This PR renames two method declarations in the Bun.WebView interface in packages/bun-types/bun.d.ts from back()/forward() to goBack()/goForward(), and adds a new type-fixture file test/integration/bun-types/fixture/webview.ts that asserts the corrected names type-check as Promise<void>.

Verification

I confirmed the runtime prototype table in src/runtime/webview/JSWebViewPrototype.cpp (lines 55-56) registers the JS-visible methods as "goBack"_s and "goForward"_s, and all backend code (JSWebView.cpp, ChromeBackend, WebKitBackend, WebViewHost) uses the same naming. The .d.ts was the only divergent location, so the rename is correct. The new fixture also references view.navigate() and view.reload(), both of which exist in the declaration file, and it uses the same expectType(...).is<...>() helper from ./utilities that other fixtures in the directory use.

Security risks

None. This is a pure ambient type-declaration change plus a compile-time-only test fixture (declare const view). No runtime code paths, auth, crypto, or I/O are touched.

Level of scrutiny

Low. The change is mechanical (two identifier renames in a .d.ts), self-contained, and directly verifiable against the C++ prototype registration. The added fixture is regression coverage that would fail the bun-types integration test if the names ever drift again.

Other factors

No bugs were reported by the bug-hunting system, there are no prior reviewer comments to address, and the PR timeline contains only the CI build notification. The fixture follows existing conventions in test/integration/bun-types/fixture/.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/integration/bun-types/bun-types.test.ts`:
- Around line 551-564: The test validates goBack() and goForward() return
Promise<void> but doesn't assert that the old names back() and forward() are
rejected, so reintroducing them wouldn't fail the test; update the test file
(the typeTest case for "goBack() and goForward() exist and return Promise<void>"
in webview-30754.ts) to add negative type assertions using `@ts-expect-error`
before calling view.back() and view.forward() to ensure those methods produce
type errors, leaving the existing expectType checks for view.goBack() and
view.goForward() unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3e6bbbc9-db81-4346-9480-80803fa9e56f

📥 Commits

Reviewing files that changed from the base of the PR and between 8e7defa and c24117e.

📒 Files selected for processing (1)
  • test/integration/bun-types/bun-types.test.ts

Comment thread test/integration/bun-types/bun-types.test.ts Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — types-only rename matching the runtime, with a regression test.

Extended reasoning...

Overview

This PR renames two method declarations on Bun.WebView in packages/bun-types/bun.d.ts from back()/forward() to goBack()/goForward(), and adds a typeTest block in test/integration/bun-types/bun-types.test.ts that pins the corrected names. I verified the runtime in src/runtime/webview/JSWebViewPrototype.cpp registers "goBack"/"goForward" on the prototype and that test/js/bun/webview/webview-chrome.test.ts already calls them, so the .d.ts was the only place out of sync.

Security risks

None. This is a pure TypeScript ambient declaration rename plus a type-level test fixture; no runtime code, auth, crypto, or I/O is touched.

Level of scrutiny

Low. The change is mechanical (two identifier renames in a .d.ts), self-contained, and the added test follows the exact typeTest pattern already used elsewhere in the same file (e.g., the bun:bundle feature() and Bunland JSX blocks), including the expectType(...).is<...>() helper and filtering diagnostics by file prefix.

Other factors

The robobun CI failures are all unrelated Rust lint/build issues (HiveArrayFallback deprecations, unused imports, unreachable pub items, musl build agent failure) in files this PR does not touch — a .d.ts/test-only change cannot cause those, so they are pre-existing on the base branch. No human reviewer comments are outstanding, and the bug-hunting system found no issues.

@deanrih

deanrih commented Jun 20, 2026

Copy link
Copy Markdown

just a follow up, will this be included in the next release?

@robobun

robobun commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator Author

Good question. One thing worth knowing in the meantime: the runtime already ships goBack() / goForward(), so await view.goBack() works today at runtime. This PR only corrects the TypeScript declarations, which were advertising back() / forward() (names that never existed at runtime). So if your editor flags view.goBack(), the call itself still runs fine.

The PR is open and waiting on a maintainer to review and merge. Once it lands, the corrected types go out with the next bun-types / @types/bun update that ships alongside a Bun release. I can't promise a specific version from here.

@robobun
robobun force-pushed the farm/a450ade8/webview-goback-types branch 2 times, most recently from 50ab9ee to 5dcb86e Compare June 20, 2026 13:42

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — types-only rename to match the runtime's goBack()/goForward(), with a regression type-test.

Extended reasoning...

Overview

This PR renames two method declarations on Bun.WebView in packages/bun-types/bun.d.ts from back()/forward() to goBack()/goForward(), and adds a typeTest case in test/integration/bun-types/bun-types.test.ts that pins the names (positive expectType checks plus @ts-expect-error on the legacy names). I verified against the runtime: src/runtime/webview/JSWebViewPrototype.cpp registers "goBack" and "goForward" on the prototype, so the .d.ts was the only place that disagreed. No native code changes.

Security risks

None. This is a pure TypeScript declaration rename plus a type-level test fixture. There is no runtime behavior change, no auth/crypto/permissions surface, and no data handling.

Level of scrutiny

Low. The change is mechanical (two identifiers renamed to match an already-shipping runtime API) and self-contained. The added test follows the established typeTest pattern used throughout the same file and filters diagnostics to its own fixture, so it cannot perturb other cases. The one Buildkite failure is in build-rust, which this PR does not touch and is unrelated to a .d.ts/test-only change.

Other factors

CodeRabbit's only suggestion (negative assertions via @ts-expect-error) was applied in 5dcb86e and the thread is resolved. No CODEOWNERS entry covers packages/bun-types or this test file. No prior review from me on this PR. The bug-hunting system found no issues.

@robobun
robobun force-pushed the farm/a450ade8/webview-goback-types branch 2 times, most recently from 14374c2 to 110cdf5 Compare June 20, 2026 14:05
Comment thread test/integration/bun-types/webview-goback.test.ts Outdated
Comment thread test/integration/bun-types/webview-goback.test.ts Outdated
@robobun
robobun force-pushed the farm/a450ade8/webview-goback-types branch 2 times, most recently from 207be72 to b070b10 Compare June 20, 2026 14:23
Comment thread test/integration/bun-types/webview-goback.test.ts Outdated
@alii

alii commented Jul 2, 2026

Copy link
Copy Markdown
Member

@robobun instead of test/integration/bun-types/webview-goback.test.ts, delete it and just update the bun-types integration test. ignore the gate failure

The runtime registers goBack/goForward on the WebView prototype
(src/runtime/webview/JSWebViewPrototype.cpp:55-56), but the type
declarations advertised back/forward. Users trusting the types hit
"TypeError: view.back is not a function" at runtime, while the actual
goBack() call reported a missing property in the IDE.

Fixes #30754
@robobun
robobun force-pushed the farm/a450ade8/webview-goback-types branch from eeb571b to 661743c Compare July 2, 2026 15:23
@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Done. Deleted test/integration/bun-types/webview-goback.test.ts (and reverted the bun-types.yml change that referenced it), and put the assertion in the bun-types integration test instead: a typeTest under Bun.WebView history navigation (#30754) that checks goBack()/goForward() resolve as Promise<void> and that back()/forward() are rejected.

Also rebased onto current main. bun test test/integration/bun-types/bun-types.test.ts passes (13/13), and reverting the bun.d.ts rename makes the new case fail (TS2551 + unused TS2578).

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the two-line .d.ts rename and the typeTest case both look correct; just re-sync the PR description's Verification section per the inline note before merge.

Extended reasoning...

Overview

This PR renames two method declarations in packages/bun-types/bun.d.ts (back()→goBack(), forward()→goForward()) so the published types match what Bun.WebView actually registers on its prototype in JSWebViewPrototype.cpp. It also adds a typeTest case to test/integration/bun-types/bun-types.test.ts that pins the new names via expectType(...).is<Promise<void>>() and rejects the legacy names via @ts-expect-error. Two files, ~30 lines total.

Security risks

None. This is a type-declaration-only change with no runtime code path, no native code, no I/O, no external input handling.

Level of scrutiny

Low. The .d.ts edit is a two-identifier rename whose correctness is verifiable by grepping the C++ prototype table cited in the description. The test addition is a copy of the established typeTest pattern used by the immediately preceding bun:bundle feature() block in the same file (same files: fixture shape, same expectedEmptyInterfacesWhenNoDOM, same diagnostics.filter(d => d.line?.startsWith(...)) → toEqual([]) assertion). No new mechanism, no new harness.

Other factors

A maintainer reviewed on 2026-07-02 and requested folding the standalone test into bun-types.test.ts; that was done exactly as asked, and the author confirmed the suite passes (13/13) and fails when the rename is reverted. All prior review threads (CodeRabbit's negative-assertion request, my earlier Windows-symlink / stderr / stale-description notes on the since-deleted standalone test) are resolved and no longer apply to the current diff.

The one remaining finding is a metadata nit: the PR description's Verification section still describes the deleted webview-goback.test.ts / workflow wiring rather than the current typeTest in bun-types.test.ts. That's flagged inline and is a description-only edit — it doesn't affect the correctness of what merges into the tree, so I'm approving the code while surfacing it.

Comment thread test/integration/bun-types/bun-types.test.ts Outdated
Comment thread test/integration/bun-types/bun-types.test.ts Outdated
Adds a bun-types fixture that the integration suite type-checks: it
asserts goBack()/goForward() resolve as Promise<void>, and marks
back()/forward() with @ts-expect-error so reintroducing either legacy
name fails the typecheck.
@robobun
robobun force-pushed the farm/a450ade8/webview-goback-types branch from 661743c to 65caf03 Compare July 2, 2026 16:11

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — types-only rename matching the runtime, with the fixture placed where alii asked.

Extended reasoning...

Overview

Two-file change: renames back()/forward() to goBack()/goForward() on Bun.WebView in packages/bun-types/bun.d.ts, and adds test/integration/bun-types/fixture/webview.ts following the existing fixture pattern (imports expectType from ./utilities, asserts return types, and uses @ts-expect-error to lock out the legacy names). Verified against src/runtime/webview/WebViewHost.cpp and ObjCRuntime.cpp — the runtime does register goBack/goForward, so the .d.ts was the only deviation.

Security risks

None. Type declarations only; no runtime, auth, crypto, or permission code touched.

Level of scrutiny

Low. This is a mechanical .d.ts fix to match already-shipped runtime behavior, and per CLAUDE.md, packages/bun-types/**/*.d.ts edits don't touch compiled code. The fixture is picked up automatically by bun-types.test.ts (which copies the whole fixture/ dir into its temp project), so no wiring changes are needed.

Other factors

The PR went through several test-shape iterations; the maintainer's final request ("it should be in the fixture dir, not as a new test") was implemented in 65caf03, and all prior review threads (mine and CodeRabbit's) are resolved. The PR description's Verification section now accurately describes the fixture approach. No bugs were found by the bug hunter on the current revision.

@robobun

robobun commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #39608, which fixes all of the open types issues in one PR, this one included.

@robobun robobun closed this Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bun.WebView] view.goBack() API missing and view.back() is not a function

3 participants