Skip to content

Commit ba6bc99

Browse files
committed
Add session lifecycle types and foreground session response types
1 parent c587ecd commit ba6bc99

6 files changed

Lines changed: 277 additions & 0 deletions
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Response from session.getForeground RPC call.
12+
* <p>
13+
* This is only available when connecting to a server running in TUI+server mode
14+
* (--ui-server).
15+
*
16+
* @since 1.0.0
17+
*/
18+
@JsonIgnoreProperties(ignoreUnknown = true)
19+
public class GetForegroundSessionResponse {
20+
21+
@JsonProperty("sessionId")
22+
private String sessionId;
23+
24+
@JsonProperty("workspacePath")
25+
private String workspacePath;
26+
27+
/**
28+
* Gets the session ID currently displayed in the TUI.
29+
*
30+
* @return the session ID, or null if no foreground session
31+
*/
32+
public String getSessionId() {
33+
return sessionId;
34+
}
35+
36+
public void setSessionId(String sessionId) {
37+
this.sessionId = sessionId;
38+
}
39+
40+
/**
41+
* Gets the workspace path of the foreground session.
42+
*
43+
* @return the workspace path, or null
44+
*/
45+
public String getWorkspacePath() {
46+
return workspacePath;
47+
}
48+
49+
public void setWorkspacePath(String workspacePath) {
50+
this.workspacePath = workspacePath;
51+
}
52+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Session lifecycle event notification.
12+
* <p>
13+
* Lifecycle events are emitted when sessions are created, deleted, updated, or
14+
* change foreground/background state (in TUI+server mode).
15+
*
16+
* @since 1.0.0
17+
*/
18+
@JsonIgnoreProperties(ignoreUnknown = true)
19+
public class SessionLifecycleEvent {
20+
21+
@JsonProperty("type")
22+
private String type;
23+
24+
@JsonProperty("sessionId")
25+
private String sessionId;
26+
27+
@JsonProperty("metadata")
28+
private SessionLifecycleEventMetadata metadata;
29+
30+
public String getType() {
31+
return type;
32+
}
33+
34+
public void setType(String type) {
35+
this.type = type;
36+
}
37+
38+
public String getSessionId() {
39+
return sessionId;
40+
}
41+
42+
public void setSessionId(String sessionId) {
43+
this.sessionId = sessionId;
44+
}
45+
46+
public SessionLifecycleEventMetadata getMetadata() {
47+
return metadata;
48+
}
49+
50+
public void setMetadata(SessionLifecycleEventMetadata metadata) {
51+
this.metadata = metadata;
52+
}
53+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Metadata for session lifecycle events.
12+
*
13+
* @since 1.0.0
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
public class SessionLifecycleEventMetadata {
17+
18+
@JsonProperty("startTime")
19+
private String startTime;
20+
21+
@JsonProperty("modifiedTime")
22+
private String modifiedTime;
23+
24+
@JsonProperty("summary")
25+
private String summary;
26+
27+
public String getStartTime() {
28+
return startTime;
29+
}
30+
31+
public void setStartTime(String startTime) {
32+
this.startTime = startTime;
33+
}
34+
35+
public String getModifiedTime() {
36+
return modifiedTime;
37+
}
38+
39+
public void setModifiedTime(String modifiedTime) {
40+
this.modifiedTime = modifiedTime;
41+
}
42+
43+
public String getSummary() {
44+
return summary;
45+
}
46+
47+
public void setSummary(String summary) {
48+
this.summary = summary;
49+
}
50+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
/**
8+
* Types of session lifecycle events.
9+
* <p>
10+
* Constants for session lifecycle event types used with
11+
* {@link com.github.copilot.sdk.CopilotClient#onLifecycle(String, SessionLifecycleHandler)}.
12+
*
13+
* @since 1.0.0
14+
*/
15+
public final class SessionLifecycleEventTypes {
16+
17+
/**
18+
* Event fired when a session is created.
19+
*/
20+
public static final String CREATED = "session.created";
21+
22+
/**
23+
* Event fired when a session is deleted.
24+
*/
25+
public static final String DELETED = "session.deleted";
26+
27+
/**
28+
* Event fired when a session is updated.
29+
*/
30+
public static final String UPDATED = "session.updated";
31+
32+
/**
33+
* Event fired when a session moves to foreground (TUI+server mode).
34+
*/
35+
public static final String FOREGROUND = "session.foreground";
36+
37+
/**
38+
* Event fired when a session moves to background (TUI+server mode).
39+
*/
40+
public static final String BACKGROUND = "session.background";
41+
42+
private SessionLifecycleEventTypes() {
43+
// Utility class
44+
}
45+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
/**
8+
* Handler for session lifecycle events.
9+
* <p>
10+
* Implement this interface to receive notifications when sessions are created,
11+
* deleted, updated, or change foreground/background state.
12+
*
13+
* @since 1.0.0
14+
*/
15+
@FunctionalInterface
16+
public interface SessionLifecycleHandler {
17+
18+
/**
19+
* Called when a session lifecycle event occurs.
20+
*
21+
* @param event
22+
* the lifecycle event
23+
*/
24+
void onLifecycleEvent(SessionLifecycleEvent event);
25+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Response from session.setForeground RPC call.
12+
* <p>
13+
* This is only available when connecting to a server running in TUI+server mode
14+
* (--ui-server).
15+
*
16+
* @since 1.0.0
17+
*/
18+
@JsonIgnoreProperties(ignoreUnknown = true)
19+
public class SetForegroundSessionResponse {
20+
21+
@JsonProperty("success")
22+
private boolean success;
23+
24+
@JsonProperty("error")
25+
private String error;
26+
27+
/**
28+
* Whether the operation was successful.
29+
*
30+
* @return true if successful
31+
*/
32+
public boolean isSuccess() {
33+
return success;
34+
}
35+
36+
public void setSuccess(boolean success) {
37+
this.success = success;
38+
}
39+
40+
/**
41+
* Gets the error message if the operation failed.
42+
*
43+
* @return the error message, or null if successful
44+
*/
45+
public String getError() {
46+
return error;
47+
}
48+
49+
public void setError(String error) {
50+
this.error = error;
51+
}
52+
}

0 commit comments

Comments
 (0)