Open kgilpin opened 5 days ago
Modify "Suggest" button to preload question into the input box without submitting it
Currently, when a user clicks the "Suggest" button, the question is preloaded into the input box but is not automatically submitted ("Pressed Enter"). This allows the user to review and edit the question before submitting it, which is the intended behavior. However, this is not clearly communicated and can cause confusion.
The main components involved in this feature are:
Currently, it seems the question is loaded correctly but there is no mechanism to submit the question automatically, which is intended but not clearly indicated to the user. We need to ensure that the preloaded text does not get automatically submitted and provide clear, user-friendly indication of this behavior.
packages/components/src/components/chat/UserMessage.vue
:
v-popper
component used to display suggestions to ensure the question is loaded into the input box upon clicking the "Suggest" button.packages/cli/src/rpc/navie/suggest.ts
:
packages/components/src/components/install-guide/ButtonGroup.vue
:
v-button
should include a click handler that loads the suggestion into the input box without submitting it automatically.Below are the detailed proposed changes:
packages/components/src/components/chat/UserMessage.vue
:
<!-- file: /home/runner/work/appmap-js/appmap-js/packages/components/src/components/chat/UserMessage.vue -->
<v-popper
v-for="(i, index) in nextStepSuggestions"
:key="index"
placement="top"
align="left"
:time-to-display="500"
>
<template #content>
<div class="key-binds" v-if="nextStepSuggestions">
<div class="key-binds__option">
<span class="keyboard">Click</span>
<span class="keyboard-plus">To preload this suggestion</span>
</div>
<div class="key-binds__option">
<span class="keyboard">Click</span>
<span class="keyboard-plus">Then press Enter to submit</span>
</div>
</div>
</template>
<v-next-prompt-button
data-cy="next-step-button"
:command="i.command"
:prompt="i.prompt"
@click.native="preloadSuggestion(i.prompt)"
>
{{ i.label }}
</v-next-prompt-button>
</v-popper>
packages/cli/src/rpc/navie/suggest.ts
:
getSuggestions
and navieSuggestHandlerV1
methods do not include unnecessary automatic submission logic.packages/components/src/components/install-guide/ButtonGroup.vue
:
<!-- file: /home/runner/work/appmap-js/appmap-js/packages/components/src/components/install-guide/ButtonGroup.vue -->
<v-button
v-for="button in buttons"
:key="button"
:class="{ button: 1, 'button--active': selectedButton === button }"
size="small"
@click.native="onClickButton(button)"
>
{{ button }}
</v-button>
<script lang="ts">
import Vue from 'vue';
import VButton from '@/components/Button.vue';
export default Vue.extend({
components: {
VButton,
},
props: {
label: String,
buttons: {
type: Array as () => string[],
default: () => [],
},
},
data() {
return {
selectedButton: undefined as undefined | string,
};
},
methods: {
onClickButton(button: string) {
const newSelection = this.selectedButton === button ? undefined : button;
this.selectedButton = newSelection;
this.$emit('preload-suggestion', newSelection);
},
},
});
</script>
Giving the user a chance to edit the question first.