Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/slop-audit/PATTERNS.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Each was found in one lane and is likely elsewhere.
asserted.
- **Motion as a contract**: a frame count, a fraction of an animation reached
at a given frame, a pixel offset, with no user path depending on the number
(Principle 6).
(Principle 7).
- **The test rebuilds the production loop**: aborts the real task, edits its
private throttle, calls its private step by hand.
- **The driver is unlike the real peer**: a test browser that never closes
Expand Down
30 changes: 15 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ is derived from it. **Process** is how to build, check and submit work.
sees it; and no SLA is promised. Current status
and plan: [#376](https://github.com/Tryanks/tcode/issues/376).

6. **gpui-base is the infrastructure; no house UI principles.** Tcode follows
the recommendations and defaults of gpui-base and gpui-kit, and keeps no
separate design contract in sync with the code: no house-wide UI rules of
its own, such as a single duration for every transition or classes of
change that must stay instant. Everything gpui-base
provides on top of GPUI — selection, scrolling, positioning, dismissal,
focus, theme tokens, motion, virtual lists, form controls — is used as it
is, defaults included, before anything of the kind is written in Tcode.
Tcode's own components are styled compositions of those primitives; they
never re-derive a primitive's rules locally. Where gpui-base demonstrably
cannot meet the need, Tcode builds what is missing — a primitive
reimplemented, a default overridden, or an element gpui-base does not have
— and the site names that gap; it is removed once gpui-base closes it.
This principle decides how something is built, never whether it is built:
what the interface does is the maintainer's call, and a primitive
6. **Upstream for behaviour; the look is Tcode's own.** gpui-base and
gpui-kit are the infrastructure for behaviour. Everything they provide on
top of GPUI — selection, scrolling, positioning, dismissal, focus, motion,
virtual lists, form controls — is used as it is before anything of the
kind is written in Tcode, and Tcode never re-derives a primitive's rules
locally. Where gpui-base demonstrably cannot meet the need, Tcode builds
what is missing — a primitive reimplemented, a behaviour default
overridden, or an element gpui-base does not have — and the site names
that gap; it is removed once gpui-base closes it. How the interface looks
is Tcode's to design and develop, not gpui-base's defaults: its type
scale, spacing, radii, elevation, colours and motion timing, the
components it composes from those primitives, and which form each kind of
information takes. Tcode gives gpui-base's theme tokens its own values so
upstream components follow them, rather than restyling each use. What the
interface does and how it looks is the maintainer's call, and a primitive
gpui-base lacks is never a reason to leave an effect out, make it instant,
or settle for less.

Expand Down
16 changes: 16 additions & 0 deletions assets/icons/bundled/arrow-right-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crates/agent/src/acp_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ impl Session {
});
self.emit(AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
})
Expand Down
25 changes: 13 additions & 12 deletions crates/agent/src/claude/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ impl Mapper {
}
}

/// The spawn item of the subagent a `can_use_tool` request comes from,
/// which Claude Code names by its `agent_id`.
fn asking_subagent(&self, request: &Value) -> Option<String> {
request
.get("agent_id")
.and_then(Value::as_str)
.and_then(|agent_id| self.task_tools.get(agent_id))
.cloned()
}

