@@ -110,36 +110,42 @@ export class CoderApi extends Api {
110110logs :ProvisionerJobLog [ ] ,
111111options ?:ClientOptions ,
112112) => {
113- const searchParams = new URLSearchParams ( { follow :"true" } ) ;
114- const lastLog = logs . at ( - 1 ) ;
115- if ( lastLog ) {
116- searchParams . append ( "after" , lastLog . id . toString ( ) ) ;
117- }
118-
119- return this . createWebSocket < ProvisionerJobLog > ( {
120- apiRoute :`/api/v2/workspacebuilds/${ buildId } /logs` ,
121- searchParams,
113+ return this . watchLogs < ProvisionerJobLog > (
114+ `/api/v2/workspacebuilds/${ buildId } /logs` ,
115+ logs ,
122116options ,
123- } ) ;
117+ ) ;
124118} ;
125119
126120watchWorkspaceAgentLogs = async (
127121agentId :string ,
128122logs :WorkspaceAgentLog [ ] ,
129123options ?:ClientOptions ,
130124) => {
125+ return this . watchLogs < WorkspaceAgentLog [ ] > (
126+ `/api/v2/workspaceagents/${ agentId } /logs` ,
127+ logs ,
128+ options ,
129+ ) ;
130+ } ;
131+
132+ private async watchLogs < TData > (
133+ apiRoute :string ,
134+ logs :{ id :number } [ ] ,
135+ options ?:ClientOptions ,
136+ ) {
131137const searchParams = new URLSearchParams ( { follow :"true" } ) ;
132138const lastLog = logs . at ( - 1 ) ;
133139if ( lastLog ) {
134140searchParams . append ( "after" , lastLog . id . toString ( ) ) ;
135141}
136142
137- return this . createWebSocket < WorkspaceAgentLog [ ] > ( {
138- apiRoute : `/api/v2/workspaceagents/ ${ agentId } /logs` ,
143+ return this . createWebSocket < TData > ( {
144+ apiRoute,
139145searchParams,
140146options,
141147} ) ;
142- } ;
148+ }
143149
144150private async createWebSocket < TData = unknown > (
145151configs :Omit < OneWayWebSocketInit , "location" > ,