Skip to content

Commit

Permalink
fix: jobShell connect container (#1386)
Browse files Browse the repository at this point in the history
## 1.回归测试ai时发现没法打开shell页面,报错如图,缺少Provider

![image](https://github.com/user-attachments/assets/91ff0802-8469-425d-88f1-9f6497cf8df9)

## 2. 修改连接getJobById的fields
  • Loading branch information
OYX-1 authored Aug 6, 2024
1 parent 1492188 commit be429fc
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-lemons-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/ai": patch
---

ai 加上国际化的 Provider
76 changes: 46 additions & 30 deletions apps/ai/src/app/clientLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { usePathname } from "next/navigation";
import { ErrorBoundary } from "src/components/ErrorBoundary";
import { Loading } from "src/components/Loading";
import { TopProgressBar } from "src/components/TopProgressBar";
import { Provider } from "src/i18n";
import en from "src/i18n/en";
import zh_cn from "src/i18n/zh_cn";
import { AntdConfigProvider } from "src/layouts/AntdConfigProvider";
import { DarkModeCookie, DarkModeProvider } from "src/layouts/darkMode";
import { RootErrorContent } from "src/layouts/error/RootErrorContent";
Expand All @@ -28,6 +31,11 @@ import { trpc } from "src/utils/trpc";

import { UiConfigContext } from "./uiContext";

const languagesMap = {
"zh_cn": zh_cn,
"en": en,
};

export function ClientLayout(props: {
children: React.ReactNode,
initialDark?: DarkModeCookie,
Expand All @@ -49,36 +57,44 @@ export function ClientLayout(props: {
?? primaryColor?.defaultColor ?? uiConfig.defaultPrimaryColor;

return (
<StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
<StyledComponentsRegistry>
<AntdStyleRegistry>
<body>
{
useConfig.isLoading ?
<Loading />
: (
<DarkModeProvider initial={props.initialDark}>
<AntdConfigProvider color={color}>
<GlobalStyle />
<TopProgressBar />
<ErrorBoundary Component={RootErrorContent} pathname={pathname ?? ""}>
<UiConfigContext.Provider
value={{
hostname,
uiConfig,
}}
>
{props.children}
</UiConfigContext.Provider>
</ErrorBoundary>
</AntdConfigProvider>
</DarkModeProvider>
)
}
<Provider initialLanguage={{
// ai还未开发国际化,先直接写zh_cn
id: "zh_cn",
definitions: languagesMap.zh_cn,
}}
>
<StyleProvider hashPriority="high" transformers={[legacyLogicalPropertiesTransformer]}>
<StyledComponentsRegistry>
<AntdStyleRegistry>
<body>
{
useConfig.isLoading ?
<Loading />
: (
<DarkModeProvider initial={props.initialDark}>
<AntdConfigProvider color={color}>
<GlobalStyle />
<TopProgressBar />
<ErrorBoundary Component={RootErrorContent} pathname={pathname ?? ""}>
<UiConfigContext.Provider
value={{
hostname,
uiConfig,
}}
>
{props.children}
</UiConfigContext.Provider>
</ErrorBoundary>
</AntdConfigProvider>
</DarkModeProvider>
)
}

</body>
</AntdStyleRegistry>
</StyledComponentsRegistry>
</StyleProvider>
</Provider>

</body>
</AntdStyleRegistry>
</StyledComponentsRegistry>
</StyleProvider>
);
}
2 changes: 1 addition & 1 deletion apps/ai/src/server/setup/jobShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ wss.on("connection", async (ws: AliveCheckedWebSocket, req) => {
});

const { job } = await asyncClientCall(client.job, "getJobById", {
fields: ["namespace", "pod"],
fields: ["container_job_info"],
jobId: currentJobInfo.jobId,
});

Expand Down
2 changes: 1 addition & 1 deletion apps/ai/src/server/trpc/route/jobs/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ export const saveImage =
const client = getAdapterClient(clusterId);

const { job } = await asyncClientCall(client.job, "getJobById", {
fields: ["node", "container_id"],
fields: ["container_job_info"],
jobId,
});

Expand Down

0 comments on commit be429fc

Please sign in to comment.