Skip to content

Commit 6e80921

Browse files
fix: hashtag actions and @mention persistence in team chat (#233)
1 parent 339f50a commit 6e80921

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

app/javascript/controllers/team_chat_controller.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export default class extends Controller {
9393
<div class="px-3 py-2 hover:bg-surface-raised cursor-pointer transition flex items-start gap-2"
9494
data-action="click->team-chat#insertHashtag"
9595
data-hashtag="${action.name}">
96-
<code class="text-purple-400 font-mono text-sm">#${this.escapeHtml(action.name)}</code>
97-
<span class="text-text-muted text-xs flex-1">${this.escapeHtml(action.description)}</span>
96+
<code class="text-purple-400 font-mono text-sm">#${this.esc(action.name)}</code>
97+
<span class="text-text-muted text-xs flex-1">${this.esc(action.description)}</span>
9898
</div>
9999
`).join('')
100100

@@ -265,7 +265,8 @@ export default class extends Controller {
265265

266266
// If agents are actively streaming, treat this as a redirect
267267
if (this.activeAgents.size > 0 && message) {
268-
this.inputTarget.value = ""
268+
const prefix = this.pinnedAgents.map(n => `@${n}`).join(" ")
269+
this.inputTarget.value = prefix ? `${prefix} ` : ""
269270
this.inputTarget.style.height = "auto"
270271
await this.sendInterrupt("redirect", message)
271272
return
@@ -334,8 +335,14 @@ export default class extends Controller {
334335
}
335336
}
336337

337-
// Sync pinned agents — if user deletes an @Name from the text, unpin it
338+
// Sync pinned agents with text — auto-pin typed @Names, unpin removed ones
338339
const val = input.value
340+
const agentNames = this.agentsValue.map(a => a.name)
341+
agentNames.forEach(name => {
342+
if (val.includes(`@${name}`) && !this.pinnedAgents.includes(name)) {
343+
this.pinnedAgents.push(name)
344+
}
345+
})
339346
this.pinnedAgents = this.pinnedAgents.filter(name => val.includes(`@${name}`))
340347

341348
// Check for hashtag input
@@ -722,7 +729,7 @@ export default class extends Controller {
722729
<div class="flex justify-start" id="coding-agent-${taskKey}">
723730
<div class="max-w-2xl w-full">
724731
<div class="bg-surface-raised rounded-2xl px-4 py-3 w-full">
725-
<div class="text-text-primary text-sm font-medium mb-1">⚡ ${this.escapeHtml(message)}</div>
732+
<div class="text-text-primary text-sm font-medium mb-1">⚡ ${this.esc(message)}</div>
726733
<pre class="coding-agent-output text-xs text-text-muted bg-surface-base rounded p-2 max-h-48 overflow-y-auto whitespace-pre-wrap hidden"></pre>
727734
</div>
728735
</div>

0 commit comments

Comments
 (0)