Skip to content

Fix workspace proxy dropping query parameters#173

Merged
khaliqgant merged 2 commits intomainfrom
fix/proxy-query-params
Jan 13, 2026
Merged

Fix workspace proxy dropping query parameters#173
khaliqgant merged 2 commits intomainfrom
fix/proxy-query-params

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

Fixes the trajectory viewer loading wrong data in cloud mode by preserving query parameters in the workspace proxy.

Root Cause

The workspace proxy route was constructing the target URL without the query string:

// Before (bug):
const targetUrl = `${targetBaseUrl}/api/${proxyPath}`;

This meant requests like:

/api/workspaces/{id}/proxy/trajectory/steps?trajectoryId=traj_xxx

Were forwarded as:

/api/trajectory/steps  (no trajectoryId!)

Without the trajectoryId parameter, the API returns ALL active trajectories (overview) instead of the specific one.

Solution

Preserve the query string when proxying:

const queryString = req.url.includes('?') ? req.url.substring(req.url.indexOf('?')) : '';
const targetUrl = `${targetBaseUrl}/api/${proxyPath}${queryString}`;

Additional Fix

Also includes server-side ID consistency fix:

  • getTrajectoryHistory now uses file's internal ID instead of index key
  • listTrajectorySteps scans by file ID if index key lookup fails

Test plan

  • Deploy to cloud
  • Open trajectory panel
  • Click on a specific trajectory from history
  • Verify correct trajectory steps load (not overview)
  • Check server logs for [workspace-proxy] GET .../trajectory/steps?trajectoryId=...

🤖 Generated with Claude Code

Agent Relay and others added 2 commits January 13, 2026 13:51
Root cause: The history list used index keys as IDs, but the steps lookup
expected file internal IDs. When these differed, wrong or no data was returned.

Fixes in getTrajectoryHistory:
- Now reads trajectory file to get actual internal ID
- Uses file's ID instead of index key for consistency
- Skips duplicates based on actual ID, not index key

Fixes in listTrajectorySteps:
- Added Strategy 2: Scan index entries by file's internal ID
- This handles cases where index key != file's internal ID
- Existing fallback to active/{id}.json remains as Strategy 3
- Added logging to help debug which lookup strategy is used

The key insight: History list must use the SAME ID that the steps lookup
will find. Previously, history used index keys but steps lookup expected
file internal IDs, causing the mismatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Root cause: The proxy route was constructing the target URL without
preserving the query string from the original request:

  const targetUrl = `${targetBaseUrl}/api/${proxyPath}`;

This meant requests like:
  /api/workspaces/{id}/proxy/trajectory/steps?trajectoryId=traj_xxx

Were forwarded as:
  /api/trajectory/steps  (no trajectoryId!)

Without the trajectoryId parameter, the API returns ALL active trajectories
instead of the specific one requested.

Fix: Extract and append the query string to the target URL.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@my-senior-dev-pr-review
Copy link
Copy Markdown

🤖 My Senior Dev — Analysis Complete

👤 For @khaliqgant

📁 Expert in src/dashboard/react-components/ (7 edits) • ⚡ 31st PR this month

View your contributor analytics →


📊 2 files reviewed • 3 need attention

⚠️ Needs Attention:

  • src/cloud/api/workspaces.ts — Significant changes to proxy handling and query parameter processing that could introduce security risks.

🚀 Open Interactive Review →

The full interface unlocks features not available in GitHub:

  • 💬 AI Chat — Ask questions on any file, get context-aware answers
  • 🔍 Smart Hovers — See symbol definitions and usage without leaving the diff
  • 📚 Code Archeology — Understand how files evolved over time (/archeology)
  • 🎯 Learning Insights — See how this PR compares to similar changes

💬 Chat here: @my-senior-dev explain this change — or try @chaos-monkey @security-auditor @optimizer @skeptic @junior-dev

📖 View all 12 personas & slash commands

You can interact with me by mentioning @my-senior-dev in any comment:

In PR comments or on any line of code:

  • Ask questions about the code or PR
  • Request explanations of specific changes
  • Get suggestions for improvements

Slash commands:

  • /help — Show all available commands
  • /archeology — See the history and evolution of changed files
  • /profile — Performance analysis and suggestions
  • /expertise — Find who knows this code best
  • /personas — List all available AI personas

AI Personas (mention to get their perspective):

Persona Focus
@chaos-monkey 🐵 Edge cases & failure scenarios
@skeptic 🤨 Challenge assumptions
@optimizer Performance & efficiency
@security-auditor 🔒 Security vulnerabilities
@accessibility-advocate Inclusive design
@junior-dev 🌱 Simple explanations
@tech-debt-collector 💳 Code quality & shortcuts
@ux-champion 🎨 User experience
@devops-engineer 🚀 Deployment & scaling
@documentation-nazi 📚 Documentation gaps
@legacy-whisperer 🏛️ Working with existing code
@test-driven-purist Testing & TDD

For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews.

@khaliqgant khaliqgant merged commit 9c0fb2a into main Jan 13, 2026
6 checks passed
@khaliqgant khaliqgant deleted the fix/proxy-query-params branch January 13, 2026 13:57
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