Skip to content

Commit 8688b37

Browse files
committed
feat(shell): add window-tab chrome and terminal gutter
1 parent 8a9ba9c commit 8688b37

25 files changed

Lines changed: 3062 additions & 479 deletions

File tree

crates/taskers-app/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ publish = false
1313
name = "taskers-gtk"
1414
path = "src/main.rs"
1515

16+
[[bin]]
17+
name = "taskersctl"
18+
path = "src/bin/taskersctl.rs"
19+
1620
[dependencies]
1721
adw.workspace = true
1822
anyhow.workspace = true
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
payload=${1-}
5+
message=
6+
taskers_ctl=${TASKERS_CTL_PATH:-}
7+
8+
if [ -z "$taskers_ctl" ] && command -v taskersctl >/dev/null 2>&1; then
9+
taskers_ctl=$(command -v taskersctl)
10+
fi
11+
12+
if [ -n "$payload" ]; then
13+
if command -v jq >/dev/null 2>&1; then
14+
message=$(
15+
printf '%s' "$payload" \
16+
| jq -r '."last-assistant-message" // .message // .title // empty' 2>/dev/null \
17+
| head -c 160
18+
)
19+
fi
20+
fi
21+
22+
if [ -z "$message" ]; then
23+
message="Turn complete"
24+
fi
25+
26+
has_embedded_surface_context() {
27+
[ -x "${taskers_ctl:-}" ] || return 1
28+
[ -n "${TASKERS_WORKSPACE_ID:-}" ] || return 1
29+
[ -n "${TASKERS_PANE_ID:-}" ] || return 1
30+
[ -n "${TASKERS_SURFACE_ID:-}" ] || return 1
31+
[ -n "${TASKERS_TTY_NAME:-}" ] || return 1
32+
33+
current_tty=$(tty 2>/dev/null || true)
34+
case "$current_tty" in
35+
/dev/*) ;;
36+
*) return 1 ;;
37+
esac
38+
39+
[ "$current_tty" = "$TASKERS_TTY_NAME" ] || return 1
40+
}
41+
42+
if has_embedded_surface_context; then
43+
"$taskers_ctl" agent-hook stop \
44+
--workspace "$TASKERS_WORKSPACE_ID" \
45+
--pane "$TASKERS_PANE_ID" \
46+
--surface "$TASKERS_SURFACE_ID" \
47+
--agent codex \
48+
--title Codex \
49+
--message "$message" >/dev/null 2>&1 || true
50+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include!(concat!(
2+
env!("CARGO_MANIFEST_DIR"),
3+
"/../taskers-cli/src/main.rs"
4+
));

crates/taskers-cli/assets/taskers-codex-notify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ has_embedded_surface_context() {
4040
}
4141

4242
if has_embedded_surface_context; then
43-
"$taskers_ctl" agent-hook notification \
43+
"$taskers_ctl" agent-hook stop \
4444
--workspace "$TASKERS_WORKSPACE_ID" \
4545
--pane "$TASKERS_PANE_ID" \
4646
--surface "$TASKERS_SURFACE_ID" \

crates/taskers-cli/src/main.rs

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,40 @@ enum SurfaceCommand {
885885
#[arg(long)]
886886
surface: SurfaceId,
887887
},
888+
AgentStart {
889+
#[arg(long)]
890+
socket: Option<PathBuf>,
891+
#[arg(long)]
892+
workspace: WorkspaceId,
893+
#[arg(long)]
894+
pane: PaneId,
895+
#[arg(long)]
896+
surface: SurfaceId,
897+
#[arg(long)]
898+
agent: String,
899+
},
900+
AgentStop {
901+
#[arg(long)]
902+
socket: Option<PathBuf>,
903+
#[arg(long)]
904+
workspace: WorkspaceId,
905+
#[arg(long)]
906+
pane: PaneId,
907+
#[arg(long)]
908+
surface: SurfaceId,
909+
#[arg(long = "exit-status")]
910+
exit_status: i32,
911+
},
912+
DismissAlert {
913+
#[arg(long)]
914+
socket: Option<PathBuf>,
915+
#[arg(long)]
916+
workspace: WorkspaceId,
917+
#[arg(long)]
918+
pane: PaneId,
919+
#[arg(long)]
920+
surface: SurfaceId,
921+
},
888922
Close {
889923
#[arg(long)]
890924
socket: Option<PathBuf>,
@@ -1885,6 +1919,58 @@ async fn main() -> anyhow::Result<()> {
18851919
.await?;
18861920
println!("{}", serde_json::to_string_pretty(&response)?);
18871921
}
1922+
SurfaceCommand::AgentStart {
1923+
socket,
1924+
workspace,
1925+
pane,
1926+
surface,
1927+
agent,
1928+
} => {
1929+
let client = ControlClient::new(resolve_socket_path(socket));
1930+
let response = client
1931+
.send(ControlCommand::StartSurfaceAgentSession {
1932+
workspace_id: workspace,
1933+
pane_id: pane,
1934+
surface_id: surface,
1935+
agent_kind: agent,
1936+
})
1937+
.await?;
1938+
println!("{}", serde_json::to_string_pretty(&response)?);
1939+
}
1940+
SurfaceCommand::AgentStop {
1941+
socket,
1942+
workspace,
1943+
pane,
1944+
surface,
1945+
exit_status,
1946+
} => {
1947+
let client = ControlClient::new(resolve_socket_path(socket));
1948+
let response = client
1949+
.send(ControlCommand::StopSurfaceAgentSession {
1950+
workspace_id: workspace,
1951+
pane_id: pane,
1952+
surface_id: surface,
1953+
exit_status,
1954+
})
1955+
.await?;
1956+
println!("{}", serde_json::to_string_pretty(&response)?);
1957+
}
1958+
SurfaceCommand::DismissAlert {
1959+
socket,
1960+
workspace,
1961+
pane,
1962+
surface,
1963+
} => {
1964+
let client = ControlClient::new(resolve_socket_path(socket));
1965+
let response = client
1966+
.send(ControlCommand::DismissSurfaceAlert {
1967+
workspace_id: workspace,
1968+
pane_id: pane,
1969+
surface_id: surface,
1970+
})
1971+
.await?;
1972+
println!("{}", serde_json::to_string_pretty(&response)?);
1973+
}
18881974
SurfaceCommand::Close {
18891975
socket,
18901976
workspace,
@@ -3010,7 +3096,7 @@ mod tests {
30103096
"TASKERS_SURFACE_ID",
30113097
"TASKERS_TTY_NAME",
30123098
"tty 2>/dev/null",
3013-
"agent-hook notification",
3099+
"agent-hook stop",
30143100
"--workspace \"$TASKERS_WORKSPACE_ID\"",
30153101
"--pane \"$TASKERS_PANE_ID\"",
30163102
"--surface \"$TASKERS_SURFACE_ID\"",

crates/taskers-control/src/controller.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,34 @@ impl InMemoryController {
381381
true,
382382
)
383383
}
384+
ControlCommand::StartSurfaceAgentSession {
385+
workspace_id,
386+
pane_id,
387+
surface_id,
388+
agent_kind,
389+
} => {
390+
model.start_surface_agent_session(workspace_id, pane_id, surface_id, agent_kind)?;
391+
(
392+
ControlResponse::Ack {
393+
message: "surface agent session started".into(),
394+
},
395+
true,
396+
)
397+
}
398+
ControlCommand::StopSurfaceAgentSession {
399+
workspace_id,
400+
pane_id,
401+
surface_id,
402+
exit_status,
403+
} => {
404+
model.stop_surface_agent_session(workspace_id, pane_id, surface_id, exit_status)?;
405+
(
406+
ControlResponse::Ack {
407+
message: "surface agent session stopped".into(),
408+
},
409+
true,
410+
)
411+
}
384412
ControlCommand::MarkSurfaceCompleted {
385413
workspace_id,
386414
pane_id,
@@ -683,6 +711,19 @@ impl InMemoryController {
683711
true,
684712
)
685713
}
714+
ControlCommand::DismissSurfaceAlert {
715+
workspace_id,
716+
pane_id,
717+
surface_id,
718+
} => {
719+
model.dismiss_surface_alert(workspace_id, pane_id, surface_id)?;
720+
(
721+
ControlResponse::Ack {
722+
message: "surface alert dismissed".into(),
723+
},
724+
true,
725+
)
726+
}
686727
ControlCommand::AgentTriggerFlash {
687728
workspace_id,
688729
pane_id,

crates/taskers-control/src/protocol.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ pub enum ControlCommand {
131131
pane_id: PaneId,
132132
surface_id: SurfaceId,
133133
},
134+
StartSurfaceAgentSession {
135+
workspace_id: WorkspaceId,
136+
pane_id: PaneId,
137+
surface_id: SurfaceId,
138+
agent_kind: String,
139+
},
140+
StopSurfaceAgentSession {
141+
workspace_id: WorkspaceId,
142+
pane_id: PaneId,
143+
surface_id: SurfaceId,
144+
exit_status: i32,
145+
},
134146
MarkSurfaceCompleted {
135147
workspace_id: WorkspaceId,
136148
pane_id: PaneId,
@@ -234,6 +246,11 @@ pub enum ControlCommand {
234246
AgentClearNotifications {
235247
target: AgentTarget,
236248
},
249+
DismissSurfaceAlert {
250+
workspace_id: WorkspaceId,
251+
pane_id: PaneId,
252+
surface_id: SurfaceId,
253+
},
237254
AgentTriggerFlash {
238255
workspace_id: WorkspaceId,
239256
pane_id: PaneId,

crates/taskers-domain/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub use model::{
1616
KEYBOARD_RESIZE_STEP, MIN_WORKSPACE_WINDOW_HEIGHT, MIN_WORKSPACE_WINDOW_WIDTH,
1717
NotificationDeliveryState, NotificationItem, PaneKind, PaneMetadata, PaneMetadataPatch,
1818
PaneRecord, PersistedSession, PrStatus, ProgressState, PullRequestState,
19-
SESSION_SCHEMA_VERSION, SurfaceRecord, WindowFrame, WindowRecord, Workspace,
20-
WorkspaceAgentState, WorkspaceAgentSummary, WorkspaceColumnRecord, WorkspaceLogEntry,
21-
WorkspaceSummary, WorkspaceViewport, WorkspaceWindowMoveTarget, WorkspaceWindowRecord,
22-
WorkspaceWindowTabRecord,
19+
SESSION_SCHEMA_VERSION, SurfaceAgentProcess, SurfaceAgentSession, SurfaceRecord, WindowFrame,
20+
WindowRecord, Workspace, WorkspaceAgentState, WorkspaceAgentSummary, WorkspaceColumnRecord,
21+
WorkspaceLogEntry, WorkspaceSummary, WorkspaceViewport, WorkspaceWindowMoveTarget,
22+
WorkspaceWindowRecord, WorkspaceWindowTabRecord,
2323
};
2424
pub use signal::{SignalEvent, SignalKind, SignalPaneMetadata};

0 commit comments

Comments
 (0)