a2a-source-edit: write frontend/src/App.jsx

This commit is contained in:
a2a-cloud
2026-07-19 22:13:39 +00:00
parent 01ed304184
commit 337a137b0f

View File

@@ -44,6 +44,7 @@ export function App() {
() => (config && needsSignIn ? signInUrl(config) : null), () => (config && needsSignIn ? signInUrl(config) : null),
[config, needsSignIn], [config, needsSignIn],
); );
const resultState = running ? "loading" : error ? "error" : result?.status === "ok" ? "success" : result ? "error" : "idle";
async function runTriage(event) { async function runTriage(event) {
event.preventDefault(); event.preventDefault();
@@ -58,6 +59,9 @@ export function App() {
max_messages: Number(maxMessages), max_messages: Number(maxMessages),
}); });
setResult(data); setResult(data);
if (data?.status && data.status !== "ok") {
setError(data.summary || "The inbox could not be triaged. Check the pasted messages and try again.");
}
} catch (err) { } catch (err) {
setError(err.message || String(err)); setError(err.message || String(err));
} finally { } finally {
@@ -157,10 +161,13 @@ export function App() {
</div> </div>
</form> </form>
<section className="results" data-testid="agent-result" data-state={resultState} aria-live="polite">
{running ? <p>Triaging the shared inbox and drafting approval-ready replies...</p> : null}
{error ? <section className="error">{error}</section> : null} {error ? <section className="error">{error}</section> : null}
{!running && !error && !result ? <p className="empty-state">Run the prefilled fixture to generate a prioritized queue, drafts, receipt, and JSON download.</p> : null}
{result ? ( {result ? (
<section className="results" data-testid="agent-result"> <>
<div className="result-header"> <div className="result-header">
<div> <div>
<p className="eyebrow">Structured result</p> <p className="eyebrow">Structured result</p>
@@ -206,8 +213,9 @@ export function App() {
</article> </article>
))} ))}
</div> </div>
</section> </>
) : null} ) : null}
</section>
</main> </main>
); );
} }