aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/assets/pi
diff options
context:
space:
mode:
Diffstat (limited to 'crates/dinggerd/assets/pi')
-rw-r--r--crates/dinggerd/assets/pi/pi-agent-state.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/dinggerd/assets/pi/pi-agent-state.ts b/crates/dinggerd/assets/pi/pi-agent-state.ts
index ceac45b..0575ba9 100644
--- a/crates/dinggerd/assets/pi/pi-agent-state.ts
+++ b/crates/dinggerd/assets/pi/pi-agent-state.ts
@@ -119,6 +119,9 @@ let draft = "";
// How full the context window is, in percent, as pi's footer shows it;
// "" when unknown (right after compacting, before the next reply).
let context = "";
+// The session's name ("" for none): dingger shows it as the agent's name,
+// whatever the terminal title says.
+let sessionName = "";
const draftDir = path.join(path.dirname(socketPath), "drafts");
// Enough to find the agent by it; the file keeps all of it.
const reportedDraftChars = 500;
@@ -212,6 +215,7 @@ async function report(state: AgentState | undefined, message?: string, end: RunE
...(controlListening ? { control: controlPath } : {}),
draft: draft.slice(0, reportedDraftChars),
context,
+ name: sessionName,
seq: Date.now() * 1000,
...(sessionFile ? { agent_session_path: sessionFile } : {}),
},
@@ -563,8 +567,9 @@ export default function (pi) {
// Each session has its own: /new starts at normal, /resume brings its own back.
importance = savedImportance(ctx);
announceImportance();
- // The report below carries it.
+ // The reports below carry them.
checkContext(ctx, true);
+ sessionName = pi.getSessionName?.() ?? "";
publishState(true);
});
@@ -588,6 +593,12 @@ export default function (pi) {
});
}
+ // /name, or a name given by an extension.
+ pi.on("session_info_changed", (event) => {
+ sessionName = event?.name ?? "";
+ void report(undefined);
+ });
+
pi.on("agent_settled", (event, ctx) => {
latestCtx = ctx;
if (ctx?.isIdle?.() !== true) {