Merged
Conversation
Consolidate createRemoteClient into createClient with automatic server mode detection. When TREQ_SERVER env var is set or server option is provided, the client routes requests through the server for TUI/web observability. Otherwise, requests execute locally. - Remove standalone createRemoteClient export - Add server routing logic to createClient - Auto-detect TREQ_SERVER environment variable - Add comprehensive client tests
Contributor
🚀 Preview DeploymentYour changes have been deployed to: 📖 Docs: https://docs-pr-9.t-req.io This preview will be automatically removed when the PR is closed. |
Greptile OverviewGreptile SummaryUnifies client API by merging Key Changes:
Implementation Quality:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant createClient
participant LocalClient
participant ServerClient
participant TreqServer
User->>createClient: createClient(config)
alt config.server OR TREQ_SERVER env var set
createClient->>ServerClient: createServerClient(config)
Note over ServerClient: Store serverUrl, token, variables
createClient-->>User: Client (server-backed)
User->>ServerClient: run() or runString()
ServerClient->>ServerClient: ensureInitialized()
alt First request (not initialized)
ServerClient->>TreqServer: POST /session (with variables)
TreqServer-->>ServerClient: sessionId
alt No TREQ_FLOW_ID env var
ServerClient->>TreqServer: POST /flows (with sessionId)
TreqServer-->>ServerClient: flowId
else TREQ_FLOW_ID set (TUI mode)
Note over ServerClient: Use existing flowId from env
end
end
ServerClient->>ServerClient: await variableSyncChain
ServerClient->>TreqServer: POST /execute (sessionId, flowId, content/path)
TreqServer-->>ServerClient: ExecuteResponse
ServerClient-->>User: Response
User->>ServerClient: close()
alt Flow was created by client
ServerClient->>TreqServer: POST /flows/{flowId}/finish
else Flow was attached (TUI mode)
Note over ServerClient: Skip finish (TUI manages flow)
end
else No server config
createClient->>LocalClient: Create local client
Note over LocalClient: Initialize engine with config
createClient-->>User: Client (local)
User->>LocalClient: run() or runString()
LocalClient->>LocalClient: engine.runFile/runString()
LocalClient-->>User: Response
User->>LocalClient: close()
Note over LocalClient: No-op (no resources to release)
end
|
andrewmelchor
added a commit
that referenced
this pull request
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidate
createRemoteClientintocreateClientwith automatic server mode detection. One API for all use cases.Changes
1. Test Fixture Update
File:
packages/app/test/fixtures/http/run-test.tsRemove explicit
serveroption - rely onTREQ_SERVERenv var injection:Type of Change
How Has This Been Tested?
Checklist