Skip to content

Fix ide browse file targets#67

Merged
GordonBeeming merged 4 commits into
mainfrom
gb/browse-file
Jul 23, 2026
Merged

Fix ide browse file targets#67
GordonBeeming merged 4 commits into
mainfrom
gb/browse-file

Conversation

@GordonBeeming

@GordonBeeming GordonBeeming commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Open explicit file targets in the hosted browser instead of stopping at their parent folder.
  • Carry each file target on its own browse URL so separate tabs and duplicate workspace sessions cannot overwrite one another.
  • Add backend and hosted-transport regression tests, including URL encoding and native empty-value normalization.

Validation

  • ./run-tests.sh (433 frontend tests, 242 Rust tests, build, smoke tests, and dependency audits)
  • cargo fmt --check
  • git diff --check

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@GordonBeeming
GordonBeeming marked this pull request as ready for review July 23, 2026 13:22
Copilot AI review requested due to automatic review settings July 23, 2026 13:22
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Workspace sessions now carry an optional initial file, expose it through a scoped HTTP endpoint, and update it during browse requests. Hosted Tauri transport retrieves the value through the shared API mechanism, with backend, frontend, and smoke-test coverage.

Changes

Workspace initial-file flow

Layer / File(s) Summary
Session state and HTTP handling
src-tauri/src/http_server.rs
ResolvedWorkspace carries scoped initial-file state, /api/initial-file returns it, and browse requests set or clear the session value.
Hosted Tauri retrieval
src/tauri.ts, src/tauri.test.ts, scripts/smoke-test.mjs
getInitialFile() uses the shared API transport, with coverage for string, null, and smoke-route responses.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HostedTauriTransport
  participant HTTPServer
  participant WorkspaceSessionState
  HostedTauriTransport->>HTTPServer: GET /api/initial-file
  HTTPServer->>WorkspaceSessionState: Read scoped initial_file
  WorkspaceSessionState-->>HTTPServer: Option<String>
  HTTPServer-->>HostedTauriTransport: Return JSON initial file
Loading

Possibly related PRs

  • GordonBeeming/ide#57: Both changes modify the Tauri HTTP server browse flow and hidden workspace session behavior.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: fixing ide browse file target handling.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gb/browse-file

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the “browse” flow so that explicit file targets can be surfaced to the hosted (HTTP) IDE session, and ensures already-open workspace sessions can be updated with a new requested file instead of only opening new sessions.

Changes:

  • Frontend: route getInitialFile() through the shared hosted/native callApi() transport.
  • Backend: add a scoped /api/initial-file endpoint and plumb per-session initial_file through workspace resolution.
  • Tests: add regression coverage for the hosted transport initial-file call and backend session update/initial-file API behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/tauri.ts Switches getInitialFile() to use the shared hosted/native API transport.
src/tauri.test.ts Adds a hosted-transport test asserting the initial-file API call is made.
src-tauri/src/http_server.rs Adds /api/initial-file, session refresh logic for initial-file, and regression tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tauri.ts
Copilot AI review requested due to automatic review settings July 23, 2026 13:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/tauri.test.ts (1)

243-252: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the scoped URL in this regression test.

The test uses an unscoped location and only checks /api/initial-file, so it would still pass if workspacePathPrefix(window.location) stopped adding the workspace hash. Set the test location to /<hash>/ and assert the full /<hash>/api/initial-file GET request.

🤖 Prompt for 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.

In `@src/tauri.test.ts` around lines 243 - 252, Update the “reads the initial file
from the scoped hosted session” test to set the browser location to a hashed
path such as /<hash>/ before importing or invoking getInitialFile, then assert
fetch was called with the complete /<hash>/api/initial-file URL while preserving
the existing GET request assertions.
🤖 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 `@src-tauri/src/http_server.rs`:
- Line 484: Decouple initial-file state from the non-unique workspace hash in
the session transport flow around resolve_workspace_by_hash, initial_file, and
the /api/initial-file handling. Enforce unique sessions per workspace root,
share initial_file at the workspace/hash level, or add a stable session
identifier to both browse updates and retrieval so each request consistently
targets the owning session.

In `@src/tauri.ts`:
- Around line 393-395: Update getInitialFile to normalize the hosted
get_initial_file response by converting null to undefined before returning it,
preserving its string | undefined contract for callers.

---

Nitpick comments:
In `@src/tauri.test.ts`:
- Around line 243-252: Update the “reads the initial file from the scoped hosted
session” test to set the browser location to a hashed path such as /<hash>/
before importing or invoking getInitialFile, then assert fetch was called with
the complete /<hash>/api/initial-file URL while preserving the existing GET
request assertions.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 83da7987-e5ed-42a0-97da-b24a1e186f82

📥 Commits

Reviewing files that changed from the base of the PR and between a21a70c and c639721.

📒 Files selected for processing (3)
  • src-tauri/src/http_server.rs
  • src/tauri.test.ts
  • src/tauri.ts

Comment thread src-tauri/src/http_server.rs Outdated
Comment thread src/tauri.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/tauri.ts:395

  • /api/initial-file returns JSON null when no file is requested (Rust Option<String>), but getInitialFile() is typed as string | undefined and readApiResponse() will currently return null at runtime. This breaks the function’s contract and can leak null into React state.
export function getInitialFile() {
  return callApi<string | null>("get_initial_file", "/api/initial-file").then(
    (path) => path ?? undefined,

Comment thread src/tauri.test.ts Outdated
Copilot AI review requested due to automatic review settings July 23, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src-tauri/src/http_server.rs:506

  • update_open_browse_session only updates the first session found for a given workspace hash (via resolve_workspace_by_hash). Because multiple WorkspaceSessionStates can share the same workspace_root_hash (see tests like workspace_summaries_dedupe_by_hash), this can make the /api/initial-file value non-deterministic: the resolver may pick a different session than the one updated, leaving the hosted browser tab with a stale/cleared initial file.

Update all matching sessions’ initial_file locks (or otherwise make resolver/update deterministic and consistent) so any session selected for the hash reflects the latest requested file.

        None => new_path.to_string(),
    };
    if let Ok(uri) = path_and_query.parse::<Uri>() {
        *request.uri_mut() = uri;
    }
}

/// Resolves a leading `/{hash}` path segment to an open workspace, rewriting the URI
/// to drop the prefix and stashing the resolved root + agent context as a request
/// extension. Runs before route matching so the existing `/api/...` and `/` routes
/// see the stripped path. Requests without a hash-shaped prefix get the
/// shared/default workspace, leaving the no-hash API surface unchanged.
///
/// A hash-shaped prefix is stripped even when it doesn't match an open workspace, so

Copilot AI review requested due to automatic review settings July 23, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@GordonBeeming
GordonBeeming merged commit afcb2da into main Jul 23, 2026
4 checks passed
@GordonBeeming
GordonBeeming deleted the gb/browse-file branch July 23, 2026 13:38
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.

2 participants