Skip to content

Commit 2be29a2

Browse files
committed
feat: profile selection dialog
1 parent ab8c589 commit 2be29a2

File tree

1 file changed

+48
-76
lines changed

1 file changed

+48
-76
lines changed

src/pages/aiAssistant/assistant.js

Lines changed: 48 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,47 @@
1+
import select from "dialogs/select";
2+
import Ref from "html-tag-js/ref";
13
import EditorFile from "lib/editorFile";
24
import styles from "./assistant.module.scss";
35

46
export default function openAIAssistantPage() {
7+
// References
8+
const profileBtnRef = new Ref();
9+
10+
// States
11+
let currentProfile = "ask"; // Default to ask profile
12+
13+
/**
14+
* Updates the profile button appearance and state
15+
* @param {string} profile - Profile type ("ask" or "write")
16+
*/
17+
const handleProfileSwitch = (profile) => {
18+
const iconEl = profileBtnRef.el.querySelector("i:first-child");
19+
const textEl = profileBtnRef.el.querySelector("span");
20+
21+
currentProfile = profile;
22+
23+
// Update button appearance based on selected profile
24+
if (profile === "ask") {
25+
iconEl.className = "icon help";
26+
textEl.textContent = "Ask";
27+
} else {
28+
iconEl.className = "icon edit";
29+
textEl.textContent = "Write";
30+
}
31+
};
32+
33+
/**
34+
* Shows profile selection menu
35+
*/
36+
const showProfileMenu = async (e) => {
37+
e.preventDefault();
38+
const profile = await select("Select Profile", [
39+
{ value: "ask", text: "Ask", icon: "help" },
40+
{ value: "write", text: "Write", icon: "edit" },
41+
]);
42+
handleProfileSwitch(profile);
43+
};
44+
545
const aiAssistantContainer = (
646
<div className="chat-container">
747
{/* Header */}
@@ -18,82 +58,16 @@ export default function openAIAssistantPage() {
1858
</button>
1959
<div className="separator"></div>
2060
<div className="profile-switcher">
21-
<button className="profile-button" id="profile-btn">
22-
<i className="icon edit"></i>
23-
<span>Write</span>
61+
<button
62+
className="profile-button"
63+
id="profile-btn"
64+
ref={profileBtnRef}
65+
onclick={showProfileMenu}
66+
>
67+
<i className="icon help"></i>
68+
<span>Ask</span>
2469
<i className="icon keyboard_arrow_down"></i>
2570
</button>
26-
<div className="profile-dropdown" id="profile-dropdown">
27-
<div className="profile-option" data-profile="ask">
28-
<div className="profile-option-header">
29-
<i className="icon info_outline"></i>
30-
<span>Ask</span>
31-
</div>
32-
<div className="profile-option-description">
33-
Suggest approaches without writing code
34-
</div>
35-
</div>
36-
<div className="profile-option" data-profile="write">
37-
<div className="profile-option-header">
38-
<i className="icon edit"></i>
39-
<span>Write</span>
40-
</div>
41-
<div className="profile-option-description">
42-
Write and implement code
43-
</div>
44-
</div>
45-
<div className="profile-option" data-profile="custom">
46-
<div className="profile-option-header">
47-
<i className="icon settings"></i>
48-
<span>Custom</span>
49-
</div>
50-
<div className="profile-option-description">
51-
Custom permissions and capabilities
52-
</div>
53-
<div className="permission-toggles" id="custom-permissions">
54-
<div className="permission-toggle">
55-
<div className="permission-label">
56-
<i data-feather="globe" className="feather-xs"></i>
57-
<span>Network Requests</span>
58-
</div>
59-
<label className="toggle-switch">
60-
<input type="checkbox" checked />
61-
<span className="toggle-slider"></span>
62-
</label>
63-
</div>
64-
<div className="permission-toggle">
65-
<div className="permission-label">
66-
<i data-feather="file" className="feather-xs"></i>
67-
<span>Read Files</span>
68-
</div>
69-
<label className="toggle-switch">
70-
<input type="checkbox" checked />
71-
<span className="toggle-slider"></span>
72-
</label>
73-
</div>
74-
<div className="permission-toggle">
75-
<div className="permission-label">
76-
<i data-feather="edit" className="feather-xs"></i>
77-
<span>Write Files</span>
78-
</div>
79-
<label className="toggle-switch">
80-
<input type="checkbox" />
81-
<span className="toggle-slider"></span>
82-
</label>
83-
</div>
84-
<div className="permission-toggle">
85-
<div className="permission-label">
86-
<i data-feather="terminal" className="feather-xs"></i>
87-
<span>Execute Commands</span>
88-
</div>
89-
<label className="toggle-switch">
90-
<input type="checkbox" />
91-
<span className="toggle-slider"></span>
92-
</label>
93-
</div>
94-
</div>
95-
</div>
96-
</div>
9771
</div>
9872
</div>
9973
<div className="header-right">
@@ -199,6 +173,4 @@ export default function openAIAssistantPage() {
199173
stylesheets: styles,
200174
hideQuickTools: true,
201175
});
202-
203-
console.log("Opened AI Assistant tab.");
204176
}

0 commit comments

Comments
 (0)