|
1 | 1 | import test from "node:test"; |
2 | 2 | import assert from "node:assert/strict"; |
3 | 3 | import { createState } from "../../state.js"; |
4 | | -import { updateIndicators, STATUS_KEY_TOPIC } from "../../tui.js"; |
| 4 | +import { updateIndicators, STATUS_KEY_TOPIC, STATUS_KEY_READONLY } from "../../tui.js"; |
5 | 5 | import { makeTUICtx } from "./helpers.js"; |
6 | 6 |
|
7 | 7 | test("updateIndicators sets context usage status with correct color tone", () => { |
@@ -89,6 +89,43 @@ test("updateIndicators shows active notebook topic when set", () => { |
89 | 89 | assert.equal(record.statuses.get(STATUS_KEY_TOPIC), "🧭 oauth"); |
90 | 90 | }); |
91 | 91 |
|
| 92 | +test("updateIndicators shows readonly indicator when enabled", () => { |
| 93 | + const state = createState(); |
| 94 | + state.readonlyEnabled = true; |
| 95 | + const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() }; |
| 96 | + const ctx = makeTUICtx({ percent: null, record }); |
| 97 | + |
| 98 | + updateIndicators(ctx, state); |
| 99 | + const s = record.statuses.get(STATUS_KEY_READONLY); |
| 100 | + assert.ok(s?.includes("\u{1F512}"), "readonly indicator should show lock emoji when enabled"); |
| 101 | + assert.ok(s?.includes("readonly"), "readonly indicator should show 'readonly' text when enabled"); |
| 102 | +}); |
| 103 | + |
| 104 | +test("updateIndicators hides readonly indicator when disabled", () => { |
| 105 | + const state = createState(); |
| 106 | + state.readonlyEnabled = false; |
| 107 | + const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() }; |
| 108 | + const ctx = makeTUICtx({ percent: null, record }); |
| 109 | + |
| 110 | + updateIndicators(ctx, state); |
| 111 | + assert.equal(record.statuses.get(STATUS_KEY_READONLY), undefined, "readonly indicator should be undefined when disabled"); |
| 112 | +}); |
| 113 | + |
| 114 | +test("updateIndicators shows readonly-specific warning widget at 70%+ context", () => { |
| 115 | + const state = createState(); |
| 116 | + state.readonlyEnabled = true; |
| 117 | + const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() }; |
| 118 | + const ctx = makeTUICtx({ percent: 85, record }); |
| 119 | + |
| 120 | + updateIndicators(ctx, state); |
| 121 | + const w = record.widgets.get("agenticoding-warning"); |
| 122 | + assert.ok(w, "warning widget should be present at 85%"); |
| 123 | + assert.ok(w[0].includes("readonly"), "widget should mention readonly"); |
| 124 | + assert.ok(w[0].includes("spawn"), "widget should mention spawn"); |
| 125 | + assert.ok(w[0].includes("handoff"), "widget should mention handoff"); |
| 126 | + assert.ok(w[0].includes("resumes readonly"), "widget should mention readonly resumption"); |
| 127 | +}); |
| 128 | + |
92 | 129 | test("updateIndicators hides widget below 70% context", () => { |
93 | 130 | const state = createState(); |
94 | 131 | const record = { statuses: new Map<string, string | undefined>(), widgets: new Map<string, string[] | undefined>() }; |
|
0 commit comments