Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Auto select workspace proxy based on lowest latency#7515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 16 commits intomainfromstevenmasley/proxy_latency_pick
May 22, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
159538c
WIP: Proxy auto select and user selection state
EmyrkMay 11, 2023
1305931
chore: Auto select based on latency
EmyrkMay 12, 2023
d1c9f3f
Add extra test for unknown latencies
EmyrkMay 12, 2023
c739f24
Move arg inside the funcs
EmyrkMay 12, 2023
ae26777
Fmt
EmyrkMay 12, 2023
523e492
Duplicate import
EmyrkMay 12, 2023
877c0c9
PR feedback
EmyrkMay 12, 2023
8d26643
Merge remote-tracking branch 'origin/main' into stevenmasley/proxy_la…
EmyrkMay 12, 2023
5c534fa
Refactor
EmyrkMay 12, 2023
a3703e1
Fix useEffect dep
EmyrkMay 18, 2023
c210e8d
Merge remote-tracking branch 'origin/main' into stevenmasley/proxy_la…
EmyrkMay 18, 2023
a358258
Fix deps comment
EmyrkMay 18, 2023
ec860c3
Remove comment
EmyrkMay 22, 2023
3197eb1
Merge remote-tracking branch 'origin/main' into stevenmasley/proxy_la…
EmyrkMay 22, 2023
ebb6a76
Mock the hook with a hook
EmyrkMay 22, 2023
549093e
Remove unused dep
EmyrkMay 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletionssite/jest.setup.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { Blob } from "buffer"
import jestFetchMock from "jest-fetch-mock"
import { ProxyLatencyReport } from "contexts/useProxyLatency"
import { RegionsResponse } from "api/typesGenerated"
import { useMemo } from "react"

jestFetchMock.enableMocks()

Expand All@@ -16,20 +17,25 @@ jestFetchMock.enableMocks()
// actual network requests. So just globally mock this hook.
jest.mock("contexts/useProxyLatency", () => ({
useProxyLatency: (proxies?: RegionsResponse) => {
if (!proxies) {
return {} as Record<string, ProxyLatencyReport>
}

return proxies.regions.reduce((acc, proxy) => {
acc[proxy.id] = {
accurate: true,
// Return a constant latency of 8ms.
// If you make this random it could break stories.
latencyMS: 8,
at: new Date(),
// Must use `useMemo` here to avoid infinite loop.
// Mocking the hook with a hook.
const latencies = useMemo(() => {
if (!proxies) {
return {} as Record<string, ProxyLatencyReport>
}
return acc
}, {} as Record<string, ProxyLatencyReport>)
return proxies.regions.reduce((acc, proxy) => {
acc[proxy.id] = {
accurate: true,
// Return a constant latency of 8ms.
// If you make this random it could break stories.
latencyMS: 8,
at: new Date(),
}
return acc
}, {} as Record<string, ProxyLatencyReport>)
}, [proxies])

return latencies
},
}))

Expand Down
3 changes: 3 additions & 0 deletionssite/src/components/AppLink/AppLink.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,9 @@ const Template: Story<AppLinkProps> = (args) => (
setProxy: () => {
return
},
clearProxy: () => {
return
},
}}
>
<AppLink {...args} />
Expand Down
3 changes: 3 additions & 0 deletionssite/src/components/Resources/AgentRow.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,9 @@ const TemplateFC = (
setProxy: () => {
return
},
clearProxy: () => {
return
},
}}
>
<AgentRow {...args} />
Expand Down
6 changes: 6 additions & 0 deletionssite/src/components/Resources/ResourceCard.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,9 @@ Example.args = {
setProxy: () => {
return
},
clearProxy: () => {
return
},
}}
>
<AgentRow
Expand DownExpand Up@@ -97,6 +100,9 @@ BunchOfMetadata.args = {
setProxy: () => {
return
},
clearProxy: () => {
return
},
}}
>
<AgentRow
Expand Down
3 changes: 3 additions & 0 deletionssite/src/components/Workspace/Workspace.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,9 @@ const Template: Story<WorkspaceProps> = (args) => (
proxies: [],
isLoading: false,
isFetched: true,
clearProxy: () => {
return
},
setProxy: () => {
return
},
Expand Down
62 changes: 0 additions & 62 deletionssite/src/contexts/ProxyContext.test.ts
View file
Open in desktop

This file was deleted.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp