Skip to content

Commit 4d3a3df

Browse files
committed
Always show interactive icon and make it clickable to toggle interactivity
Fixes #121
1 parent 6f88fd1 commit 4d3a3df

File tree

4 files changed

+69
-21
lines changed

4 files changed

+69
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- Show empty stdout for testcase with a placeholder instead of hiding it
1010
- Added file name to the file template picker item's description to improve matching
11+
- Always show interactive icon and make it clickable to toggle testcase interactivity
1112

1213
# 4.0.0
1314

src/extension/providers/JudgeViewProvider.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
931931
case "OPEN_INTERACTOR":
932932
this._openInteractor();
933933
break;
934+
case "TOGGLE_INTERACTIVE":
935+
this._toggleInteractive(uuid);
936+
break;
934937
}
935938
this.requestSave();
936939
}
@@ -1387,6 +1390,21 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
13871390
});
13881391
}
13891392

1393+
private _toggleInteractive(uuid: string) {
1394+
const testcase = this._findTestcase(uuid);
1395+
if (!testcase) {
1396+
return;
1397+
}
1398+
1399+
testcase.mode = testcase.mode === "interactive" ? "standard" : "interactive";
1400+
super._postMessage({
1401+
type: "SET",
1402+
uuid,
1403+
property: "mode",
1404+
value: testcase.mode,
1405+
});
1406+
}
1407+
13901408
private _compare(uuid: string) {
13911409
const testcase = this._findTestcase(uuid);
13921410
if (!testcase) {

src/shared/judge-messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ActionValues = [
1414
"DEBUG",
1515
"REQUEST_DATA",
1616
"OPEN_INTERACTOR",
17+
"TOGGLE_INTERACTIVE",
1718
] as const;
1819

1920
export type ActionValue = (typeof ActionValues)[number];

src/webview/judge/TestcaseToolbar.svelte

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
handleAction("STOP");
4646
}
4747
48+
function handleToggleInteractive() {
49+
handleAction("TOGGLE_INTERACTIVE");
50+
}
51+
4852
// Derived values
4953
const status = $derived(testcase.status);
5054
const visible = $derived(testcase.shown);
@@ -117,13 +121,21 @@
117121
</p>
118122
</div>
119123
{/if}
120-
{#if testcase.mode === "interactive"}
121-
<div class="toolbar-badge-container toolbar-badge" data-status="CE">
122-
<div class="toolbar-icon toolbar-icon-exclude-highlight">
123-
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
124-
</div>
125-
</div>
126-
{/if}
124+
<div
125+
class="toolbar-badge-container toolbar-badge"
126+
data-status={testcase.mode === "interactive" ? "CE" : "NA"}
127+
>
128+
<button
129+
class="toolbar-icon toolbar-icon-exclude-highlight"
130+
data-tooltip={testcase.mode === "interactive"
131+
? "Make Non-Interactive"
132+
: "Make Interactive"}
133+
aria-label={testcase.mode === "interactive" ? "Make Non-Interactive" : "Make Interactive"}
134+
onclick={handleToggleInteractive}
135+
>
136+
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
137+
</button>
138+
</div>
127139
</div>
128140
<div class="testcase-buttons">
129141
<button class="toolbar-icon" data-tooltip="Run Testcase" aria-label="Run" onclick={handleRun}>
@@ -175,13 +187,21 @@
175187
</div>
176188
<p class="toolbar-badge-text">COMPILING</p>
177189
</div>
178-
{#if testcase.mode === "interactive"}
179-
<div class="toolbar-badge-container toolbar-badge" data-status="CE">
180-
<div class="toolbar-icon toolbar-icon-exclude-highlight">
181-
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
182-
</div>
183-
</div>
184-
{/if}
190+
<div
191+
class="toolbar-badge-container toolbar-badge"
192+
data-status={testcase.mode === "interactive" ? "CE" : "NA"}
193+
>
194+
<button
195+
class="toolbar-icon toolbar-icon-exclude-highlight"
196+
data-tooltip={testcase.mode === "interactive"
197+
? "Make Non-Interactive"
198+
: "Make Interactive"}
199+
aria-label={testcase.mode === "interactive" ? "Make Non-Interactive" : "Make Interactive"}
200+
onclick={handleToggleInteractive}
201+
>
202+
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
203+
</button>
204+
</div>
185205
</div>
186206
</div>
187207
{:else if status === "RUNNING"}
@@ -204,13 +224,21 @@
204224
></div>
205225
</button>
206226
</div>
207-
{#if testcase.mode === "interactive"}
208-
<div class="toolbar-badge-container toolbar-badge" data-status="CE">
209-
<div class="toolbar-icon toolbar-icon-exclude-highlight">
210-
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
211-
</div>
212-
</div>
213-
{/if}
227+
<div
228+
class="toolbar-badge-container toolbar-badge"
229+
data-status={testcase.mode === "interactive" ? "CE" : "NA"}
230+
>
231+
<button
232+
class="toolbar-icon toolbar-icon-exclude-highlight"
233+
data-tooltip={testcase.mode === "interactive"
234+
? "Make Non-Interactive"
235+
: "Make Interactive"}
236+
aria-label={testcase.mode === "interactive" ? "Make Non-Interactive" : "Make Interactive"}
237+
onclick={handleToggleInteractive}
238+
>
239+
<div class="codicon codicon-bolded codicon-chat-sparkle"></div>
240+
</button>
241+
</div>
214242
<div class="toolbar-icon toolbar-icon-exclude-highlight">
215243
<div class="codicon codicon-loading codicon-modifier-spin"></div>
216244
</div>

0 commit comments

Comments
 (0)