pub(super) fn on_control_request(&mut self, msg: &Value) -> Vec<AgentEvent> {
let request = match msg.get("request") {
Some(r) => r,
Expand Down Expand Up @@ -326,6 +336,7 @@ impl Mapper {
},
);
return vec![AgentEvent::UserInputRequested {
parent_item_id: self.asking_subagent(request),
request_id,
questions,
delivery: UserInputDelivery::Blocking,
Expand Down Expand Up @@ -412,15 +423,10 @@ impl Mapper {
}
self.pending_approvals
.insert(request_id.clone(), PendingApproval { input, suggestions });
let parent_item_id = request
.get("agent_id")
.and_then(Value::as_str)
.and_then(|agent_id| self.task_tools.get(agent_id))
.cloned();
vec![AgentEvent::ApprovalRequested(ApprovalRequest {
id: request_id,
turn_id: self.current_turn_id.clone(),
parent_item_id,
parent_item_id: self.asking_subagent(request),
kind,
reason,
blocked_path,
Expand Down Expand Up @@ -475,15 +481,10 @@ impl Mapper {
suggestions: HashMap::new(),
},
);
let parent_item_id = request
.get("agent_id")
.and_then(Value::as_str)
.and_then(|agent_id| self.task_tools.get(agent_id))
.cloned();
events.push(AgentEvent::ApprovalRequested(ApprovalRequest {
id: request_id,
turn_id: self.current_turn_id.clone(),
parent_item_id,
parent_item_id: self.asking_subagent(request),
kind: ApprovalKind::Plan { item_id, markdown },
reason: None,
blocked_path: None,
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/claude/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ impl Mapper {
.insert(request_id.clone(), PendingUserInput::Elicitation { fields });
vec![AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
}]
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/claude/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,7 @@ fn an_mcp_form_is_asked_as_questions_with_its_defaults_and_answered_in_its_types
let [
AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
},
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ impl SessionActor for Actor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
})
Expand Down
2 changes: 2 additions & 0 deletions crates/agent/src/codex/server_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl Actor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id: key,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
})
Expand Down Expand Up @@ -241,6 +242,7 @@ impl Actor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery: UserInputDelivery::Blocking,
})
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/codex/subagents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ impl Actor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id: message_id.to_owned(),
parent_item_id: None,
questions: open,
delivery: UserInputDelivery::Async,
})
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/codex/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ fn async_question_answers_steer_the_running_turn_with_codex_reply_envelope() {
));
let AgentEvent::UserInputRequested {
request_id,
parent_item_id: None,
questions,
delivery,
} = events.try_recv().unwrap()
Expand Down
34 changes: 31 additions & 3 deletions crates/agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,9 @@ pub enum AgentEvent {
/// ending does not settle it; [`AgentEvent::UserInputResolved`] does.
UserInputRequested {
request_id: String,
/// Spawn item of the subagent that asks, as on [`ApprovalRequest`].
#[serde(default, skip_serializing_if = "Option::is_none")]
parent_item_id: Option<String>,
questions: Vec<UserInputQuestion>,
#[serde(default, skip_serializing_if = "UserInputDelivery::is_blocking")]
delivery: UserInputDelivery,
Expand Down Expand Up @@ -3155,6 +3158,14 @@ pub enum AgentEvent {
/// Another thread's model acted on this thread through `tcode_control`. This is
/// never emitted by an adapter; the runtime records it in the target thread.
ControlAction(ControlAction),
/// A request a `tcode_control` child put to this thread in a callback has
/// left the host, answered or withdrawn. Never emitted by an adapter; the
/// runtime records it in the lead, whose card for the callback shows it.
ChildRequestSettled {
child_id: String,
request_id: String,
answer: ChildRequestAnswer,
},
/// A row of a thread's log that this build cannot read, as it is stored:
/// a record of a type or shape Tcode no longer has. Never emitted by an
/// adapter nor written; the store reads it in the row's place.
Expand Down Expand Up @@ -3190,9 +3201,8 @@ pub enum AgentEvent {
message: String,
},
/// The harness tries a failed request again inside its open turn.
/// `message` is its account of this attempt, which stands in for the
/// attempt before it; a request that fails for good is an
/// [`Self::Error`] or ends the turn.
/// `message` is its account of this attempt; a request that fails for
/// good is an [`Self::Error`] or ends the turn.
RequestRetry {
message: String,
},
Expand Down Expand Up @@ -3949,6 +3959,23 @@ pub enum ContextFreshness {
AwaitingObservation,
}

/// How a child's request ([`AgentEvent::ChildRequestSettled`]) was settled.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum ChildRequestAnswer {
/// `label` is the chosen [`ApprovalOption`]'s, for an option.
Approval {
decision: ApprovalDecision,
#[serde(default, skip_serializing_if = "Option::is_none")]
label: Option<String>,
},
/// Keyed by question id, as [`AgentEvent::UserInputResolved`]'s; empty
/// when it ended unanswered.
Input {
answers: serde_json::Map<String, serde_json::Value>,
},
}

/// One `tcode_control` write, as the target thread records it.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ControlAction {
Expand Down Expand Up @@ -4343,6 +4370,7 @@ mod thread_item_serde_tests {
));
let event = AgentEvent::UserInputRequested {
request_id: "q".into(),
parent_item_id: None,
questions: Vec::new(),
delivery: UserInputDelivery::Async,
};
Expand Down
5 changes: 3 additions & 2 deletions crates/agent/src/opencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,9 +1537,9 @@ impl OpenCodeActor {
else {
return;
};
if self.mapper.scope(session_id).is_none() {
let Some(parent_item_id) = self.mapper.scope(session_id) else {
return;
}
};
let fields: Vec<&Value> = form["fields"]
.as_array()
.into_iter()
Expand Down Expand Up @@ -1568,6 +1568,7 @@ impl OpenCodeActor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id: form_id.to_owned(),
parent_item_id,
questions,
delivery: UserInputDelivery::Blocking,
})
Expand Down
1 change: 1 addition & 0 deletions crates/agent/src/pi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ impl PiActor {
self.events
.emit(AgentEvent::UserInputRequested {
request_id: id,
parent_item_id: None,
questions: vec![question],
delivery: UserInputDelivery::Blocking,
})
Expand Down
Loading
Loading