v0.8.8: Qt front end redesign, responsive shell, UI input tests
The window is no longer one file pretending to be a chat box. The transcript, the run panel, the composer and the two consent dialogs are their own QML components over one Theme singleton, and the shell around them adapts to the screen: docked and scrollable on a desktop, a slide-out drawer on a phone. QML (app/qml/, new except Main.qml): - Theme.qml: single QML singleton, dark Breeze-flavoured tokens (surface, border, accent, text/textDim/textFaint, radius, pad, gap, sizes, monospace); diffLineColor() for unified-diff rows, compactBreakpoint 880, touchTarget 34, segmentHeight 30, headerHeight 42. - ChatView.qml: a row-type dispatcher over the transcript model (message, thought, tool, note), follow-the-tail scrolling with a "jump to latest" button once the user scrolls up, and an empty state that says where the agent runs and what it can do. - MessageCard.qml, ThinkBlock.qml, NoteLine.qml, ToolCard.qml (status pill, arguments, collapsible output, 500-line cut, diff colouring, spinner while the call runs), TodoPanel.qml. - Sidebar.qml: workspace/provider/status, mode and approval segmented rows, plan switch, the engine's todo list, version footer; scrolls, so a short window still reaches every control. - Composer.qml: auto-growing field, Enter sends / Shift+Enter newlines, red Stop while a turn runs, autocorrect hints off, finger-sized targets. - ConsentDialog.qml (Deny / Once / Always -> CST_PERM_*) and AskDialog.qml (the model's options become buttons, free text stays possible). - Main.qml: shell with header, draggable sidebar splitter (hover feedback, 200-560 px, double-click resets), transcript, composer, the two dialogs, Esc to cancel and Ctrl+L to clear. Under 880 px the sidebar becomes a drawer with a scrim instead of squeezing the chat away. AgentCore / main.cpp: - provider, model, approval and planMode are properties now; approval and plan mode write back into the engine's config, and renderMarkdown() calls cst_web_md_html(), so a table or a code fence looks like the WebUI's. - the todo hook writes m_todo on the GUI thread (it was written from the worker thread before: a data race on a QString member). - --size WxH for the window (the layout tests drive it), and the Basic style is chosen by default: the Breeze Quick style registers its types with relative URLs, which floods the log and breaks the composer. UI tests (app/src/ui/): - --uitest drives the real window with synthesized input and exits with the number of failures: 15 checks over docking/drawer transitions, mouse clicks and touch taps reaching the engine's mode, the plan switch, the composer arming the send button, and a 460x900 -> 1200x820 resize round trip. - every control the tests touch carries an objectName; the sidebar's implicitHeight binding loop is gone. Tests: cst-app-selftest and --uitest pass in the standalone app build, ctest cst-app-selftest passes in the repo build (38/38 on the host). Version 0.8.8.
This commit is contained in:
+40
-1
@@ -1,6 +1,7 @@
|
||||
/* cst-agent-app: the Qt front end.
|
||||
*
|
||||
* cst-agent-app --workspace DIR [--provider p] [--model m] [--api-key k]
|
||||
* cst-agent-app --size WxH window geometry (480x900, 1180x800, ...)
|
||||
* cst-agent-app --selftest embedding checks, no window, no network
|
||||
*
|
||||
* The engine runs in this process (see app/README.md); nothing listens on a
|
||||
@@ -13,6 +14,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickStyle>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTextStream>
|
||||
@@ -23,6 +25,7 @@
|
||||
|
||||
#include "core/AgentCore.h"
|
||||
#include "core/ToolProvider.h"
|
||||
#include "ui/UiTest.h"
|
||||
#include "cst_version.h"
|
||||
|
||||
namespace {
|
||||
@@ -97,6 +100,11 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
/* The window styles its own controls; the platform style only adds noise
|
||||
* here (the KDE Breeze plugin logs a line per registered type and trips
|
||||
* over the composer's TextArea). An explicit choice still wins. */
|
||||
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
|
||||
QQuickStyle::setStyle(QStringLiteral("Basic"));
|
||||
QGuiApplication::setApplicationName(QStringLiteral("cst-agent-app"));
|
||||
QGuiApplication::setApplicationVersion(QStringLiteral(CST_VERSION));
|
||||
QGuiApplication::setOrganizationName(QStringLiteral("cst-agent"));
|
||||
@@ -116,10 +124,18 @@ int main(int argc, char **argv) {
|
||||
QStringLiteral("model name"), QStringLiteral("name"));
|
||||
QCommandLineOption planOpt(QStringLiteral("plan"),
|
||||
QStringLiteral("start in plan mode"));
|
||||
QCommandLineOption uitestOpt(
|
||||
QStringLiteral("uitest"),
|
||||
QStringLiteral("drive the window with synthesized mouse/touch input and exit"));
|
||||
QCommandLineOption sizeOpt(QStringLiteral("size"),
|
||||
QStringLiteral("initial window size, e.g. 480x900"),
|
||||
QStringLiteral("WxH"));
|
||||
parser.addOption(wsOpt);
|
||||
parser.addOption(providerOpt);
|
||||
parser.addOption(modelOpt);
|
||||
parser.addOption(planOpt);
|
||||
parser.addOption(uitestOpt);
|
||||
parser.addOption(sizeOpt);
|
||||
parser.process(app);
|
||||
|
||||
QString ws = parser.value(wsOpt);
|
||||
@@ -138,9 +154,32 @@ int main(int argc, char **argv) {
|
||||
if (parser.isSet(planOpt))
|
||||
core.setPlanMode(true);
|
||||
|
||||
/* --uitest: same window, driven by synthesized input (app/src/ui/UiTest.cpp). */
|
||||
if (parser.isSet(uitestOpt))
|
||||
return app::runUiTest(core, parser.value(sizeOpt));
|
||||
|
||||
/* The layout is responsive; --size is how it gets exercised without a
|
||||
* different screen (see app/README.md). */
|
||||
int winW = 0, winH = 0;
|
||||
const QString size = parser.value(sizeOpt);
|
||||
if (!size.isEmpty()) {
|
||||
const int x = size.indexOf(QLatin1Char('x'));
|
||||
bool okW = false, okH = false;
|
||||
if (x > 0) {
|
||||
winW = size.left(x).toInt(&okW);
|
||||
winH = size.mid(x + 1).toInt(&okH);
|
||||
}
|
||||
if (!okW || !okH || winW < 320 || winH < 360) {
|
||||
QTextStream(stderr) << "--size wants WxH (at least 320x360)\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("agent"), &core);
|
||||
const QUrl url(QStringLiteral("qrc:/qt/qml/CstAgent/qml/Main.qml"));
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("initialWidth"), winW);
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("initialHeight"), winH);
|
||||
const QUrl url(QStringLiteral("qrc:/qt/qml/CstAgent/Main.qml"));
|
||||
QObject::connect(
|
||||
&engine, &QQmlApplicationEngine::objectCreated, &app,
|
||||
[url](QObject *obj, const QUrl &objUrl) {
|
||||
|
||||
Reference in New Issue
Block a user