The issue lies in how you're using ref from Vue 3. In Vue 3, ref returns a reactive reference, which is an object with a value property. To mutate the value, you need to access and update the value property explicitly.
viewers is a ref created with an initial value of an empty array [].
When you want to update the array, you need to reassign the entire property with a new array that includes the added element. This maintains reactivity.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The concise syntax viewers.value = [...viewers.value, newElement] creates a new array by spreading the existing viewers.value and adding the new element.
Why push didn't work:viewers.value is an object with a value property, not an array directly. push is a method on arrays, not on the ref object. By accessing viewers.value.push, you were trying to call push on the ref object itself, hence the error.
Best practice: To avoid similar issues, consider using a concise, immutable update pattern:
This separates the mutation logic and makes it clear that you're intentionally updating the viewers ref. This pattern also helps with debugging and readability.