Skip to content

Add Runtime and Console transport core#132

Open
lynnswap wants to merge 26 commits into
mainfrom
codex/runtime-console-core
Open

Add Runtime and Console transport core#132
lynnswap wants to merge 26 commits into
mainfrom
codex/runtime-console-core

Conversation

@lynnswap
Copy link
Copy Markdown
Owner

Summary

  • Add first-class Runtime and Console core models/protocol payloads, including target-scoped runtime objects, execution contexts, console messages, counts, repeat handling, and clear state.
  • Add Runtime and Console transport adapters and wire Runtime/Console bootstrap, target capability metadata, frame-target enablement, and provisional target handling into InspectorSession and TransportSession.
  • Move shared stack trace payloads out of Network ownership and update DOM/CSS integration around runtime-agent target ownership.
  • Align DOM and Network UI rendering with ObservationBridge direct rendering so selected style hydration and request detail changes update only the affected native surfaces.
  • Update research/architecture docs and add coverage across core, transport, runtime, and UI reset/selection behavior.

Testing

  • swift test --filter WebInspectorCoreTests
  • swift test --filter WebInspectorTransportTests
  • swift test --filter WebInspectorRuntimeTests
  • swift test
  • git diff --check
  • xcodebuild test -workspace WebInspectorKit.xcworkspace -scheme WebInspectorKit -destination 'platform=iOS Simulator,name=iPhone 17,OS=latest'
  • codex-review against main: clean

Screenshots

  • Not applicable; this PR does not add Console UI.

Related

  • None

lynnswap added 24 commits May 26, 2026 15:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4281f29cbb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/WebInspectorRuntime/InspectorSession.swift Outdated
Comment thread Sources/WebInspectorRuntime/InspectorSession.swift
Comment thread Sources/WebInspectorRuntime/InspectorSession.swift
Copy link
Copy Markdown
Owner Author

@lynnswap lynnswap left a comment

Choose a reason for hiding this comment

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

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbe78bdfbf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1002 to +1004
selectedNodeStyleHydrationTask?.cancel()
selectedNodeStyleHydrationTask = nil
selectedNodeStyleHydrationIdentity = nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset selected style refresh state when cancelling hydration

Cancelling selectedNodeStyleHydrationTask here leaves the selected node in .loading when cancellation happens mid-refresh (for example, switching away from the Elements view while style requests are in flight). refreshStyles(for:) explicitly skips markRefreshFailed on CancellationError, and selectedNodeStyleHydrationState() treats .loading as .refreshing, so when the view becomes active again no new refresh is scheduled and the UI can remain stuck in a perpetual loading state for that node.

Useful? React with 👍 / 👎.

Comment on lines +430 to +436
if let defaultContextKey = targetState.normalContextKey {
if oldContextKeys.contains(defaultContextKey) {
targetState.normalContextKey = record.key
}
} else {
targetState.normalContextKey = record.key
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Promote main-world context when later normal context arrives

The default context for a target is only set once unless the previous default is explicitly replaced, so if a subframe normal context is seen before the page’s main-world context, normalContextKey stays pinned to the subframe. RuntimeSession.evaluateIntent prefers selected/default context, so subsequent evaluations for that page target can run in the wrong frame context instead of the main world whenever event ordering delivers subframe context creation first.

Useful? React with 👍 / 👎.

Comment on lines +2194 to +2195
for record in snapshot.executionContextsByKey.values.sorted(by: { $0.id.rawValue < $1.id.rawValue }) {
runtime.applyExecutionContextCreated(record)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use deterministic key when seeding runtime contexts

executionContextId is now only unique within a runtime-agent target, but this seed pass sorts solely by id. When two contexts share the same id across different runtime agents, their relative order depends on dictionary iteration, which is explicitly unpredictable; whichever one is applied first can become the target’s default/selected normal context. That makes initial evaluation routing nondeterministic after reconnect/bootstrap for pages with colliding context IDs.

Useful? React with 👍 / 👎.

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