diff options
| author | Danilo M. <danix@danix.xyz> | 2026-12-04 11:32:56 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-12-04 11:32:56 +0100 |
| commit | 1a5c04780f7ec7ab1055cd4594aae3e6374fedd0 (patch) | |
| tree | 6a034af3c21f72a2e2447c63a1f04724ec673039 | |
| parent | e64b96dae06ea56c71fada1dc5a20e355267534c (diff) | |
| download | quickshell-1a5c04780f7ec7ab1055cd4594aae3e6374fedd0.tar.gz quickshell-1a5c04780f7ec7ab1055cd4594aae3e6374fedd0.zip | |
feat(assistant): writes or read only chip on every tool
The chip came from a description ending "Read-only.", which most tools
lack. It now reads the tool file's writes key: peach "writes", green
"read only".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | desktop/modules/assistant/AssistantModule.qml | 5 | ||||
| -rw-r--r-- | desktop/modules/assistant/AssistantPage.qml | 16 |
2 files changed, 12 insertions, 9 deletions
diff --git a/desktop/modules/assistant/AssistantModule.qml b/desktop/modules/assistant/AssistantModule.qml index b56b163..49e8c7b 100644 --- a/desktop/modules/assistant/AssistantModule.qml +++ b/desktop/modules/assistant/AssistantModule.qml @@ -262,8 +262,9 @@ Module { + " try:\n t = tomllib.load(open(p, 'rb'))\n" + " d, c = t.get('description', ''), t.get('cloud')\n" + " cloud = c if c is True or c == 'safe' else False\n" - + " except Exception as e:\n d, cloud = f'unreadable: {e}', False\n" - + " out.append({'name': name, 'on': on, 'cloud': cloud, 'description': d})\n" + + " writes = t.get('writes') is True\n" + + " except Exception as e:\n d, cloud, writes = f'unreadable: {e}', False, False\n" + + " out.append({'name': name, 'on': on, 'cloud': cloud, 'writes': writes, 'description': d})\n" + "print(json.dumps(sorted(out, key=lambda t: t['name'])))\n" function listTools() { diff --git a/desktop/modules/assistant/AssistantPage.qml b/desktop/modules/assistant/AssistantPage.qml index 680692f..7691cb5 100644 --- a/desktop/modules/assistant/AssistantPage.qml +++ b/desktop/modules/assistant/AssistantPage.qml @@ -745,10 +745,12 @@ Column { id: toolText anchors { left: toolSw.right; leftMargin: 10; right: cloudMark.left; rightMargin: 10 verticalCenter: parent.verticalCenter } - // A description ending "Read-only." shows it as a chip by - // the name instead. The toml keeps the sentence: the model - // reads the description too. + // Every tool gets a chip: "writes" for one whose toml says + // writes = true, "read only" otherwise. A description ending + // "Read-only." drops that sentence here; the toml keeps it, + // since the model reads the description too. readonly property var ro: /\s*Read-only\.\s*$/.exec(toolRow.modelData.description ?? "") + readonly property color chip: toolRow.modelData.writes ? Theme.peach : Theme.green Row { spacing: 8 Text { @@ -759,16 +761,16 @@ Column { } Rectangle { anchors.verticalCenter: parent.verticalCenter - visible: toolText.ro !== null width: roText.implicitWidth + 12 height: roText.implicitHeight + 4 radius: height / 2 - color: Qt.alpha(Theme.overlay, 0.35) + color: Qt.alpha(toolText.chip, 0.18) + border { width: 1; color: Qt.alpha(toolText.chip, 0.55) } Text { id: roText anchors.centerIn: parent - text: "read only" - color: Theme.subtext + text: toolRow.modelData.writes ? "writes" : "read only" + color: toolText.chip font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 5 } } } |
