-
Notifications
You must be signed in to change notification settings - Fork 961
fix(site): update useAgentLogs
to make it more testable and add more tests
#19126
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d6e00c3
43d0ca8
727bddd
d46d144
91a6fc1
ecbe7b0
d13bcdc
0f21097
abd6553
bade97a
e11fefd
bc3d095
550d09e
cc7e632
79c7ffd
43a0d3a
982d3e1
41c5a12
42cb73b
3a5f7bb
35a40df
306dbc7
f49e55a
c2fc772
2cabd85
855f3ca
453894b
c9f2b12
80865fe
f930b29
a311ac9
5657536
6547a2f
c818aec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ import type { | |||||
Template, | ||||||
Workspace, | ||||||
WorkspaceAgent, | ||||||
WorkspaceAgentLog, | ||||||
WorkspaceAgentMetadata, | ||||||
} from "api/typesGenerated"; | ||||||
import { Button } from "components/Button/Button"; | ||||||
|
@@ -79,21 +80,21 @@ export const AgentRow: FC<AgentRowProps> = ({ | |||||
const agentLogs = useAgentLogs(agent.id, showLogs); | ||||||
const logListRef = useRef<List>(null); | ||||||
const logListDivRef = useRef<HTMLDivElement>(null); | ||||||
const startupLogs = useMemo(() => { | ||||||
const allLogs = agentLogs || []; | ||||||
|
||||||
const logs = [...allLogs]; | ||||||
if (agent.logs_overflowed) { | ||||||
logs.push({ | ||||||
const startupLogs = useMemo<readonly WorkspaceAgentLog[]>(() => { | ||||||
if (!agent.logs_overflowed) { | ||||||
return agentLogs; | ||||||
} | ||||||
return [ | ||||||
...agentLogs, | ||||||
{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also I know it was already like this, but is shoving a log entry on the end really the best way to do this? this |
||||||
id: -1, | ||||||
level: "error", | ||||||
output: | ||||||
"Startup logs exceeded the max size of 1MB, and will not continue to be written to the database! Logs will continue to be written to the /tmp/coder-startup-script.log file in the workspace.", | ||||||
created_at: new Date().toISOString(), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're leaking in here. I feel like this should be...
Suggested change
since that's probably more "correct" and deterministic |
||||||
source_id: "", | ||||||
}); | ||||||
} | ||||||
return logs; | ||||||
}, | ||||||
]; | ||||||
}, [agentLogs, agent.logs_overflowed]); | ||||||
const [bottomOfLogs, setBottomOfLogs] = useState(true); | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agentLogs
is no longer nullable, so a bunch of logic can be removed