Repository: sunner/ChatALL
File: src/store/index.js (JavaScript)

Code before:
        done: true,
        hide: false,
      });

      for (const bot of bots) {
        const message = {
          type: "response",
          content: "",
          format: bot.getOutputFormat(),
          model: bot.constructor._model,
          done: false,
          highlight: false,
          hide: false,
          className: bot.getClassname(),
        };

        // workaround for tracking message position
        const currentChat = state.chats[state.currentChatIndex];
        message.index = currentChat.messages.push(message) - 1;

        bot.sendPrompt(
          prompt,
          (indexes, values) =>
            dispatch("updateMessage", { indexes, message: values }),
          { chatIndex: state.currentChatIndex, messageIndex: message.index },
        );

        getMatomo().trackEvent(
          "prompt",
          "sendTo",
          bot.getClassname(),
          prompt.length,
        );
      }
    },
    updateMessage({ commit, state }, { indexes, message: values }) {
      commit("updateMessage", { indexes, message: values });

      // workaround for notifing the message window to scroll to bottom
      commit("incrementUpdateCounter");

      const i =
        indexes.chatIndex == -1 ? state.currentChatIndex : indexes.chatIndex;
      const chat = state.chats[i];
      const message = { ...chat.messages[indexes.messageIndex], ...values };
      if (values.done) {
        getMatomo().trackEvent(
          "prompt",
          "received",
          message.className,
          message.content.length,

Review comment (suggestion):
```suggestion
          id,
```

Provide an uuid for all messages is good for future. Since all messages have an `id`, it is no need to specify `prompt`.

Code after:
  actions: {
    sendPrompt({ commit, state, dispatch }, { prompt, bots, promptId }) {
      const id = promptId ? promptId : uuidv4();
      if (!promptId) {
        // if promptId not found, not a resend
        commit("addMessage", {
          type: "prompt",
          content: prompt,
          done: true,
          hide: false,
          id: id,
        });
      }
      commit("setLatestPromptId", id); // to keep track of the latest prompt for hiding old prompt's resend button

      for (const bot of bots) {
        const message = {
          type: "response",
          content: "",
          format: bot.getOutputFormat(),
          model: bot.constructor._model,
          done: false,
          highlight: false,
          hide: false,
          className: bot.getClassname(),
          promptId: id,
        };

        // workaround for tracking message position
        const currentChat = state.chats[state.currentChatIndex];
        message.index = currentChat.messages.push(message) - 1;

        bot.sendPrompt(
          prompt,
          (indexes, values) =>
            dispatch("updateMessage", { indexes, message: values }),
          { chatIndex: state.currentChatIndex, messageIndex: message.index },
        );

        getMatomo().trackEvent(
          "prompt",
          "sendTo",
          bot.getClassname(),
          prompt.length,
        );
      }
    },
    updateMessage({ commit, state }, { indexes, message: values }) {
      commit("updateMessage", { indexes, message: values });

      // workaround for notifing the message window to scroll to bottom