fix(kanban): address PR correctness and CI regressions (#1137)
This commit is contained in:
1 parent
190a93a4cf
commit
1735de7d9d
25 files changed
+809
-159
No files matched your search
@@ -12,6 +12,8 @@ interface KanbanPreferencesStore {
|
||||
slug: String,
|
||||
)
|
||||
|
||||
fun clearSelectedBoard(endpoint: String)
|
||||
|
||||
fun getViewMode(): String
|
||||
|
||||
fun setViewMode(mode: String)
|
||||
@@ -45,6 +47,10 @@ class InMemoryKanbanPreferencesStore : KanbanPreferencesStore {
|
||||
selectedBoards[endpoint] = slug
|
||||
}
|
||||
|
||||
override fun clearSelectedBoard(endpoint: String) {
|
||||
selectedBoards.remove(endpoint)
|
||||
}
|
||||
|
||||
override fun getViewMode(): String = viewMode
|
||||
|
||||
override fun setViewMode(mode: String) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.data.model
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@@ -146,18 +147,18 @@ data class CreateTaskBody(
|
||||
val assignee: String? = null,
|
||||
val tenant: String? = null,
|
||||
val priority: Int = 0,
|
||||
val workspaceKind: String? = null,
|
||||
val workspacePath: String? = null,
|
||||
@SerialName("workspace_kind") val workspaceKind: String? = null,
|
||||
@SerialName("workspace_path") val workspacePath: String? = null,
|
||||
val parents: List<String> = emptyList(),
|
||||
val triage: Boolean = false,
|
||||
val maxRuntimeSeconds: Int? = null,
|
||||
@SerialName("max_runtime_seconds") val maxRuntimeSeconds: Int? = null,
|
||||
val skills: List<String>? = null,
|
||||
val goalMode: Boolean = false,
|
||||
val goalMaxTurns: Int? = null,
|
||||
val modelOverride: String? = null,
|
||||
val providerOverride: String? = null,
|
||||
val reasoningEffort: String? = null,
|
||||
val projectId: String? = null,
|
||||
@SerialName("goal_mode") val goalMode: Boolean = false,
|
||||
@SerialName("goal_max_turns") val goalMaxTurns: Int? = null,
|
||||
@SerialName("model_override") val modelOverride: String? = null,
|
||||
@SerialName("provider_override") val providerOverride: String? = null,
|
||||
@SerialName("reasoning_effort") val reasoningEffort: String? = null,
|
||||
@SerialName("project_id") val projectId: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -174,14 +175,14 @@ data class UpdateTaskBody(
|
||||
val title: String? = null,
|
||||
val body: String? = null,
|
||||
val result: String? = null,
|
||||
val blockReason: String? = null,
|
||||
@SerialName("block_reason") val blockReason: String? = null,
|
||||
val summary: String? = null,
|
||||
val metadata: Map<String, JsonElement>? = null,
|
||||
val modelOverride: String? = null,
|
||||
val providerOverride: String? = null,
|
||||
val clearModelOverride: Boolean = false,
|
||||
val reasoningEffort: String? = null,
|
||||
val clearReasoningEffort: Boolean = false,
|
||||
@SerialName("model_override") val modelOverride: String? = null,
|
||||
@SerialName("provider_override") val providerOverride: String? = null,
|
||||
@SerialName("clear_model_override") val clearModelOverride: Boolean = false,
|
||||
@SerialName("reasoning_effort") val reasoningEffort: String? = null,
|
||||
@SerialName("clear_reasoning_effort") val clearReasoningEffort: Boolean = false,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@@ -199,12 +200,12 @@ data class BulkTasksBody(
|
||||
val result: String? = null,
|
||||
val summary: String? = null,
|
||||
val metadata: Map<String, JsonElement>? = null,
|
||||
val reclaimFirst: Boolean = false,
|
||||
val modelOverride: String? = null,
|
||||
val providerOverride: String? = null,
|
||||
val clearModelOverride: Boolean = false,
|
||||
val reasoningEffort: String? = null,
|
||||
val clearReasoningEffort: Boolean = false,
|
||||
@SerialName("reclaim_first") val reclaimFirst: Boolean = false,
|
||||
@SerialName("model_override") val modelOverride: String? = null,
|
||||
@SerialName("provider_override") val providerOverride: String? = null,
|
||||
@SerialName("clear_model_override") val clearModelOverride: Boolean = false,
|
||||
@SerialName("reasoning_effort") val reasoningEffort: String? = null,
|
||||
@SerialName("clear_reasoning_effort") val clearReasoningEffort: Boolean = false,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -2,6 +2,20 @@ package com.m57.hermescontrol.ui.kanban
|
||||
|
||||
import com.m57.hermescontrol.data.model.UpdateTaskBody
|
||||
|
||||
private val ALL_REASONING_EFFORTS = listOf("none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra")
|
||||
|
||||
fun supportedKanbanReasoningEfforts(
|
||||
supportsReasoning: Boolean,
|
||||
canDisableReasoning: Boolean,
|
||||
): List<String> =
|
||||
if (!supportsReasoning) {
|
||||
listOf("")
|
||||
} else if (canDisableReasoning) {
|
||||
ALL_REASONING_EFFORTS
|
||||
} else {
|
||||
ALL_REASONING_EFFORTS.filterNot { it == "none" }
|
||||
}
|
||||
|
||||
/**
|
||||
* Task model override matching desktop's TaskModelOverride contract:
|
||||
* - model: model name or ID
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.m57.hermescontrol.ui.kanban
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.produceState
|
||||
import com.m57.hermescontrol.data.model.KanbanTask
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
enum class KanbanArcState {
|
||||
QUEUED,
|
||||
@@ -48,3 +51,16 @@ object KanbanRuntimeHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** One coarse clock per board screen, rather than one coroutine per task card. */
|
||||
@Composable
|
||||
fun rememberKanbanNowSeconds(enabled: Boolean): Long =
|
||||
produceState(
|
||||
initialValue = System.currentTimeMillis() / 1000L,
|
||||
key1 = enabled,
|
||||
) {
|
||||
while (enabled) {
|
||||
delay(5_000L)
|
||||
value = System.currentTimeMillis() / 1000L
|
||||
}
|
||||
}.value
|
||||
@@ -89,6 +89,7 @@ import com.m57.hermescontrol.ui.kanban.components.KanbanCreateTaskDialog
|
||||
import com.m57.hermescontrol.ui.kanban.components.KanbanFilterSheet
|
||||
import com.m57.hermescontrol.ui.kanban.components.KanbanOrchestrationDialog
|
||||
import com.m57.hermescontrol.ui.kanban.components.KanbanTaskCard
|
||||
import com.m57.hermescontrol.util.StreamingUriRequestBody
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -107,6 +108,7 @@ fun KanbanScreen(
|
||||
viewModel: KanbanViewModel = viewModel { KanbanViewModel() },
|
||||
) {
|
||||
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
val nowSeconds = rememberKanbanNowSeconds(state.tasks.any { it.status.equals("running", ignoreCase = true) })
|
||||
val context = LocalContext.current
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
@@ -168,10 +170,12 @@ fun KanbanScreen(
|
||||
try {
|
||||
val cachedFile = File(pendingExportPath!!)
|
||||
if (cachedFile.exists()) {
|
||||
context.contentResolver.openOutputStream(uri)?.use { output ->
|
||||
cachedFile.inputStream().use { input ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
withContext(Dispatchers.IO) {
|
||||
context.contentResolver.openOutputStream(uri)?.use { output ->
|
||||
cachedFile.inputStream().use { input ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
} ?: error("Unable to open selected destination")
|
||||
}
|
||||
viewModel.showToast("Board exported successfully")
|
||||
}
|
||||
@@ -199,50 +203,64 @@ fun KanbanScreen(
|
||||
}
|
||||
}
|
||||
|
||||
val inputStream = context.contentResolver.openInputStream(uri)
|
||||
if (inputStream != null) {
|
||||
val bytes = withContext(Dispatchers.IO) { inputStream.use { it.readBytes() } }
|
||||
val targetPath = "kanban-imports/$fileName"
|
||||
val pathBody = targetPath.toRequestBody("text/plain".toMediaTypeOrNull())
|
||||
val overwriteBody = "true".toRequestBody("text/plain".toMediaTypeOrNull())
|
||||
val filePart =
|
||||
MultipartBody.Part.createFormData(
|
||||
"file",
|
||||
fileName,
|
||||
bytes.toRequestBody("application/gzip".toMediaTypeOrNull()),
|
||||
)
|
||||
val uploadResult =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall {
|
||||
ApiClient.hermesApi.uploadManagedFileStream(pathBody, overwriteBody, filePart)
|
||||
val contentLength =
|
||||
context.contentResolver
|
||||
.query(
|
||||
uri,
|
||||
arrayOf(OpenableColumns.SIZE),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
)?.use { cursor ->
|
||||
val sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE)
|
||||
if (sizeIndex != -1 && cursor.moveToFirst() && !cursor.isNull(sizeIndex)) {
|
||||
cursor.getLong(sizeIndex).takeIf { it >= 0L } ?: -1L
|
||||
} else {
|
||||
-1L
|
||||
}
|
||||
} ?: -1L
|
||||
val targetPath = "kanban-imports/$fileName"
|
||||
val pathBody = targetPath.toRequestBody("text/plain".toMediaTypeOrNull())
|
||||
val overwriteBody = "true".toRequestBody("text/plain".toMediaTypeOrNull())
|
||||
val requestBody =
|
||||
StreamingUriRequestBody(
|
||||
contentResolver = context.contentResolver,
|
||||
uri = uri,
|
||||
contentType = "application/gzip".toMediaTypeOrNull(),
|
||||
contentLength = contentLength,
|
||||
)
|
||||
val filePart = MultipartBody.Part.createFormData("file", fileName, requestBody)
|
||||
val uploadResult =
|
||||
withContext(Dispatchers.IO) {
|
||||
safeApiCall {
|
||||
ApiClient.hermesApi.uploadManagedFileStream(pathBody, overwriteBody, filePart)
|
||||
}
|
||||
when (uploadResult) {
|
||||
is NetworkResult.Success -> {
|
||||
val serverPath =
|
||||
uploadResult.data.entry?.path ?: uploadResult.data.path ?: targetPath
|
||||
val importResult = viewModel.importBoard(serverPath)
|
||||
when (importResult) {
|
||||
is NetworkResult.Success -> {
|
||||
val res = importResult.data
|
||||
var msg = "Board '${res.name}' imported"
|
||||
if (res.renamed) msg += " (as ${res.board})"
|
||||
viewModel.showToast(msg)
|
||||
viewModel.loadBoards()
|
||||
}
|
||||
}
|
||||
when (uploadResult) {
|
||||
is NetworkResult.Success -> {
|
||||
val serverPath =
|
||||
uploadResult.data.entry?.path ?: uploadResult.data.path ?: targetPath
|
||||
val importResult = viewModel.importBoard(serverPath)
|
||||
when (importResult) {
|
||||
is NetworkResult.Success -> {
|
||||
val res = importResult.data
|
||||
var msg = "Board '${res.name}' imported"
|
||||
if (res.renamed) msg += " (as ${res.board})"
|
||||
viewModel.showToast(msg)
|
||||
viewModel.loadBoards()
|
||||
}
|
||||
|
||||
is NetworkResult.Failure -> {
|
||||
viewModel.showToast("Import failed: ${importResult.error.message}")
|
||||
}
|
||||
}
|
||||
runCatching {
|
||||
ApiClient.hermesApi.deleteManagedFile(ManagedFileDelete(serverPath))
|
||||
is NetworkResult.Failure -> {
|
||||
viewModel.showToast("Import failed: ${importResult.error.message}")
|
||||
}
|
||||
}
|
||||
runCatching {
|
||||
ApiClient.hermesApi.deleteManagedFile(ManagedFileDelete(serverPath))
|
||||
}
|
||||
}
|
||||
|
||||
is NetworkResult.Failure -> {
|
||||
viewModel.showToast("Failed to upload archive: ${uploadResult.error.message}")
|
||||
}
|
||||
is NetworkResult.Failure -> {
|
||||
viewModel.showToast("Failed to upload archive: ${uploadResult.error.message}")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -270,14 +288,14 @@ fun KanbanScreen(
|
||||
IconButton(onClick = { showFilterSheet = true }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.FilterList,
|
||||
contentDescription = "Filter",
|
||||
contentDescription = stringResource(R.string.kanban_filter),
|
||||
)
|
||||
}
|
||||
Box {
|
||||
IconButton(onClick = { showBoardMenu = true }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.MoreVert,
|
||||
contentDescription = "Board options",
|
||||
contentDescription = stringResource(R.string.kanban_board_options),
|
||||
)
|
||||
}
|
||||
DropdownMenu(
|
||||
@@ -285,7 +303,7 @@ fun KanbanScreen(
|
||||
onDismissRequest = { showBoardMenu = false },
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text("New Board") },
|
||||
text = { Text(stringResource(R.string.kanban_new_board)) },
|
||||
onClick = {
|
||||
showBoardMenu = false
|
||||
showCreateBoardDialog = true
|
||||
@@ -439,7 +457,7 @@ fun KanbanScreen(
|
||||
IconButton(onClick = { showFilterSheet = true }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.FilterList,
|
||||
contentDescription = "Filters",
|
||||
contentDescription = stringResource(R.string.kanban_filters),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
@@ -695,6 +713,7 @@ fun KanbanScreen(
|
||||
items(group.tasks, key = { it.id }) { task ->
|
||||
KanbanTaskCard(
|
||||
task = task,
|
||||
nowSeconds = nowSeconds,
|
||||
defaultAssignee =
|
||||
state.orchestration
|
||||
?.resolvedDefaultAssignee,
|
||||
@@ -743,6 +762,7 @@ fun KanbanScreen(
|
||||
items(colTasks, key = { it.id }) { task ->
|
||||
KanbanTaskCard(
|
||||
task = task,
|
||||
nowSeconds = nowSeconds,
|
||||
defaultAssignee =
|
||||
state.orchestration
|
||||
?.resolvedDefaultAssignee,
|
||||
@@ -931,13 +951,19 @@ fun KanbanScreen(
|
||||
}
|
||||
},
|
||||
) {
|
||||
Text(if (selectedTaskIds.size == filteredTasks.size) "Clear" else "All")
|
||||
Text(
|
||||
if (selectedTaskIds.size == filteredTasks.size) {
|
||||
stringResource(R.string.kanban_clear_selection)
|
||||
} else {
|
||||
stringResource(R.string.kanban_select_all)
|
||||
},
|
||||
)
|
||||
}
|
||||
Button(
|
||||
onClick = { showBulkMoveDialog = true },
|
||||
enabled = selectedTaskIds.isNotEmpty(),
|
||||
) {
|
||||
Text("Move")
|
||||
Text(stringResource(R.string.kanban_move))
|
||||
}
|
||||
Button(
|
||||
onClick = { showBulkAssignDialog = true },
|
||||
@@ -965,7 +991,7 @@ fun KanbanScreen(
|
||||
},
|
||||
enabled = selectedTaskIds.isNotEmpty(),
|
||||
) {
|
||||
Text("Archive")
|
||||
Text(stringResource(R.string.kanban_action_archive))
|
||||
}
|
||||
Button(
|
||||
onClick = { showBulkDeleteDialog = true },
|
||||
@@ -983,7 +1009,10 @@ fun KanbanScreen(
|
||||
selectedTaskIds = emptySet()
|
||||
},
|
||||
) {
|
||||
Icon(Icons.Default.Close, contentDescription = "Close multi-select")
|
||||
Icon(
|
||||
Icons.Default.Close,
|
||||
contentDescription = stringResource(R.string.kanban_close_multi_select),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,7 +1026,7 @@ fun KanbanScreen(
|
||||
}
|
||||
AlertDialog(
|
||||
onDismissRequest = { showBulkMoveDialog = false },
|
||||
title = { Text("Move ${selectedTaskIds.size} tasks") },
|
||||
title = { Text(stringResource(R.string.kanban_move_tasks, selectedTaskIds.size)) },
|
||||
text = {
|
||||
Column {
|
||||
writableMoveColumns.forEach { col ->
|
||||
@@ -1097,13 +1126,13 @@ fun KanbanScreen(
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { showCreateBoardDialog = false },
|
||||
title = { Text("Create New Board") },
|
||||
title = { Text(stringResource(R.string.kanban_create_new_board)) },
|
||||
text = {
|
||||
Column {
|
||||
OutlinedTextField(
|
||||
value = boardSlug,
|
||||
onValueChange = { boardSlug = it },
|
||||
label = { Text("Slug (id)") },
|
||||
label = { Text(stringResource(R.string.kanban_slug)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
)
|
||||
@@ -1111,7 +1140,7 @@ fun KanbanScreen(
|
||||
OutlinedTextField(
|
||||
value = boardName,
|
||||
onValueChange = { boardName = it },
|
||||
label = { Text("Display Name") },
|
||||
label = { Text(stringResource(R.string.kanban_display_name)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
)
|
||||
@@ -1119,7 +1148,7 @@ fun KanbanScreen(
|
||||
OutlinedTextField(
|
||||
value = boardDesc,
|
||||
onValueChange = { boardDesc = it },
|
||||
label = { Text("Description") },
|
||||
label = { Text(stringResource(R.string.kanban_description)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@@ -1184,7 +1213,7 @@ fun KanbanScreen(
|
||||
},
|
||||
enabled = boardSlug.isNotBlank(),
|
||||
) {
|
||||
Text("Create")
|
||||
Text(stringResource(R.string.action_add))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
@@ -1333,16 +1362,16 @@ private fun ConfirmActionDialog(
|
||||
) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text("Confirm action") },
|
||||
title = { Text(stringResource(R.string.kanban_confirm_action)) },
|
||||
text = { Text(message) },
|
||||
confirmButton = {
|
||||
Button(onClick = onConfirm) {
|
||||
Text("Confirm")
|
||||
Text(stringResource(R.string.action_confirm))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text("Cancel")
|
||||
Text(stringResource(R.string.action_cancel))
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -1376,7 +1405,7 @@ private fun CompleteTaskDialog(
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) {
|
||||
Text("Cancel")
|
||||
Text(stringResource(R.string.action_cancel))
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@@ -345,7 +345,7 @@ private fun TaskOverviewTab(
|
||||
onClick = onReclaim,
|
||||
shape = RoundedCornerShape(6.dp),
|
||||
) {
|
||||
Text("Reclaim task")
|
||||
Text(stringResource(R.string.kanban_reclaim_task))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ private fun TaskOverviewTab(
|
||||
onDismissRequest = { assigneeMenuExpanded = false },
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text("Unassigned") },
|
||||
text = { Text(stringResource(R.string.kanban_assignee_unassigned)) },
|
||||
onClick = {
|
||||
onReassign(null)
|
||||
assigneeMenuExpanded = false
|
||||
@@ -591,7 +591,7 @@ private fun TaskOverviewTab(
|
||||
IconButton(onClick = { isEditingDescription = true }) {
|
||||
Icon(
|
||||
Icons.Filled.Edit,
|
||||
contentDescription = "Edit Description",
|
||||
contentDescription = stringResource(R.string.kanban_edit_description),
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
}
|
||||
@@ -608,14 +608,14 @@ private fun TaskOverviewTab(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) {
|
||||
OutlinedButton(onClick = { isEditingDescription = false }) {
|
||||
Text("Cancel")
|
||||
Text(stringResource(R.string.action_cancel))
|
||||
}
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Button(onClick = {
|
||||
onSaveDescription(descriptionDraft)
|
||||
isEditingDescription = false
|
||||
}) {
|
||||
Text("Save")
|
||||
Text(stringResource(R.string.action_save))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -676,7 +676,7 @@ private fun TaskDiscussionTab(
|
||||
) {
|
||||
if (comments.isEmpty()) {
|
||||
item {
|
||||
Text("No comments yet.", style = MaterialTheme.typography.bodySmall)
|
||||
Text(stringResource(R.string.kanban_no_comments), style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
} else {
|
||||
items(comments, key = { it.id }) { comment ->
|
||||
@@ -712,7 +712,7 @@ private fun TaskDiscussionTab(
|
||||
OutlinedTextField(
|
||||
value = newCommentText,
|
||||
onValueChange = { newCommentText = it },
|
||||
placeholder = { Text("Write a comment...") },
|
||||
placeholder = { Text(stringResource(R.string.kanban_write_comment)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
maxLines = 4,
|
||||
enabled = !isSubmitting,
|
||||
@@ -733,7 +733,7 @@ private fun TaskDiscussionTab(
|
||||
) {
|
||||
Icon(Icons.Filled.RestartAlt, contentDescription = null, modifier = Modifier.size(16.dp))
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text("Note & Requeue")
|
||||
Text(stringResource(R.string.kanban_note_requeue))
|
||||
}
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
}
|
||||
@@ -754,12 +754,19 @@ private fun TaskDiscussionTab(
|
||||
Icon(Icons.AutoMirrored.Filled.Send, contentDescription = null, modifier = Modifier.size(16.dp))
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
}
|
||||
Text("Comment")
|
||||
Text(stringResource(R.string.kanban_comment))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatRunDuration(durationSeconds: Long): String =
|
||||
when {
|
||||
durationSeconds < 60L -> "${durationSeconds}s"
|
||||
durationSeconds < 3600L -> "${durationSeconds / 60L}m"
|
||||
else -> "${durationSeconds / 3600L}h"
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TaskRunsTab(
|
||||
runs: List<com.m57.hermescontrol.data.model.KanbanRun>,
|
||||
@@ -771,12 +778,16 @@ private fun TaskRunsTab(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
item {
|
||||
Text("Execution Runs", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
stringResource(R.string.kanban_execution_runs),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
}
|
||||
|
||||
if (runs.isEmpty()) {
|
||||
item {
|
||||
Text("No run history available.", style = MaterialTheme.typography.bodySmall)
|
||||
Text(stringResource(R.string.kanban_no_run_history), style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
} else {
|
||||
items(runs, key = { it.id }) { run ->
|
||||
@@ -791,7 +802,7 @@ private fun TaskRunsTab(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(
|
||||
text = "Run #${run.id}",
|
||||
text = stringResource(R.string.kanban_run_number, run.id),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
@@ -806,15 +817,40 @@ private fun TaskRunsTab(
|
||||
},
|
||||
)
|
||||
}
|
||||
run.profile?.let { Text("Profile: $it", style = MaterialTheme.typography.bodySmall) }
|
||||
run.outcome?.let { Text("Outcome: $it", style = MaterialTheme.typography.bodySmall) }
|
||||
run.profile?.let {
|
||||
Text(
|
||||
stringResource(R.string.kanban_run_profile, it),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
run.outcome?.let {
|
||||
Text(
|
||||
stringResource(R.string.kanban_run_outcome, it),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
if (run.startedAt != null && run.endedAt != null && run.endedAt >= run.startedAt) {
|
||||
Text(
|
||||
stringResource(
|
||||
R.string.kanban_run_duration,
|
||||
formatRunDuration(run.endedAt - run.startedAt),
|
||||
),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
run.error?.let {
|
||||
Text(
|
||||
"Error: $it",
|
||||
stringResource(R.string.kanban_run_error, it),
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
run.summary?.takeIf { it.isNotBlank() }?.let {
|
||||
Text(
|
||||
stringResource(R.string.kanban_run_summary, it),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,7 +859,11 @@ private fun TaskRunsTab(
|
||||
if (workerLog != null && workerLog.exists && workerLog.content.isNotBlank()) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text("Worker Log Output", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
stringResource(R.string.kanban_worker_log),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(6.dp))
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant),
|
||||
@@ -852,12 +892,16 @@ private fun TaskActivityTab(
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
item {
|
||||
Text("Event Timeline", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
stringResource(R.string.kanban_event_timeline),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
}
|
||||
|
||||
if (events.isEmpty()) {
|
||||
item {
|
||||
Text("No activity events.", style = MaterialTheme.typography.bodySmall)
|
||||
Text(stringResource(R.string.kanban_no_activity), style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
} else {
|
||||
items(events, key = { it.id }) { event ->
|
||||
@@ -951,7 +995,11 @@ private fun TaskFilesTab(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text("Attachments", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold)
|
||||
Text(
|
||||
stringResource(R.string.kanban_attachments),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
Button(
|
||||
onClick = { launcher.launch("*/*") },
|
||||
enabled = !isUploading,
|
||||
@@ -960,7 +1008,7 @@ private fun TaskFilesTab(
|
||||
CircularProgressIndicator(modifier = Modifier.size(16.dp), strokeWidth = 2.dp)
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
}
|
||||
Text("Upload")
|
||||
Text(stringResource(R.string.kanban_upload))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,7 +1020,7 @@ private fun TaskFilesTab(
|
||||
) {
|
||||
if (attachments.isEmpty()) {
|
||||
item {
|
||||
Text("No attachments uploaded.", style = MaterialTheme.typography.bodySmall)
|
||||
Text(stringResource(R.string.kanban_no_attachments), style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
} else {
|
||||
items(attachments, key = { it.id }) { att ->
|
||||
@@ -993,7 +1041,7 @@ private fun TaskFilesTab(
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = att.filename?.ifBlank { "File #${att.id}" } ?: "File #${att.id}",
|
||||
text = att.filename.ifBlank { "File #${att.id}" },
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
|
||||
@@ -52,6 +52,7 @@ data class KanbanTaskUiState(
|
||||
class KanbanTaskViewModel(
|
||||
private val repository: KanbanRepository = KanbanRepositoryImpl(),
|
||||
private val eventsClientProvider: () -> KanbanEventsClient = { KanbanEventsClient() },
|
||||
private val enableFallbackPolling: Boolean = true,
|
||||
) : ViewModel(),
|
||||
ToastHost {
|
||||
private val _uiState = MutableStateFlow(KanbanTaskUiState())
|
||||
@@ -63,17 +64,30 @@ class KanbanTaskViewModel(
|
||||
private var currentLoadGen: Int = 0
|
||||
private var reloadJob: Job? = null
|
||||
private var logPollJob: Job? = null
|
||||
private var detailPollJob: Job? = null
|
||||
|
||||
fun loadTask(
|
||||
board: String,
|
||||
taskId: String,
|
||||
) {
|
||||
val gen = ++currentLoadGen
|
||||
reloadJob?.cancel()
|
||||
stopLogPolling()
|
||||
detailPollJob?.cancel()
|
||||
activeTaskId = taskId
|
||||
_uiState.update { it.copy(isLoading = true, errorMessage = null) }
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isLoading = true,
|
||||
detail = null,
|
||||
workerLog = null,
|
||||
estimate = null,
|
||||
errorMessage = null,
|
||||
)
|
||||
}
|
||||
loadProfiles()
|
||||
loadModelOptions()
|
||||
connectEvents(board)
|
||||
startDetailPolling(board, taskId)
|
||||
|
||||
viewModelScope.launch {
|
||||
when (val result = repository.getTask(taskId = taskId, board = board)) {
|
||||
@@ -191,8 +205,23 @@ class KanbanTaskViewModel(
|
||||
logPollJob = null
|
||||
}
|
||||
|
||||
private fun startDetailPolling(
|
||||
board: String,
|
||||
taskId: String,
|
||||
) {
|
||||
if (!enableFallbackPolling) return
|
||||
detailPollJob =
|
||||
viewModelScope.launch {
|
||||
while (isActive) {
|
||||
delay(DETAIL_POLL_INTERVAL_MS)
|
||||
loadTaskSilently(board, taskId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun connectEvents(board: String) {
|
||||
if (eventsBoard == board) return
|
||||
eventsClient?.disconnect()
|
||||
eventsBoard = board
|
||||
val client = eventsClient ?: eventsClientProvider().also { eventsClient = it }
|
||||
client.connect(
|
||||
@@ -536,6 +565,8 @@ class KanbanTaskViewModel(
|
||||
|
||||
public override fun onCleared() {
|
||||
stopLogPolling()
|
||||
detailPollJob?.cancel()
|
||||
reloadJob?.cancel()
|
||||
eventsClient?.disconnect()
|
||||
super.onCleared()
|
||||
}
|
||||
@@ -547,5 +578,6 @@ class KanbanTaskViewModel(
|
||||
private companion object {
|
||||
const val RELOAD_DEBOUNCE_MS = 250L
|
||||
const val POLL_INTERVAL_MS = 3000L
|
||||
const val DETAIL_POLL_INTERVAL_MS = 30_000L
|
||||
}
|
||||
}
|
||||
@@ -174,13 +174,14 @@ class KanbanViewModel(
|
||||
loadOrchestration()
|
||||
loadModelOptions()
|
||||
viewModelScope.launch {
|
||||
when (val result = repository.getBoards(includeArchived = _uiState.value.includeArchived)) {
|
||||
when (val result = repository.getBoards(includeArchived = false)) {
|
||||
is NetworkResult.Success -> {
|
||||
val boards = result.data.boards
|
||||
_uiState.update { it.copy(isLoading = false, boards = boards) }
|
||||
val targetBoard =
|
||||
boards.find { it.id == previouslySelectedId }
|
||||
?: boards.find { it.id == result.data.current }
|
||||
?: boards.find { it.id.equals("default", ignoreCase = true) }
|
||||
?: boards.firstOrNull()
|
||||
if (targetBoard != null) {
|
||||
selectBoard(targetBoard)
|
||||
@@ -531,7 +532,9 @@ class KanbanViewModel(
|
||||
_uiState.update { it.copy(isLoading = true) }
|
||||
when (val res = repository.deleteBoard(slug, delete = false)) {
|
||||
is NetworkResult.Success -> {
|
||||
_uiState.update { it.copy(toastMessage = "Board archived") }
|
||||
val endpoint = endpointProvider()
|
||||
preferences.clearSelectedBoard(endpoint)
|
||||
_uiState.update { it.copy(selectedBoard = null, toastMessage = "Board archived") }
|
||||
loadBoards()
|
||||
}
|
||||
|
||||
@@ -652,13 +655,19 @@ class KanbanViewModel(
|
||||
val board = _uiState.value.selectedBoard ?: return
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(isLoading = true) }
|
||||
when (val res = repository.bulkTasks(board.id, BulkTasksBody(ids = taskIds, assignee = assignee))) {
|
||||
val body =
|
||||
BulkTasksBody(
|
||||
ids = taskIds,
|
||||
assignee = assignee ?: "",
|
||||
reclaimFirst = true,
|
||||
)
|
||||
when (val res = repository.bulkTasks(board.id, body)) {
|
||||
is NetworkResult.Success -> {
|
||||
val results = res.data.results
|
||||
val succeeded = results.filter { it.ok }.map { it.id }.toSet()
|
||||
val failed = results.filter { !it.ok }.map { it.id }.toSet()
|
||||
val firstError = results.firstOrNull { !it.ok }?.error
|
||||
val actionName = if (assignee != null) "Assigned" else "Unassigned"
|
||||
val actionName = if (!assignee.isNullOrBlank()) "Assigned" else "Unassigned"
|
||||
val msg =
|
||||
when {
|
||||
failed.isEmpty() -> "$actionName ${succeeded.size} tasks"
|
||||
|
||||
+4
-4
@@ -61,7 +61,7 @@ fun KanbanBoardSettingsDialog(
|
||||
OutlinedTextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
label = { Text("Board Name") },
|
||||
label = { Text(stringResource(R.string.kanban_board_name)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
)
|
||||
@@ -69,7 +69,7 @@ fun KanbanBoardSettingsDialog(
|
||||
OutlinedTextField(
|
||||
value = description,
|
||||
onValueChange = { description = it },
|
||||
label = { Text("Description") },
|
||||
label = { Text(stringResource(R.string.kanban_description)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
minLines = 2,
|
||||
)
|
||||
@@ -121,8 +121,8 @@ fun KanbanBoardSettingsDialog(
|
||||
OutlinedTextField(
|
||||
value = defaultWorkdir,
|
||||
onValueChange = { defaultWorkdir = it },
|
||||
label = { Text("Default Workdir") },
|
||||
placeholder = { Text("e.g. /home/user/project") },
|
||||
label = { Text(stringResource(R.string.kanban_default_workdir)) },
|
||||
placeholder = { Text(stringResource(R.string.kanban_workdir_example)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
)
|
||||
|
||||
+16
-7
@@ -43,6 +43,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.m57.hermescontrol.R
|
||||
@@ -83,7 +84,7 @@ fun KanbanCreateTaskDialog(
|
||||
val descTextFieldState = rememberSyncedTextFieldState(desc) { desc = it }
|
||||
var selectedColumn by remember(defaultColumn) { mutableStateOf(defaultColumn) }
|
||||
var selectedAssignee by remember(defaultAssignee) {
|
||||
mutableStateOf(defaultAssignee ?: profiles.firstOrNull()?.name ?: "default")
|
||||
mutableStateOf(defaultAssignee.orEmpty())
|
||||
}
|
||||
var priority by remember { mutableIntStateOf(0) }
|
||||
var goalMode by remember { mutableStateOf(false) }
|
||||
@@ -222,7 +223,13 @@ fun KanbanCreateTaskDialog(
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Column {
|
||||
Text(if (isDef) "${profile.name} (Default)" else profile.name)
|
||||
Text(
|
||||
if (isDef) {
|
||||
stringResource(R.string.kanban_assignee_default_suffix, profile.name)
|
||||
} else {
|
||||
profile.name
|
||||
},
|
||||
)
|
||||
if (profile.model != null) {
|
||||
Text(
|
||||
profile.model,
|
||||
@@ -311,6 +318,7 @@ fun KanbanCreateTaskDialog(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { showAdvanced = !showAdvanced }
|
||||
.testTag("kanban_advanced_options")
|
||||
.padding(vertical = 8.dp),
|
||||
) {
|
||||
Text(
|
||||
@@ -409,15 +417,16 @@ fun KanbanCreateTaskDialog(
|
||||
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
) {
|
||||
listOf(
|
||||
"scratch" to "Scratch (Default)",
|
||||
"worktree" to "Worktree",
|
||||
"dir" to "Dir",
|
||||
"scratch" to stringResource(R.string.kanban_workspace_scratch),
|
||||
"worktree" to stringResource(R.string.kanban_workspace_worktree),
|
||||
"dir" to stringResource(R.string.kanban_workspace_dir),
|
||||
).forEach { (kind, label) ->
|
||||
FilterChip(
|
||||
selected = workspaceKind == kind,
|
||||
onClick = { workspaceKind = kind },
|
||||
label = { Text(label) },
|
||||
enabled = !isCreating,
|
||||
modifier = Modifier.testTag("kanban_workspace_kind_$kind"),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -435,7 +444,7 @@ fun KanbanCreateTaskDialog(
|
||||
Text(stringResource(R.string.kanban_workspace_path_hint))
|
||||
}
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier.fillMaxWidth().testTag("kanban_workspace_path"),
|
||||
singleLine = true,
|
||||
enabled = !isCreating,
|
||||
)
|
||||
@@ -448,7 +457,7 @@ fun KanbanCreateTaskDialog(
|
||||
value = skillsText,
|
||||
onValueChange = { skillsText = it },
|
||||
label = { Text(stringResource(R.string.kanban_skills)) },
|
||||
placeholder = { Text("e.g. git, coding, tests") },
|
||||
placeholder = { Text(stringResource(R.string.kanban_skills_placeholder)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
enabled = !isCreating,
|
||||
|
||||
@@ -21,8 +21,11 @@ import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.m57.hermescontrol.R
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -60,7 +63,7 @@ fun KanbanFilterSheet(
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
TextButton(onClick = onClearFilters) {
|
||||
Text("Clear all")
|
||||
Text(stringResource(R.string.kanban_clear_all))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,10 +78,11 @@ fun KanbanFilterSheet(
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp),
|
||||
) {
|
||||
Text("Show archived tasks", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(stringResource(R.string.kanban_show_archived), style = MaterialTheme.typography.bodyMedium)
|
||||
Switch(
|
||||
checked = includeArchived,
|
||||
onCheckedChange = onToggleIncludeArchived,
|
||||
modifier = Modifier.testTag("kanban_show_archived"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -91,10 +95,11 @@ fun KanbanFilterSheet(
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp),
|
||||
) {
|
||||
Text("Group running lane by profile", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(stringResource(R.string.kanban_group_running), style = MaterialTheme.typography.bodyMedium)
|
||||
Switch(
|
||||
checked = groupRunning,
|
||||
onCheckedChange = onToggleGroupRunning,
|
||||
modifier = Modifier.testTag("kanban_group_running"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -102,7 +107,7 @@ fun KanbanFilterSheet(
|
||||
|
||||
// Assignee Filter
|
||||
Text(
|
||||
text = "Assignee",
|
||||
text = stringResource(R.string.kanban_assignee),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(vertical = 4.dp),
|
||||
@@ -120,7 +125,7 @@ fun KanbanFilterSheet(
|
||||
selected = selectedAssignee == null,
|
||||
onClick = { onSelectAssignee(null) },
|
||||
)
|
||||
Text("All assignees", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(stringResource(R.string.kanban_all_assignees), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
|
||||
assignees.forEach { assignee ->
|
||||
@@ -144,7 +149,7 @@ fun KanbanFilterSheet(
|
||||
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))
|
||||
|
||||
Text(
|
||||
text = "Tenant",
|
||||
text = stringResource(R.string.kanban_tenant),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(vertical = 4.dp),
|
||||
@@ -162,7 +167,7 @@ fun KanbanFilterSheet(
|
||||
selected = selectedTenant == null,
|
||||
onClick = { onSelectTenant(null) },
|
||||
)
|
||||
Text("All tenants", style = MaterialTheme.typography.bodyMedium)
|
||||
Text(stringResource(R.string.kanban_all_tenants), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
|
||||
tenants.forEach { tenant ->
|
||||
|
||||
+43
-18
@@ -33,6 +33,7 @@ import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.data.model.ModelProvider
|
||||
import com.m57.hermescontrol.data.model.PinnedModel
|
||||
import com.m57.hermescontrol.ui.kanban.KanbanModelOverride
|
||||
import com.m57.hermescontrol.ui.kanban.supportedKanbanReasoningEfforts
|
||||
import com.m57.hermescontrol.ui.model.components.ModelPickerDialog
|
||||
|
||||
@Composable
|
||||
@@ -123,6 +124,14 @@ fun KanbanModelOverrideEditor(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
val selectedCapabilities =
|
||||
modelProviders
|
||||
.firstOrNull { it.slug == override.provider }
|
||||
?.capabilities
|
||||
?.get(override.model)
|
||||
val reasoningSupported = selectedCapabilities?.reasoning != false
|
||||
val canDisableReasoning = selectedCapabilities?.can_disable_reasoning != false
|
||||
val supportedEfforts = supportedKanbanReasoningEfforts(reasoningSupported, canDisableReasoning)
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
modifier =
|
||||
@@ -130,24 +139,33 @@ fun KanbanModelOverrideEditor(
|
||||
.fillMaxWidth()
|
||||
.horizontalScroll(rememberScrollState()),
|
||||
) {
|
||||
listOf(
|
||||
"" to stringResource(R.string.kanban_effort_inherit),
|
||||
"none" to stringResource(R.string.kanban_effort_none),
|
||||
"low" to stringResource(R.string.kanban_effort_low),
|
||||
"medium" to stringResource(R.string.kanban_effort_medium),
|
||||
"high" to stringResource(R.string.kanban_effort_high),
|
||||
).forEach { (effortVal, label) ->
|
||||
FilterChip(
|
||||
selected = override.effort == effortVal,
|
||||
onClick = {
|
||||
if (enabled) {
|
||||
onOverrideChange(override.copy(effort = effortVal))
|
||||
supportedEfforts
|
||||
.map { effortVal ->
|
||||
effortVal to
|
||||
when (effortVal) {
|
||||
"" -> stringResource(R.string.kanban_effort_inherit)
|
||||
"none" -> stringResource(R.string.kanban_effort_none)
|
||||
"minimal" -> stringResource(R.string.kanban_effort_minimal)
|
||||
"low" -> stringResource(R.string.kanban_effort_low)
|
||||
"medium" -> stringResource(R.string.kanban_effort_medium)
|
||||
"high" -> stringResource(R.string.kanban_effort_high)
|
||||
"xhigh" -> stringResource(R.string.kanban_effort_xhigh)
|
||||
"max" -> stringResource(R.string.kanban_effort_max)
|
||||
"ultra" -> stringResource(R.string.kanban_effort_ultra)
|
||||
else -> effortVal
|
||||
}
|
||||
},
|
||||
label = { Text(label) },
|
||||
enabled = enabled,
|
||||
)
|
||||
}
|
||||
}.forEach { (effortVal, label) ->
|
||||
FilterChip(
|
||||
selected = override.effort == effortVal,
|
||||
onClick = {
|
||||
if (enabled) {
|
||||
onOverrideChange(override.copy(effort = effortVal))
|
||||
}
|
||||
},
|
||||
label = { Text(label) },
|
||||
enabled = enabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +175,14 @@ fun KanbanModelOverrideEditor(
|
||||
title = stringResource(R.string.kanban_select_model),
|
||||
pinnedModels = pinnedModels,
|
||||
onSelect = { provider, model ->
|
||||
onOverrideChange(override.copy(provider = provider, model = model))
|
||||
val capabilities = modelProviders.firstOrNull { it.slug == provider }?.capabilities?.get(model)
|
||||
onOverrideChange(
|
||||
override.copy(
|
||||
provider = provider,
|
||||
model = model,
|
||||
effort = if (capabilities?.reasoning == false) "" else override.effort,
|
||||
),
|
||||
)
|
||||
showPickerDialog = false
|
||||
},
|
||||
onDismiss = { showPickerDialog = false },
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ private fun ProfileDescriptionEditor(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
minLines = 2,
|
||||
maxLines = 4,
|
||||
placeholder = { Text("Profile description for routing") },
|
||||
placeholder = { Text(stringResource(R.string.kanban_profile_description_hint)) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.data.model.KanbanTask
|
||||
import com.m57.hermescontrol.theme.LocalHermesStatusColors
|
||||
import com.m57.hermescontrol.ui.kanban.KanbanArcState
|
||||
@@ -47,6 +49,7 @@ fun KanbanTaskCard(
|
||||
modifier: Modifier = Modifier,
|
||||
isSelected: Boolean = false,
|
||||
defaultAssignee: String? = null,
|
||||
nowSeconds: Long = System.currentTimeMillis() / 1000L,
|
||||
onActionClick: ((KanbanTask) -> Unit)? = null,
|
||||
) {
|
||||
val statusColors = LocalHermesStatusColors.current
|
||||
@@ -60,9 +63,9 @@ fun KanbanTaskCard(
|
||||
else -> MaterialTheme.colorScheme.outline
|
||||
}
|
||||
|
||||
val arcState = KanbanRuntimeHelper.arcState(task, defaultAssignee)
|
||||
val arcState = KanbanRuntimeHelper.arcState(task, defaultAssignee, nowSeconds)
|
||||
val isWontRun = KanbanRuntimeHelper.isWontRun(task, defaultAssignee)
|
||||
val elapsed = KanbanRuntimeHelper.formatElapsed(task.startedAt)
|
||||
val elapsed = KanbanRuntimeHelper.formatElapsed(task.startedAt, nowSeconds)
|
||||
|
||||
val cardColors =
|
||||
if (isSelected) {
|
||||
@@ -103,7 +106,11 @@ fun KanbanTaskCard(
|
||||
arcState == KanbanArcState.RUNNING -> {
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = "· ${elapsed ?: "working"}",
|
||||
text =
|
||||
stringResource(
|
||||
R.string.kanban_runtime_elapsed,
|
||||
elapsed ?: stringResource(R.string.kanban_runtime_working),
|
||||
),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = statusColors.success,
|
||||
@@ -113,7 +120,7 @@ fun KanbanTaskCard(
|
||||
arcState == KanbanArcState.STALE -> {
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = "· STALE",
|
||||
text = stringResource(R.string.kanban_runtime_stale_badge),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = statusColors.warning,
|
||||
@@ -123,7 +130,7 @@ fun KanbanTaskCard(
|
||||
isWontRun -> {
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = "· WON'T RUN",
|
||||
text = stringResource(R.string.kanban_runtime_wont_run_badge),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = statusColors.error,
|
||||
@@ -146,7 +153,7 @@ fun KanbanTaskCard(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.MoreVert,
|
||||
contentDescription = "Task actions",
|
||||
contentDescription = stringResource(R.string.kanban_task_actions),
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.m57.hermescontrol.util
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okio.BufferedSink
|
||||
import okio.source
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
* A streaming OkHttp [RequestBody] backed by an Android SAF [Uri] and [ContentResolver].
|
||||
*
|
||||
* Streams bytes directly from the open stream into OkHttp's [BufferedSink] without
|
||||
* buffering the entire file into heap memory (avoiding OutOfMemoryError on large archives).
|
||||
*/
|
||||
class StreamingUriRequestBody(
|
||||
private val contentResolver: ContentResolver,
|
||||
private val uri: Uri,
|
||||
private val contentType: MediaType?,
|
||||
private val contentLength: Long = -1L,
|
||||
) : RequestBody() {
|
||||
override fun contentType(): MediaType? = contentType
|
||||
|
||||
override fun contentLength(): Long = contentLength
|
||||
|
||||
override fun writeTo(sink: BufferedSink) {
|
||||
val inputStream =
|
||||
contentResolver.openInputStream(uri)
|
||||
?: throw IOException("Unable to open input stream for URI: $uri")
|
||||
inputStream.use { stream ->
|
||||
stream.source().use { source ->
|
||||
sink.writeAll(source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user