Spaces:
Sleeping
Sleeping
Copilot
copilot-swe-agent[bot]
sethmcknight
commited on
Commit
·
129f7f8
1
Parent(s):
f88b1d2
Make policy suggestion cards clickable to auto-submit prompts (#69)
Browse files* Initial plan
* Implement clickable prompt suggestion buttons
Co-authored-by: sethmcknight <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: sethmcknight <[email protected]>
- static/chat.css +22 -2
- static/js/chat.js +39 -8
- templates/chat.html +8 -8
static/chat.css
CHANGED
|
@@ -114,7 +114,8 @@
|
|
| 114 |
margin-top: 1.5rem;
|
| 115 |
}
|
| 116 |
|
| 117 |
-
.policy-topics li
|
|
|
|
| 118 |
background: white;
|
| 119 |
padding: 1rem;
|
| 120 |
border-radius: 8px;
|
|
@@ -122,11 +123,30 @@
|
|
| 122 |
color: #475569;
|
| 123 |
font-weight: 500;
|
| 124 |
transition: transform 0.2s, box-shadow 0.2s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
|
| 127 |
-
.policy-topics li:hover
|
|
|
|
| 128 |
transform: translateY(-2px);
|
| 129 |
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
.message {
|
|
|
|
| 114 |
margin-top: 1.5rem;
|
| 115 |
}
|
| 116 |
|
| 117 |
+
.policy-topics li,
|
| 118 |
+
.policy-suggestion-btn {
|
| 119 |
background: white;
|
| 120 |
padding: 1rem;
|
| 121 |
border-radius: 8px;
|
|
|
|
| 123 |
color: #475569;
|
| 124 |
font-weight: 500;
|
| 125 |
transition: transform 0.2s, box-shadow 0.2s;
|
| 126 |
+
cursor: pointer;
|
| 127 |
+
font-size: inherit;
|
| 128 |
+
font-family: inherit;
|
| 129 |
+
width: 100%;
|
| 130 |
+
display: block;
|
| 131 |
+
text-align: center;
|
| 132 |
+
border: 1px solid #e2e8f0;
|
| 133 |
}
|
| 134 |
|
| 135 |
+
.policy-topics li:hover,
|
| 136 |
+
.policy-suggestion-btn:hover {
|
| 137 |
transform: translateY(-2px);
|
| 138 |
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
| 139 |
+
background: #f8fafc;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.policy-suggestion-btn:focus {
|
| 143 |
+
outline: 2px solid #667eea;
|
| 144 |
+
outline-offset: 2px;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.policy-suggestion-btn:active {
|
| 148 |
+
transform: translateY(0px);
|
| 149 |
+
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
| 150 |
}
|
| 151 |
|
| 152 |
.message {
|
static/js/chat.js
CHANGED
|
@@ -43,6 +43,9 @@ class ChatInterface {
|
|
| 43 |
this.loadQuerySuggestions();
|
| 44 |
this.focusInput();
|
| 45 |
this.initializeSourcePanel();
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
|
@@ -768,16 +771,44 @@ class ChatInterface {
|
|
| 768 |
<div class="welcome-icon">🤖</div>
|
| 769 |
<h2>Welcome to PolicyWise!</h2>
|
| 770 |
<p>I'm here to help you find information about company policies and procedures. Ask me anything about:</p>
|
| 771 |
-
<
|
| 772 |
-
<
|
| 773 |
-
<
|
| 774 |
-
<
|
| 775 |
-
<
|
| 776 |
-
<
|
| 777 |
-
<
|
| 778 |
-
</
|
| 779 |
`;
|
| 780 |
this.messagesContainer.appendChild(welcomeDiv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 781 |
}
|
| 782 |
|
| 783 |
/**
|
|
|
|
| 43 |
this.loadQuerySuggestions();
|
| 44 |
this.focusInput();
|
| 45 |
this.initializeSourcePanel();
|
| 46 |
+
|
| 47 |
+
// Setup initial policy suggestion buttons if they exist
|
| 48 |
+
this.setupPolicySuggestionButtons();
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
|
|
|
| 771 |
<div class="welcome-icon">🤖</div>
|
| 772 |
<h2>Welcome to PolicyWise!</h2>
|
| 773 |
<p>I'm here to help you find information about company policies and procedures. Ask me anything about:</p>
|
| 774 |
+
<div class="policy-topics" role="group" aria-label="Suggested policy topics">
|
| 775 |
+
<button class="policy-suggestion-btn" data-topic="Remote work policies">Remote work policies</button>
|
| 776 |
+
<button class="policy-suggestion-btn" data-topic="PTO and leave policies">PTO and leave policies</button>
|
| 777 |
+
<button class="policy-suggestion-btn" data-topic="Expense reimbursement">Expense reimbursement</button>
|
| 778 |
+
<button class="policy-suggestion-btn" data-topic="Information security">Information security</button>
|
| 779 |
+
<button class="policy-suggestion-btn" data-topic="Employee benefits">Employee benefits</button>
|
| 780 |
+
<button class="policy-suggestion-btn" data-topic="And much more...">And much more...</button>
|
| 781 |
+
</div>
|
| 782 |
`;
|
| 783 |
this.messagesContainer.appendChild(welcomeDiv);
|
| 784 |
+
|
| 785 |
+
// Add click event listeners to policy suggestion buttons
|
| 786 |
+
this.setupPolicySuggestionButtons();
|
| 787 |
+
}
|
| 788 |
+
|
| 789 |
+
/**
|
| 790 |
+
* Setup click handlers for policy suggestion buttons
|
| 791 |
+
*/
|
| 792 |
+
setupPolicySuggestionButtons() {
|
| 793 |
+
const suggestionButtons = this.messagesContainer.querySelectorAll('.policy-suggestion-btn');
|
| 794 |
+
suggestionButtons.forEach(button => {
|
| 795 |
+
button.addEventListener('click', () => {
|
| 796 |
+
const topic = button.getAttribute('data-topic');
|
| 797 |
+
if (topic && topic !== "And much more...") {
|
| 798 |
+
const prompt = `Tell me about ${topic.toLowerCase()}`;
|
| 799 |
+
this.messageInput.value = prompt;
|
| 800 |
+
this.sendMessage();
|
| 801 |
+
}
|
| 802 |
+
});
|
| 803 |
+
|
| 804 |
+
// Add keyboard support
|
| 805 |
+
button.addEventListener('keydown', (e) => {
|
| 806 |
+
if (e.key === 'Enter' || e.key === ' ') {
|
| 807 |
+
e.preventDefault();
|
| 808 |
+
button.click();
|
| 809 |
+
}
|
| 810 |
+
});
|
| 811 |
+
});
|
| 812 |
}
|
| 813 |
|
| 814 |
/**
|
templates/chat.html
CHANGED
|
@@ -36,14 +36,14 @@
|
|
| 36 |
<div class="welcome-icon" aria-hidden="true">🤖</div>
|
| 37 |
<h2>Welcome to PolicyWise!</h2>
|
| 38 |
<p>I'm here to help you find information about company policies and procedures. Ask me anything about:</p>
|
| 39 |
-
<
|
| 40 |
-
<
|
| 41 |
-
<
|
| 42 |
-
<
|
| 43 |
-
<
|
| 44 |
-
<
|
| 45 |
-
<
|
| 46 |
-
</
|
| 47 |
</div>
|
| 48 |
</div>
|
| 49 |
|
|
|
|
| 36 |
<div class="welcome-icon" aria-hidden="true">🤖</div>
|
| 37 |
<h2>Welcome to PolicyWise!</h2>
|
| 38 |
<p>I'm here to help you find information about company policies and procedures. Ask me anything about:</p>
|
| 39 |
+
<div class="policy-topics" role="group" aria-label="Suggested policy topics">
|
| 40 |
+
<button class="policy-suggestion-btn" data-topic="Remote work policies">Remote work policies</button>
|
| 41 |
+
<button class="policy-suggestion-btn" data-topic="PTO and leave policies">PTO and leave policies</button>
|
| 42 |
+
<button class="policy-suggestion-btn" data-topic="Expense reimbursement">Expense reimbursement</button>
|
| 43 |
+
<button class="policy-suggestion-btn" data-topic="Information security">Information security</button>
|
| 44 |
+
<button class="policy-suggestion-btn" data-topic="Employee benefits">Employee benefits</button>
|
| 45 |
+
<button class="policy-suggestion-btn" data-topic="And much more...">And much more...</button>
|
| 46 |
+
</div>
|
| 47 |
</div>
|
| 48 |
</div>
|
| 49 |
|