feat: adopt Workspace resource keys

This commit is contained in:
2026-08-21 10:20:32 +09:00
parent 9989aed916
commit 85d1815dcf
33 changed files with 678 additions and 294 deletions
+6 -13
View File
@@ -348,17 +348,6 @@ fn state_style(state: &str) -> Style {
}
}
fn short_worker_id(worker: &BackendWorkerSummary) -> String {
if let Some(human_key) = worker.human_key.as_ref() {
return human_key.clone();
}
format!(
"{}:{}",
short_text(&worker.runtime_id),
short_text(&worker.worker_id)
)
}
fn short_text(text: &str) -> String {
const MAX: usize = 24;
let mut chars = text.chars();
@@ -370,6 +359,10 @@ fn short_text(text: &str) -> String {
}
}
fn short_worker_id(worker: &BackendWorkerSummary) -> String {
worker.resource_key.clone()
}
fn working_directory_text(worker: &BackendWorkerSummary) -> String {
let Some(wd) = worker.working_directory.as_ref() else {
return "wd:—".to_string();
@@ -393,7 +386,7 @@ mod tests {
BackendWorkerSummary {
runtime_id: runtime_id.to_string(),
worker_id: worker_id.to_string(),
human_key: None,
resource_key: "W-1".to_string(),
host_id: "host".to_string(),
label: "label".to_string(),
display_name: "label".to_string(),
@@ -429,7 +422,7 @@ mod tests {
.into_iter()
.map(|span| span.content)
.collect::<String>();
assert!(text.starts_with("runtime-a:worker-b"));
assert!(text.starts_with("W-1"));
assert!(text.contains("[running]"));
assert!(text.contains("profile:default"));
assert!(text.contains("wd:—"));
+2 -2
View File
@@ -537,9 +537,9 @@ pub(super) fn panel_ticket_reference(row: &PanelRow) -> String {
.as_ref()
.map(|ticket| {
ticket
.human_key
.resource_key
.clone()
.unwrap_or_else(|| ticket.id.clone())
.unwrap_or_else(|| "resource key unavailable".to_string())
})
.unwrap_or_else(|| match &row.key {
PanelRowKey::Ticket(id) | PanelRowKey::InvalidTicket(id) => id.clone(),
+9 -3
View File
@@ -1737,7 +1737,13 @@ fn panel_ticket_rows_render_state_title_then_detail_line() {
let state_start = 2;
let title_start = state_start + TICKET_STATE_COLUMN_WIDTH + 1;
let row_id = row.ticket.as_ref().unwrap().id.as_str();
let human_key = row.ticket.as_ref().unwrap().human_key.as_deref().unwrap();
let resource_key = row
.ticket
.as_ref()
.unwrap()
.resource_key
.as_deref()
.unwrap();
assert!(title_line.starts_with(""));
assert!(detail_line.starts_with("│ meta "));
@@ -1747,7 +1753,7 @@ fn panel_ticket_rows_render_state_title_then_detail_line() {
display_column(&title_line, "Workspace Dashboard composer targets"),
title_start
);
assert!(detail_line.contains(human_key));
assert!(detail_line.contains(resource_key));
assert!(detail_line.contains("Gate: clear"));
assert!(detail_line.contains("Action: Wait"));
}
@@ -3266,7 +3272,7 @@ fn panel_test_ticket_row(
) -> PanelRow {
let ticket = crate::workspace_panel::TicketPanelEntry {
id: id.to_string(),
human_key: Some("T-1".to_string()),
resource_key: Some("T-1".to_string()),
title: title.to_string(),
priority: "P2".to_string(),
workflow_state: TicketWorkflowState::parse(state).unwrap_or(TicketWorkflowState::Planning),
+3 -3
View File
@@ -253,7 +253,7 @@ impl NextUserAction {
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct TicketPanelEntry {
pub(crate) id: String,
pub(crate) human_key: Option<String>,
pub(crate) resource_key: Option<String>,
pub(crate) title: String,
pub(crate) priority: String,
pub(crate) workflow_state: TicketWorkflowState,
@@ -1064,7 +1064,7 @@ pub(crate) fn build_current_ticket_row(
fn ticket_summary_from_meta(meta: &TicketMeta) -> TicketSummary {
TicketSummary {
id: meta.id.clone(),
human_key: meta.human_key.clone(),
resource_key: meta.resource_key.clone(),
slug: meta.slug.clone(),
title: meta.title.clone(),
status: meta.status.clone(),
@@ -1240,7 +1240,7 @@ fn ticket_row(
let next_action = projection.next_action.map(next_user_action_from_workspace);
let entry = TicketPanelEntry {
id: summary.id.clone(),
human_key: summary.human_key.clone(),
resource_key: summary.resource_key.clone(),
title: summary.title.clone(),
priority: summary.priority.clone(),
workflow_state: summary.workflow_state,