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

fix: let workspace pages download partial logs for unhealthy workspaces#13761

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
Parkreiner merged 19 commits intomainfrommes/log-fix
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
f1f5f88
fix: get basic fix in for preventing download logs from blowing up UI
ParkreinerJul 1, 2024
edd6362
fix: make sure blob units can't go out of bounds
ParkreinerJul 1, 2024
901aa39
fix: make sure timeout is cleared on component unmount
ParkreinerJul 1, 2024
e1d8113
fix: reduce risk of shared cache state breaking useAgentLogs
ParkreinerJul 2, 2024
87f57aa
fix: allow partial downloading of logs
ParkreinerJul 2, 2024
5bf2baf
fix: make sure useMemo cache is used properly
ParkreinerJul 2, 2024
5c2316b
wip: commit current progress on updated logs functionality
ParkreinerJul 2, 2024
edd6569
docs: rewrite comment for clarity
ParkreinerJul 2, 2024
2eb7d6e
refactor: clean up current code
ParkreinerJul 2, 2024
fa06515
fix: update styles for unavailable logs
ParkreinerJul 2, 2024
8fb4496
fix: resolve linter violations
ParkreinerJul 2, 2024
6935f50
fix: update type signature of getErrorDetail
ParkreinerJul 2, 2024
f74eda4
fix: revert log/enabled logic for useAgentLogs
ParkreinerJul 2, 2024
7b76eb7
fix: remove memoization from DownloadLogsDialog
ParkreinerJul 2, 2024
07ff536
fix: update name of timeout state
ParkreinerJul 2, 2024
460aa53
refactor: make log web sockets logic more clear
ParkreinerJul 2, 2024
5a449b4
docs: reword comment for clarity
ParkreinerJul 2, 2024
eb4f88c
fix: commit current style update progress
ParkreinerJul 2, 2024
71692b6
fix: finish style updates
ParkreinerJul 2, 2024
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
7 changes: 5 additions & 2 deletionssite/src/api/errors.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,15 +110,18 @@ export const getValidationErrorMessage = (error: unknown): string => {
return validationErrors.map((error) => error.detail).join("\n");
};

export const getErrorDetail = (error: unknown): string | undefined| null=> {
export const getErrorDetail = (error: unknown): string | undefined => {
if (error instanceof Error) {
return "Please check the developer console for more details.";
}

if (isApiError(error)) {
return error.response.data.detail;
}

if (isApiErrorResponse(error)) {
return error.detail;
}
return null;

return undefined;
};
31 changes: 22 additions & 9 deletionssite/src/modules/resources/AgentLogs/useAgentLogs.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,22 +15,35 @@ export type UseAgentLogsOptions = Readonly<{
enabled?: boolean;
}>;

/**
* Defines a custom hook that gives you all workspace agent logs for a given
* workspace.
*
* Depending on the status of the workspace, all logs may or may not be
* available.
*/
export function useAgentLogs(
options: UseAgentLogsOptions,
): readonly WorkspaceAgentLog[] | undefined {
const { workspaceId, agentId, agentLifeCycleState, enabled = true } = options;

const queryClient = useQueryClient();
const queryOptions = agentLogs(workspaceId, agentId);
const query = useQuery({
...queryOptions,
enabled,
});
const logs = query.data;
const { data: logs, isFetched } = useQuery({ ...queryOptions, enabled });

// Track the ID of the last log received when the initial logs response comes
// back. If the logs are not complete, the ID will mark the start point of the
// Web sockets response so that the remaining logs can be received over time
const lastQueriedLogId = useRef(0);
useEffect(() => {
if (logs && lastQueriedLogId.current === 0) {
lastQueriedLogId.current = logs[logs.length - 1].id;
const isAlreadyTracking = lastQueriedLogId.current !== 0;
if (isAlreadyTracking) {
return;
}

const lastLog = logs?.at(-1);
if (lastLog !== undefined) {
lastQueriedLogId.current = lastLog.id;
}
}, [logs]);

Expand All@@ -42,7 +55,7 @@ export function useAgentLogs(
});

useEffect(() => {
if (agentLifeCycleState !== "starting" || !query.isFetched) {
if (agentLifeCycleState !== "starting" || !isFetched) {
return;
}

Expand All@@ -69,7 +82,7 @@ export function useAgentLogs(
return () => {
socket.close();
};
}, [addLogs, agentId, agentLifeCycleState,query.isFetched]);
}, [addLogs, agentId, agentLifeCycleState, isFetched]);

return logs;
}
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp